diff options
| author | Zog | 2017-12-18 08:52:18 +0100 |
|---|---|---|
| committer | Zog | 2017-12-19 14:21:52 +0100 |
| commit | 0403917aab03cfc3200f62e70f255bc7887cdcdf (patch) | |
| tree | a417a100bd8e9c6dd9eb583683733670c7e3c550 /spec/views | |
| parent | 3a78b0d44affe79ec297f1a25ee3cfe4ecd32a74 (diff) | |
| download | chouette-core-0403917aab03cfc3200f62e70f255bc7887cdcdf.tar.bz2 | |
Refs #5291@0.5h; Update view
Update the view to match the actual controller behaviour.
Diffstat (limited to 'spec/views')
| -rw-r--r-- | spec/views/offer_workbenches/show.html.erb_spec.rb | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/spec/views/offer_workbenches/show.html.erb_spec.rb b/spec/views/offer_workbenches/show.html.erb_spec.rb index 44dfe88f1..cc01c9d0e 100644 --- a/spec/views/offer_workbenches/show.html.erb_spec.rb +++ b/spec/views/offer_workbenches/show.html.erb_spec.rb @@ -1,5 +1,18 @@ require 'spec_helper' +RSpec::Matchers.define :have_box_for_item do |item, disabled| + match do |actual| + klass = "#{TableBuilderHelper.item_row_class_name([item])}-#{item.id}" + if disabled + selector = "tr.#{klass} [type=checkbox][disabled][value='#{item.id}']" + else + selector = "tr.#{klass} [type=checkbox][value='#{item.id}']:not([disabled])" + end + expect(actual).to have_selector(selector, count: 1) + end + description { "have a #{disabled ? "disabled ": ""}box for the item ##{item.id}" } +end + describe "workbenches/show", :type => :view do let!(:ids) { ['STIF:CODIFLIGNE:Line:C00840', 'STIF:CODIFLIGNE:Line:C00086'] } let!(:lines) { @@ -18,7 +31,7 @@ describe "workbenches/show", :type => :view do before :each do lines controller.request.path_parameters[:id] = workbench.id - expect(workbench.referentials).to include same_organisation_referential + expect(workbench.referentials).to include same_organisation_referential expect(workbench.referentials).to_not include different_organisation_referential expect(workbench.all_referentials).to include same_organisation_referential expect(workbench.all_referentials).to include different_organisation_referential @@ -26,15 +39,19 @@ describe "workbenches/show", :type => :view do end it { should have_link_for_each_item(referentials, "show", -> (referential){ view.referential_path(referential) }) } - it "should enable the checkbox for the referential which belongs to the same organisation" do - klass = "#{TableBuilderHelper.item_row_class_name(referentials)}-#{same_organisation_referential.id}" - selector = "tr.#{klass} [type=checkbox][value='#{same_organisation_referential.id}']:not([disabled])" - expect(rendered).to have_selector(selector, count: 1) + + context "without permission" do + it "should disable all the checkboxes" do + expect(rendered).to have_box_for_item same_organisation_referential, false + expect(rendered).to have_box_for_item different_organisation_referential, true + end end - it "should disable the checkbox for the referential which does not belong to the same organisation" do - klass = "#{TableBuilderHelper.item_row_class_name(referentials)}-#{different_organisation_referential.id}" - selector = "tr.#{klass} [type=checkbox][disabled][value='#{different_organisation_referential.id}']" - expect(rendered).to have_selector(selector, count: 1) + with_permission "referentials.destroy" do + it "should enable the checkbox for the referential which belongs to the same organisation and disable the other one" do + expect(rendered).to have_box_for_item same_organisation_referential, false + expect(rendered).to have_box_for_item different_organisation_referential, true + end end + end |
