Remove the PropositionAccepting abstraction

This commit is contained in:
Petko Bordjukov 2015-08-14 23:58:51 +03:00
parent 4e3ff3eacc
commit d279ab6f0d
6 changed files with 5 additions and 17 deletions

View File

@ -1,7 +0,0 @@
module PropositionAccepting
extend ActiveSupport::Concern
included do
has_many :propositions, as: :proposition_accepting
end
end

View File

@ -1,6 +1,5 @@
class Proposition < ActiveRecord::Base class Proposition < ActiveRecord::Base
belongs_to :proposer, class_name: 'User' belongs_to :proposer, class_name: 'User'
belongs_to :proposition_accepting, polymorphic: true
belongs_to :proposable, polymorphic: true belongs_to :proposable, polymorphic: true
enum status: [:undecided, :approved, :rejected, :backup] enum status: [:undecided, :approved, :rejected, :backup]

View File

@ -1,6 +1,4 @@
class Track < ActiveRecord::Base class Track < ActiveRecord::Base
include PropositionAccepting
belongs_to :conference belongs_to :conference
has_many :events has_many :events

View File

@ -0,0 +1,5 @@
class RemovePropositionAcceptingFieldsFromPropositions < ActiveRecord::Migration
def change
remove_reference :propositions, :proposition_accepting, index: true, foreign_key: true, polymorphic: true
end
end

View File

@ -1,7 +1,6 @@
FactoryGirl.define do FactoryGirl.define do
factory :proposition do factory :proposition do
association :proposer, factory: :user association :proposer, factory: :user
association :proposition_accepting, factory: :track
association :proposable, factory: :event association :proposable, factory: :event
end end
end end

View File

@ -6,16 +6,10 @@ RSpec.describe Proposition, type: :model do
expect(create(:proposition, proposer: user).proposer).to eq user expect(create(:proposition, proposer: user).proposer).to eq user
end 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 it 'belongs to a proposable' do
event = create :event event = create :event
expect(create(:proposition, proposable: event).proposable).to eq event expect(create(:proposition, proposable: event).proposable).to eq event
end end
it 'is invalid without an existing proposition_accepting'
it 'is invalid without an existing proposable' it 'is invalid without an existing proposable'
end end