From d279ab6f0d5573b54ffcab7c39fc869ac1bba73c Mon Sep 17 00:00:00 2001 From: Petko Bordjukov Date: Fri, 14 Aug 2015 23:58:51 +0300 Subject: [PATCH] Remove the PropositionAccepting abstraction --- app/models/concerns/proposition_accepting.rb | 7 ------- app/models/proposition.rb | 1 - app/models/track.rb | 2 -- ...emove_proposition_accepting_fields_from_propositions.rb | 5 +++++ spec/factories/propositions.rb | 1 - spec/models/proposition_spec.rb | 6 ------ 6 files changed, 5 insertions(+), 17 deletions(-) delete mode 100644 app/models/concerns/proposition_accepting.rb create mode 100644 db/migrate/20150814204500_remove_proposition_accepting_fields_from_propositions.rb diff --git a/app/models/concerns/proposition_accepting.rb b/app/models/concerns/proposition_accepting.rb deleted file mode 100644 index 91323e8..0000000 --- a/app/models/concerns/proposition_accepting.rb +++ /dev/null @@ -1,7 +0,0 @@ -module PropositionAccepting - extend ActiveSupport::Concern - - included do - has_many :propositions, as: :proposition_accepting - end -end diff --git a/app/models/proposition.rb b/app/models/proposition.rb index 8c16d93..dd62544 100644 --- a/app/models/proposition.rb +++ b/app/models/proposition.rb @@ -1,6 +1,5 @@ class Proposition < ActiveRecord::Base belongs_to :proposer, class_name: 'User' - belongs_to :proposition_accepting, polymorphic: true belongs_to :proposable, polymorphic: true enum status: [:undecided, :approved, :rejected, :backup] diff --git a/app/models/track.rb b/app/models/track.rb index a8bf6f1..f33bb85 100644 --- a/app/models/track.rb +++ b/app/models/track.rb @@ -1,6 +1,4 @@ class Track < ActiveRecord::Base - include PropositionAccepting - belongs_to :conference has_many :events diff --git a/db/migrate/20150814204500_remove_proposition_accepting_fields_from_propositions.rb b/db/migrate/20150814204500_remove_proposition_accepting_fields_from_propositions.rb new file mode 100644 index 0000000..05a508d --- /dev/null +++ b/db/migrate/20150814204500_remove_proposition_accepting_fields_from_propositions.rb @@ -0,0 +1,5 @@ +class RemovePropositionAcceptingFieldsFromPropositions < ActiveRecord::Migration + def change + remove_reference :propositions, :proposition_accepting, index: true, foreign_key: true, polymorphic: true + end +end diff --git a/spec/factories/propositions.rb b/spec/factories/propositions.rb index 72287fc..c2b69aa 100644 --- a/spec/factories/propositions.rb +++ b/spec/factories/propositions.rb @@ -1,7 +1,6 @@ FactoryGirl.define do factory :proposition do association :proposer, factory: :user - association :proposition_accepting, factory: :track association :proposable, factory: :event end end diff --git a/spec/models/proposition_spec.rb b/spec/models/proposition_spec.rb index 0d512f3..80e5731 100644 --- a/spec/models/proposition_spec.rb +++ b/spec/models/proposition_spec.rb @@ -6,16 +6,10 @@ RSpec.describe Proposition, type: :model do expect(create(:proposition, proposer: user).proposer).to eq user end - it 'belongs to a proposition_accepting' do - track = create :track - expect(create(:proposition, proposition_accepting: track).proposition_accepting).to eq track - end - it 'belongs to a proposable' do event = create :event expect(create(:proposition, proposable: event).proposable).to eq event end - it 'is invalid without an existing proposition_accepting' it 'is invalid without an existing proposable' end