aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorLuc Donnet2015-01-07 21:58:56 +0100
committerLuc Donnet2015-01-07 21:58:56 +0100
commitbaaed4653623cfc918ada7250c4fd879aad28893 (patch)
treeec1e7da111c2ccd95f82013e2d40d6b455f80815 /spec
parentc39887f2e4f6a12ab3af205c58a1330d8b28f5e9 (diff)
downloadchouette-core-baaed4653623cfc918ada7250c4fd879aad28893.tar.bz2
Fix spec and update devise usage
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/routes_controller_spec.rb10
-rw-r--r--spec/features/companies_spec.rb2
-rw-r--r--spec/features/referentials_spec.rb1
-rw-r--r--spec/features/routes_spec.rb22
-rw-r--r--spec/features/stop_areas_spec.rb6
-rw-r--r--spec/support/capybara.rb1
-rw-r--r--spec/support/database_cleaner.rb21
-rw-r--r--spec/support/helpers.rb4
-rw-r--r--spec/support/helpers/session_helpers.rb19
-rw-r--r--spec/support/referential.rb8
-rw-r--r--spec/views/vehicle_journeys/_vehicle_journey_at_stop_fields.html.erb_spec.rb6
11 files changed, 71 insertions, 29 deletions
diff --git a/spec/controllers/routes_controller_spec.rb b/spec/controllers/routes_controller_spec.rb
index 83505effe..006921ed8 100644
--- a/spec/controllers/routes_controller_spec.rb
+++ b/spec/controllers/routes_controller_spec.rb
@@ -28,7 +28,6 @@ describe RoutesController, :type => :controller do
it_behaves_like "line and referential linked"
end
-
describe "GET /index" do
before(:each) do
get :index, :line_id => route.line_id,
@@ -37,8 +36,8 @@ describe RoutesController, :type => :controller do
it_behaves_like "line and referential linked"
it_behaves_like "redirected to referential_line_path(referential,line)"
-
end
+
describe "POST /create" do
before(:each) do
post :create, :line_id => route.line_id,
@@ -49,15 +48,18 @@ describe RoutesController, :type => :controller do
it_behaves_like "line and referential linked"
it_behaves_like "redirected to referential_line_path(referential,line)"
end
+
describe "PUT /update" do
before(:each) do
put :update, :id => route.id, :line_id => route.line_id,
- :referential_id => referential.id
+ :referential_id => referential.id,
+ :route => { }
end
it_behaves_like "route, line and referential linked"
it_behaves_like "redirected to referential_line_path(referential,line)"
end
+
describe "GET /show" do
before(:each) do
get :show, :id => route.id,
@@ -75,7 +77,7 @@ describe RoutesController, :type => :controller do
it "assigns route.stop_points.paginate(:page => nil) as @stop_points" do
expect(assigns[:stop_points]).to eq(route.stop_points.paginate(:page => nil))
end
-
end
+
end
diff --git a/spec/features/companies_spec.rb b/spec/features/companies_spec.rb
index e5c7ae6e5..3628d04f0 100644
--- a/spec/features/companies_spec.rb
+++ b/spec/features/companies_spec.rb
@@ -4,7 +4,7 @@ require 'spec_helper'
describe "Companies", :type => :feature do
login_user
- let!(:companies) { Array.new(2) { create :company } }
+ let!(:companies) { Array.new(2) { create :company } }
subject { companies.first }
describe "list" do
diff --git a/spec/features/referentials_spec.rb b/spec/features/referentials_spec.rb
index d4a21479f..65225d28d 100644
--- a/spec/features/referentials_spec.rb
+++ b/spec/features/referentials_spec.rb
@@ -51,7 +51,6 @@ describe "Referentials", :type => :feature do
let(:referential) { create(:referential, :organisation => @user.organisation) }
it "should remove referential" do
- pending "Unauthorized DELETE (ticket #14)"
visit referential_path(referential)
click_link "Supprimer"
expect(Referential.where(:slug => referential.slug)).to be_blank
diff --git a/spec/features/routes_spec.rb b/spec/features/routes_spec.rb
index da4120309..0c98f8725 100644
--- a/spec/features/routes_spec.rb
+++ b/spec/features/routes_spec.rb
@@ -10,51 +10,55 @@ describe "Routes", :type => :feature do
describe "from lines page to a line page" do
it "display line's routes" do
- pending
visit referential_lines_path(referential)
click_link "#{line.name}"
expect(page).to have_content(route.name)
expect(page).to have_content(route2.name)
end
end
+
describe "from line's page to route's page" do
it "display route properties" do
- pending
visit referential_line_path(referential,line)
click_link "#{route.name}"
expect(page).to have_content(route.name)
expect(page).to have_content(route.number)
end
end
+
describe "from line's page, create a new route" do
it "return to line's page that display new route" do
- pending
visit referential_line_path(referential,line)
click_link "Ajouter une séquence d'arrêts"
- fill_in "Nom", :with => "A to B"
+ save_and_open_page
+ fill_in "route_name", :with => "A to B"
fill_in "Indice", :with => "AB"
+ select 'aller', :from => "route_direction_code"
+ select 'aller', :from => "route_wayback_code"
click_button("Créer Séquence d'arrêts")
expect(page).to have_content("A to B")
end
end
+
describe "from line's page, select a route and edit it" do
it "return to line's page with changed name" do
- pending
visit referential_line_path(referential,line)
click_link "#{route.name}"
click_link "Modifier cette séquence d'arrêts"
- fill_in "Nom", :with => "#{route.name}-changed"
+ save_and_open_page
+ fill_in "route_name", :with => "#{route.name}-changed"
+ save_and_open_page
click_button("Modifier Séquence d'arrêts")
expect(page).to have_content("#{route.name}-changed")
end
end
+
describe "from line's page, select a route and delete it" do
it "return to line's page without route name" do
- pending
visit referential_line_path(referential,line)
click_link "#{route.name}"
- #click_link "Supprimer cette séquence d'arrêts"
- #page.should_not have_content(route.name)
+ click_link "Supprimer cette séquence d'arrêts"
+ expect(page).not_to have_content(route.name)
end
end
end
diff --git a/spec/features/stop_areas_spec.rb b/spec/features/stop_areas_spec.rb
index 4d1b7e2bb..ff5a73438 100644
--- a/spec/features/stop_areas_spec.rb
+++ b/spec/features/stop_areas_spec.rb
@@ -25,7 +25,7 @@ describe "StopAreas", :type => :feature do
it "display map" do
visit referential_stop_areas_path(referential)
click_link "#{stop_areas.first.name}"
- expect(page).to have_selector("#map", :class => 'stop_area')
+ expect(page).to have_selector("#map.stop_area")
end
end
@@ -34,7 +34,7 @@ describe "StopAreas", :type => :feature do
it "creates stop_area and return to show" do
visit referential_stop_areas_path(referential)
click_link "Ajouter un arrêt"
- fill_in "Nom", :with => "StopArea 1"
+ fill_in "stop_area_name", :with => "StopArea 1"
fill_in "Numéro d'enregistrement", :with => "test-1"
fill_in "Identifiant Neptune", :with => "test:StopArea:1"
click_button("Créer arrêt")
@@ -46,7 +46,7 @@ describe "StopAreas", :type => :feature do
it "edit stop_area" do
visit referential_stop_area_path(referential, subject)
click_link "Modifier cet arrêt"
- fill_in "Nom", :with => "StopArea Modified"
+ fill_in "stop_area_name", :with => "StopArea Modified"
fill_in "Numéro d'enregistrement", :with => "test-1"
click_button("Modifier arrêt")
expect(page).to have_content("StopArea Modified")
diff --git a/spec/support/capybara.rb b/spec/support/capybara.rb
new file mode 100644
index 000000000..eb8124f44
--- /dev/null
+++ b/spec/support/capybara.rb
@@ -0,0 +1 @@
+Capybara.asset_host = 'http://localhost:3000'
diff --git a/spec/support/database_cleaner.rb b/spec/support/database_cleaner.rb
new file mode 100644
index 000000000..a9758d437
--- /dev/null
+++ b/spec/support/database_cleaner.rb
@@ -0,0 +1,21 @@
+RSpec.configure do |config|
+ config.before(:suite) do
+ DatabaseCleaner.clean_with(:truncation)
+ end
+
+ config.before(:each) do
+ DatabaseCleaner.strategy = :transaction
+ end
+
+ config.before(:each, :js => true) do
+ DatabaseCleaner.strategy = :truncation
+ end
+
+ config.before(:each) do
+ DatabaseCleaner.start
+ end
+
+ config.append_after(:each) do
+ DatabaseCleaner.clean
+ end
+end
diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb
new file mode 100644
index 000000000..5e1becafb
--- /dev/null
+++ b/spec/support/helpers.rb
@@ -0,0 +1,4 @@
+require 'support/helpers/session_helpers'
+RSpec.configure do |config|
+ config.include Features::SessionHelpers, type: :feature
+end
diff --git a/spec/support/helpers/session_helpers.rb b/spec/support/helpers/session_helpers.rb
new file mode 100644
index 000000000..17a3fc51b
--- /dev/null
+++ b/spec/support/helpers/session_helpers.rb
@@ -0,0 +1,19 @@
+module Features
+ module SessionHelpers
+ def sign_up_with(email, password, confirmation)
+ visit new_user_session_path
+ fill_in '#registration_new #user_email', with: email
+ fill_in 'Password', with: password
+ fill_in 'Password confirmation', :with => confirmation
+ click_button 'Sign up'
+ end
+
+ def signin(email, password)
+ visit new_user_session_path
+ save_and_open_page
+ fill_in '#session_new #user_email', with: email
+ fill_in 'Password', with: password
+ click_button 'Sign in'
+ end
+ end
+end
diff --git a/spec/support/referential.rb b/spec/support/referential.rb
index d20b68ee6..c1a043b8f 100644
--- a/spec/support/referential.rb
+++ b/spec/support/referential.rb
@@ -27,10 +27,6 @@ RSpec.configure do |config|
config.include ReferentialHelper
config.before(:suite) do
- # Clean all tables to start
- DatabaseCleaner.clean_with :truncation
- # Use transactions for tests
- DatabaseCleaner.strategy = :transaction
# Truncating doesn't drop schemas, ensure we're clean here, first *may not* exist
Apartment::Tenant.drop('first') rescue nil
# Create the default tenant for our tests
@@ -39,8 +35,6 @@ RSpec.configure do |config|
end
config.before(:each) do
- # Start transaction for this test
- #DatabaseCleaner.start
# Switch into the default tenant
first_referential.switch
end
@@ -48,8 +42,6 @@ RSpec.configure do |config|
config.after(:each) do
# Reset tenant back to `public`
Apartment::Tenant.reset
- # Rollback transaction
- DatabaseCleaner.clean
end
end
diff --git a/spec/views/vehicle_journeys/_vehicle_journey_at_stop_fields.html.erb_spec.rb b/spec/views/vehicle_journeys/_vehicle_journey_at_stop_fields.html.erb_spec.rb
index 037658851..ac7b5326d 100644
--- a/spec/views/vehicle_journeys/_vehicle_journey_at_stop_fields.html.erb_spec.rb
+++ b/spec/views/vehicle_journeys/_vehicle_journey_at_stop_fields.html.erb_spec.rb
@@ -12,15 +12,15 @@ describe "/vehicle_journeys/_vehicle_journey_at_stop_fields", :type => :view do
def render_collection
render( :partial => "vehicle_journeys/vehicle_journey_at_stop_fields", :collection => vehicle_journey.vehicle_journey_at_stops, :as => :vehicle_journey_at_stop, :locals => { :vehicle_journey_at_stops_size => 1 } )
end
-
+
it "should render vehicle_journey_at_stop's departure time" do
- render_collection
expect(rendered).to have_selector("td select[name='vehicle_journey[vehicle_journey_at_stops_attributes[0][departure_time(5i)]]']")
end
it "should render vehicle_journey_at_stop's stop_point_id" do
render_collection
- expect(rendered).to have_field("vehicle_journey[number]")
+ puts rendered.inspect
+ expect(rendered).to have_field("vehicle_journey[vehicle_journey_at_stops_attributes][0][stop_point_id]")
expect(rendered).to have_field("vehicle_journey[vehicle_journey_at_stops_attributes][0][stop_point_id]",
:with => vehicle_journey_at_stop.stop_point_id,
:type => "hidden")