aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuc Donnet2015-01-07 21:58:56 +0100
committerLuc Donnet2015-01-07 21:58:56 +0100
commitbaaed4653623cfc918ada7250c4fd879aad28893 (patch)
treeec1e7da111c2ccd95f82013e2d40d6b455f80815
parentc39887f2e4f6a12ab3af205c58a1330d8b28f5e9 (diff)
downloadchouette-core-baaed4653623cfc918ada7250c4fd879aad28893.tar.bz2
Fix spec and update devise usage
-rw-r--r--Gemfile4
-rw-r--r--Gemfile.lock15
-rw-r--r--app/assets/stylesheets/modules/devise.css.scss8
-rw-r--r--app/controllers/application_controller.rb1
-rw-r--r--app/controllers/referentials_controller.rb7
-rw-r--r--app/controllers/routes_controller.rb4
-rw-r--r--app/controllers/stop_areas_controller.rb4
-rw-r--r--app/controllers/time_tables_controller.rb3
-rw-r--r--app/views/companies/_companies.erb4
-rw-r--r--app/views/connection_links/_connection_links.erb2
-rw-r--r--app/views/devise/sessions/new.html.erb4
-rw-r--r--app/views/networks/_networks.erb2
-rw-r--r--app/views/time_tables/_time_tables.html.erb2
-rw-r--r--app/views/time_tables/index.html.erb2
-rw-r--r--config/environments/test.rb14
-rw-r--r--config/initializers/devise.rb122
-rw-r--r--config/initializers/devise_permitted_parameters.rb17
-rw-r--r--config/initializers/filter_parameter_logging.rb4
-rw-r--r--config/initializers/remove_simple_form_bootstrap3_inputs.rb32
-rw-r--r--config/initializers/simple_form.rb68
-rw-r--r--config/initializers/simple_form_bootstrap.rb168
-rw-r--r--config/initializers/wrap_parameters.rb12
-rw-r--r--config/routes.rb7
-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
34 files changed, 407 insertions, 199 deletions
diff --git a/Gemfile b/Gemfile
index 745c0f185..6b8f2121b 100644
--- a/Gemfile
+++ b/Gemfile
@@ -80,7 +80,7 @@ gem 'raphael-rails'
gem 'rails-assets-bootstrap-sass-official', '~> 3.3.0'
gem 'font-awesome-sass', '~> 4.2.0'
gem 'will_paginate-bootstrap'
-gem 'simple_form'
+gem 'simple_form', '~> 3.1.0'
gem 'rails-assets-tagmanager', '~> 3.0.1.0'
gem 'rails-assets-typeahead.js', '~> 0.10.5'
gem "breadcrumbs_on_rails"
@@ -99,7 +99,7 @@ gem 'inherited_resources'
gem 'google-analytics-rails'
# Model
-gem 'will_paginate', '~> 3.0'
+gem 'will_paginate', '~> 3.0', :git => "https://github.com/mislav/will_paginate.git"
gem 'ransack'
gem 'squeel'
gem 'ninoxe', :git => 'https://github.com/afimb/ninoxe.git', :branch => "rails4"
diff --git a/Gemfile.lock b/Gemfile.lock
index 7206994bf..bf60b28f5 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,6 +1,6 @@
GIT
remote: https://github.com/afimb/ninoxe.git
- revision: bfe0ccb3519e6b0e4e99657c1f108d07754ff7c7
+ revision: 9cff11ccd859b0d7288a20bef04fa9941512985c
branch: rails4
specs:
ninoxe (1.1.3)
@@ -13,6 +13,12 @@ GIT
foreigner (= 1.6.0)
georuby-ext (= 0.0.5)
+GIT
+ remote: https://github.com/mislav/will_paginate.git
+ revision: 74a6cd0197072903cd8b83744133744ff4b4c046
+ specs:
+ will_paginate (3.0.4)
+
GEM
remote: http://rubygems.org/
remote: https://rails-assets.org/
@@ -51,7 +57,7 @@ GEM
minitest (~> 5.1)
thread_safe (~> 0.1)
tzinfo (~> 1.1)
- acts-as-taggable-on (3.4.2)
+ acts-as-taggable-on (3.4.3)
activerecord (>= 3.2, < 5)
acts_as_list (0.6.0)
activerecord (>= 3.0)
@@ -413,7 +419,6 @@ GEM
rubyzip (>= 0.9, < 1.2)
warden (1.2.3)
rack (>= 1.0)
- will_paginate (3.0.5)
will_paginate-bootstrap (1.0.0)
will_paginate (>= 3.0.3)
xpath (2.0.0)
@@ -487,7 +492,7 @@ DEPENDENCIES
rubyzip (~> 1.1.6)
sass-rails (~> 4.0.3)
sdoc (~> 0.4.0)
- simple_form
+ simple_form (~> 3.1.0)
spring
sqlite3
squeel
@@ -497,5 +502,5 @@ DEPENDENCIES
turbolinks
uglifier (>= 1.3.0)
warbler
- will_paginate (~> 3.0)
+ will_paginate (~> 3.0)!
will_paginate-bootstrap
diff --git a/app/assets/stylesheets/modules/devise.css.scss b/app/assets/stylesheets/modules/devise.css.scss
index b4a1d2076..7a762b95f 100644
--- a/app/assets/stylesheets/modules/devise.css.scss
+++ b/app/assets/stylesheets/modules/devise.css.scss
@@ -14,14 +14,6 @@
#devise_middle{
min-height: 620px;
padding: 30px 20px 0px 20px;
-
- #registrations_new{
-
- .form-group{
- margin-bottom: 5px;
- }
-
- }
#sessions_new{
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 04dd281d5..4359ee02e 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -2,6 +2,7 @@ class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :authenticate_user!
before_filter :set_locale
+ helper LanguageEngine::Engine.helpers
def set_locale
I18n.locale = session[:language] || I18n.default_locale
diff --git a/app/controllers/referentials_controller.rb b/app/controllers/referentials_controller.rb
index 9cf4a5f62..643c780a4 100644
--- a/app/controllers/referentials_controller.rb
+++ b/app/controllers/referentials_controller.rb
@@ -25,18 +25,25 @@ class ReferentialsController < BreadcrumbController
def resource
@referential ||= current_organisation.referentials.find_by_id(params[:id])
end
+
def collection
@referentials ||= current_organisation.referentials.order(:name)
end
+
def build_resource
super.tap do |referential|
referential.user_id = current_user.id
referential.user_name = current_user.name
end
end
+
def create_resource(referential)
referential.organisation = current_organisation
super
end
+ def permitted_params
+ params.permit(referential: [ :name, :slug, :prefix, :time_zone, :upper_corner, :lower_corner, :organisation_id ])
+ end
+
end
diff --git a/app/controllers/routes_controller.rb b/app/controllers/routes_controller.rb
index 6454ce068..c74b0ade8 100644
--- a/app/controllers/routes_controller.rb
+++ b/app/controllers/routes_controller.rb
@@ -75,5 +75,9 @@ class RoutesController < ChouetteController
end
end
+ def permitted_params
+ params.require(:route).permit( :direction_code, :wayback_code, :line_id, :objectid, :object_version, :creation_time, :creator_id, :name, :comment, :opposite_route_id, :published_name, :number, :direction, :wayback, { stop_points_attributes: [ :id, :_destroy, :position, :stop_area_id ] } )
+ end
+
end
diff --git a/app/controllers/stop_areas_controller.rb b/app/controllers/stop_areas_controller.rb
index 6277b5814..0b816ca45 100644
--- a/app/controllers/stop_areas_controller.rb
+++ b/app/controllers/stop_areas_controller.rb
@@ -133,4 +133,8 @@ class StopAreasController < ChouetteController
end
end
+ def permitted_params
+ params.permit(stop_area: [ :routing_stop_ids, :routing_line_ids, :children_ids, :stop_area_type, :parent_id, :objectid, :object_version, :creation_time, :creator_id, :name, :comment, :area_type, :registration_number, :nearest_topic_name, :fare_code, :longitude, :latitude, :long_lat_type, :country_code, :street_name, :zip_code, :city_name, :mobility_restricted_suitability, :stairs_availability, :lift_availability, :int_user_needs, :coordinates, :url, :time_zone ])
+ end
+
end
diff --git a/app/controllers/time_tables_controller.rb b/app/controllers/time_tables_controller.rb
index be0a3c4bd..52493987a 100644
--- a/app/controllers/time_tables_controller.rb
+++ b/app/controllers/time_tables_controller.rb
@@ -89,7 +89,6 @@ class TimeTablesController < ChouetteController
end
def permitted_params
- params.permit(time_table: [ :objectid, :object_version, :creation_time, :creator_id, :version, :comment,
-:int_day_types, :monday, :tuesday, :wednesday, :thursday, :friday, :saturday, :sunday, :start_date, :end_date, :dates_attributes, :periods_attributes, :tag_list, :tag_search ] )
+ params.permit(time_table: [ :objectid, :object_version, :creation_time, :creator_id, :version, :comment, :int_day_types, :monday, :tuesday, :wednesday, :thursday, :friday, :saturday, :sunday, :start_date, :end_date, :dates_attributes, :periods_attributes, :tag_list, :tag_search ] )
end
end
diff --git a/app/views/companies/_companies.erb b/app/views/companies/_companies.erb
index bfb7a0b5b..9464f0c1a 100644
--- a/app/views/companies/_companies.erb
+++ b/app/views/companies/_companies.erb
@@ -1,8 +1,8 @@
<div class="page_info">
- <span class="search"> <%= t("will_paginate.page_entries_info.search") %></span> <%= page_entries_info( @companies.to_a ) %>
+ <span class="search"> <%= t("will_paginate.page_entries_info.search") %></span> <%= page_entries_info( @companies ) %>
</div>
<div class="companies paginated_content">
- <%= paginated_content(@companies) %>
+ <%= paginated_content(@companies) %>
</div>
<div class="pagination">
<%= will_paginate @companies, :container => false, renderer: RemoteBootstrapPaginationLinkRenderer %>
diff --git a/app/views/connection_links/_connection_links.erb b/app/views/connection_links/_connection_links.erb
index 3717ecb9c..cfc1d45f4 100644
--- a/app/views/connection_links/_connection_links.erb
+++ b/app/views/connection_links/_connection_links.erb
@@ -1,5 +1,5 @@
<div class="page_info">
- <span class="search"> <%= t("will_paginate.page_entries_info.search") %></span> <%= page_entries_info @connection_links.to_a %>
+ <span class="search"> <%= t("will_paginate.page_entries_info.search") %></span> <%= page_entries_info @connection_links %>
</div>
<div class="connection_links paginated_content">
<%= paginated_content(@connection_links) %>
diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb
index 9334bab35..bac1ad2f5 100644
--- a/app/views/devise/sessions/new.html.erb
+++ b/app/views/devise/sessions/new.html.erb
@@ -11,7 +11,7 @@
<div class="col-md-4 login">
<div class="panel panel-default">
<div class="panel-body">
- <%= simple_form_for(resource, :as => resource_name, :url => session_path(resource_name), :wrapper => "form_without_label" ) do |form| %>
+ <%= simple_form_for(resource, :as => resource_name, :url => session_path(resource_name), :wrapper => "form_without_label", :form_class => 'session_new' ) do |form| %>
<%= form.input :email, :label => false, :placeholder => t("helpers.label.user.email"), input_html: { :class => "form-control" } %>
<div class="row">
<div class="col-md-6">
@@ -39,7 +39,7 @@
<div class="panel panel-default">
<div class="panel-heading"><%= t("devise.registrations.new.title") %></div>
<div class="panel-body">
- <%= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name), :wrapper => "form_without_label" ) do |form| %>
+ <%= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name), :wrapper => "form_without_label", input_html: { class: "registration_new" } ) do |form| %>
<%= form.simple_fields_for :organisation, Organisation.new do |organisation| %>
<%= organisation.input :name, :label => false, :placeholder => t("helpers.label.user.organisation_name"), input_html: { :class => "form-control" } %>
<% end %>
diff --git a/app/views/networks/_networks.erb b/app/views/networks/_networks.erb
index 65ea7d069..9d95d63b6 100644
--- a/app/views/networks/_networks.erb
+++ b/app/views/networks/_networks.erb
@@ -1,5 +1,5 @@
<div class="page_info">
- <span class="search"> <%= t("will_paginate.page_entries_info.search") %></span> <%= page_entries_info @networks.to_a %>
+ <span class="search"> <%= t("will_paginate.page_entries_info.search") %></span> <%= page_entries_info @networks %>
</div>
<div class="networks paginated_content">
<%= paginated_content(@networks) %>
diff --git a/app/views/time_tables/_time_tables.html.erb b/app/views/time_tables/_time_tables.html.erb
index ba95c1811..4458f653d 100644
--- a/app/views/time_tables/_time_tables.html.erb
+++ b/app/views/time_tables/_time_tables.html.erb
@@ -1,5 +1,5 @@
<div class="page_info">
- <span class="search"> <%= t("will_paginate.page_entries_info.search") %></span> <%= page_entries_info @time_tables.to_a %>
+ <span class="search"> <%= t("will_paginate.page_entries_info.search") %></span> <%= page_entries_info @time_tables %>
</div>
<div class="time_tables paginated_content">
<%= paginated_content(@time_tables) %>
diff --git a/app/views/time_tables/index.html.erb b/app/views/time_tables/index.html.erb
index e9802b4bc..9b3ee6e12 100644
--- a/app/views/time_tables/index.html.erb
+++ b/app/views/time_tables/index.html.erb
@@ -1,4 +1,4 @@
-<%= title_tag t('time_tables.index.title') %>
+<%= title_tag t('time_tables.index.title') %>
<%= search_form_for @q, :url => referential_time_tables_path(@referential), remote: true, :html => {:method => :get, class: "form-inline", :id => "search", role: "form"} do |f| %>
<div class="panel panel-default">
diff --git a/config/environments/test.rb b/config/environments/test.rb
index 661865fd0..90bf328fc 100644
--- a/config/environments/test.rb
+++ b/config/environments/test.rb
@@ -55,10 +55,18 @@ ChouetteIhm::Application.configure do
# api key to geoportail IGN (production key link to application url root referer)
config.geoportail_api_key = "aaaaaaaaaaaaaa"
- # Specific for each company
- config.company_name = "afimb"
- config.company_theme = "#61970b"
+ # Specific theme for each company
+ # AFIMB
+ config.company_name = "afimb"
+ config.company_theme = "#61970b" # AFIMB color
config.company_contact = "http://www.chouette.mobi/contact-support/"
+ config.accept_user_creation = true
+
+ # CITYWAY
+ # config.company_name = "cityway"
+ # config.company_theme = "#32adb0"
+ # config.company_contact = "http://www.cityway.fr/contact/?rub_code=14"
+ # config.accept_user_creation = false
# file to data for demo
config.demo_data = "tmp/demo.zip"
diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb
index 23cb26e8f..8177839bd 100644
--- a/config/initializers/devise.rb
+++ b/config/initializers/devise.rb
@@ -1,25 +1,27 @@
# Use this hook to configure devise mailer, warden hooks and so forth.
# Many of these configuration options can be set straight in your model.
Devise.setup do |config|
+ # The secret key used by Devise. Devise uses this key to generate
+ # random tokens. Changing this key will render invalid all existing
+ # confirmation, reset password and unlock tokens in the database.
+ config.secret_key = 'e9b20cea45078c982c9cd42cc64c484071d582a3d366ad2b51f676d168bccb2e0fd20e87ebe64aff57ad7f8a1a1c50b76cb9dc4039c287a195f9621fdb557993'
# ==> Mailer Configuration
# Configure the e-mail address which will be shown in Devise::Mailer,
- # note that it will be overwritten if you use your own mailer class with default "from" parameter.
+ # note that it will be overwritten if you use your own mailer class
+ # with default "from" parameter.
config.mailer_sender = ChouetteIhm::Application.config.mailer_sender
# Configure the class responsible to send e-mails.
# config.mailer = "Devise::Mailer"
- # Automatically apply schema changes in tableless databases
- # config.apply_schema = false
-
- # ==> ORM configuration
+ # ==> ORM configuration
# Load and configure the ORM. Supports :active_record (default) and
# :mongoid (bson_ext recommended) by default. Other ORMs may be
# available as additional gems.
require 'devise/orm/active_record'
- # ==> Configuration for any authentication mechanism
+ # ==> Configuration for any authentication mechanism
# Configure which keys are used when authenticating a user. The default is
# just :email. You can configure it to use [:username, :subdomain], so for
# authenticating a user, both parameters are required. Remember that those
@@ -41,7 +43,7 @@ Devise.setup do |config|
# to authenticate or find a user. Default is :email.
config.case_insensitive_keys = [ :email ]
- # Configure which authentication keys should have whitespace stripped.
+ # Configure which authentication keys should have whitespace stripped.
# These keys will have whitespace before and after removed upon creating or
# modifying a user and when used to authenticate or find a user. Default is :email.
config.strip_whitespace_keys = [ :email ]
@@ -52,17 +54,18 @@ Devise.setup do |config|
# enable it only for database (email + password) authentication.
# config.params_authenticatable = true
- # Tell if authentication through HTTP Basic Auth is enabled. False by default.
+ # Tell if authentication through HTTP Auth is enabled. False by default.
# It can be set to an array that will enable http authentication only for the
- # given strategies, for example, `config.http_authenticatable = [:token]` will
- # enable it only for token authentication.
+ # given strategies, for example, `config.http_authenticatable = [:database]` will
+ # enable it only for database authentication. The supported strategies are:
+ # :database = Support basic authentication with authentication key + password
# config.http_authenticatable = false
- # If http headers should be returned for AJAX requests. True by default.
+ # If 401 status code should be returned for AJAX requests. True by default.
# config.http_authenticatable_on_xhr = true
- # The realm used in Http Basic Authentication. "Application" by default.
- # config.http_authentication_realm = "Application"
+ # The realm used in Http Basic Authentication. 'Application' by default.
+ # config.http_authentication_realm = 'Application'
# It will change confirmation, password recovery and other workflows
# to behave the same regardless if the e-mail provided was right or wrong.
@@ -70,22 +73,28 @@ Devise.setup do |config|
# config.paranoid = true
# By default Devise will store the user in session. You can skip storage for
- # :http_auth and :token_auth by adding those symbols to the array below.
+ # particular strategies by setting this option.
# Notice that if you are skipping storage for all authentication paths, you
# may want to disable generating routes to Devise's sessions controller by
- # passing :skip => :sessions to `devise_for` in your config/routes.rb
+ # passing skip: :sessions to `devise_for` in your config/routes.rb
config.skip_session_storage = [:http_auth]
+ # By default, Devise cleans up the CSRF token on authentication to
+ # avoid CSRF token fixation attacks. This means that, when using AJAX
+ # requests for sign in and sign up, you need to get a new CSRF token
+ # from the server. You can disable this option at your own risk.
+ # config.clean_up_csrf_token_on_authentication = true
+
# ==> Configuration for :database_authenticatable
# For bcrypt, this is the cost for hashing the password and defaults to 10. If
# using other encryptors, it sets how many times you want the password re-encrypted.
#
# Limiting the stretches to just one in testing will increase the performance of
# your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
- # a value less than 10 in other environments.
+ # a value less than 10 in other environments. Note that, for bcrypt (the default
+ # encryptor), the cost increases exponentially with the number of stretches (e.g.
+ # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation).
config.stretches = Rails.env.test? ? 1 : 10
-
- config.secret_key = 'e9b20cea45078c982c9cd42cc64c484071d582a3d366ad2b51f676d168bccb2e0fd20e87ebe64aff57ad7f8a1a1c50b76cb9dc4039c287a195f9621fdb557993'
# Setup a pepper to generate the encrypted password.
# config.pepper = "0420ef6a1b6b0ac63b9ac1e2b9624b411e331345a1bad99c85986f70aef62e9c7912955ea1616135224fc7c4ac319085a5e33831fb215a5e45043816746a2c2f"
@@ -110,18 +119,26 @@ Devise.setup do |config|
# Default: false
# config.validate_on_invite = true
- # ==> Configuration for :confirmable
+# ==> Configuration for :confirmable
# A period that the user is allowed to access the website even without
- # confirming his account. For instance, if set to 2.days, the user will be
- # able to access the website for two days without confirming his account,
+ # confirming their account. For instance, if set to 2.days, the user will be
+ # able to access the website for two days without confirming their account,
# access will be blocked just in the third day. Default is 0.days, meaning
- # the user cannot access the website without confirming his account.
+ # the user cannot access the website without confirming their account.
# config.allow_unconfirmed_access_for = 2.days
+ # A period that the user is allowed to confirm their account before their
+ # token becomes invalid. For example, if set to 3.days, the user can confirm
+ # their account within 3 days after the mail was sent, but on the fourth day
+ # their account can't be confirmed with the token any more.
+ # Default is nil, meaning there is no restriction on how long a user can take
+ # before confirming their account.
+ # config.confirm_within = 3.days
+
# If true, requires any email changes to be confirmed (exactly the same way as
# initial account confirmation) to be applied. Requires additional unconfirmed_email
- # db field (see migrations). Until confirmed new email is stored in
- # unconfirmed email column, and copied to email column on successful confirmation.
+ # db field (see migrations). Until confirmed, new email is stored in
+ # unconfirmed_email column, and copied to email column on successful confirmation.
config.reconfirmable = false
# Defines which key will be used when confirming an account
@@ -131,24 +148,22 @@ Devise.setup do |config|
# The time the user will be remembered without asking for credentials again.
# config.remember_for = 2.weeks
+ # Invalidates all the remember me tokens when the user signs out.
+ config.expire_all_remember_me_on_sign_out = true
+
# If true, extends the user's remember period when remembered via cookie.
# config.extend_remember_period = false
- # This configures your application to use the salt as the remember token.
- # Leave this set to true - this option was kept for backwards compatibility
- # and will be removed in some future releases.
- # config.use_salt_as_remember_token = true
-
# Options to be passed to the created cookie. For instance, you can set
- # :secure => true in order to force SSL only cookies.
+ # secure: true in order to force SSL only cookies.
# config.rememberable_options = {}
# ==> Configuration for :validatable
- # Range for password length. Default is 6..128.
- # config.password_length = 6..128
+ # Range for password length.
+ config.password_length = 6..128
# Email regex used to validate email formats. It simply asserts that
- # an one (and only one) @ exists in the given string. This is mainly
+ # one (and only one) @ exists in the given string. This is mainly
# to give user feedback and not to assert the e-mail validity.
# config.email_regexp = /\A[^@]+@[^@]+\z/
@@ -157,6 +172,9 @@ Devise.setup do |config|
# time the user will be asked for credentials again. Default is 30 minutes.
# config.timeout_in = 30.minutes
+ # If true, expires auth token on session timeout.
+ # config.expire_auth_token_on_timeout = false
+
# ==> Configuration for :lockable
# Defines which strategy will be used to lock an account.
# :failed_attempts = Locks an account after a number of failed attempts to sign in.
@@ -180,6 +198,9 @@ Devise.setup do |config|
# Time interval to unlock the account if :time is enabled as unlock_strategy.
# config.unlock_in = 1.hour
+ # Warn on the last attempt before the account is locked.
+ # config.last_attempt_warning = true
+
# ==> Configuration for :recoverable
#
# Defines which key will be used when recovering the password for an account
@@ -195,13 +216,11 @@ Devise.setup do |config|
# :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1,
# :authlogic_sha512 (then you should set stretches above to 20 for default behavior)
# and :restful_authentication_sha1 (then you should set stretches to 10, and copy
- # REST_AUTH_SITE_KEY to pepper)
+ # REST_AUTH_SITE_KEY to pepper).
+ #
+ # Require the `devise-encryptable` gem when using anything other than bcrypt
config.encryptor = :sha1
- # ==> Configuration for :token_authenticatable
- # Defines name of the authentication token params key
- # config.token_authentication_key = :auth_token
-
# ==> Scopes configuration
# Turn scoped views on. Before rendering "sessions/new", it will first check for
# "users/sessions/new". It's turned off by default because it's slower if you
@@ -212,9 +231,8 @@ Devise.setup do |config|
# devise role declared in your routes (usually :user).
# config.default_scope = :user
- # Configure sign_out behavior.
- # Sign_out action can be scoped (i.e. /users/sign_out affects only :user scope).
- # The default is true, which means any logout action will sign out all active scopes.
+ # Set this configuration to false if you want /users/sign_out to sign out
+ # only the current scope. By default, Devise signs out all scopes.
# config.sign_out_all_scopes = true
# ==> Navigation configuration
@@ -226,15 +244,15 @@ Devise.setup do |config|
# should add them to the navigational formats lists.
#
# The "*/*" below is required to match Internet Explorer requests.
- # config.navigational_formats = ["*/*", :html]
+ # config.navigational_formats = ['*/*', :html]
# The default HTTP method used to sign out a resource. Default is :delete.
- config.sign_out_via = Rails.env.test? ? :get : :delete
+ config.sign_out_via = :delete
# ==> OmniAuth
# Add a new OmniAuth provider. Check the wiki for more information on setting
# up on your models and hooks.
- # config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo'
+ # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
# ==> Warden configuration
# If you want to use other strategies, that are not supported by Devise, or
@@ -242,8 +260,22 @@ Devise.setup do |config|
#
# config.warden do |manager|
# manager.intercept_401 = false
- # manager.default_strategies(:scope => :user).unshift :some_external_strategy
+ # manager.default_strategies(scope: :user).unshift :some_external_strategy
# end
+
+ # ==> Mountable engine configurations
+ # When using Devise inside an engine, let's call it `MyEngine`, and this engine
+ # is mountable, there are some extra configurations to be taken into account.
+ # The following options are available, assuming the engine is mounted as:
+ #
+ # mount MyEngine, at: '/my_engine'
+ #
+ # The router that invoked `devise_for`, in the example above, would be:
+ # config.router_name = :my_engine
+ #
+ # When using omniauth, Devise cannot automatically set Omniauth path,
+ # so you need to do it manually. For the users scope, it would be:
+ # config.omniauth_path_prefix = '/my_engine/users/auth'
end
Rails.application.config.to_prepare do
diff --git a/config/initializers/devise_permitted_parameters.rb b/config/initializers/devise_permitted_parameters.rb
new file mode 100644
index 000000000..5ac054b39
--- /dev/null
+++ b/config/initializers/devise_permitted_parameters.rb
@@ -0,0 +1,17 @@
+module DevisePermittedParameters
+ extend ActiveSupport::Concern
+
+ included do
+ before_filter :configure_permitted_parameters
+ end
+
+ protected
+
+ def configure_permitted_parameters
+ devise_parameter_sanitizer.for(:sign_up) { |u| u.permit( :name, :email, :password, :password_confirmation, { organisation_attributes: [:name] } ) }
+ devise_parameter_sanitizer.for(:account_update) { |u| u.permit( :name, :email, :password, :password_confirmation, :current_password, { organisation_attributes: [:name] } ) }
+ end
+
+end
+
+DeviseController.send :include, DevisePermittedParameters
diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb
new file mode 100644
index 000000000..2ab23e63c
--- /dev/null
+++ b/config/initializers/filter_parameter_logging.rb
@@ -0,0 +1,4 @@
+# Be sure to restart your server when you modify this file.
+
+# Configure sensitive parameters which will be filtered from the log file.
+Rails.application.config.filter_parameters += [:password, :password_confirmation]
diff --git a/config/initializers/remove_simple_form_bootstrap3_inputs.rb b/config/initializers/remove_simple_form_bootstrap3_inputs.rb
deleted file mode 100644
index 448487308..000000000
--- a/config/initializers/remove_simple_form_bootstrap3_inputs.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-inputs = %w[
- CollectionSelectInput
- DateTimeInput
- FileInput
- GroupedCollectionSelectInput
- NumericInput
- PasswordInput
- RangeInput
- StringInput
- TextInput
-]
-
-# Instead of creating top-level custom input classes like TextInput, we wrap it into a module and override
-# mapping in SimpleForm::FormBuilder directly
-#
-SimpleFormBootstrapInputs = Module.new
-inputs.each do |input_type|
- superclass = "SimpleForm::Inputs::#{input_type}".constantize
-
- new_class = SimpleFormBootstrapInputs.const_set(input_type, Class.new(superclass) do
- def input_html_classes
- super.push('form-control')
- end
- end)
-
- # Now override existing usages of superclass with new_class
- SimpleForm::FormBuilder.mappings.each do |(type, target_class)|
- if target_class == superclass
- SimpleForm::FormBuilder.map_type(type, to: new_class)
- end
- end
-end
diff --git a/config/initializers/simple_form.rb b/config/initializers/simple_form.rb
index a128195d2..d5492e529 100644
--- a/config/initializers/simple_form.rb
+++ b/config/initializers/simple_form.rb
@@ -5,8 +5,8 @@ SimpleForm.setup do |config|
# wrapper, change the order or even add your own to the
# stack. The options given below are used to wrap the
# whole input.
- config.wrappers :default, :class => :input,
- :hint_class => :field_with_hint, :error_class => :field_with_errors do |b|
+ config.wrappers :default, class: :input,
+ hint_class: :field_with_hint, error_class: :field_with_errors do |b|
## Extensions enabled by default
# Any of these extensions can be disabled for a
# given input by passing: `f.input EXTENSION_NAME => false`.
@@ -18,13 +18,13 @@ SimpleForm.setup do |config|
b.use :html5
# Calculates placeholders automatically from I18n
- # You can also pass a string as f.input :placeholder => "Placeholder"
+ # You can also pass a string as f.input placeholder: "Placeholder"
b.use :placeholder
## Optional extensions
- # They are disabled unless you pass `f.input EXTENSION_NAME => :lookup`
+ # They are disabled unless you pass `f.input EXTENSION_NAME => true`
# to the input. If so, they will retrieve the values from the model
- # if any exists. If you want to enable the lookup for any of those
+ # if any exists. If you want to enable any of those
# extensions by default, you can change `b.optional` to `b.use`.
# Calculates maxlength from length validations for string inputs
@@ -41,8 +41,14 @@ SimpleForm.setup do |config|
## Inputs
b.use :label_input
- b.use :hint, :wrap_with => { :tag => :span, :class => :hint }
- b.use :error, :wrap_with => { :tag => :span, :class => :error }
+ b.use :hint, wrap_with: { tag: :span, class: :hint }
+ b.use :error, wrap_with: { tag: :span, class: :error }
+
+ ## full_messages_for
+ # If you want to display the full error message for the attribute, you can
+ # use the component :full_error, like:
+ #
+ # b.use :full_error, wrap_with: { tag: :span, class: :error }
end
# The default wrapper to be used by the FormBuilder.
@@ -50,8 +56,8 @@ SimpleForm.setup do |config|
# Define the way to render check boxes / radio buttons with labels.
# Defaults to :nested for bootstrap config.
- # :inline => input + label
- # :nested => label > input
+ # inline: input + label
+ # nested: label > input
config.boolean_style = :nested
# Default class for buttons
@@ -66,7 +72,7 @@ SimpleForm.setup do |config|
config.error_notification_tag = :div
# CSS class to add for error notification helper.
- config.error_notification_class = 'alert alert-error'
+ config.error_notification_class = 'error_notification'
# ID to add for error notification helper.
# config.error_notification_id = nil
@@ -92,13 +98,14 @@ SimpleForm.setup do |config|
# config.item_wrapper_class = nil
# How the label text should be generated altogether with the required text.
- # config.label_text = lambda { |label, required| "#{required} #{label}" }
+ # config.label_text = lambda { |label, required, explicit_label| "#{required} #{label}" }
# You can define the class to use on all labels. Default is nil.
- config.label_class = 'col-lg-3 control-label'
+ # config.label_class = nil
- # You can define the class to use on all forms. Default is simple_form.
- config.form_class = "simple_form form-horizontal"
+ # You can define the default class to be used on forms. Can be overriden
+ # with `html: { :class }`. Defaulting to none.
+ # config.default_form_class = nil
# You can define which elements should obtain additional classes
# config.generate_additional_classes_for = [:wrapper, :label, :input]
@@ -106,8 +113,11 @@ SimpleForm.setup do |config|
# Whether attributes are required by default (or not). Default is true.
# config.required_by_default = true
- # Tell browsers whether to use default HTML5 validations (novalidate option).
- # Default is enabled.
+ # Tell browsers whether to use the native HTML5 validations (novalidate form option).
+ # These validations are enabled in SimpleForm's internal config but disabled by default
+ # in this configuration, which is recommended due to some quirks from different browsers.
+ # To stop SimpleForm from generating the novalidate option, enabling the HTML5 validations,
+ # change this configuration to true.
config.browser_validations = false
# Collection of methods to detect if a file type was given.
@@ -120,7 +130,11 @@ SimpleForm.setup do |config|
# Custom wrappers for input types. This should be a hash containing an input
# type as key and the wrapper that will be used for all inputs with specified type.
- # config.wrapper_mappings = { :string => :prepend }
+ # config.wrapper_mappings = { string: :prepend }
+
+ # Namespaces where SimpleForm should look for custom input classes that
+ # override default inputs.
+ # config.custom_inputs_namespaces << "CustomInputs"
# Default priority for time_zone inputs.
# config.time_zone_priority = nil
@@ -128,15 +142,25 @@ SimpleForm.setup do |config|
# Default priority for country inputs.
# config.country_priority = nil
- # Default size for text inputs.
- # config.default_input_size = 50
-
# When false, do not use translations for labels.
- config.translate_labels = true
+ # config.translate_labels = true
# Automatically discover new inputs in Rails' autoload path.
- # config.inputs_discovery = false
+ # config.inputs_discovery = true
# Cache SimpleForm inputs discovery
# config.cache_discovery = !Rails.env.development?
+
+ # Default class for inputs
+ # config.input_class = nil
+
+ # Define the default class of the input wrapper of the boolean input.
+ config.boolean_label_class = 'checkbox'
+
+ # Defines if the default input wrapper class should be included in radio
+ # collection wrappers.
+ # config.include_default_input_wrapper_class = true
+
+ # Defines which i18n scope will be used in Simple Form.
+ # config.i18n_scope = 'simple_form'
end
diff --git a/config/initializers/simple_form_bootstrap.rb b/config/initializers/simple_form_bootstrap.rb
index 552a2ff66..f9fc81d70 100644
--- a/config/initializers/simple_form_bootstrap.rb
+++ b/config/initializers/simple_form_bootstrap.rb
@@ -1,58 +1,162 @@
# Use this setup block to configure all options available in SimpleForm.
SimpleForm.setup do |config|
- config.wrappers :bootstrap, :tag => 'div', :class => 'form-group', :error_class => 'error' do |b|
+ config.error_notification_class = 'alert alert-danger'
+ config.button_class = 'btn btn-default'
+ config.boolean_label_class = nil
+
+ config.wrappers :vertical_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
b.use :html5
b.use :placeholder
- b.use :label
- b.wrapper :tag => 'div', :class => 'col-lg-9' do |ba|
- ba.use :input
- ba.use :error, :wrap_with => { :tag => 'span', :class => 'help-inline' }
- ba.use :hint, :wrap_with => { :tag => 'p', :class => 'help-block' }
+ b.optional :maxlength
+ b.optional :pattern
+ b.optional :min_max
+ b.optional :readonly
+ b.use :label, class: 'control-label'
+
+ b.use :input, class: 'form-control'
+ b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
+ b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
+ end
+
+ config.wrappers :vertical_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
+ b.use :html5
+ b.use :placeholder
+ b.optional :maxlength
+ b.optional :readonly
+ b.use :label, class: 'control-label'
+
+ b.use :input
+ b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
+ b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
+ end
+
+ config.wrappers :vertical_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
+ b.use :html5
+ b.optional :readonly
+
+ b.wrapper tag: 'div', class: 'checkbox' do |ba|
+ ba.use :label_input
end
+
+ b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
+ b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
end
- config.wrappers :form_without_label, :tag => 'div', :class => 'form-group', :error_class => 'error' do |b|
+ config.wrappers :vertical_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
+ b.use :html5
+ b.optional :readonly
+ b.use :label, class: 'control-label'
+ b.use :input
+ b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
+ b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
+ end
+
+ config.wrappers :horizontal_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
b.use :html5
b.use :placeholder
- b.use :label
- b.wrapper :tag => 'div', :class => 'col-lg-12' do |ba|
- ba.use :input
- ba.use :error, :wrap_with => { :tag => 'span', :class => 'help-inline' }
- ba.use :hint, :wrap_with => { :tag => 'p', :class => 'help-block' }
+ b.optional :maxlength
+ b.optional :pattern
+ b.optional :min_max
+ b.optional :readonly
+ b.use :label, class: 'col-sm-3 control-label'
+
+ b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
+ ba.use :input, class: 'form-control'
+ ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
+ ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
end
end
- config.wrappers :prepend, :tag => 'div', :class => "form-group", :error_class => 'error' do |b|
+ config.wrappers :horizontal_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
b.use :html5
b.use :placeholder
- b.use :label
- b.wrapper :tag => 'div', :class => 'col-lg-9' do |input|
- input.wrapper :tag => 'div', :class => 'input-prepend' do |prepend|
- prepend.use :input
+ b.optional :maxlength
+ b.optional :readonly
+ b.use :label, class: 'col-sm-3 control-label'
+
+ b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
+ ba.use :input
+ ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
+ ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
+ end
+ end
+
+ config.wrappers :horizontal_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
+ b.use :html5
+ b.optional :readonly
+
+ b.wrapper tag: 'div', class: 'col-sm-offset-3 col-sm-9' do |wr|
+ wr.wrapper tag: 'div', class: 'checkbox' do |ba|
+ ba.use :label_input
end
- input.use :hint, :wrap_with => { :tag => 'span', :class => 'help-block' }
- input.use :error, :wrap_with => { :tag => 'span', :class => 'help-inline' }
+
+ wr.use :error, wrap_with: { tag: 'span', class: 'help-block' }
+ wr.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
+ end
+ end
+
+ config.wrappers :horizontal_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
+ b.use :html5
+ b.optional :readonly
+
+ b.use :label, class: 'col-sm-3 control-label'
+
+ b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
+ ba.use :input
+ ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
+ ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
end
end
- config.wrappers :append, :tag => 'div', :class => "form-group", :error_class => 'error' do |b|
+ config.wrappers :inline_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
b.use :html5
b.use :placeholder
- b.use :label
- b.wrapper :tag => 'div', :class => 'col-lg-9' do |input|
- input.wrapper :tag => 'div', :class => 'input-append' do |append|
- append.use :input
- end
- input.use :hint, :wrap_with => { :tag => 'span', :class => 'help-block' }
- input.use :error, :wrap_with => { :tag => 'span', :class => 'help-inline' }
+ b.optional :maxlength
+ b.optional :pattern
+ b.optional :min_max
+ b.optional :readonly
+ b.use :label, class: 'sr-only'
+
+ b.use :input, class: 'form-control'
+ b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
+ b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
+ end
+
+ config.wrappers :form_without_label, :tag => 'div', :class => 'form-group', :error_class => 'error' do |b|
+
+ b.use :html5
+ b.use :placeholder
+ b.optional :maxlength
+ b.optional :pattern
+ b.optional :min_max
+ b.optional :readonly
+
+ b.wrapper tag: 'div', class: 'col-sm-12' do |ba|
+ ba.use :input, class: 'form-control'
+ ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
+ ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
end
+ end
+
+ config.wrappers :nested, :tag => 'span', :error_class => 'has-error' do |b|
+ b.use :html5
+ b.use :placeholder
+ b.optional :readonly
+ b.use :input
+ b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
+ b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
end
- # Wrappers for forms and inputs using the Twitter Bootstrap toolkit.
- # Check the Bootstrap docs (http://twitter.github.com/bootstrap)
+ # Wrappers for forms and inputs using the Bootstrap toolkit.
+ # Check the Bootstrap docs (http://getbootstrap.com)
# to learn about the different styles for forms and inputs,
# buttons and other elements.
- config.default_wrapper = :bootstrap
- config.button_class = 'btn'
- config.label_class = 'col-lg-3 control-label'
+ config.default_wrapper = :vertical_form
+ config.wrapper_mappings = {
+ check_boxes: :vertical_radio_and_checkboxes,
+ radio_buttons: :vertical_radio_and_checkboxes,
+ file: :vertical_file_input,
+ boolean: :vertical_boolean,
+ }
end
+
diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb
index da4fb076f..33725e95f 100644
--- a/config/initializers/wrap_parameters.rb
+++ b/config/initializers/wrap_parameters.rb
@@ -1,14 +1,14 @@
# Be sure to restart your server when you modify this file.
-#
+
# This file contains settings for ActionController::ParamsWrapper which
# is enabled by default.
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
ActiveSupport.on_load(:action_controller) do
- wrap_parameters :format => [:json]
+ wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
end
-# Disable root element in JSON by default.
-ActiveSupport.on_load(:active_record) do
- self.include_root_in_json = false
-end
+# To enable root element in JSON for ActiveRecord objects.
+# ActiveSupport.on_load(:active_record) do
+# self.include_root_in_json = true
+# end
diff --git a/config/routes.rb b/config/routes.rb
index c48feaa5b..3ac8be84c 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,20 +1,17 @@
ChouetteIhm::Application.routes.draw do
- devise_scope :users do
- #match "/users/sign_up" => "subscriptions#new",
- end
devise_for :users, :controllers => { :registrations => "registrations" }
+ resources :users
devise_scope :user do
authenticated :user do
root :to => 'referentials#index', as: :authenticated_root
end
unauthenticated :user do
- root :to => 'devise/registrations#new', as: :unauthenticated_root
+ root :to => 'devise/sessions#new', as: :unauthenticated_root
end
end
-
namespace :api do
namespace :v1 do
resources :time_tables, :only => [:index, :show]
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")