Show More
Commit Description:
fixed dependency errors in spec
Commit Description:
fixed dependency errors in spec
File last commit:
Show/Diff file:
Action:
spec/controllers/main_controller_spec.rb | 144 lines | 4.4 KiB | text/x-ruby | RubyLexer |
jittat
[web] added main_controller_spec...
r71 require File.dirname(__FILE__) + '/../spec_helper'
Jittat Fakcharoenphol
fixed dependency errors in spec
r293 require File.dirname(__FILE__) + '/../config_spec_helper'
Jittat Fakcharoenphol
shows problems availabe in contests
r278
describe MainController, "when a user comes to list page" do
it "should redirect user to login page when unlogged-in user try to access main/list" do
get 'list'
response.should redirect_to(:action => 'login')
end
end
describe MainController, "when a logged in user comes to list page, with multicontests off" do
integrate_views
Jittat Fakcharoenphol
fixed dependency errors in spec
r293 include ConfigSpecHelperMethods
Jittat Fakcharoenphol
shows problems availabe in contests
r278
fixtures :users
fixtures :problems
fixtures :contests
before(:each) do
disable_multicontest
end
it "should list available problems" do
john = users(:john)
get "list", {}, {:user_id => john.id}
response.should render_template 'main/list'
response.should have_text(/add/)
response.should have_text(/easy_problem/)
response.should have_text(/hard_problem/)
end
end
describe MainController, "when a logged in user comes to list page, with multicontests on" do
integrate_views
Jittat Fakcharoenphol
fixed dependency errors in spec
r293 include ConfigSpecHelperMethods
Jittat Fakcharoenphol
shows problems availabe in contests
r278
fixtures :users
fixtures :problems
fixtures :contests
before(:each) do
enable_multicontest
end
it "should list only available public problems to users with no contest assigned" do
john = users(:john)
get "list", {}, {:user_id => john.id}
response.should render_template('main/list')
response.should have_text(/add/)
response.should_not have_text(/easy_problem/)
response.should_not have_text(/hard_problem/)
end
it "should list available problems on a specific contest" do
james = users(:james)
get "list", {}, {:user_id => james.id}
response.should render_template('main/list')
response.should have_text(/add/)
response.should have_text(/easy_problem/)
response.should_not have_text(/hard_problem/)
end
it "should shows available problems by contests" do
james = users(:james)
get "list", {}, {:user_id => james.id}
response.should render_template('main/list')
response.should have_text(Regexp.new('Contest A.*easy_problem', Regexp::MULTILINE))
end
it "should shows available problems by contests; problems belonging to more the one contest should appear many times" do
jack = users(:jack)
get "list", {}, {:user_id => jack.id}
response.should render_template('main/list')
response.should have_text(Regexp.new('Contest A.*easy_problem.*Contest B.*easy_problem', Regexp::MULTILINE))
response.should have_text(Regexp.new('Contest B.*hard_problem', Regexp::MULTILINE))
end
end
describe MainController, "when a user loads sources and compiler messages" do
jittat
[web] added main_controller_spec...
r71
before(:each) do
jittat
Merged online-registration branch changes r297:303 into the trunk...
r158 @problem = mock(Problem, :name => 'test', :output_only => false)
jittat
[web] added main_controller_spec...
r71 @language = mock(Language, :name => 'cpp', :ext => 'cpp')
@submission = mock(Submission,
:id => 1,
:user_id => 1,
:problem => @problem,
:language => @language,
:source => 'sample source',
:compiler_message => 'none')
Jittat Fakcharoenphol
shows problems availabe in contests
r278
jittat
[web] added main_controller_spec...
r71 @user = mock(User, :id => 1, :login => 'john')
Jittat Fakcharoenphol
shows problems availabe in contests
r278 @user.should_receive(:update_start_time).at_most(:once)
jittat
Merged online-registration branch changes r297:303 into the trunk...
r158 @another_user = mock(User, :id => 2, :login => 'mary')
Jittat Fakcharoenphol
shows problems availabe in contests
r278 @another_user.should_receive(:update_start_time).at_most(:once)
jittat
[web] add test result page...
r79
Jittat Fakcharoenphol
shows problems availabe in contests
r278 User.should_receive(:find).
with(1).any_number_of_times.
and_return(@user)
User.should_receive(:find).
with(2).any_number_of_times.
and_return(@another_user)
Submission.should_receive(:find).
any_number_of_times.with(@submission.id.to_s).
and_return(@submission)
jittat
[web] added main_controller_spec...
r71 end
it "should let user sees her own source" do
Jittat Fakcharoenphol
shows problems availabe in contests
r278 @submission.should_receive(:download_filename).and_return("foo.c")
jittat
[web] added configurations...
r76 get 'source', {:id => @submission.id}, {:user_id => 1}
jittat
[web] added main_controller_spec...
r71 response.should be_success
end
it "should let user sees her own compiler message" do
jittat
[web] added configurations...
r76 get 'compiler_msg', {:id => @submission.id}, {:user_id => 1}
jittat
[web] added main_controller_spec...
r71 response.should be_success
end
it "should not let user sees other user's source" do
jittat
[web] added configurations...
r76 get 'source', {:id => @submission.id}, {:user_id => 2}
jittat
[web] added main_controller_spec...
r71 flash[:notice].should =~ /[Ee]rror/
response.should redirect_to(:action => 'list')
end
it "should not let user sees other user's compiler message" do
jittat
[web] added configurations...
r76 get 'compiler_msg', {:id => @submission.id}, {:user_id => 2}
jittat
[web] added main_controller_spec...
r71 flash[:notice].should =~ /[Ee]rror/
response.should redirect_to(:action => 'list')
end
end
Jittat Fakcharoenphol
shows problems availabe in contests
r278