Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/diaspora/diaspora.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Neff <benjamin@coding4coffee.ch>2017-08-06 19:31:01 +0300
committerBenjamin Neff <benjamin@coding4coffee.ch>2017-08-12 16:39:23 +0300
commit2a6515fab911febca372af9d24164cbce2c1852a (patch)
treecb4dcfa9a4ddba2b31442f3457993327386b7e4e /spec/controllers/comments_controller_spec.rb
parent955ef43a0e8e7cad249826d5bfd83117ea0f6684 (diff)
Add `params` keyword to controller specs
Diffstat (limited to 'spec/controllers/comments_controller_spec.rb')
-rw-r--r--spec/controllers/comments_controller_spec.rb30
1 files changed, 15 insertions, 15 deletions
diff --git a/spec/controllers/comments_controller_spec.rb b/spec/controllers/comments_controller_spec.rb
index a155cf531..4b9e22ce5 100644
--- a/spec/controllers/comments_controller_spec.rb
+++ b/spec/controllers/comments_controller_spec.rb
@@ -21,13 +21,13 @@ describe CommentsController, :type => :controller do
end
it 'responds to format json' do
- post :create, comment_hash.merge(:format => 'json')
+ post :create, params: comment_hash, format: :json
expect(response.code).to eq('201')
expect(response.body).to match comment_hash[:text]
end
it 'responds to format mobile' do
- post :create, comment_hash.merge(:format => 'mobile')
+ post :create, params: comment_hash, format: :mobile
expect(response).to be_success
end
end
@@ -39,21 +39,21 @@ describe CommentsController, :type => :controller do
end
it 'comments' do
- post :create, comment_hash
+ post :create, params: comment_hash
expect(response.code).to eq('201')
end
it "doesn't overwrite author_id" do
new_user = FactoryGirl.create(:user)
comment_hash[:author_id] = new_user.person.id.to_s
- post :create, comment_hash
+ post :create, params: comment_hash
expect(Comment.find_by_text(comment_hash[:text]).author_id).to eq(alice.person.id)
end
it "doesn't overwrite id" do
old_comment = alice.comment!(@post, "hello")
comment_hash[:id] = old_comment.id
- post :create, comment_hash
+ post :create, params: comment_hash
expect(old_comment.reload.text).to eq('hello')
end
end
@@ -63,7 +63,7 @@ describe CommentsController, :type => :controller do
@post = eve.post :status_message, :text => 'GIANTS', :to => aspect_to_post
expect(alice).not_to receive(:comment)
- post :create, comment_hash
+ post :create, params: comment_hash
expect(response.code).to eq("404")
expect(response.body).to eq(I18n.t("comments.create.error"))
end
@@ -85,7 +85,7 @@ describe CommentsController, :type => :controller do
comment = bob.comment!(@message, "hey")
expect(bob).to receive(:retract).with(comment)
- delete :destroy, :format => "js", :post_id => 1, :id => comment.id
+ delete :destroy, params: {post_id: 1, id: comment.id}, format: :js
expect(response.status).to eq(204)
end
@@ -93,7 +93,7 @@ describe CommentsController, :type => :controller do
comment = alice.comment!(@message, "hey")
expect(bob).to receive(:retract).with(comment)
- delete :destroy, :format => "js", :post_id => 1, :id => comment.id
+ delete :destroy, params: {post_id: 1, id: comment.id}, format: :js
expect(response.status).to eq(204)
end
end
@@ -103,7 +103,7 @@ describe CommentsController, :type => :controller do
comment = alice.comment!(@message, "hey")
expect(alice).to receive(:retract).with(comment)
- delete :destroy, :format => "js", :post_id => 1, :id => comment.id
+ delete :destroy, params: {post_id: 1, id: comment.id}, format: :js
expect(response.status).to eq(204)
end
@@ -112,13 +112,13 @@ describe CommentsController, :type => :controller do
comment2 = eve.comment!(@message, "hey")
expect(alice).not_to receive(:retract).with(comment1)
- delete :destroy, :format => "js", :post_id => 1, :id => comment2.id
+ delete :destroy, params: {post_id: 1, id: comment2.id}, format: :js
expect(response.status).to eq(403)
end
end
it 'renders nothing and 404 on a nonexistent comment' do
- delete :destroy, :post_id => 1, :id => 343415
+ delete :destroy, params: {post_id: 1, id: 343_415}
expect(response.status).to eq(404)
expect(response.body.strip).to be_empty
end
@@ -131,19 +131,19 @@ describe CommentsController, :type => :controller do
end
it 'works for mobile' do
- get :index, :post_id => @message.id, :format => 'mobile'
+ get :index, params: {post_id: @message.id}, format: :mobile
expect(response).to be_success
end
it 'returns all the comments for a post' do
comments = [alice, bob, eve].map{ |u| u.comment!(@message, "hey") }
- get :index, :post_id => @message.id, :format => :json
+ get :index, params: {post_id: @message.id}, format: :json
expect(JSON.parse(response.body).map {|comment| comment["id"] }).to match_array(comments.map(&:id))
end
it 'returns a 404 on a nonexistent post' do
- get :index, :post_id => 235236, :format => :json
+ get :index, params: {post_id: 235_236}, format: :json
expect(response.status).to eq(404)
end
@@ -151,7 +151,7 @@ describe CommentsController, :type => :controller do
aspect_to_post = eve.aspects.where(:name => "generic").first
message = eve.post(:status_message, :text => "hey", :to => aspect_to_post.id)
bob.comment!(@message, "hey")
- get :index, :post_id => message.id, :format => :json
+ get :index, params: {post_id: message.id}, format: :json
expect(response.status).to eq(404)
end
end