Add task to simulate data migration
This way we can check everything is OK before actually migrating the data to the translations tables.
This commit is contained in:
@@ -11,6 +11,7 @@ describe "Globalize tasks" do
|
||||
end
|
||||
|
||||
let :run_rake_task do
|
||||
Rake::Task["globalize:simulate_migrate_data"].reenable
|
||||
Rake::Task["globalize:migrate_data"].reenable
|
||||
Rake.application.invoke_task "globalize:migrate_data"
|
||||
end
|
||||
@@ -115,5 +116,34 @@ describe "Globalize tasks" do
|
||||
expect(page.send(:"title_#{I18n.locale}")).to eq("In English")
|
||||
end
|
||||
end
|
||||
|
||||
context "Invalid data" do
|
||||
let!(:valid_process) do
|
||||
create(:legislation_process).tap do |process|
|
||||
process.translations.delete_all
|
||||
process.update_column(:title, "Title")
|
||||
process.reload
|
||||
end
|
||||
end
|
||||
|
||||
let!(:invalid_process) do
|
||||
create(:legislation_process).tap do |process|
|
||||
process.translations.delete_all
|
||||
process.update_column(:title, "")
|
||||
process.reload
|
||||
end
|
||||
end
|
||||
|
||||
it "simulates the task and aborts without creating any translations" do
|
||||
expect(valid_process).to be_valid
|
||||
expect(invalid_process).not_to be_valid
|
||||
|
||||
expect { run_rake_task }.to raise_exception("Simulation failed!")
|
||||
|
||||
expect(Legislation::Process::Translation.count).to eq 0
|
||||
expect(valid_process.reload.title).to eq "Title"
|
||||
expect(invalid_process.reload.title).to eq ""
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user