Permalink
Browse files

Update for capybara test helper

  • Loading branch information...
1 parent 6274c0d commit 5f13ba725cd3796a378008a07de5061bb5640103 @rossta committed Apr 2, 2012
View
@@ -20,13 +20,19 @@ def organization_name=(organization_name)
end
def organization
- Organization.new(:name => organization_name)
+ @@organization ||= Organization.new(:name => organization_name)
end
def api
@@api ||= API.new
end
+ def reset!
+ @@organization_name = nil
+ @@organization = nil
+ @@api = nil
+ end
+
end
end
@@ -7,7 +7,8 @@ def setup_for_github_login(team_member = dummy_github_team_member)
"provider" => 'github',
"uid" => team_member.id
}
- organization = mock('Organization', :find_team_member => team_member)
+ organization = mock('Organization')
+ organization.stub!(:find_team_member => team_member)
OpenSesame::Github.stub(:organization).and_return(organization)
team_member
end
@@ -1,27 +0,0 @@
-module OpenSesame
- module Github
- module Capybara
-
- def setup_for_github_login(team_member = dummy_github_team_member)
- OmniAuth.config.mock_auth[:github] = {
- "provider" => 'github',
- "uid" => team_member.id
- }
- organization = mock('Organization', :find_team_member => team_member)
- GardenWall.stub(:organization).and_return(organization)
- team_member
- end
-
- def login_with_github
- setup_for_github_login
- visit root_path
- click_link 'github'
- end
-
- def dummy_github_team_member(attributes = {})
- OpenSesame::Github::TeamMember.new(attributes.reverse_merge!(:id => 171, :login => "rossta"))
- end
-
- end
- end
-end
@@ -15,7 +15,7 @@ def authenticate!
if team_member = organization.find_team_member(omniauth["uid"])
success! team_member
else
- fail 'Authentication'
+ fail 'Sorry, you do not have access'
end
end
@@ -4,8 +4,9 @@ class TeamMember < Base
lazy_attr_reader :id, :login, :url, :avatar_url, :gravatar_id
class << self
+
def organization
- @organization ||= OpenSesame::Github.organization
+ OpenSesame::Github.organization
end
def serialize_into_session(record)

0 comments on commit 5f13ba7

Please sign in to comment.