2010-05-09 12:44:53 +00:00
|
|
|
### Authentication
|
|
|
|
|
|
|
|
Given /^I am not authenticated$/ do
|
2010-06-10 22:07:59 +00:00
|
|
|
visit('/admin/sign_out')
|
2010-05-09 12:44:53 +00:00
|
|
|
end
|
|
|
|
|
2011-06-27 15:27:07 +00:00
|
|
|
Given /^I am an authenticated "([^"]*)"$/ do |role|
|
2011-08-25 21:28:56 +00:00
|
|
|
@member = Site.first.memberships.where(:role => role.downcase).first || FactoryGirl.create(role.downcase.to_sym, :site => Site.first)
|
2011-06-27 15:27:07 +00:00
|
|
|
|
2011-11-27 08:29:09 +00:00
|
|
|
step %{I go to login}
|
|
|
|
step %{I fill in "Email" with "#{@member.account.email}"}
|
|
|
|
step %{I fill in "Password" with "easyone"}
|
|
|
|
step %{I press "Log in"}
|
2010-05-09 12:44:53 +00:00
|
|
|
end
|
|
|
|
|
2011-06-27 15:27:07 +00:00
|
|
|
Given /^I am an authenticated user$/ do
|
2011-11-27 08:29:09 +00:00
|
|
|
step %{I am an authenticated "admin"}
|
2011-06-27 15:27:07 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
Then /^I should see the access denied message$/ do
|
2011-11-27 08:29:09 +00:00
|
|
|
step %{I should see "You are not authorized to access this page"}
|
2011-06-27 15:27:07 +00:00
|
|
|
end
|
|
|
|
|
2010-05-09 12:44:53 +00:00
|
|
|
Then /^I am redirected to "([^\"]*)"$/ do |url|
|
|
|
|
assert [301, 302].include?(@integration_session.status), "Expected status to be 301 or 302, got #{@integration_session.status}"
|
|
|
|
location = @integration_session.headers["Location"]
|
|
|
|
assert_equal url, location
|
|
|
|
visit location
|
|
|
|
end
|
|
|
|
|
2012-03-03 15:18:08 +00:00
|
|
|
Given /^I have an admin account$/ do
|
|
|
|
@member = Site.first.memberships.where(:role => 'admin').first || FactoryGirl.create(:admin, :site => Site.first, :password => 'easyone')
|
|
|
|
@email = @member.account.email
|
|
|
|
@password = 'easyone'
|
|
|
|
end
|
|
|
|
|
|
|
|
Given /^I attempt to access an admin page when not logged in$/ do
|
|
|
|
@admin_path = edit_admin_current_site_path
|
|
|
|
visit @admin_path
|
|
|
|
end
|
|
|
|
|
|
|
|
When /^I login with my admin account$/ do
|
|
|
|
fill_in 'Email', :with => @email
|
|
|
|
fill_in 'Password', :with => @password
|
|
|
|
click_button 'Log in'
|
|
|
|
end
|
|
|
|
|
|
|
|
Then /^I should be redirected the the admin page I was attempting to access$/ do
|
|
|
|
save_and_open_page
|
|
|
|
current_path.should == edit_admin_current_site_path
|
|
|
|
end
|
|
|
|
|
2010-07-28 10:17:56 +00:00
|
|
|
### Cross-domain authentication
|
|
|
|
|
|
|
|
When /^I forget to press the button on the cross-domain notice page$/ do
|
|
|
|
@admin.updated_at = 2.minutes.ago
|
|
|
|
Mongoid::Persistence::Update.new(@admin).send(:update)
|
|
|
|
end
|
|
|
|
|
|
|
|
### Common
|
2010-05-09 12:44:53 +00:00
|
|
|
|
2011-06-28 13:38:13 +00:00
|
|
|
Then /^I debug$/ do
|
|
|
|
debugger
|
|
|
|
0
|
|
|
|
end
|