aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/views/workbenches/_filters.html.slim8
-rw-r--r--spec/features/workbenches/workbenches_show_spec.rb30
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