Skip to content

Commit

Permalink
Merge branch 'master' into rails-5---deprecated-method-collect-in-sea…
Browse files Browse the repository at this point in the history
…rches_controller
  • Loading branch information
yuenmichelle1 authored Aug 9, 2024
2 parents 6d8f30d + 9db089a commit 6ad570b
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
14 changes: 7 additions & 7 deletions spec/controllers/notifications_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
let!(:notifications){ create_list :notification, 2 }

it 'should scope updates to the user' do
put :read, { format: :json, id: notifications.map(&:id).join(',') }
put :read, params: { format: :json, id: notifications.map(&:id).join(',') }
statuses = notifications.map{ |notification| notification.reload.delivered }
expect(statuses).to all be false
end
Expand Down Expand Up @@ -68,18 +68,18 @@
let!(:others){ create_list :notification, 2, section: 'project-1' }

it 'should scope updates to the user with specified ids' do
put :read, { format: :json, id: ([record, record2] + others).map(&:id).join(',') }
put :read, params: { format: :json, id: ([record, record2] + others).map(&:id).join(',') }
owned_statuses = [record, record2].map{ |notification| notification.reload.delivered }
expect(owned_statuses).to all be true
end

it 'should not update unspecified notifications with specified ids' do
put :read, { format: :json, id: ([record, record2] + others).map(&:id).join(',') }
put :read, params: { format: :json, id: ([record, record2] + others).map(&:id).join(',') }
expect(record3.reload).to_not be_delivered
end

it 'should scope updates to the user with specified ids' do
put :read, { format: :json, id: ([record, record2] + others).map(&:id).join(',') }
put :read, params: { format: :json, id: ([record, record2] + others).map(&:id).join(',') }
other_statuses = others.map{ |notification| notification.reload.delivered }
expect(other_statuses).to all be false
end
Expand All @@ -97,18 +97,18 @@
end

it 'should scope updates to the user with the specified section' do
put :read, { format: :json, section: 'project-1' }
put :read, params: { format: :json, section: 'project-1' }
section_statuses = [record, record2].map{ |notification| notification.reload.delivered }
expect(section_statuses).to all be true
end

it 'should not update other sections for the user' do
put :read, { format: :json, section: 'project-1' }
put :read, params: { format: :json, section: 'project-1' }
expect(record3.reload).to_not be_delivered
end

it 'should not update for other users in the section' do
put :read, { format: :json, section: 'project-1' }
put :read, params: { format: :json, section: 'project-1' }
expect(others.map(&:reload).map(&:delivered)).to all be false
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/searches_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
RSpec.describe SearchesController, type: :controller do
let(:send_request){ get :index, request_params.merge(format: :json) }
let(:send_request){ get :index, params: request_params.merge(format: :json) }

describe '#index' do
context 'without a section param' do
Expand Down
6 changes: 3 additions & 3 deletions spec/controllers/tags_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
if serializer
allow(serializer).to receive(:resource).and_call_original
end
get :popular, params
get :popular, params: params
end

it 'should use the correct serializer' do
Expand Down Expand Up @@ -129,7 +129,7 @@
let!(:tag){ create :tag, name: 'foo' }
let(:params){ { } }
subject{ response }
before(:each){ get :autocomplete, params }
before(:each){ get :autocomplete, params: params }

context 'without a search' do
let(:params){ { search: 'f' } }
Expand All @@ -153,7 +153,7 @@
completer = double results: []
expect(TagCompletion).to receive(:new).with('f', 'project-1', limit: 5).and_return completer
expect(completer).to receive :results
get :autocomplete, params
get :autocomplete, params: params
end
end
end
Expand Down
10 changes: 5 additions & 5 deletions spec/controllers/unsubscribe_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,31 @@

context 'with a valid token' do
it 'should render' do
get :index, token: valid_token
get :index, params: { token: valid_token }
expect(response).to be_ok
end

it 'should log the event' do
expect(EventLog).to receive(:create).with label: 'unsubscribe', user_id: user.id, payload: { ip: String }
get :index, token: valid_token
get :index, params: { token: valid_token }
end

it 'should unsubscribe the user' do
get :index, token: valid_token
get :index, params: { token: valid_token }
digests = user.subscription_preferences.map &:email_digest
expect(digests).to all eql 'never'
end
end

context 'without a valid token' do
it 'should render' do
get :index, token: 'nope'
get :index, params: { token: 'nope' }
expect(response).to be_ok
end

it 'should log the event' do
expect(EventLog).to receive(:create).with label: 'unsubscribe', user_id: nil, payload: { ip: String }
get :index, token: 'nope'
get :index, params: { token: 'nope' }
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/users_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

before(:each) do
allow(controller).to receive(:current_user).and_return current_user
get :autocomplete, params
get :autocomplete, params: params
end

context 'without an authorized user' do
Expand Down Expand Up @@ -61,7 +61,7 @@
completer = double results: []
expect(UsernameCompletion).to receive(:new).with(current_user, 'f', limit: 5).and_return completer
expect(completer).to receive :results
get :autocomplete, params
get :autocomplete, params: params
end
end
end
Expand Down

0 comments on commit 6ad570b

Please sign in to comment.