Merge pull request #1787 from namangupta01/program_speakers
programs.speakers now gives all speakers
This commit is contained in:
commit
81831d7df9
2 changed files with 4 additions and 3 deletions
|
|
@ -42,7 +42,8 @@ class Program < ActiveRecord::Base
|
||||||
has_many :event_schedules, through: :events
|
has_many :event_schedules, through: :events
|
||||||
|
|
||||||
has_many :event_users, through: :events
|
has_many :event_users, through: :events
|
||||||
has_many :speakers, -> { distinct }, through: :event_users, source: :user do
|
has_many :program_events_speakers, -> {where(event_role: 'speaker')}, through: :events, source: :event_users
|
||||||
|
has_many :speakers, -> { distinct }, through: :program_events_speakers, source: :user do
|
||||||
def confirmed
|
def confirmed
|
||||||
joins(:events).where(events: { state: :confirmed })
|
joins(:events).where(events: { state: :confirmed })
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,8 @@ describe Program do
|
||||||
it { is_expected.to have_many(:events).dependent(:destroy) }
|
it { is_expected.to have_many(:events).dependent(:destroy) }
|
||||||
it { is_expected.to have_many(:event_schedules).through(:events) }
|
it { is_expected.to have_many(:event_schedules).through(:events) }
|
||||||
it { is_expected.to have_many(:event_users).through(:events) }
|
it { is_expected.to have_many(:event_users).through(:events) }
|
||||||
it { is_expected.to have_many(:speakers).through(:event_users).source(:user) }
|
it { is_expected.to have_many(:program_events_speakers).through(:events).source(:event_users) }
|
||||||
|
it { is_expected.to have_many(:speakers).through(:program_events_speakers).source(:user) }
|
||||||
it { is_expected.to accept_nested_attributes_for(:event_types) }
|
it { is_expected.to accept_nested_attributes_for(:event_types) }
|
||||||
it { is_expected.to accept_nested_attributes_for(:tracks) }
|
it { is_expected.to accept_nested_attributes_for(:tracks) }
|
||||||
it { is_expected.to accept_nested_attributes_for(:difficulty_levels) }
|
it { is_expected.to accept_nested_attributes_for(:difficulty_levels) }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue