Skip to content

Commit

Permalink
Fix the quadicon settings migration for users without quadicon settings
Browse files Browse the repository at this point in the history
  • Loading branch information
skateman committed Jun 22, 2018
1 parent 3ab4941 commit f9d1043
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions db/migrate/20180606083431_convert_quadicon_settings_keys.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ def up
say_with_time("Converting :ems quadicon settings keys for users to :ems_infra") do
User.all.each do |user|
settings = user.settings
next unless settings[:quadicons]
settings[:quadicons][:ems_infra] = settings[:quadicons].delete(:ems)
user.update_attributes(:settings => settings)
end
Expand All @@ -17,6 +18,7 @@ def down
say_with_time("Converting :ems_infra quadicon settings keys for users to :ems") do
User.all.each do |user|
settings = user.settings
next unless settings[:quadicons]
settings[:quadicons][:ems] = settings[:quadicons].delete(:ems_infra)
user.update_attributes(:settings => settings)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@
expect(user.settings[:quadicons][:ems]).to be_nil
expect(user.settings[:quadicons][:ems_infra]).to be_falsey
end

it 'skips the user when the quadicons are not set' do
user = user_stub.create!

migrate

user.reload

expect(user.settings).to eq({})
end
end

migration_context :down do
Expand All @@ -27,5 +37,15 @@
expect(user.settings[:quadicons][:ems_infra]).to be_nil
expect(user.settings[:quadicons][:ems]).to be_falsey
end

it 'skips the user when the quadicons are not set' do
user = user_stub.create!

migrate

user.reload

expect(user.settings).to eq({})
end
end
end

0 comments on commit f9d1043

Please sign in to comment.