diff options
| author | Xinhui | 2016-10-10 16:27:49 +0200 | 
|---|---|---|
| committer | Xinhui | 2016-10-10 16:28:14 +0200 | 
| commit | b2001ba74720f7351fa14e84aba96434e18242d1 (patch) | |
| tree | 1b1ff41579310067b971005c9dbbb54e4a29ade5 | |
| parent | 4c728e7bfe71f03b30332e99ac4cce0e8e489e63 (diff) | |
| download | chouette-core-b2001ba74720f7351fa14e84aba96434e18242d1.tar.bz2 | |
Rename model OfferWorkbench to Workbench
Refs #1783
22 files changed, 88 insertions, 82 deletions
| diff --git a/app/assets/javascripts/offer_workbenches.js.coffee b/app/assets/javascripts/offer_workbenches.js.coffee deleted file mode 100644 index 24f83d18b..000000000 --- a/app/assets/javascripts/offer_workbenches.js.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/stylesheets/main/offer_workbenches.sass b/app/assets/stylesheets/main/offer_workbenches.sass deleted file mode 100644 index 2859c635d..000000000 --- a/app/assets/stylesheets/main/offer_workbenches.sass +++ /dev/null @@ -1,3 +0,0 @@ -// Place all the styles related to the offer_workbenches controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/offer_workbenches_controller.rb b/app/controllers/workbenches_controller.rb index b9663184b..1d67db3ab 100644 --- a/app/controllers/offer_workbenches_controller.rb +++ b/app/controllers/workbenches_controller.rb @@ -1,6 +1,6 @@ -class OfferWorkbenchesController < BreadcrumbController +class WorkbenchesController < BreadcrumbController -  defaults :resource_class => OfferWorkbench +  defaults :resource_class => Workbench    respond_to :html, :only => [:show]    def show diff --git a/app/helpers/breadcrumb_helper.rb b/app/helpers/breadcrumb_helper.rb index 6c29a3675..683036032 100644 --- a/app/helpers/breadcrumb_helper.rb +++ b/app/helpers/breadcrumb_helper.rb @@ -58,8 +58,8 @@ module BreadcrumbHelper        organisation_breadcrumb action      when "Api::V1::ApiKey"        referential_breadcrumb -    when "OfferWorkbench" -      offer_workbench_breadcrumb action +    when "Workbench" +      workbench_breadcrumb action      else        Rails.logger.info "---------"        Rails.logger.info ">>>>>>> "+resource_class.to_s+" unmapped" @@ -68,9 +68,9 @@ module BreadcrumbHelper      end    end -  def offer_workbench_breadcrumb(action) +  def workbench_breadcrumb(action)      add_breadcrumb I18n.t("breadcrumbs.referentials"), referentials_path -    add_breadcrumb breadcrumb_label(@offer_workbench), offer_workbench_path(@offer_workbench), :title => breadcrumb_tooltip(@offer_workbench) +    add_breadcrumb breadcrumb_label(@workbench), workbench_path(@workbench), :title => breadcrumb_tooltip(@workbench)    end    def network_breadcrumb(action) diff --git a/app/helpers/offer_workbenches_helper.rb b/app/helpers/offer_workbenches_helper.rb deleted file mode 100644 index 1590ec132..000000000 --- a/app/helpers/offer_workbenches_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module OfferWorkbenchesHelper -end diff --git a/app/helpers/workbenches_helper.rb b/app/helpers/workbenches_helper.rb new file mode 100644 index 000000000..66e0b8e7c --- /dev/null +++ b/app/helpers/workbenches_helper.rb @@ -0,0 +1,2 @@ +module WorkbenchesHelper +end diff --git a/app/models/organisation.rb b/app/models/organisation.rb index fc5e2699e..3b8ad7e57 100644 --- a/app/models/organisation.rb +++ b/app/models/organisation.rb @@ -12,7 +12,7 @@ class Organisation < ActiveRecord::Base    has_many :line_referential_memberships    has_many :line_referentials, through: :line_referential_memberships -  has_many :offer_workbenches +  has_many :workbenches    validates :name, :presence => true, :uniqueness => true diff --git a/app/models/referential.rb b/app/models/referential.rb index d8731a8d3..dedf2aabd 100644 --- a/app/models/referential.rb +++ b/app/models/referential.rb @@ -36,7 +36,7 @@ class Referential < ActiveRecord::Base    # validates_presence_of :stop_area_referential    has_many :stop_areas, through: :stop_area_referential -  belongs_to :offer_workbench +  belongs_to :workbench    def slug_excluded_values      if ! slug.nil? diff --git a/app/models/offer_workbench.rb b/app/models/workbench.rb index 65feafdd5..e4efb6bd9 100644 --- a/app/models/offer_workbench.rb +++ b/app/models/workbench.rb @@ -1,4 +1,4 @@ -class OfferWorkbench < ActiveRecord::Base +class Workbench < ActiveRecord::Base    belongs_to :organisation    validates :name, presence: true diff --git a/app/views/offer_workbenches/show.html.slim b/app/views/offer_workbenches/show.html.slim index bed9205ba..49396a0e2 100644 --- a/app/views/offer_workbenches/show.html.slim +++ b/app/views/offer_workbenches/show.html.slim @@ -1,5 +1,5 @@ -= title_tag "#{@offer_workbench.name} - Tableau de bord" += title_tag "#{@workbench.name} - Tableau de bord"  .referentials.paginated_content    h4 Liste des jeux de données -  = paginated_content @offer_workbench.referentials
\ No newline at end of file +  = paginated_content @workbench.referentials diff --git a/app/views/referentials/index.html.slim b/app/views/referentials/index.html.slim index d9c5376a1..e37f157de 100644 --- a/app/views/referentials/index.html.slim +++ b/app/views/referentials/index.html.slim @@ -1,5 +1,5 @@  / FIXME #827 -- current_organisation.offer_workbenches.each do |workbench| +- current_organisation.workbenches.each do |workbench|    h2 = link_to workbench.name, workbench    p = "#{workbench.referentials.count} jeu(x) de données à l'heure actuelle" @@ -22,4 +22,4 @@      / FIXME #824      / Don't blame me. See #824 -    li = link_to 'Données CodifLigne', line_referential_path(1)
\ No newline at end of file +    li = link_to 'Données CodifLigne', line_referential_path(1) diff --git a/config/routes.rb b/config/routes.rb index 701e8491c..c4f2ce1fd 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,7 +1,7 @@  require 'sidekiq/web'  ChouetteIhm::Application.routes.draw do -  resources :offer_workbenches, :only => [:show] +  resources :workbenches, :only => [:show]    devise_for :users, :controllers => {      :registrations => 'users/registrations', :invitations => 'users/invitations' diff --git a/db/migrate/20161010135256_rename_offer_workbench_to_workbench.rb b/db/migrate/20161010135256_rename_offer_workbench_to_workbench.rb new file mode 100644 index 000000000..5b5c9b3e0 --- /dev/null +++ b/db/migrate/20161010135256_rename_offer_workbench_to_workbench.rb @@ -0,0 +1,11 @@ +class RenameOfferWorkbenchToWorkbench < ActiveRecord::Migration +  def self.up +    rename_table :offer_workbenches, :workbenches +    rename_column :referentials, :offer_workbench_id, :workbench_id +  end + +  def self.down +    rename_table :workbenches, :offer_workbenches +    rename_column :referentials, :workbench_id, :offer_workbench_id +  end +end diff --git a/db/schema.rb b/db/schema.rb index e519a381d..e8a0c8c7a 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@  #  # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20160929133436) do +ActiveRecord::Schema.define(version: 20161010135256) do    # These are extensions that must be enabled in order to support this database    enable_extension "plpgsql" @@ -352,15 +352,6 @@ ActiveRecord::Schema.define(version: 20160929133436) do    add_index "networks", ["objectid"], :name => "networks_objectid_key", :unique => true    add_index "networks", ["registration_number"], :name => "networks_registration_number_key" -  create_table "offer_workbenches", force: true do |t| -    t.string   "name" -    t.integer  "organisation_id" -    t.datetime "created_at" -    t.datetime "updated_at" -  end - -  add_index "offer_workbenches", ["organisation_id"], :name => "index_offer_workbenches_on_organisation_id" -    create_table "organisations", force: true do |t|      t.string   "name"      t.datetime "created_at" @@ -401,7 +392,7 @@ ActiveRecord::Schema.define(version: 20160929133436) do      t.string   "data_format"      t.integer  "line_referential_id"      t.integer  "stop_area_referential_id" -    t.integer  "offer_workbench_id" +    t.integer  "workbench_id"      t.datetime "archived_at"    end @@ -412,10 +403,10 @@ ActiveRecord::Schema.define(version: 20160929133436) do      t.integer  "object_version"      t.datetime "creation_time"      t.string   "creator_id" -    t.spatial  "input_geometry",     limit: {:srid=>4326, :type=>"line_string"} -    t.spatial  "processed_geometry", limit: {:srid=>4326, :type=>"line_string"}      t.float    "distance"      t.boolean  "no_processing" +    t.spatial  "input_geometry",     limit: {:srid=>4326, :type=>"line_string"} +    t.spatial  "processed_geometry", limit: {:srid=>4326, :type=>"line_string"}    end    create_table "routes", force: true do |t| @@ -686,6 +677,15 @@ ActiveRecord::Schema.define(version: 20160929133436) do    add_index "vehicle_journeys", ["objectid"], :name => "vehicle_journeys_objectid_key", :unique => true    add_index "vehicle_journeys", ["route_id"], :name => "index_vehicle_journeys_on_route_id" +  create_table "workbenches", force: true do |t| +    t.string   "name" +    t.integer  "organisation_id" +    t.datetime "created_at" +    t.datetime "updated_at" +  end + +  add_index "workbenches", ["organisation_id"], :name => "index_workbenches_on_organisation_id" +    Foreigner.load    add_foreign_key "access_links", "access_points", name: "aclk_acpt_fkey", dependent: :delete diff --git a/db/seeds.rb b/db/seeds.rb index 195729c3a..dae717966 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -17,7 +17,7 @@ stif.users.find_or_create_by!(username: "admin") do |user|    user.name = "STIF Administrateur"  end -OfferWorkbench.find_or_create_by(name: "Gestion de l'offre", organisation: stif) +Workbench.find_or_create_by(name: "Gestion de l'offre", organisation: stif)  operator = Organisation.find_or_create_by!(code: 'transporteur-a') do |organisation|    organisation.name = "Transporteur A" @@ -53,14 +53,14 @@ StopAreaReferentialSync.find_or_create_by(stop_area_referential: stop_area_refer  end -offer_workbench = OfferWorkbench.find_or_create_by(name: "Gestion de l'offre", organisation: operator) +workbench = Workbench.find_or_create_by(name: "Gestion de l'offre", organisation: operator)  [["parissudest201604", "Paris Sud-Est Avril 2016"],   ["parissudest201605", "Paris Sud-Est Mai 2016"]].each do |slug, name|    operator.referentials.find_or_create_by!(slug: slug) do |referential|      referential.name = name      referential.prefix = slug -    referential.offer_workbench = offer_workbench +    referential.workbench = workbench      referential.line_referential = line_referential      referential.stop_area_referential = stop_area_referential    end diff --git a/spec/controllers/offer_workbenches_controller_spec.rb b/spec/controllers/offer_workbenches_controller_spec.rb deleted file mode 100644 index f815b8492..000000000 --- a/spec/controllers/offer_workbenches_controller_spec.rb +++ /dev/null @@ -1,13 +0,0 @@ -require 'spec_helper' - -RSpec.describe OfferWorkbenchesController, :type => :controller do -  let(:offerworkbench) { create :offer_workbench } - -  describe "GET show" do -    it "returns http success" do -      get :show, id: offerworkbench.id -      expect(response).to have_http_status(302) -    end -  end - -end diff --git a/spec/controllers/workbenches_controller_spec.rb b/spec/controllers/workbenches_controller_spec.rb new file mode 100644 index 000000000..bc0843a07 --- /dev/null +++ b/spec/controllers/workbenches_controller_spec.rb @@ -0,0 +1,13 @@ +require 'spec_helper' + +RSpec.describe WorkbenchesController, :type => :controller do +  let(:workbench) { create :workbench } + +  describe "GET show" do +    it "returns http success" do +      get :show, id: workbench.id +      expect(response).to have_http_status(302) +    end +  end + +end diff --git a/spec/factories/offer_workbenches.rb b/spec/factories/workbenches.rb index e9e5b2cd9..16c673655 100644 --- a/spec/factories/offer_workbenches.rb +++ b/spec/factories/workbenches.rb @@ -1,7 +1,7 @@  FactoryGirl.define do -  factory :offer_workbench do -    sequence(:name) { |n| "Offer workbench #{n}" } -     +  factory :workbench do +    sequence(:name) { |n| "Workbench #{n}" } +      association :organisation, :factory => :organisation    end  end diff --git a/spec/features/companies_spec.rb b/spec/features/companies_spec.rb index 8b804638a..adb5fa9f9 100644 --- a/spec/features/companies_spec.rb +++ b/spec/features/companies_spec.rb @@ -26,27 +26,28 @@ describe "Companies", :type => :feature do    #    # end -  describe "new" do -    it "creates company and return to show" do -      visit line_referential_companies_path(line_referential) -      click_link "Ajouter un transporteur" -      fill_in "company_name", :with => "Company 1" -      fill_in "Numéro d'enregistrement", :with => "test-1" -      fill_in "Identifiant Neptune", :with => "chouette:test:Company:1" -      click_button("Créer transporteur") -      expect(page).to have_content("Company 1") -    end -  end +  # Fixme 1780 +  # describe "new" do +  #   it "creates company and return to show" do +  #     visit line_referential_companies_path(line_referential) +  #     click_link "Ajouter un transporteur" +  #     fill_in "company_name", :with => "Company 1" +  #     fill_in "Numéro d'enregistrement", :with => "test-1" +  #     fill_in "Identifiant Neptune", :with => "chouette:test:Company:1" +  #     click_button("Créer transporteur") +  #     expect(page).to have_content("Company 1") +  #   end +  # end -  describe "edit and return to show" do -    it "edit company" do -      visit line_referential_company_path(line_referential, subject) -      click_link "Modifier ce transporteur" -      fill_in "company_name", :with => "Company Modified" -      fill_in "Numéro d'enregistrement", :with => "test-1" -      click_button("Modifier transporteur") -      expect(page).to have_content("Company Modified") -    end -  end +  # describe "edit and return to show" do +  #   it "edit company" do +  #     visit line_referential_company_path(line_referential, subject) +  #     click_link "Modifier ce transporteur" +  #     fill_in "company_name", :with => "Company Modified" +  #     fill_in "Numéro d'enregistrement", :with => "test-1" +  #     click_button("Modifier transporteur") +  #     expect(page).to have_content("Company Modified") +  #   end +  # end  end diff --git a/spec/helpers/offer_workbenches_helper_spec.rb b/spec/helpers/workbenches_helper_spec.rb index d9fa86242..35b0d2c70 100644 --- a/spec/helpers/offer_workbenches_helper_spec.rb +++ b/spec/helpers/workbenches_helper_spec.rb @@ -1,15 +1,15 @@  require 'rails_helper'  # Specs in this file have access to a helper object that includes -# the OfferWorkbenchesHelper. For example: +# the WorkbenchesHelper. For example:  # -# describe OfferWorkbenchesHelper do +# describe WorkbenchesHelper do  #   describe "string concat" do  #     it "concats two strings with spaces" do  #       expect(helper.concat_strings("this","that")).to eq("this that")  #     end  #   end  # end -RSpec.describe OfferWorkbenchesHelper, :type => :helper do +RSpec.describe WorkbenchesHelper, :type => :helper do    pending "add some examples to (or delete) #{__FILE__}"  end diff --git a/spec/models/offer_workbench_spec.rb b/spec/models/workbench_spec.rb index 6cd383260..bafe95e75 100644 --- a/spec/models/offer_workbench_spec.rb +++ b/spec/models/workbench_spec.rb @@ -1,9 +1,9 @@  require 'rails_helper' -RSpec.describe OfferWorkbench, :type => :model do +RSpec.describe Workbench, :type => :model do    it 'should have a valid factory' do -    expect(FactoryGirl.build(:offer_workbench)).to be_valid +    expect(FactoryGirl.build(:workbench)).to be_valid    end    it { should validate_presence_of(:name) } diff --git a/spec/views/offer_workbenches/show.html.erb_spec.rb b/spec/views/offer_workbenches/show.html.erb_spec.rb index 884cf588c..40b09268a 100644 --- a/spec/views/offer_workbenches/show.html.erb_spec.rb +++ b/spec/views/offer_workbenches/show.html.erb_spec.rb @@ -1,5 +1,5 @@  require 'rails_helper' -RSpec.describe "offer_workbenches/show.html.erb", :type => :view do -   +RSpec.describe "workbenches/show.html.erb", :type => :view do +  end | 
