Show More
Commit Description:
Merge pull request #15 from nattee/master...
Commit Description:
Merge pull request #15 from nattee/master finalizing merge of nattee's master
References:
File last commit:
Show/Diff file:
Action:
spec/integration/contest_managements_spec.rb | 136 lines | 3.6 KiB | text/x-ruby | RubyLexer |
Jittat Fakcharoenphol
logs out users after contests changed
r294 require 'spec_helper'
require 'config_spec_helper'
require 'delorean'
describe "ContestManagements" do
include ConfigSpecHelperMethods
fixtures :users
fixtures :problems
fixtures :contests
fixtures :roles
before(:each) do
@admin_user = users(:mary)
@contest_b = contests(:contest_b)
@james = users(:james)
@jack = users(:jack)
set_contest_time_limit('3:00')
set_indv_contest_mode
Jittat Fakcharoenphol
a cleaner, testable way to log out user after contest changed
r295 enable_multicontest
Jittat Fakcharoenphol
logs out users after contests changed
r294 end
it "should reset users' timer when their contests change" do
Jittat Fakcharoenphol
sends notification emails to users after contest upgrade.
r296 session = open_session
session.extend(MainSessionMethods)
Jittat Fakcharoenphol
logs out users after contests changed
r294
Jittat Fakcharoenphol
sends notification emails to users after contest upgrade.
r296 james_login_and_get_main_list(session)
session.response.should_not have_text(/OVER/)
Jittat Fakcharoenphol
logs out users after contests changed
r294
Delorean.time_travel_to(190.minutes.since) do
Jittat Fakcharoenphol
sends notification emails to users after contest upgrade.
r296 session.get_main_list
session.response.should have_text(/OVER/)
Jittat Fakcharoenphol
logs out users after contests changed
r294
Jittat Fakcharoenphol
sends notification emails to users after contest upgrade.
r296 session.get '/' # logout
session.get '/main/list' # clearly log out
session.response.should_not render_template 'main/list'
Jittat Fakcharoenphol
logs out users after contests changed
r294
admin_change_users_contest_to("james", @contest_b, true)
Jittat Fakcharoenphol
sends notification emails to users after contest upgrade.
r296 james_login_and_get_main_list(session)
session.response.should_not have_text(/OVER/)
Jittat Fakcharoenphol
logs out users after contests changed
r294 end
end
Jittat Fakcharoenphol
a cleaner, testable way to log out user after contest changed
r295 it "should force users to log out when their contests change" do
Jittat Fakcharoenphol
sends notification emails to users after contest upgrade.
r296 session = open_session
session.extend(MainSessionMethods)
Jittat Fakcharoenphol
a cleaner, testable way to log out user after contest changed
r295
Jittat Fakcharoenphol
sends notification emails to users after contest upgrade.
r296 james_login_and_get_main_list(session)
session.response.should_not have_text(/OVER/)
Jittat Fakcharoenphol
a cleaner, testable way to log out user after contest changed
r295
Delorean.time_travel_to(190.minutes.since) do
Jittat Fakcharoenphol
sends notification emails to users after contest upgrade.
r296 session.get_main_list
session.response.should have_text(/OVER/)
Jittat Fakcharoenphol
a cleaner, testable way to log out user after contest changed
r295
admin_change_users_contest_to("james", @contest_b, true)
Jittat Fakcharoenphol
sends notification emails to users after contest upgrade.
r296 session.get '/main/list'
session.response.should_not render_template 'main/list'
session.should be_redirect
Jittat Fakcharoenphol
a cleaner, testable way to log out user after contest changed
r295
Delorean.time_travel_to(200.minutes.since) do
Jittat Fakcharoenphol
sends notification emails to users after contest upgrade.
r296 james_login_and_get_main_list(session)
session.response.should_not have_text(/OVER/)
Jittat Fakcharoenphol
a cleaner, testable way to log out user after contest changed
r295 end
end
end
Jittat Fakcharoenphol
sends notification emails to users after contest upgrade.
r296 it "should maintain admin logged-in sessions even when their contests change" do
session = open_session
session.extend(MainSessionMethods)
session.login('mary', 'goodbye')
session.get_main_list
session.response.should_not have_text(/OVER/)
Delorean.time_travel_to(190.minutes.since) do
session.get_main_list
session.response.should have_text(/OVER/)
admin_change_users_contest_to("mary", @contest_b, true)
session.get '/main/list'
session.response.should render_template 'main/list'
end
end
Jittat Fakcharoenphol
logs out users after contests changed
r294 private
module MainSessionMethods
def login(login_name, password)
post '/login/login', :login => login_name, :password => password
assert_redirected_to '/main/list'
end
def get_main_list
get '/main/list'
assert_template 'main/list'
end
Jittat Fakcharoenphol
a cleaner, testable way to log out user after contest changed
r295
def get_main_list_and_assert_logout
get '/main/list'
assert_redirected_to '/main'
end
Jittat Fakcharoenphol
logs out users after contests changed
r294 end
module ContestManagementSessionMethods
def change_users_contest_to(user_login_list, contest, reset_timer=false)
post_data = {
:contest => {:id => contest.id},
:operation => 'assign',
:login_list => user_login_list
}
post_data[:reset_timer] = true if reset_timer
post '/user_admin/manage_contest', post_data
end
end
def admin_change_users_contest_to(user_list, contest, reset_timer)
admin_session = open_session
admin_session.extend(MainSessionMethods)
admin_session.extend(ContestManagementSessionMethods)
admin_session.login('mary','goodbye')
admin_session.get '/main/list'
admin_session.change_users_contest_to(user_list, contest, reset_timer)
end
def james_login_and_get_main_list(session)
session.login('james', 'morning')
session.get_main_list
end
end