summaryrefslogtreecommitdiff
path: root/spec/controllers/comments_controller_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/controllers/comments_controller_spec.rb')
-rw-r--r--spec/controllers/comments_controller_spec.rb46
1 files changed, 18 insertions, 28 deletions
diff --git a/spec/controllers/comments_controller_spec.rb b/spec/controllers/comments_controller_spec.rb
index 1ea63211..12972217 100644
--- a/spec/controllers/comments_controller_spec.rb
+++ b/spec/controllers/comments_controller_spec.rb
@@ -1,32 +1,22 @@
-require_relative '../../app/controllers/comments_controller'
-require 'fakes'
-require 'fakes-rspec'
-
describe CommentsController do
- let(:sut) { CommentsController.new }
-
- describe 'when commenting on a creation' do
- let(:flash_hash) { {} }
- let(:payload){ {:creation_id=>88, :comment => {:body => 'blah'}} }
- let(:command){ fake }
-
- before(:each) do
- sut.stub(:params).and_return(payload)
- sut.stub(:flash).and_return(flash_hash)
- sut.stub(:redirect_to).and_return(nil)
- sut.stub(:command_for).with(CommentOnCreationCommand).and_return(command)
-
- sut.create
- end
-
- it "should save the new comment" do
- command.should have_received(:run, payload)
- end
- it "should display a message indicated that the comment was saved" do
- flash_hash[:notice].should_not be_nil
- end
- it "should redirect to the creation#show page" do
-
+ describe "POST create" do
+ describe "when signed in" do
+ let(:user) { FactoryGirl.create(:user) }
+ let(:creation) { FactoryGirl.create(:creation) }
+ before :each do
+ http_login(user)
+ end
+ describe 'when commenting on a creation' do
+ before(:each) do
+ post :create, {:creation_id => creation.id, :comment => {:body => 'blah'}}
+ end
+ it "should display a message indicated that the comment was saved" do
+ flash[:notice].should_not be_nil
+ end
+ it "should redirect to the creation#show page" do
+ response.should redirect_to(creation)
+ end
+ end
end
end
end