diff options
| author | Robert | 2017-07-14 10:25:32 +0200 | 
|---|---|---|
| committer | Robert | 2017-07-17 13:13:29 +0200 | 
| commit | 03c2dcba29f1d6b4a8d22bd091e036fcf5600924 (patch) | |
| tree | e384d5a4203bb607839a0727ff856d1eecdde759 | |
| parent | df21b37cb3f4c4b56a4873247c5bb2759fd549f7 (diff) | |
| download | chouette-core-03c2dcba29f1d6b4a8d22bd091e036fcf5600924.tar.bz2 | |
Fixes: #3555@1h
- Import#parent_id & #parent_type migration generated
- Import#belongs_to :parent, class_name: to_s specified
- Import#belongs_to :parent, class_name: to_s implemented
| -rw-r--r-- | app/controllers/import_tasks_controller.rb | 1 | ||||
| -rw-r--r-- | app/models/import.rb | 2 | ||||
| -rw-r--r-- | db/migrate/20170715041954_add_parent_type_and_parent_id_to_imports.rb | 6 | ||||
| -rw-r--r-- | db/schema.rb | 4 | ||||
| -rw-r--r-- | spec/controllers/api/v1/netex_import_controller_spec.rb | 12 | ||||
| -rw-r--r-- | spec/models/import_spec.rb | 1 | 
6 files changed, 24 insertions, 2 deletions
diff --git a/app/controllers/import_tasks_controller.rb b/app/controllers/import_tasks_controller.rb index 0e3ed6445..cb377ec5a 100644 --- a/app/controllers/import_tasks_controller.rb +++ b/app/controllers/import_tasks_controller.rb @@ -1,4 +1,3 @@ -# coding: utf-8  class ImportTasksController < ChouetteController    defaults :resource_class => ImportTask diff --git a/app/models/import.rb b/app/models/import.rb index d0736ab0b..535c676b1 100644 --- a/app/models/import.rb +++ b/app/models/import.rb @@ -3,6 +3,8 @@ class Import < ActiveRecord::Base    belongs_to :workbench    belongs_to :referential +  belongs_to :parent, class_name: to_s +    extend Enumerize    enumerize :status, in: %i(new pending successful failed running aborted canceled) diff --git a/db/migrate/20170715041954_add_parent_type_and_parent_id_to_imports.rb b/db/migrate/20170715041954_add_parent_type_and_parent_id_to_imports.rb new file mode 100644 index 000000000..96c1c2a59 --- /dev/null +++ b/db/migrate/20170715041954_add_parent_type_and_parent_id_to_imports.rb @@ -0,0 +1,6 @@ +class AddParentTypeAndParentIdToImports < ActiveRecord::Migration +  def change +    add_column :imports, :parent_id, :bigint +    add_column :imports, :parent_type, :string +  end +end diff --git a/db/schema.rb b/db/schema.rb index e64e5c04a..b56027f48 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: 20170607141317) do +ActiveRecord::Schema.define(version: 20170715041954) do    # These are extensions that must be enabled in order to support this database    enable_extension "plpgsql" @@ -285,6 +285,8 @@ ActiveRecord::Schema.define(version: 20170607141317) do      t.datetime "ended_at"      t.string   "token_download"      t.string   "type",                  limit: 255 +    t.integer  "parent_id",             limit: 8 +    t.string   "parent_type"    end    add_index "imports", ["referential_id"], name: "index_imports_on_referential_id", using: :btree diff --git a/spec/controllers/api/v1/netex_import_controller_spec.rb b/spec/controllers/api/v1/netex_import_controller_spec.rb new file mode 100644 index 000000000..b6b90f7d1 --- /dev/null +++ b/spec/controllers/api/v1/netex_import_controller_spec.rb @@ -0,0 +1,12 @@ +RSpec.describe Api::V1::NetexImportController, type: :controller do +  let( :netex_import ){ build_stubbed :netex_import } + +  it_behaves_like "api key protected controller" do +    let(:data){ netex_import } +  end + +  describe "POST #create" do + +  end + +end diff --git a/spec/models/import_spec.rb b/spec/models/import_spec.rb index a2855d086..34bfb0b23 100644 --- a/spec/models/import_spec.rb +++ b/spec/models/import_spec.rb @@ -3,6 +3,7 @@ require 'rails_helper'  RSpec.describe Import, :type => :model do    it { should belong_to(:referential) }    it { should belong_to(:workbench) } +  it { should belong_to(:parent).class_name(described_class.to_s) }    it { should enumerize(:status).in(:new, :pending, :successful, :failed, :canceled, :running, :aborted ) }  | 
