Show More
Commit Description:
Merged online-registration branch changes r297:303 into the trunk...
Commit Description:
Merged online-registration branch changes r297:303 into the trunk
git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@303 6386c4cd-e34a-4fa8-8920-d93eb39b512e
References:
File last commit:
Show/Diff file:
Action:
spec/controllers/test_controller_spec.rb
| 28 lines
| 916 B
| text/x-ruby
| RubyLexer
|
|
r80 | |||
require File.dirname(__FILE__) + '/../spec_helper' | ||||
describe TestController do | ||||
before(:each) do | ||||
@john = mock(User, :id => "1", :login => 'john') | ||||
@john_result = mock(TestRequest, :id => "1", :user_id => @john.id) | ||||
@mary_result = mock(TestRequest, :id => "2", :user_id => @john.id + '1') | ||||
|
r158 | User.should_receive(:find).at_least(:once).with(@john.id).and_return(@john) | ||
|
r80 | end | ||
it "should let user see her testing result" do | ||||
TestRequest.should_receive(:find).with(@john_result.id). | ||||
and_return(@john_result) | ||||
get 'result', {:id => @john_result.id}, {:user_id => @john.id} | ||||
response.should be_success | ||||
end | ||||
it "should not let user see other's testing result" do | ||||
TestRequest.should_receive(:find).with(@mary_result.id). | ||||
and_return(@mary_result) | ||||
get 'result', {:id => @mary_result.id}, {:user_id => @john.id} | ||||
response.should redirect_to(:action => 'index') | ||||
end | ||||
end | ||||