Skip to content

Instantly share code, notes, and snippets.

@cnk
Forked from haikuwebdev/gist:6215
Created August 19, 2008 18:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cnk/6216 to your computer and use it in GitHub Desktop.
Save cnk/6216 to your computer and use it in GitHub Desktop.
require File.dirname(__FILE__) + '/../test_helper'
class EditorActionsTest < ActionController::IntegrationTest
# CNK not sure if we are going to use fixtures
# I would prefer to use factories but am having trouble with that
# fixtures :users, :roles, :roles_users, :pages
def setup
@home_page = Factory.create_home_page
@editor = Factory.create_user_with_role('editor', :login => 'abenter', :email => 'abenter@caltech.edu', :password => 'abenter', :password_confirmation => 'abenter')
end
def test_editor_editing_pages
# Before logging in, there shouldn't be any edit links
get '/'
assert_response :success
assert_no_tag "a[href=login]"
# now login, and we should have edit links
puts "login is #{@editor.login}"
puts "login is #{@editor.password}"
get '/login'
assert_template 'sessions/new'
assert_select "form" do
assert_select "input#password"
end
post '/session', :login => @editor.login, :password => @editor.password
assert_redirected_to '/'
assert_equal "Logged in successfully", flash[:notice]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment