Skip to content

Commit

Permalink
update deprecated style in controller specs. add key params when decl…
Browse files Browse the repository at this point in the history
…aring params for request in specs controllers a-m (#354)
  • Loading branch information
yuenmichelle1 authored Aug 9, 2024
1 parent b32fed1 commit 1d3fb85
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions spec/controllers/comments_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
let(:href_params){ CGI.parse URI.parse(first_href).query }

context 'when false' do
before(:each){ get :index, format: :json, section: 'project-1', subject_default: false }
before(:each){ get :index, format: :json, params: { section: 'project-1', subject_default: false } }

it 'should filter comments from subject default boards' do
expect(response_ids).to match_array comment_ids
Expand All @@ -40,7 +40,7 @@
end

context 'when true' do
before(:each){ get :index, format: :json, section: 'project-1', subject_default: true }
before(:each){ get :index, params: { format: :json, section: 'project-1', subject_default: true } }

it 'should filter comments from subject default boards' do
expect(response_ids).to match_array [subject_default_comment.id.to_s]
Expand Down Expand Up @@ -86,7 +86,7 @@
end

it 'should set the user ip' do
post :create, request_params.merge(format: :json)
post :create, params: request_params.merge(format: :json)
id = response.json['comments'].first['id']
comment = Comment.find id
expect(comment.user_ip).to eql request.remote_ip
Expand All @@ -109,7 +109,7 @@
context 'with a non-author user' do
let(:record){ create :comment }
let(:user){ create :user }
let(:send_request){ put upvote_method, id: record.id.to_s, format: :json }
let(:send_request){ put upvote_method, params: { id: record.id.to_s, format: :json }}
before(:each){ allow(subject).to receive(:current_user).and_return user }

it_behaves_like 'a controller restricting',
Expand Down
10 changes: 5 additions & 5 deletions spec/controllers/conversations_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@
end

it 'should have the correct participant ids' do
post :create, request_params.merge(format: :json)
post :create, params: request_params.merge(format: :json)
conversation = Conversation.first
user_ids = [current_user.id] + recipients.map(&:id)
expect(conversation.participant_ids).to match_array user_ids
end

it 'should set the user ip' do
post :create, request_params.merge(format: :json)
post :create, params: request_params.merge(format: :json)
conversation_id = response.json['conversations'].first['id']
message = Message.where(conversation_id: conversation_id).first
expect(message.user_ip).to eql request.remote_ip
Expand All @@ -64,7 +64,7 @@
let!(:record){ create :conversation_with_messages, user: user }

def destroy_conversation
delete :destroy, id: record.id, format: :json
delete :destroy, params: { id: record.id, format: :json }
end

it 'should set the status' do
Expand Down Expand Up @@ -110,7 +110,7 @@ def destroy_conversation
let(:record){ create :conversation_with_messages }
let(:recipient){ record.user_conversations.where(is_unread: true).first.user }
let(:sender){ record.user_conversations.where(is_unread: false ).first.user }
let(:json){ get(:index, unread: true); response.json['conversations'] }
let(:json){ get(:index, params: { unread: true }); response.json['conversations'] }

before(:each) do
allow(subject).to receive(:current_user).and_return current_user
Expand Down Expand Up @@ -146,7 +146,7 @@ def destroy_conversation

it 'should mark the conversation as read' do
expect(Conversation).to receive(:mark_as_read_by).with [record.id], recipient.id
get :show, id: record.id.to_s
get :show, params: { id: record.id.to_s }
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/discussions_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
end

it 'should set the user ip' do
post :create, request_params.merge(format: :json)
post :create, params: request_params.merge(format: :json)
discussion_id = response.json['discussions'].first['id']
comment = Comment.where(discussion_id: discussion_id).first
expect(comment.user_ip).to eql request.remote_ip
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/messages_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
end

it 'should set the user ip' do
post :create, request_params.merge(format: :json)
post :create, params: request_params.merge(format: :json)
id = response.json['messages'].first['id']
message = Message.find id
expect(message.user_ip).to eql request.remote_ip
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/moderations_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
before(:each) do
create :moderation, :closed
create :moderation, :watched
get :index, state: state, format: :json
get :index, params: { state: state, format: :json }
end

context 'with a valid state' do
Expand Down Expand Up @@ -84,7 +84,7 @@
context 'when the target is already reported' do
before(:each) do
create :reported_comment, target: target, message: 'first', user: first_user
post :create, request_params.merge(format: :json)
post :create, params: request_params.merge(format: :json)
end

let(:first_user){ create :user }
Expand Down

0 comments on commit 1d3fb85

Please sign in to comment.