-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Spec coverage for migration 20240210161248
- Loading branch information
Showing
41 changed files
with
1,353 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,3 +29,4 @@ todo.txt | |
migration_version.yml | ||
|
||
.DS_Store | ||
current_project.bak |
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
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
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
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 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe Dsu::Migration::Factory do | ||
let(:options) { {} } | ||
|
||
describe '.migrate_if!' do | ||
before do | ||
create(:migration_version, version: version) | ||
end | ||
|
||
context 'when the migration version is not 20230613121411' do | ||
before do | ||
allow(Dsu::Migration::Service20240210161248).to receive(:new) # Stub the :new method | ||
described_class.migrate_if!(options: options) | ||
end | ||
|
||
let(:version) { 0 } | ||
|
||
it 'does not call the migration service' do | ||
expect(Dsu::Migration::Service20240210161248).to_not have_received(:new) | ||
end | ||
end | ||
|
||
context 'when the migration version is 20230613121411' do | ||
before do | ||
create(:migration_version, version: 20230613121411) # rubocop:disable Style/NumericLiterals | ||
allow(Dsu::Migration::Service20240210161248).to receive(:new).and_call_original # Stub :new but allow it to call the original method | ||
described_class.migrate_if!(options: options) | ||
end | ||
|
||
let(:version) { 20230613121411 } # rubocop:disable Style/NumericLiterals | ||
|
||
it 'calls the migration service' do | ||
expect(Dsu::Migration::Service20240210161248).to have_received(:new) | ||
end | ||
end | ||
end | ||
end |
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,97 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe Dsu::Migration::Service20240210161248, type: :migration do | ||
subject(:service) { described_class.new(options: options) } | ||
|
||
before do | ||
create(:migration_version, version: migration_version, options: options) | ||
end | ||
|
||
let(:options) { {} } | ||
let(:migration_version) { 20230613121411 } # rubocop:disable Style/NumericLiterals | ||
|
||
describe '#initialize' do | ||
let(:migration_version) { 0 } | ||
|
||
it_behaves_like 'no error is raised' | ||
end | ||
|
||
describe '#migrate!' do | ||
subject(:service_migrate) { service.migrate! } | ||
|
||
context 'when the migration version is not 20230613121411' do | ||
let(:migration_version) { 0 } | ||
let(:expected_error) do | ||
/Actual migration version .+ is not the expected migration version 20230613121411/ | ||
end | ||
|
||
it_behaves_like 'an error is raised' | ||
end | ||
|
||
context 'when the migration version is 20230613121411' do | ||
before do | ||
mock_migration_version_for(version: migration_version) | ||
service_migrate | ||
end | ||
|
||
shared_examples 'the migration was run in pretend mode' do | ||
let(:expected) { File.join('spec', 'fixtures', 'folders', migration_version.to_s) } | ||
let(:actual) { Dsu::Support::Fileable.dsu_folder } | ||
|
||
it 'does not make any changes to the dsu folder structure or configuration file' do | ||
expect(dsu_folders_match(expected: expected, actual: actual)).to be(true) | ||
end | ||
end | ||
|
||
context 'when the pretend option is implicitly set to true (not provided)' do | ||
it_behaves_like 'the migration was run in pretend mode' | ||
end | ||
|
||
context 'when the pretend option is explicitly set to true' do | ||
let(:options) { { pretend: true } } | ||
|
||
it_behaves_like 'the migration was run in pretend mode' | ||
end | ||
|
||
context 'when the pretend option is set to false' do | ||
let(:options) { { pretend: false } } | ||
let(:expected) { File.join('spec', 'fixtures', 'folders', 20240210161248.to_s) } # rubocop:disable Style/NumericLiterals | ||
let(:actual) { Dsu::Support::Fileable.dsu_folder } | ||
|
||
it 'migrates the dsu folder structure and configuration file' do | ||
expect(dsu_folders_match(expected: expected, actual: actual)).to be(true) | ||
end | ||
|
||
it 'sets all the entry group versions to the correct migration version' do | ||
all_entry_groups = Dsu::Models::EntryGroup.all | ||
expect(all_entry_groups.all? do |entry_group| | ||
entry_group.version == 20240210161248 # rubocop:disable Style/NumericLiterals | ||
end).to be(true) | ||
end | ||
|
||
it 'sets all the color theme versions to the correct migration version' do | ||
all_color_themes = Dsu::Models::ColorTheme.all | ||
expect(all_color_themes.all? do |color_theme| | ||
color_theme.version == 20240210161248 # rubocop:disable Style/NumericLiterals | ||
end).to be(true) | ||
end | ||
|
||
it 'sets the configuration file version to the correct migration version' do | ||
expect(Dsu::Models::Configuration.new.version).to eq(20240210161248) # rubocop:disable Style/NumericLiterals | ||
end | ||
|
||
it 'sets the migration version file version to the correct migration version' do | ||
expect(Dsu::Models::MigrationVersion.new.version).to eq(20240210161248) # rubocop:disable Style/NumericLiterals | ||
end | ||
|
||
it 'copies the christmas color theme' do | ||
expect(Dsu::Models::ColorTheme.new(theme_name: 'christmas').exist?).to be(true) | ||
end | ||
|
||
it 'copies the light color theme' do | ||
expect(Dsu::Models::ColorTheme.new(theme_name: 'light').exist?).to be(true) | ||
end | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.