aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/features/timebands_spec.rb62
-rw-r--r--spec/views/timebands/edit.html.erb_spec.rb23
-rw-r--r--spec/views/timebands/index.html.erb_spec.rb20
-rw-r--r--spec/views/timebands/new.html.erb_spec.rb21
-rw-r--r--spec/views/timebands/show.html.erb_spec.rb24
5 files changed, 150 insertions, 0 deletions
diff --git a/spec/features/timebands_spec.rb b/spec/features/timebands_spec.rb
new file mode 100644
index 000000000..6f07fab4f
--- /dev/null
+++ b/spec/features/timebands_spec.rb
@@ -0,0 +1,62 @@
+# -*- coding: utf-8 -*-
+require 'spec_helper'
+
+describe "Timebands", :type => :feature do
+ login_user
+
+ let!(:timebands) { Array.new(2) { create(:timeband) } }
+ subject { timebands.first }
+
+ describe "list" do
+ it "display timebands" do
+ visit referential_timebands_path(referential)
+ expect(page).to have_content(timebands.first.name)
+ expect(page).to have_content(timebands.last.name)
+ end
+
+ end
+
+ describe "show" do
+ it "display timeband" do
+ visit referential_timebands_path(referential)
+ click_link "#{timebands.first.name}"
+ expect(page).to have_content(timebands.first.name)
+ end
+
+ end
+
+ describe "new" do
+ it "creates timeband and return to show" do
+ visit referential_timebands_path(referential)
+ click_link "Ajouter une plage horaire"
+ fill_in "Titre", :with => "Timeband 1"
+
+ select '10', from: 'timeband_start_time_4i'
+ select '00', from: 'timeband_start_time_5i'
+ select '11', from: 'timeband_end_time_4i'
+ select '00', from: 'timeband_end_time_5i'
+
+ click_button("Créer plage horaire")
+ expect(page).to have_content("Timeband 1")
+ end
+ end
+
+ describe "edit and return to show" do
+ it "edit timeband" do
+ visit referential_timeband_path(referential, subject)
+ click_link "Modifier cette plage horaire"
+ fill_in "Titre", :with => "Timeband Modified"
+ click_button("Modifier plage horaire")
+ expect(page).to have_content("Timeband Modified")
+ end
+ end
+
+ describe "delete and return to list" do
+ it "delete timeband" do
+ visit referential_timebands_path(referential)
+ page.all('.remove')[0].click
+ expect(page).to_not have_content("Timeband Modified")
+ end
+ end
+
+end
diff --git a/spec/views/timebands/edit.html.erb_spec.rb b/spec/views/timebands/edit.html.erb_spec.rb
new file mode 100644
index 000000000..26c85c229
--- /dev/null
+++ b/spec/views/timebands/edit.html.erb_spec.rb
@@ -0,0 +1,23 @@
+require 'spec_helper'
+
+describe "/timebands/edit", :type => :view do
+ assign_referential
+ let!(:timeband) { assign(:timeband, create(:timeband) ) }
+
+ describe "test" do
+ it "should render h2 with the group name" do
+ render
+ expect(rendered).to have_selector("h2", text: Regexp.new(timeband.name))
+ end
+ end
+
+ describe "form" do
+ it "should render input for timeband" do
+ render
+ expect(rendered).to have_selector("form") do
+ with_tag "input[type=text][name='timeband[name]'][value=?]", timeband.name
+ end
+ end
+
+ end
+end
diff --git a/spec/views/timebands/index.html.erb_spec.rb b/spec/views/timebands/index.html.erb_spec.rb
new file mode 100644
index 000000000..0ce0c419c
--- /dev/null
+++ b/spec/views/timebands/index.html.erb_spec.rb
@@ -0,0 +1,20 @@
+require 'spec_helper'
+
+describe "/timebands/index", :type => :view do
+
+ assign_referential
+ let!(:timebands) { assign :timebands, Array.new(2){ create(:timeband) }.paginate }
+
+ it "should render a show link for each timeband" do
+ render
+ timebands.each do |timeband|
+ expect(rendered).to have_selector("a[href='#{view.referential_timeband_path(referential, timeband)}']", :text => timeband.name)
+ end
+ end
+
+ it "should render a link to create a new timeband" do
+ render
+ expect(view.content_for(:sidebar)).to have_selector(".actions a[href='#{new_referential_timeband_path(referential)}']")
+ end
+
+end
diff --git a/spec/views/timebands/new.html.erb_spec.rb b/spec/views/timebands/new.html.erb_spec.rb
new file mode 100644
index 000000000..73a99cad5
--- /dev/null
+++ b/spec/views/timebands/new.html.erb_spec.rb
@@ -0,0 +1,21 @@
+require 'spec_helper'
+
+describe "/timebands/new", :type => :view do
+ assign_referential
+ let!(:timeband) { assign(:timeband, build(:timeband)) }
+
+ describe "form" do
+
+ it "should render inputs" do
+ render
+ expect(rendered).to have_selector("form") do
+ with_selector "input[type=text][name=?]", timeband.name
+ with_selector "select[start_time(4i)=?]", timeband.start_time
+ with_selector "select[start_time(5i)=?]", timeband.start_time
+ with_selector "select[end_time(4i)=?]", timeband.end_time
+ with_selector "select[end_time(5i)=?]", timeband.end_time
+ end
+ end
+
+ end
+end
diff --git a/spec/views/timebands/show.html.erb_spec.rb b/spec/views/timebands/show.html.erb_spec.rb
new file mode 100644
index 000000000..d43ba588c
--- /dev/null
+++ b/spec/views/timebands/show.html.erb_spec.rb
@@ -0,0 +1,24 @@
+require 'spec_helper'
+
+describe "/timebands/show", :type => :view do
+
+ assign_referential
+ let!(:timeband) { assign(:timeband, create(:timeband)) }
+
+ it "should render h2 with the timeband name" do
+ render
+ expect(rendered).to have_selector("h2", text: Regexp.new(timeband.name))
+ end
+
+ it "should render a link to edit the timeband" do
+ render
+ expect(view.content_for(:sidebar)).to have_selector(".actions a[href='#{view.edit_referential_timeband_path(referential, timeband)}']")
+ end
+
+ it "should render a link to remove the timeband" do
+ render
+ expect(view.content_for(:sidebar)).to have_selector(".actions a[href='#{view.referential_timeband_path(referential, timeband)}'][class='remove']")
+ end
+
+end
+