-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* keyword argument defaults need to be keyword-ized * Regression test for city merge bug
- Loading branch information
Nick Barnwell
authored
Apr 12, 2018
1 parent
13a8e8d
commit e75ff26
Showing
3 changed files
with
40 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
require 'spec_helper' | ||
|
||
describe CitiesController do | ||
before do | ||
[:away_ye_waitlisted, :authenticate_user!, :authorized?].each do |s| | ||
allow(controller).to receive(s).and_return true | ||
end | ||
end | ||
|
||
describe '#update' do | ||
let(:unapproved_city) { | ||
city = create(:city, :unapproved) | ||
(1..10).each { |i| create(:user, home_city: city) } | ||
city | ||
} | ||
|
||
let(:merge_request) { | ||
{ | ||
id: unapproved_city.city_code, | ||
city: {id: unapproved_city.id}, | ||
merge_city_id: create(:city).id, | ||
approval_action: "merge" | ||
} | ||
} | ||
|
||
it 'should move all users from City A to City B upon merge' do | ||
city_a = unapproved_city | ||
city_a_users = city_a.users | ||
city_b_id = merge_request[:merge_city_id] | ||
|
||
patch :update, merge_request | ||
expect(response).to redirect_to(city_path(city_a)) | ||
expect(city_a_users.map { | ||
|u| u.reload.home_city_id == city_b_id | ||
}.all?).to eq(true) | ||
end | ||
end | ||
end |