From 90edc648f877c3cdb0a9654469ec86cf6843bc5b Mon Sep 17 00:00:00 2001 From: Naman Gupta <01namangupta@gmail.com> Date: Thu, 9 Nov 2017 01:40:56 +0530 Subject: [PATCH 1/3] programs.speakers is fixed --- app/models/program.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/program.rb b/app/models/program.rb index 612d8154..03e5725a 100644 --- a/app/models/program.rb +++ b/app/models/program.rb @@ -42,7 +42,8 @@ class Program < ActiveRecord::Base has_many :event_schedules, 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 joins(:events).where(events: { state: :confirmed }) end From ada0f814a7d9bd5f05b58c35b3bae9fcc7c397ff Mon Sep 17 00:00:00 2001 From: Naman Gupta <01namangupta@gmail.com> Date: Thu, 9 Nov 2017 02:00:49 +0530 Subject: [PATCH 2/3] linting error is fixed --- app/models/program.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/program.rb b/app/models/program.rb index 03e5725a..addda157 100644 --- a/app/models/program.rb +++ b/app/models/program.rb @@ -42,7 +42,7 @@ class Program < ActiveRecord::Base has_many :event_schedules, through: :events has_many :event_users, through: :events - has_many :program_events_speakers, -> {where(event_role: 'speaker')},through: :events, source: :event_users + 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 joins(:events).where(events: { state: :confirmed }) From d0dbb7d29e4cd0d1165a7f72210c5f283b08f45c Mon Sep 17 00:00:00 2001 From: Naman Gupta <01namangupta@gmail.com> Date: Thu, 9 Nov 2017 02:39:41 +0530 Subject: [PATCH 3/3] tests are fixed --- spec/models/program_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/models/program_spec.rb b/spec/models/program_spec.rb index 1c8eabd9..62e576f4 100644 --- a/spec/models/program_spec.rb +++ b/spec/models/program_spec.rb @@ -15,8 +15,8 @@ describe Program do 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_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(:tracks) } it { is_expected.to accept_nested_attributes_for(:difficulty_levels) }