aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/models/stop_area_referential_sync.rb6
-rw-r--r--app/models/stop_area_sync_operation.rb3
-rw-r--r--app/views/stop_area_referentials/show.html.slim12
-rw-r--r--db/migrate/20160929131958_drop_stop_area_sync_operations.rb (renamed from db/migrate/20160909093322_create_stop_area_sync_operations.rb)9
-rw-r--r--db/schema.rb12
-rw-r--r--spec/factories/stop_area_sync_operations.rb8
-rw-r--r--spec/models/stop_area_referential_sync_spec.rb15
-rw-r--r--spec/models/stop_area_sync_operation_spec.rb9
8 files changed, 13 insertions, 61 deletions
diff --git a/app/models/stop_area_referential_sync.rb b/app/models/stop_area_referential_sync.rb
index 3a9b2d03b..54a3fce46 100644
--- a/app/models/stop_area_referential_sync.rb
+++ b/app/models/stop_area_referential_sync.rb
@@ -1,9 +1,3 @@
class StopAreaReferentialSync < ActiveRecord::Base
belongs_to :stop_area_referential
- has_many :stop_area_sync_operations, dependent: :destroy
-
- def record_status status, message
- stop_area_sync_operations << StopAreaSyncOperation.new(status: status, message: message)
- stop_area_sync_operations.first.destroy while stop_area_sync_operations.count > 30
- end
end
diff --git a/app/models/stop_area_sync_operation.rb b/app/models/stop_area_sync_operation.rb
deleted file mode 100644
index ca0fde4db..000000000
--- a/app/models/stop_area_sync_operation.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-class StopAreaSyncOperation < ActiveRecord::Base
- belongs_to :stop_area_referential_sync
-end
diff --git a/app/views/stop_area_referentials/show.html.slim b/app/views/stop_area_referentials/show.html.slim
index 32fe950dc..761393013 100644
--- a/app/views/stop_area_referentials/show.html.slim
+++ b/app/views/stop_area_referentials/show.html.slim
@@ -9,12 +9,12 @@
span.badge = @stop_area_referential.stop_areas.size
= link_to Referential.human_attribute_name("stop_areas"), stop_area_referential_stop_areas_path(@stop_area_referential)
-- unless @stop_area_referential.stop_area_referential_sync.stop_area_sync_operations.empty?
- h3 Historique des synchronisations
+/ - unless @stop_area_referential.stop_area_referential_sync.stop_area_sync_operations.empty?
+/ h3 Historique des synchronisations
- ul.list-group width="75%"
- - @stop_area_referential.stop_area_referential_sync.stop_area_sync_operations.each do |sync|
- li = "#{sync.created_at.to_formatted_s(:short)} - #{sync.message}"
+/ ul.list-group width="75%"
+/ - @stop_area_referential.stop_area_referential_sync.stop_area_sync_operations.each do |sync|
+/ li = "#{sync.created_at.to_formatted_s(:short)} - #{sync.message}"
- content_for :sidebar do
- ul.actions \ No newline at end of file
+ ul.actions
diff --git a/db/migrate/20160909093322_create_stop_area_sync_operations.rb b/db/migrate/20160929131958_drop_stop_area_sync_operations.rb
index fef4f5e1f..859d20b28 100644
--- a/db/migrate/20160909093322_create_stop_area_sync_operations.rb
+++ b/db/migrate/20160929131958_drop_stop_area_sync_operations.rb
@@ -1,10 +1,13 @@
-class CreateStopAreaSyncOperations < ActiveRecord::Migration
- def change
+class DropStopAreaSyncOperations < ActiveRecord::Migration
+ def up
+ drop_table :stop_area_sync_operations if table_exists?(:stop_area_sync_operations)
+ end
+
+ def down
create_table :stop_area_sync_operations do |t|
t.string :status
t.references :stop_area_referential_sync
t.string :message
-
t.timestamps
end
add_index :stop_area_sync_operations, :stop_area_referential_sync_id, name: 'stop_area_referential_sync_id'
diff --git a/db/schema.rb b/db/schema.rb
index e3e669450..83a8beb9e 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: 20160929131440) do
+ActiveRecord::Schema.define(version: 20160929131958) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -471,16 +471,6 @@ ActiveRecord::Schema.define(version: 20160929131440) do
t.datetime "updated_at"
end
- create_table "stop_area_sync_operations", force: true do |t|
- t.string "status"
- t.integer "stop_area_referential_sync_id"
- t.string "message"
- t.datetime "created_at"
- t.datetime "updated_at"
- end
-
- add_index "stop_area_sync_operations", ["stop_area_referential_sync_id"], :name => "stop_area_referential_sync_id"
-
create_table "stop_areas", force: true do |t|
t.integer "parent_id", limit: 8
t.string "objectid", null: false
diff --git a/spec/factories/stop_area_sync_operations.rb b/spec/factories/stop_area_sync_operations.rb
deleted file mode 100644
index c62f7f9c6..000000000
--- a/spec/factories/stop_area_sync_operations.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-FactoryGirl.define do
- factory :stop_area_sync_operation do
- status "MyString"
-stop_area_referential_sync nil
-message "MyString"
- end
-
-end
diff --git a/spec/models/stop_area_referential_sync_spec.rb b/spec/models/stop_area_referential_sync_spec.rb
index bc5f92b2d..5f1e1e124 100644
--- a/spec/models/stop_area_referential_sync_spec.rb
+++ b/spec/models/stop_area_referential_sync_spec.rb
@@ -6,19 +6,4 @@ RSpec.describe StopAreaReferentialSync, :type => :model do
end
it { is_expected.to belong_to(:stop_area_referential) }
- it { is_expected.to have_many(:stop_area_sync_operations) }
-
- describe '.record_status'
- let!(:stop_area_ref_sync) { create(:stop_area_referential_sync) }
- let!(:stop_area_ref_sync_with_records) { create(:stop_area_referential_sync_with_record, stop_area_sync_operations_count: 30) }
-
- it 'should add a new record' do
- stop_area_ref_sync.record_status :ok, "message"
- expect(stop_area_ref_sync.stop_area_sync_operations.count).to eq(1)
- end
-
- it 'should not have more than 30 records' do
- stop_area_ref_sync_with_records.record_status :ok, "message"
- expect(stop_area_ref_sync_with_records.stop_area_sync_operations.count).to eq(30)
- end
end
diff --git a/spec/models/stop_area_sync_operation_spec.rb b/spec/models/stop_area_sync_operation_spec.rb
deleted file mode 100644
index a98108d71..000000000
--- a/spec/models/stop_area_sync_operation_spec.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-require 'rails_helper'
-
-RSpec.describe StopAreaSyncOperation, :type => :model do
- it 'should have a valid factory' do
- expect(FactoryGirl.build(:stop_area_sync_operation)).to be_valid
- end
-
- it { is_expected.to belong_to(:stop_area_referential_sync) }
-end