diff options
| author | cedricnjanga | 2017-11-09 14:36:40 +0100 |
|---|---|---|
| committer | cedricnjanga | 2017-11-09 14:36:40 +0100 |
| commit | dca27ca43414267d316c40071d542435182ea464 (patch) | |
| tree | a2708b76bb2dbcd2b9775417e790e7c1d30c4964 /spec | |
| parent | c11478d257807db1fb8f19f201a2ec0b61f16c78 (diff) | |
| parent | 205d69f10d7011246b331dbf9c0e504b322ff377 (diff) | |
| download | chouette-core-dca27ca43414267d316c40071d542435182ea464.tar.bz2 | |
Merge branch 'master' into staging
Diffstat (limited to 'spec')
26 files changed, 331 insertions, 42 deletions
diff --git a/spec/controllers/api/v1/imports_controller_spec.rb b/spec/controllers/api/v1/imports_controller_spec.rb index 266b25486..8077dd052 100644 --- a/spec/controllers/api/v1/imports_controller_spec.rb +++ b/spec/controllers/api/v1/imports_controller_spec.rb @@ -29,7 +29,7 @@ RSpec.describe Api::V1::ImportsController, type: :controller do it 'should be successful' do expect { - post :create, workbench_id: workbench.id, workbench_import: {file: file, creator: 'test'}, format: :json + post :create, workbench_id: workbench.id, workbench_import: {name: "test", file: file, creator: 'test'}, format: :json }.to change{WorkbenchImport.count}.by(1) expect(response).to be_success end diff --git a/spec/controllers/referentials_controller_spec.rb b/spec/controllers/referentials_controller_spec.rb index a3be0dbd1..fba063085 100644 --- a/spec/controllers/referentials_controller_spec.rb +++ b/spec/controllers/referentials_controller_spec.rb @@ -22,4 +22,12 @@ describe ReferentialsController, :type => :controller do end end + describe 'GET select_compliance_control_set' do + it 'gets compliance control set for current organisation' do + compliance_control_set = create(:compliance_control_set, organisation: @user.organisation) + create(:compliance_control_set) + get :select_compliance_control_set, referential_id: referential.id + expect(assigns[:compliance_control_sets]).to eq([compliance_control_set]) + end + end end diff --git a/spec/controllers/routes_controller_spec.rb b/spec/controllers/routes_controller_spec.rb index 336f20945..fb29c8d73 100644 --- a/spec/controllers/routes_controller_spec.rb +++ b/spec/controllers/routes_controller_spec.rb @@ -89,7 +89,7 @@ RSpec.describe RoutesController, type: :controller do id: route.id end.to change { Route.count }.by(1) - expect(Route.last.name).to eq(route.name) + expect(Route.last.name).to eq( I18n.t('activerecord.copy', name: route.name)) expect(Route.last.published_name).to eq(route.published_name) end end diff --git a/spec/decorators/referential_decorator_spec.rb b/spec/decorators/referential_decorator_spec.rb index 16da8d30b..3959a5924 100644 --- a/spec/decorators/referential_decorator_spec.rb +++ b/spec/decorators/referential_decorator_spec.rb @@ -34,6 +34,7 @@ RSpec.describe ReferentialDecorator, type: [:helper, :decorator] do expect_action_link_hrefs.to eq([ referential_time_tables_path(object), new_referential_path(from: object), + referential_select_compliance_control_set_path(object) ]) end end @@ -46,6 +47,7 @@ RSpec.describe ReferentialDecorator, type: [:helper, :decorator] do expect_action_link_hrefs.to eq([ referential_time_tables_path(object), new_referential_path(from: object), + referential_select_compliance_control_set_path(object), archive_referential_path(object), referential_path(object) ]) diff --git a/spec/factories/referentials.rb b/spec/factories/referentials.rb index 5348ad96b..a4155d181 100644 --- a/spec/factories/referentials.rb +++ b/spec/factories/referentials.rb @@ -3,11 +3,17 @@ FactoryGirl.define do sequence(:name) { |n| "Test #{n}" } sequence(:slug) { |n| "test_#{n}" } sequence(:prefix) { |n| "test_#{n}" } - association :organisation - association :workbench association :line_referential association :stop_area_referential + association :organisation time_zone "Europe/Paris" ready { true } + + factory :workbench_referential do + association :workbench + before :create do | ref | + ref.workbench.organisation = ref.organisation + end + end end end diff --git a/spec/features/compliance_control_sets_spec.rb b/spec/features/compliance_control_sets_spec.rb new file mode 100644 index 000000000..500d4ce6f --- /dev/null +++ b/spec/features/compliance_control_sets_spec.rb @@ -0,0 +1,82 @@ +RSpec.describe "ComplianceControlSets", type: :feature do + + login_user + + # We setup a control_set with two blocks and one direct control (meaning that it is not attached to a block) + # Then we add one control to the first block and two controls to the second block + let( :control_set ){ create :compliance_control_set, organisation: organisation } + let( :controls ){ control_set.compliance_controls } + + let(:blox){ + 2.times.map{ | _ | create :compliance_control_block, compliance_control_set: control_set } + } + + before do + blox.first.update transport_mode: 'bus', transport_submode: 'bus' + blox.second.update transport_mode: 'train', transport_submode: 'train' + + make_control + make_control blox.first, severity: :error + make_control blox.second, times: 2 + end + + describe 'show' do + before do + visit compliance_control_set_path( control_set ) + end + + it 'we can see the controls inside their blocks' do + controls.each do | control | + expect( page ).to have_content(control.code) + end + end + + it 'we can apply a severity filter' do + controls.take(2).each do | control | + control.update criticity: 'error' + end + check('error') + click_on('Filtrer') + controls.each do | control | + if control.criticity == 'error' + expect( page ).to have_content(control.code) + else + expect( page ).not_to have_content(control.code) + end + end + end + + it 'we can apply a subclass filter' do + controls.first.update(origin_code: 'x-Route-y') + controls.second.update(origin_code: 'x-Line-y') + + within('#subclass-filter') do + check('Itinéraire') + check('Ligne') + end + click_on('Filtrer') + controls.each do | control | + if control.origin_code[/-Generic-/] + expect( page ).not_to have_content(control.code) + else + expect( page ).to have_content(control.code) + end + end + end + + end + + def make_control ccblock=nil, times: 1, severity: :warning + times.times do + make_one_control ccblock, severity + end + end + + def make_one_control ccblock, severity + create( :generic_attribute_control_min_max, + code: random_string, + compliance_control_block: ccblock, + compliance_control_set: control_set) + end + +end diff --git a/spec/features/connection_links_spec.rb b/spec/features/connection_links_spec.rb index 7272242fe..2f6283dcd 100644 --- a/spec/features/connection_links_spec.rb +++ b/spec/features/connection_links_spec.rb @@ -1,4 +1,4 @@ -RSpec.describe "ConnectionLinks", :type => :feature do +RSpec.describe "ConnectionLinks", type: :feature do login_user let!(:connection_links) { Array.new(2) { create(:connection_link) } } diff --git a/spec/features/workbenches_spec.rb b/spec/features/workbenches_spec.rb index e33f8c134..f1151a67b 100644 --- a/spec/features/workbenches_spec.rb +++ b/spec/features/workbenches_spec.rb @@ -1,6 +1,4 @@ -# coding: utf-8 - -describe 'Workbenches', type: :feature do +RSpec.describe 'Workbenches', type: :feature do login_user let(:line_ref) { create :line_referential } @@ -8,7 +6,7 @@ describe 'Workbenches', type: :feature do let(:ref_metadata) { create(:referential_metadata, lines: [line]) } let!(:workbench) { create(:workbench, line_referential: line_ref, organisation: @user.organisation) } - let!(:referential) { create :referential, workbench: workbench, metadatas: [ref_metadata], organisation: @user.organisation } + let!(:referential) { create :workbench_referential, workbench: workbench, metadatas: [ref_metadata], organisation: @user.organisation } describe 'show' do context 'ready' do @@ -25,10 +23,10 @@ describe 'Workbenches', type: :feature do end context 'filtering' do - let(:another_organisation) { create :organisation } + let!(:another_organisation) { create :organisation } let(:another_line) { create :line, line_referential: line_ref } let(:another_ref_metadata) { create(:referential_metadata, lines: [another_line]) } - let!(:other_referential) { create :referential, workbench: workbench, metadatas: [another_ref_metadata], organisation: another_organisation} + let!(:other_referential) { create :workbench_referential, workbench: workbench, metadatas: [another_ref_metadata] } before(:each) do visit workbench_path(workbench) @@ -53,7 +51,7 @@ describe 'Workbenches', type: :feature do it 'should be possible to filter by multiple organisation' do find("#q_organisation_name_eq_any_#{@user.organisation.name.parameterize.underscore}").set(true) - find("#q_organisation_name_eq_any_#{another_organisation.name.parameterize.underscore}").set(true) + find("#q_organisation_name_eq_any_#{other_referential.organisation.name.parameterize.underscore}").set(true) click_button I18n.t('actions.filter') expect(page).to have_content(referential.name) diff --git a/spec/helpers/table_builder_helper_spec.rb b/spec/helpers/table_builder_helper_spec.rb index e17196a19..a8854bf97 100644 --- a/spec/helpers/table_builder_helper_spec.rb +++ b/spec/helpers/table_builder_helper_spec.rb @@ -7,7 +7,7 @@ end describe TableBuilderHelper, type: :helper do describe "#table_builder_2" do it "builds a table" do - referential = build_stubbed(:referential) + referential = build_stubbed(:workbench_referential) workbench = referential.workbench user_context = UserContext.new( @@ -81,6 +81,7 @@ describe TableBuilderHelper, type: :helper do <li><a href="/referentials/#{referential.id}/edit">Editer</a></li> <li><a href="/referentials/#{referential.id}/time_tables">Calendriers</a></li> <li><a href="/referentials/new?from=#{referential.id}">Dupliquer</a></li> + <li><a href="/referentials/#{referential.id}/select_compliance_control_set">Valider</a></li> <li><a rel="nofollow" data-method="put" href="/referentials/#{referential.id}/archive">Conserver</a></li> <li class="delete-action"><a data-confirm="Etes vous sûr de vouloir supprimer ce jeu de données ?" rel="nofollow" data-method="delete" href="/referentials/#{referential.id}"><span class="fa fa-trash mr-xs"></span>Supprimer</a></li> </ul> diff --git a/spec/lib/compliance_control_set_cloner_spec.rb b/spec/lib/compliance_control_set_cloner_spec.rb index 4305ec70b..c17f0bb52 100644 --- a/spec/lib/compliance_control_set_cloner_spec.rb +++ b/spec/lib/compliance_control_set_cloner_spec.rb @@ -7,7 +7,6 @@ RSpec.describe ComplianceControlSetCloner do let( :source_set ){ create :compliance_control_set } let( :set_prefix ){ I18n.t('compliance_control_sets.clone.prefix') } let( :block_prefix ){ I18n.t('compliance_control_blocks.clone.prefix') } - let( :control_prefix ){ I18n.t('compliance_controls.clone.prefix') } context 'Copying empty set' do @@ -96,7 +95,7 @@ RSpec.describe ComplianceControlSetCloner do expect( target.compliance_control_set ).to eq( target_set ) expect( target.control_attributes ).to eq(source.control_attributes) expect( target.criticity ).to eq(source.criticity ) - expect( target.name ).to eq([control_prefix, source.name].join(' ')) + expect( target.name ).to eq(source.name) expect( target.origin_code ).to eq(source.origin_code ) expect( target.type ).to eq(source.type) end diff --git a/spec/lib/compliance_control_set_copier_spec.rb b/spec/lib/compliance_control_set_copier_spec.rb index a9e576cf7..0f15d86d0 100644 --- a/spec/lib/compliance_control_set_copier_spec.rb +++ b/spec/lib/compliance_control_set_copier_spec.rb @@ -99,6 +99,10 @@ RSpec.describe ComplianceControlSetCopier do expect( actual ).to eq( expected ) end + + it 'returns the newly-created ComplianceCheckSet' do + expect(subject.copy(cc_set.id, ref.id)).to eq(cck_set) + end end end diff --git a/spec/models/chouette/route/route_duplication_spec.rb b/spec/models/chouette/route/route_duplication_spec.rb index 6645b909f..5bcd13fc8 100644 --- a/spec/models/chouette/route/route_duplication_spec.rb +++ b/spec/models/chouette/route/route_duplication_spec.rb @@ -11,7 +11,7 @@ RSpec.describe Route do describe 'properties' do it 'same attribute values' do route.duplicate - expect( values_for_create(Route.last, except: %w{objectid}) ).to eq( values_for_create( route, except: %w{objectid} ) ) + expect( values_for_create(Route.last, except: %w{objectid name checksum checksum_source}) ).to eq( values_for_create( route, except: %w{objectid name checksum checksum_source} ) ) end it 'and others cannot' do expect{ route.duplicate name: 'YAN', line_id: 42 }.to raise_error(ArgumentError) @@ -38,7 +38,7 @@ RSpec.describe Route do let( :second_duplicate ){ first_duplicate.reload.duplicate } it 'the required attributes' do - expect( values_for_create(first_duplicate, except: %w{objectid}) ).to eq( values_for_create( second_duplicate, except: %w{objectid} ) ) + expect( values_for_create(first_duplicate, except: %w{objectid name checksum checksum_source}) ).to eq( values_for_create( second_duplicate, except: %w{objectid name checksum checksum_source} ) ) end it 'the stop areas' do diff --git a/spec/models/compliance_control_class_level_defaults/compliance_control_subclass_pattern_spec.rb b/spec/models/compliance_control_class_level_defaults/compliance_control_subclass_pattern_spec.rb new file mode 100644 index 000000000..868eca984 --- /dev/null +++ b/spec/models/compliance_control_class_level_defaults/compliance_control_subclass_pattern_spec.rb @@ -0,0 +1,17 @@ +RSpec.describe ComplianceControl do + let( :subject ){ described_class.subclass_patterns } + + context 'subclass_patterns' do + it 'are correctly defined' do + expect_it.to eq( + generic: 'Generic', + journey_pattern: 'JourneyPattern', + line: 'Line', + route: 'Route', + routing_constraint_zone: 'RoutingConstraint', + vehicle_journey: 'VehicleJourney' + ) + end + end + +end diff --git a/spec/models/compliance_control_spec.rb b/spec/models/compliance_control_spec.rb index db73dab21..4267459ea 100644 --- a/spec/models/compliance_control_spec.rb +++ b/spec/models/compliance_control_spec.rb @@ -4,10 +4,6 @@ RSpec.describe ComplianceControl, type: :model do let(:compliance_control) { build_stubbed :compliance_control } - it 'should have a valid factory' do - expect(compliance_control).to be_valid - end - it { should belong_to :compliance_control_set } it { should belong_to :compliance_control_block } diff --git a/spec/models/import_spec.rb b/spec/models/import_spec.rb index c06d05dab..7be05908a 100644 --- a/spec/models/import_spec.rb +++ b/spec/models/import_spec.rb @@ -10,7 +10,7 @@ RSpec.describe Import, type: :model do it { should validate_presence_of(:workbench) } it { should validate_presence_of(:creator) } - it { should allow_value('file.zip').for(:file).with_message(I18n.t('activerecord.errors.models.imports.wrong_file_extension')) } + it { should allow_value('file.zip').for(:file).with_message(I18n.t('activerecord.errors.models.import.attributes.file.wrong_file_extension')) } it { should_not allow_values('file.json', 'file.png', 'file.pdf').for(:file) } let(:workbench_import) { build_stubbed(:workbench_import) } diff --git a/spec/models/referential/referential_org_through_workbench_spec.rb b/spec/models/referential/referential_org_through_workbench_spec.rb new file mode 100644 index 000000000..358a9e5e6 --- /dev/null +++ b/spec/models/referential/referential_org_through_workbench_spec.rb @@ -0,0 +1,44 @@ +RSpec.describe Referential do + + describe 'Normalisation between Workbench and Organisation' do + + context 'no workbench' do + subject{ create( :referential, workbench: nil ) } + it do + expect_it.to be_valid + end + end + context 'workbench with same organisation' do + let( :workbench ){ create :workbench} + subject do + create( :referential, + workbench: workbench, + organisation: workbench.organisation ) + end + it do + expect_it.to be_valid + end + end + + context 'workbench with different organisation' do + let( :workbench ){ create :workbench} + subject do + build( :referential, workbench: workbench) + end + before do + subject.organisation = build_stubbed(:organisation) + end + it 'is not valid' do + expect_it.not_to be_valid + end + it 'has correct error message' do + subject.valid? + errors = subject.errors.messages[:inconsistent_organisation] + expect(errors.grep(%r<#{subject.organisation.name}>)).not_to be_empty + expect(errors.grep(%r<#{workbench.organisation.name}>)).not_to be_empty + end + end + + end + +end diff --git a/spec/models/referential_spec.rb b/spec/models/referential_spec.rb index bb8fabb2e..ad9c43010 100644 --- a/spec/models/referential_spec.rb +++ b/spec/models/referential_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe Referential, :type => :model do - let(:ref) { create :referential, metadatas: [create(:referential_metadata)] } + let(:ref) { create :workbench_referential, metadatas: [create(:referential_metadata)] } # it "create a rule_parameter_set" do # referential = create(:referential) diff --git a/spec/models/referential_suite/referential_suite_current_new_spec.rb b/spec/models/referential_suite/referential_suite_current_new_spec.rb new file mode 100644 index 000000000..a910a12da --- /dev/null +++ b/spec/models/referential_suite/referential_suite_current_new_spec.rb @@ -0,0 +1,64 @@ +RSpec.describe ReferentialSuite do + + describe 'Normalisation of current and new towards a proper Referential' do + + subject { create :referential_suite, new: nil, current: nil } + + describe 'valid' do + context 'current and new nil' do + it do + expect_it.to be_valid + end + end + + context 'current nil and new pointing correctly back' do + let( :child ){ create :referential, referential_suite: subject } + it do + subject.new_id = child.id + expect_it.to be_valid + end + end + + context 'new nil and current pointing correctly back' do + let( :child ){ create :referential, referential_suite: subject } + it do + subject.current_id = child.id + expect_it.to be_valid + end + end + + context 'new and current pointing correctly back' do + let( :child ){ create :referential, referential_suite: subject } + let( :sibbling ){ create :referential, referential_suite: subject } + it do + subject.current_id = child.id + subject.new_id = sibbling.id + expect_it.to be_valid + end + end + end + + describe 'invalid' do + context 'current points to incorrect referential(not a child), new is nil' do + let( :current ){ create :referential } + it do + subject.current_id = current.id + expect_it.not_to be_valid + expect( subject.errors.messages[:inconsistent_new] ).to be_nil + expect( subject.errors.messages[:inconsistent_current].first ).to match(%r<#{current.name}>) + end + end + context 'current points to correct referential, new to incorrect referential(not a child)' do + let( :current ){ create :referential, referential_suite: subject } + let( :new ){ create :referential, referential_suite: create( :referential_suite ) } + it do + subject.current_id = current.id + subject.new_id = new.id + expect_it.not_to be_valid + expect( subject.errors.messages[:inconsistent_current] ).to be_nil + expect( subject.errors.messages[:inconsistent_new].first ).to match(%r<#{new.name}>) + end + end + end + end +end diff --git a/spec/models/referential_suite_spec.rb b/spec/models/referential_suite/referential_suite_spec.rb index 771187b55..771187b55 100644 --- a/spec/models/referential_suite_spec.rb +++ b/spec/models/referential_suite/referential_suite_spec.rb diff --git a/spec/policies/compliance_control_policy_spec.rb b/spec/policies/compliance_control_policy_spec.rb index d7c80143d..c66fa8f93 100644 --- a/spec/policies/compliance_control_policy_spec.rb +++ b/spec/policies/compliance_control_policy_spec.rb @@ -2,27 +2,18 @@ require 'rails_helper' RSpec.describe ComplianceControlPolicy do - let(:user) { User.new } - - subject { described_class } - - permissions ".scope" do - pending "add some examples to (or delete) #{__FILE__}" - end - - permissions :show? do - pending "add some examples to (or delete) #{__FILE__}" - end + let( :record ){ build_stubbed :compliance_control } + before { stub_policy_scope(record) } permissions :create? do - pending "add some examples to (or delete) #{__FILE__}" + it_behaves_like 'permitted policy outside referential', 'compliance_controls.create' end permissions :update? do - pending "add some examples to (or delete) #{__FILE__}" + it_behaves_like 'permitted policy outside referential', 'compliance_controls.update' end permissions :destroy? do - pending "add some examples to (or delete) #{__FILE__}" + it_behaves_like 'permitted policy outside referential', 'compliance_controls.destroy' end end diff --git a/spec/policies/compliance_control_set_policy_spec.rb b/spec/policies/compliance_control_set_policy_spec.rb new file mode 100644 index 000000000..6ab0bd60c --- /dev/null +++ b/spec/policies/compliance_control_set_policy_spec.rb @@ -0,0 +1,23 @@ +require 'rails_helper' + +RSpec.describe ComplianceControlSetPolicy do + + let( :record ){ build_stubbed :compliance_control_set } + before { stub_policy_scope(record) } + + permissions :create? do + it_behaves_like 'permitted policy outside referential', 'compliance_controls_sets.create' + end + + permissions :update? do + it_behaves_like 'permitted policy outside referential', 'compliance_controls_sets.update' + end + + permissions :clone? do + it_behaves_like 'permitted policy outside referential', 'compliance_controls_sets.create' + end + + permissions :destroy? do + it_behaves_like 'permitted policy outside referential', 'compliance_controls_sets.destroy' + end +end diff --git a/spec/requests/api/v1/netex_import_spec.rb b/spec/requests/api/v1/netex_import_spec.rb index b6728168e..a90e51e5b 100644 --- a/spec/requests/api/v1/netex_import_spec.rb +++ b/spec/requests/api/v1/netex_import_spec.rb @@ -2,7 +2,7 @@ RSpec.describe "NetexImport", type: :request do describe 'POST netex_imports' do - let( :referential ){ create :referential } + let( :referential ){ create :workbench_referential } let( :workbench ){ referential.workbench } let( :workbench_import ){ create :workbench_import } diff --git a/spec/support/pundit/shared_examples.rb b/spec/support/pundit/shared_examples.rb index 49c6845da..49f915626 100644 --- a/spec/support/pundit/shared_examples.rb +++ b/spec/support/pundit/shared_examples.rb @@ -129,3 +129,23 @@ RSpec.shared_examples 'permitted policy' do end end end + +RSpec.shared_examples 'permitted policy outside referential' do + | permission | + + context 'permission absent → ' do + it "denies user" do + expect_it.not_to permit(user_context, record) + end + end + + context 'permission present → ' do + before do + add_permissions(permission, to_user: user) + end + + it 'allows user' do + expect_it.to permit(user_context, record) + end + end +end
\ No newline at end of file diff --git a/spec/workers/compliance_control_set_copy_worker_spec.rb b/spec/workers/compliance_control_set_copy_worker_spec.rb new file mode 100644 index 000000000..0ff721e75 --- /dev/null +++ b/spec/workers/compliance_control_set_copy_worker_spec.rb @@ -0,0 +1,35 @@ +RSpec.describe ComplianceControlSetCopyWorker do + let(:control_set_id) { 55 } + let(:referential_id) { 99 } + let(:check_set) { double(ComplianceCheckSet, id: 888) } + let(:stub_validation_request) do + stub_request( + :get, + "#{Rails.configuration.iev_url}/boiv_iev/referentials/validator/new?id=#{check_set.id}" + ) + end + + before(:each) do + allow_any_instance_of( + ComplianceControlSetCopier + ).to receive(:copy).and_return(check_set) + + stub_validation_request + end + + it "calls ComplianceControlSetCopier" do + expect_any_instance_of( + ComplianceControlSetCopier + ).to receive(:copy) + .with(control_set_id, referential_id) + .and_return(check_set) + + ComplianceControlSetCopyWorker.new.perform(control_set_id, referential_id) + end + + it "calls the Java API to launch validation" do + ComplianceControlSetCopyWorker.new.perform(control_set_id, referential_id) + + expect(stub_validation_request).to have_been_requested + end +end diff --git a/spec/workers/workbench_import/workbench_import_with_corrupt_zip_spec.rb b/spec/workers/workbench_import/workbench_import_with_corrupt_zip_spec.rb index 5e34b208a..47626f5a1 100644 --- a/spec/workers/workbench_import/workbench_import_with_corrupt_zip_spec.rb +++ b/spec/workers/workbench_import/workbench_import_with_corrupt_zip_spec.rb @@ -1,6 +1,5 @@ RSpec.describe WorkbenchImportWorker do - shared_examples_for 'corrupt zipfile data' do subject { described_class.new } let( :workbench_import ){ create :workbench_import, status: :pending } @@ -23,7 +22,7 @@ RSpec.describe WorkbenchImportWorker do message = workbench_import.messages.last expect( message.criticity ).to eq('error') expect( message.message_key ).to eq('corrupt_zip_file') - expect( message.message_attributes ).to eq( 'import_name' => workbench_import.name ) + expect( message.message_attributes ).to eq( 'source_filename' => workbench_import.file.file.file ) end it 'does not change current step' do diff --git a/spec/workers/workbench_import/workbench_import_worker_spec.rb b/spec/workers/workbench_import/workbench_import_worker_spec.rb index deaa1e3a5..47ca2b4ff 100644 --- a/spec/workers/workbench_import/workbench_import_worker_spec.rb +++ b/spec/workers/workbench_import/workbench_import_worker_spec.rb @@ -115,8 +115,8 @@ RSpec.describe WorkbenchImportWorker, type: [:worker, :request] do let( :spurious ){ [spurious1, spurious2] } let( :messages ){ double('messages') } let( :message_attributes ){{criticity: :warning, message_key: 'inconsistent_zip_file'}} - let( :message1_attributes ){ message_attributes.merge(message_attributes: {'import_name' => import.name, 'spurious_dirs' => spurious1.join(', ')}) } - let( :message2_attributes ){ message_attributes.merge(message_attributes: {'import_name' => import.name, 'spurious_dirs' => spurious2.join(', ')}) } + let( :message1_attributes ){ message_attributes.merge(message_attributes: {'source_filename' => import.file.file.file, 'spurious_dirs' => spurious1.join(', ')}) } + let( :message2_attributes ){ message_attributes.merge(message_attributes: {'source_filename' => import.file.file.file, 'spurious_dirs' => spurious2.join(', ')}) } before do allow(import).to receive(:messages).and_return(messages) |
