#465: Update specs for Projects::CommentsController

This commit is contained in:
Vokhmin Alexey V 2015-04-14 22:58:59 +03:00
parent c7d5ca7305
commit 07ae486d5b
2 changed files with 5 additions and 5 deletions

View File

@ -8,7 +8,7 @@ describe Projects::CommentsController, type: :controller do
@create_params = { comment: { body: 'I am a comment!' }, name_with_owner: @project.name_with_owner, @create_params = { comment: { body: 'I am a comment!' }, name_with_owner: @project.name_with_owner,
commit_id: @commit.id, format: :json } commit_id: @commit.id, format: :json }
@update_params = { comment: { body: 'updated' }, name_with_owner: @project.name_with_owner, commit_id: @commit.id } @update_params = { comment: { body: 'updated' }, name_with_owner: @project.name_with_owner, commit_id: @commit.id, format: :json }
allow_any_instance_of(Project).to receive(:versions).and_return(%w(v1.0 v2.0)) allow_any_instance_of(Project).to receive(:versions).and_return(%w(v1.0 v2.0))

View File

@ -45,25 +45,25 @@ shared_examples_for 'user without update stranger comment ability' do
end end
shared_examples_for 'user with destroy comment ability' do shared_examples_for 'user with destroy comment ability' do
it 'should be able to perform destroy action' do it 'should be able to perform destroy action' do
delete :destroy, {id: @comment.id}.merge(@path) delete :destroy, {id: @comment.id, format: :json}.merge(@path)
expect(response).to be_success #redirect_to(@return_path) expect(response).to be_success #redirect_to(@return_path)
end end
it 'should delete comment from database' do it 'should delete comment from database' do
expect do expect do
delete :destroy, {id: @comment.id}.merge(@path) delete :destroy, {id: @comment.id, format: :json}.merge(@path)
end.to change(Comment, :count).by(-1) end.to change(Comment, :count).by(-1)
end end
end end
shared_examples_for 'user without destroy comment ability' do shared_examples_for 'user without destroy comment ability' do
it 'should not be able to perform destroy action' do it 'should not be able to perform destroy action' do
delete :destroy, {id: @comment.id}.merge(@path) delete :destroy, {id: @comment.id, format: :json}.merge(@path)
expect(response).to redirect_to(forbidden_path) expect(response).to redirect_to(forbidden_path)
end end
it 'should not delete comment from database' do it 'should not delete comment from database' do
expect do expect do
delete :destroy, {id: @comment.id}.merge(@path) delete :destroy, {id: @comment.id, format: :json}.merge(@path)
end.to_not change(Issue, :count) end.to_not change(Issue, :count)
end end
end end