aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2017-12-21 17:26:44 +0100
committerTeddy Wing2017-12-21 18:15:05 +0100
commit10d2e7cdf08de08f96e4978595dc33ab26f9d50d (patch)
tree1565e402a4ec8879dc107db197ff9a302c26cff6
parent7aec5b94868bc2e7473f7ded4be7a585fb7b174e (diff)
downloadchouette-core-10d2e7cdf08de08f96e4978595dc33ab26f9d50d.tar.bz2
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
-rw-r--r--config/locales/purchase_windows.en.yml2
-rw-r--r--config/locales/purchase_windows.fr.yml2
-rw-r--r--spec/features/purchase_windows_spec.rb23
3 files changed, 25 insertions, 2 deletions
diff --git a/config/locales/purchase_windows.en.yml b/config/locales/purchase_windows.en.yml
index 5ffed305a..59d00673a 100644
--- a/config/locales/purchase_windows.en.yml
+++ b/config/locales/purchase_windows.en.yml
@@ -48,7 +48,7 @@ en:
title: purchase window %{name}
simple_form:
labels:
- purchase_windows:
+ purchase_window:
date_value: Date
add_a_date: Add a date
add_a_date_range: Add a date range
diff --git a/config/locales/purchase_windows.fr.yml b/config/locales/purchase_windows.fr.yml
index df5d45d82..01476cd92 100644
--- a/config/locales/purchase_windows.fr.yml
+++ b/config/locales/purchase_windows.fr.yml
@@ -48,7 +48,7 @@ fr:
title: Calendrier commercial %{name}
simple_form:
labels:
- calendar:
+ purchase_window:
date_value: Date
add_a_date: Ajouter une date
add_a_date_range: Ajouter un intervalle de dates
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