diff options
author | Louise Crow <louise.crow@gmail.com> | 2015-03-30 16:00:02 +0100 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2015-03-30 16:00:02 +0100 |
commit | f24cc98afa25ad6010ae5316eecc15dfdb3fa79b (patch) | |
tree | c32fecb16bb2097da7dfdf90e6915fce0bf1a425 /spec/controllers/admin_comment_controller_spec.rb | |
parent | 823e58dc69960c600230b10604a0051359173f85 (diff) | |
parent | 3c0604cf900ad274d8f6ff421d39854ccbf4b6af (diff) |
Merge branch 'release/0.21'0.21.0.0
Conflicts:
locale/cy/app.po
locale/es_NI/app.po
locale/hr/app.po
locale/is_IS/app.po
locale/sr@latin/app.po
Diffstat (limited to 'spec/controllers/admin_comment_controller_spec.rb')
-rw-r--r-- | spec/controllers/admin_comment_controller_spec.rb | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/spec/controllers/admin_comment_controller_spec.rb b/spec/controllers/admin_comment_controller_spec.rb new file mode 100644 index 000000000..f87231e3b --- /dev/null +++ b/spec/controllers/admin_comment_controller_spec.rb @@ -0,0 +1,66 @@ +require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') + +describe AdminCommentController do + + describe :edit do + + before do + @comment = FactoryGirl.create(:comment) + get :edit, :id => @comment.id + end + + it 'renders the edit template' do + expect(response).to render_template('edit') + end + + it 'gets the comment' do + assigns[:comment].should == @comment + end + + end + + describe :update do + + context 'on valid data submission' do + + before do + @comment = FactoryGirl.create(:comment) + atts = FactoryGirl.attributes_for(:comment, :body => 'I am new') + put :update, :id => @comment.id, :comment => atts + end + + it 'gets the comment' do + assigns[:comment].should == @comment + end + + it 'updates the comment' do + Comment.find(@comment.id).body.should == 'I am new' + end + + it 'logs the update event' do + most_recent_event = Comment.find(@comment.id).info_request_events.last + most_recent_event.event_type.should == 'edit_comment' + most_recent_event.comment_id.should == @comment.id + end + + it 'shows a success notice' do + flash[:notice].should == "Comment successfully updated." + end + + it 'redirects to the request page' do + response.should redirect_to(admin_request_path(@comment.info_request)) + end + end + + context 'on invalid data submission' do + + it 'renders the edit template' do + @comment = FactoryGirl.create(:comment) + put :update, :id => @comment.id, :comment => {:body => ''} + response.should render_template('edit') + end + + end + end + +end |