Skip to content

Instantly share code, notes, and snippets.

@ngauthier
Created July 28, 2010 15:31
Show Gist options
  • Save ngauthier/494907 to your computer and use it in GitHub Desktop.
Save ngauthier/494907 to your computer and use it in GitHub Desktop.
require 'test_helper'
class ManageOrganizationsTest < ActionController::IntegrationTest
def should_be_on(path)
current_path = URI.parse(current_url).path
assert_equal path, current_path
end
def should_see(content)
assert page.has_content?(content), "Page did not have content: #{content}"
end
def logged_in_as(role, organization)
@current_user = Factory("user_#{role}".to_sym, :organization => organization)
visit new_user_session_path
fill_in "Login", :with => @current_user.login
fill_in "Password", :with => @current_user.password
click "Sign in"
should_see 'signed in'
case role
when "admin"
should_be_on organizations_path
else
should_be_on organization_path(@current_user.organization)
end
end
def test_manage_orgs
@organization = Factory(:organization, :name => "My Org")
logged_in_as 'admin', @organization
@tour = Factory :tour, :title => "My Tour", :organization => @organization
visit organization_path(@organization)
should_see 'My Tour'
@collections_node = Factory(:node, :parent => @tour.root_node, :name => 'Collections')
@van_gogh_node = Factory(:node, :parent => @collections_node, :name => "Van Gogh")
visit node_path(@tour.root_node)
should_see 'Home'
click_link 'Collections'
should_be_on node_path(@collections_node)
should_see 'Van Gogh'
click_link 'Van Gogh'
should_be_on node_path(@van_gogh_node)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment