aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorEdouard Maffert2016-09-09 16:07:34 +0200
committerEdouard Maffert2016-09-09 16:07:34 +0200
commit2d52366ebac8af84cfec37dab9df5b43261fffe4 (patch)
treeb820e064516f58b4f5fed6cddde99f7f5b9e042b /spec
parent4747990c6d3ceb5020d06099d086500b066db6e4 (diff)
downloadchouette-core-2d52366ebac8af84cfec37dab9df5b43261fffe4.tar.bz2
associate networks to line referential
Diffstat (limited to 'spec')
-rw-r--r--spec/factories/chouette_networks.rb3
-rw-r--r--spec/features/networks_spec.rb23
-rw-r--r--spec/models/chouette/active_record_spec.rb2
-rw-r--r--spec/routing/group_of_lines_spec.rb12
-rw-r--r--spec/routing/networks_spec.rb12
-rw-r--r--spec/views/networks/edit.html.erb_spec.rb5
-rw-r--r--spec/views/networks/index.html.erb_spec.rb14
-rw-r--r--spec/views/networks/new.html.erb_spec.rb4
-rw-r--r--spec/views/networks/show.html.erb_spec.rb8
9 files changed, 43 insertions, 40 deletions
diff --git a/spec/factories/chouette_networks.rb b/spec/factories/chouette_networks.rb
index f9cc4b5d6..3ad719cd9 100644
--- a/spec/factories/chouette_networks.rb
+++ b/spec/factories/chouette_networks.rb
@@ -4,6 +4,7 @@ FactoryGirl.define do
sequence(:name) { |n| "Network #{n}" }
sequence(:objectid) { |n| "chouette:test:GroupOfLine:#{n}" }
sequence(:registration_number) { |n| "test-#{n}" }
- end
+ association :line_referential
+ end
end
diff --git a/spec/features/networks_spec.rb b/spec/features/networks_spec.rb
index b68dda558..fc73ea6a2 100644
--- a/spec/features/networks_spec.rb
+++ b/spec/features/networks_spec.rb
@@ -4,39 +4,40 @@ require 'spec_helper'
describe "Networks", :type => :feature do
login_user
- let!(:networks) { Array.new(2) { create(:network) } }
+ let(:line_referential) { create :line_referential }
+ let!(:networks) { Array.new(2) { create(:network, line_referential: line_referential) } }
subject { networks.first }
describe "list" do
it "display networks" do
- visit referential_networks_path(referential)
+ visit line_referential_networks_path(line_referential)
expect(page).to have_content(networks.first.name)
expect(page).to have_content(networks.last.name)
end
-
- end
+
+ end
describe "show" do
it "display network" do
# allow(subject).to receive(:stop_areas).and_return(Array.new(2) { create(:stop_area) })
- visit referential_networks_path(referential)
+ visit line_referential_networks_path(line_referential)
click_link "#{networks.first.name}"
expect(page).to have_content(networks.first.name)
end
# it "display map" do
# # allow(subject).to receive(:stop_areas).and_return(Array.new(2) { create(:stop_area) })
- # visit referential_networks_path(referential)
+ # visit line_referential_networks_path(line_referential)
# click_link "#{networks.first.name}"
# expect(page).to have_selector("#map.network")
# end
-
+
end
describe "new" do
it "creates network and return to show" do
# allow(subject).to receive(:stop_areas).and_return(Array.new(2) { create(:stop_area) })
- visit referential_networks_path(referential)
+ visit line_referential_networks_path(line_referential)
click_link "Ajouter un réseau"
fill_in "network_name", :with => "Network 1"
fill_in "Numéro d'enregistrement", :with => "test-1"
@@ -49,7 +50,7 @@ describe "Networks", :type => :feature do
describe "edit and return to show" do
it "edit network" do
# allow(subject).to receive(:stop_areas).and_return(Array.new(2) { create(:stop_area) })
- visit referential_network_path(referential, subject)
+ visit line_referential_network_path(line_referential, subject)
click_link "Modifier ce réseau"
fill_in "network_name", :with => "Network Modified"
fill_in "Numéro d'enregistrement", :with => "test-1"
@@ -60,8 +61,8 @@ describe "Networks", :type => :feature do
# describe "delete", :js => true do
# it "delete network and return to the list" do
- # subject.stub(:stop_areas).and_return(Array.new(2) { create(:stop_area) })
- # visit referential_network_path(referential, subject)
+ # subject.stub(:stop_areas).and_return(Array.new(2) { create(:stop_area) })
+ # visit line_referential_network_path(line_referential, subject)
# click_link "Supprimer ce réseau"
# page.evaluate_script('window.confirm = function() { return true; }')
# click_button "Valider"
diff --git a/spec/models/chouette/active_record_spec.rb b/spec/models/chouette/active_record_spec.rb
index 110807e51..355d26dad 100644
--- a/spec/models/chouette/active_record_spec.rb
+++ b/spec/models/chouette/active_record_spec.rb
@@ -11,7 +11,7 @@ describe Chouette::ActiveRecord, :type => :model do
end
it "should return ptnetwork for Chouette::Network" do
- expect(Chouette::Network.table_name).to eq("networks")
+ expect(Chouette::Network.table_name).to eq("public.networks")
end
it "should return timetable_date for Chouette::TimeTableDate" do
diff --git a/spec/routing/group_of_lines_spec.rb b/spec/routing/group_of_lines_spec.rb
index ee5596cf7..8bc437249 100644
--- a/spec/routing/group_of_lines_spec.rb
+++ b/spec/routing/group_of_lines_spec.rb
@@ -3,21 +3,21 @@ require 'spec_helper'
describe GroupOfLinesController do
describe "routing" do
it "not recognize #routes" do
- get( "/referentials/1/group_of_lines/2/routes").should_not route_to(
+ get( "/line_referentials/1/group_of_lines/2/routes").should_not route_to(
:controller => "group_of_lines", :action => "routes",
- :referential_id => "1", :id => "2"
+ :line_referential_id => "1", :id => "2"
)
end
it "not recognize #lines" do
- get( "/referentials/1/group_of_lines/2/lines").should_not route_to(
+ get( "/line_referentials/1/group_of_lines/2/lines").should_not route_to(
:controller => "group_of_lines", :action => "lines",
- :referential_id => "1", :id => "2"
+ :line_referential_id => "1", :id => "2"
)
end
it "recognize and generate #show" do
- get( "/referentials/1/group_of_lines/2").should route_to(
+ get( "/line_referentials/1/group_of_lines/2").should route_to(
:controller => "group_of_lines", :action => "show",
- :referential_id => "1", :id => "2"
+ :line_referential_id => "1", :id => "2"
)
end
end
diff --git a/spec/routing/networks_spec.rb b/spec/routing/networks_spec.rb
index c0544980d..8d5366f88 100644
--- a/spec/routing/networks_spec.rb
+++ b/spec/routing/networks_spec.rb
@@ -3,21 +3,21 @@ require 'spec_helper'
describe NetworksController do
describe "routing" do
it "not recognize #routes" do
- get( "/referentials/1/networks/2/routes").should_not route_to(
+ get( "/line_referentials/1/networks/2/routes").should_not route_to(
:controller => "networks", :action => "routes",
- :referential_id => "1", :id => "2"
+ :line_referential_id => "1", :id => "2"
)
end
it "not recognize #lines" do
- get( "/referentials/1/networks/2/lines").should_not route_to(
+ get( "/line_referentials/1/networks/2/lines").should_not route_to(
:controller => "networks", :action => "lines",
- :referential_id => "1", :id => "2"
+ :line_referential_id => "1", :id => "2"
)
end
it "recognize and generate #show" do
- get( "/referentials/1/networks/2").should route_to(
+ get( "/line_referentials/1/networks/2").should route_to(
:controller => "networks", :action => "show",
- :referential_id => "1", :id => "2"
+ :line_referential_id => "1", :id => "2"
)
end
end
diff --git a/spec/views/networks/edit.html.erb_spec.rb b/spec/views/networks/edit.html.erb_spec.rb
index 2a18e09b6..f77459837 100644
--- a/spec/views/networks/edit.html.erb_spec.rb
+++ b/spec/views/networks/edit.html.erb_spec.rb
@@ -1,12 +1,13 @@
require 'spec_helper'
describe "/networks/edit", :type => :view do
- assign_referential
+
let!(:network) { assign(:network, create(:network) ) }
+ let!(:line_referential) { assign :line_referential, network.line_referential }
describe "test" do
it "should render h2 with the group name" do
- render
+ render
expect(rendered).to have_selector("h2", :text => Regexp.new(network.name))
end
end
diff --git a/spec/views/networks/index.html.erb_spec.rb b/spec/views/networks/index.html.erb_spec.rb
index d78ef7c95..2aef66920 100644
--- a/spec/views/networks/index.html.erb_spec.rb
+++ b/spec/views/networks/index.html.erb_spec.rb
@@ -2,20 +2,20 @@ require 'spec_helper'
describe "/networks/index", :type => :view do
- assign_referential
- let!(:networks) { assign :networks, Array.new(2){ create(:network) }.paginate }
+ let!(:line_referential) { assign :line_referential, create(:line_referential) }
+ let!(:networks) { assign :networks, Array.new(2){ create(:network, line_referential: line_referential) }.paginate }
let!(:search) { assign :q, Ransack::Search.new(Chouette::Network) }
- it "should render a show link for each group" do
- render
- networks.each do |network|
- expect(rendered).to have_selector(".network a[href='#{view.referential_network_path(referential, network)}']", :text => network.name)
+ it "should render a show link for each group" do
+ render
+ networks.each do |network|
+ expect(rendered).to have_selector(".network a[href='#{view.line_referential_network_path(line_referential, network)}']", :text => network.name)
end
end
it "should render a link to create a new group" do
render
- expect(view.content_for(:sidebar)).to have_selector(".actions a[href='#{new_referential_network_path(referential)}']")
+ expect(view.content_for(:sidebar)).to have_selector(".actions a[href='#{new_line_referential_network_path(line_referential)}']")
end
end
diff --git a/spec/views/networks/new.html.erb_spec.rb b/spec/views/networks/new.html.erb_spec.rb
index 0e9c08372..41fba412b 100644
--- a/spec/views/networks/new.html.erb_spec.rb
+++ b/spec/views/networks/new.html.erb_spec.rb
@@ -1,11 +1,11 @@
require 'spec_helper'
describe "/networks/new", :type => :view do
- assign_referential
+
let!(:network) { assign(:network, build(:network)) }
+ let!(:line_referential) { assign :line_referential, network.line_referential }
describe "form" do
-
it "should render input for name" do
render
expect(rendered).to have_selector("form") do
diff --git a/spec/views/networks/show.html.erb_spec.rb b/spec/views/networks/show.html.erb_spec.rb
index 29efacb17..e73ab55c3 100644
--- a/spec/views/networks/show.html.erb_spec.rb
+++ b/spec/views/networks/show.html.erb_spec.rb
@@ -1,10 +1,10 @@
require 'spec_helper'
describe "/networks/show", :type => :view do
-
- assign_referential
+
let!(:network) { assign(:network, create(:network)) }
let!(:map) { assign(:map, double(:to_html => '<div id="map"/>'.html_safe)) }
+ let!(:line_referential) { assign :line_referential, network.line_referential }
it "should render h2 with the network name" do
render
@@ -18,12 +18,12 @@ describe "/networks/show", :type => :view do
it "should render a link to edit the network" do
render
- expect(view.content_for(:sidebar)).to have_selector(".actions a[href='#{view.edit_referential_network_path(referential, network)}']")
+ expect(view.content_for(:sidebar)).to have_selector(".actions a[href='#{view.edit_line_referential_network_path(line_referential, network)}']")
end
it "should render a link to remove the network" do
render
- expect(view.content_for(:sidebar)).to have_selector(".actions a[href='#{view.referential_network_path(referential, network)}'][class='remove']")
+ expect(view.content_for(:sidebar)).to have_selector(".actions a[href='#{view.line_referential_network_path(line_referential, network)}'][class='remove']")
end
end