diff options
| author | Luc Donnet | 2018-01-16 10:05:31 +0100 |
|---|---|---|
| committer | GitHub | 2018-01-16 10:05:31 +0100 |
| commit | b1c55750bb43736c2cb6f9619bddc453cfadb1aa (patch) | |
| tree | 455c246de077f7db95a3bd6549a979dbf57597d7 | |
| parent | 06b37dd16a136eee747103de2144a96cf1718adc (diff) | |
| parent | 88b1e7c640d89d5bb435e4e415105b071ef0d457 (diff) | |
| download | chouette-core-b1c55750bb43736c2cb6f9619bddc453cfadb1aa.tar.bz2 | |
Merge pull request #242 from af83/5140-workbenches-show--organisation-filter-should-show-orgs-
5140-workbenches-show--organisation-filter-should-show-orgs-in-workgroup--v2
| -rw-r--r-- | app/views/workbenches/_filters.html.slim | 8 | ||||
| -rw-r--r-- | spec/features/workbenches/workbenches_show_spec.rb | 30 |
2 files changed, 36 insertions, 2 deletions
diff --git a/app/views/workbenches/_filters.html.slim b/app/views/workbenches/_filters.html.slim index 4d9e0066c..491749515 100644 --- a/app/views/workbenches/_filters.html.slim +++ b/app/views/workbenches/_filters.html.slim @@ -19,7 +19,13 @@ .form-group.togglable = f.label t('activerecord.models.organisation.one'), required: false, class: 'control-label' - = f.input :organisation_name_eq_any, collection: Organisation.order('name').pluck(:name), as: :check_boxes, label: false, label_method: lambda{|w| ("<span>#{w}</span>").html_safe}, required: false, wrapper_html: { class: 'checkbox_list' } + = f.input :organisation_name_eq_any, + collection: @workbench.workgroup.organisations.order('name').pluck(:name), + as: :check_boxes, + label: false, + label_method: lambda { |w| ("<span>#{w}</span>").html_safe }, + required: false, + wrapper_html: { class: 'checkbox_list' } .form-group.togglable = f.label Referential.human_attribute_name(:validity_period), required: false, class: 'control-label' diff --git a/spec/features/workbenches/workbenches_show_spec.rb b/spec/features/workbenches/workbenches_show_spec.rb index f1151a67b..2b215bb03 100644 --- a/spec/features/workbenches/workbenches_show_spec.rb +++ b/spec/features/workbenches/workbenches_show_spec.rb @@ -26,7 +26,23 @@ RSpec.describe 'Workbenches', type: :feature do 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 :workbench_referential, workbench: workbench, metadatas: [another_ref_metadata] } + let(:other_workbench) do + create( + :workbench, + line_referential: line_ref, + organisation: another_organisation, + workgroup: workbench.workgroup + ) + end + let!(:other_referential) do + create( + :workbench_referential, + workbench: other_workbench, + metadatas: [another_ref_metadata], + organisation: other_workbench.organisation + ) + end + before(:each) do visit workbench_path(workbench) @@ -64,6 +80,18 @@ RSpec.describe 'Workbenches', type: :feature do click_button I18n.t('actions.filter') expect(find(box)).to be_checked end + + it 'only lists organisations in the current workgroup' do + unaffiliated_workbench = workbench.dup + unaffiliated_workbench.update(organisation: create(:organisation)) + + expect(page).to have_selector( + "#q_organisation_name_eq_any_#{@user.organisation.name.parameterize.underscore}" + ) + expect(page).to_not have_selector( + "#q_organisation_name_eq_any_#{unaffiliated_workbench.name.parameterize.underscore}" + ) + end end context 'filter by status' do |
