From 10d2e7cdf08de08f96e4978595dc33ab26f9d50d Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Thu, 21 Dec 2017 17:26:44 +0100 Subject: purchase_windows_spec: Add #index new/create test Add a feature spec that creates a new `PurchaseWindow` from the #index page. Fix i18n keys for `simple_form` to correctly show labels inside the form and be able to identify the correct elements inside the test. Refs #5366 --- spec/features/purchase_windows_spec.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 spec/features/purchase_windows_spec.rb (limited to 'spec/features') diff --git a/spec/features/purchase_windows_spec.rb b/spec/features/purchase_windows_spec.rb new file mode 100644 index 000000000..c30be48a3 --- /dev/null +++ b/spec/features/purchase_windows_spec.rb @@ -0,0 +1,23 @@ +describe "PurchaseWindows", type: :feature do + login_user + + describe "#index" do + with_permissions('purchase_windows.create') do + it "allows users to create new purchase windows" do + name = 'Test purchase window create' + + visit(referential_purchase_windows_path(first_referential.id)) + + click_link(I18n.t('purchase_windows.actions.new')) + + fill_in('purchase_window[name]', with: name) + select('#DD2DAA', from: 'purchase_window[color]') + + click_link(I18n.t('simple_form.labels.purchase_window.add_a_date_range')) + click_button(I18n.t('actions.submit')) + + expect(page).to have_content(name) + end + end + end +end -- cgit v1.2.3 From 174d002f2a14df9e2dfd317271882668fa2a90bb Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Thu, 21 Dec 2017 18:07:24 +0100 Subject: purchase_windows_spec: Add feature test for PurchaseWindow update Test that `PurchaseWindow`s can be updated starting from the `#index` page. Refs #5366 --- spec/features/purchase_windows_spec.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'spec/features') diff --git a/spec/features/purchase_windows_spec.rb b/spec/features/purchase_windows_spec.rb index c30be48a3..0fa576434 100644 --- a/spec/features/purchase_windows_spec.rb +++ b/spec/features/purchase_windows_spec.rb @@ -19,5 +19,28 @@ describe "PurchaseWindows", type: :feature do expect(page).to have_content(name) end end + + with_permissions('purchase_windows.update') do + it "allows users to update purchase windows" do + actual_name = 'Existing purchase window' + expected_name = 'Updated purchase window' + create( + :purchase_window, + referential: first_referential, + name: actual_name + ) + + visit(referential_purchase_windows_path(first_referential.id)) + + click_link(actual_name) + + click_link(I18n.t('purchase_windows.actions.edit')) + fill_in('purchase_window[name]', with: expected_name) + + click_button(I18n.t('actions.submit')) + + expect(page).to have_content(expected_name) + end + end end end -- cgit v1.2.3 From 7c3837d9b5aeac60ce4ea203baba61cd99293a8b Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Thu, 21 Dec 2017 18:09:21 +0100 Subject: purchase_windows_spec: Add feature spec for destroy Check that `PurchaseWindow`s can be destroyed, starting from the `#index` page. Update the i18n key used in the decorator to get the text that appears in the alert when destroying a `PurchaseWindow` so that it correctly corresponds to the one used in the locale file. Refs #5366 --- spec/features/purchase_windows_spec.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'spec/features') diff --git a/spec/features/purchase_windows_spec.rb b/spec/features/purchase_windows_spec.rb index 0fa576434..8edc85cc6 100644 --- a/spec/features/purchase_windows_spec.rb +++ b/spec/features/purchase_windows_spec.rb @@ -42,5 +42,24 @@ describe "PurchaseWindows", type: :feature do expect(page).to have_content(expected_name) end end + + with_permissions('purchase_windows.destroy') do + it "allows users to destroy purchase windows" do + name = 'Existing purchase window' + create( + :purchase_window, + referential: first_referential, + name: name + ) + + visit(referential_purchase_windows_path(first_referential.id)) + + click_link(name) + + click_link(I18n.t('purchase_windows.actions.destroy')) + + expect(page).to_not have_content(name) + end + end end end -- cgit v1.2.3