Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warnings: Use alias_method > alias_attribute for non-attributes #45

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/models/caffeinate/campaign_subscription.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class CampaignSubscription < ApplicationRecord
has_one :previous_mailing, -> { sent.order(sent_at: :desc) }, class_name: '::Caffeinate::Mailing', foreign_key: :caffeinate_campaign_subscription_id

belongs_to :caffeinate_campaign, class_name: 'Caffeinate::Campaign', foreign_key: :caffeinate_campaign_id
alias_attribute :campaign, :caffeinate_campaign
alias_method :campaign, :caffeinate_campaign

belongs_to :subscriber, polymorphic: true
belongs_to :user, polymorphic: true, optional: true
Expand Down
4 changes: 2 additions & 2 deletions app/models/caffeinate/mailing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ class Mailing < ApplicationRecord
self.table_name = 'caffeinate_mailings'

belongs_to :caffeinate_campaign_subscription, class_name: 'Caffeinate::CampaignSubscription'
alias_attribute :subscription, :caffeinate_campaign_subscription
has_one :caffeinate_campaign, through: :caffeinate_campaign_subscription
alias_attribute :campaign, :caffeinate_campaign
alias_method :subscription, :caffeinate_campaign_subscription
alias_method :campaign, :caffeinate_campaign

scope :upcoming, -> { joins(:caffeinate_campaign_subscription).where(caffeinate_campaign_subscription: ::Caffeinate::CampaignSubscription.active).unsent.unskipped.where('send_at < ?', ::Caffeinate.config.time_now).order('send_at asc') }
scope :unsent, -> { unskipped.where(sent_at: nil) }
Expand Down
6 changes: 3 additions & 3 deletions spec/caffeinate/schedule_evaluator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
campaign
end

let(:sub) { create(:caffeinate_campaign_subscription, campaign: campaign) }
let(:sub) { create(:caffeinate_campaign_subscription, caffeinate_campaign: campaign) }

it 'succeeds' do
expect(sub.caffeinate_mailings.first.send_at.to_i).to eq 3.days.from_now.to_i
Expand All @@ -31,7 +31,7 @@
campaign
end

let(:sub) { create(:caffeinate_campaign_subscription, campaign: campaign) }
let(:sub) { create(:caffeinate_campaign_subscription, caffeinate_campaign: campaign) }

it 'succeeds' do
expect(sub.mailings.first.send_at.to_i).to eq 2.days.from_now.to_i
Expand All @@ -58,7 +58,7 @@ def five_pm(evaluator, mailing)
campaign
end

let(:sub) { create(:caffeinate_campaign_subscription, campaign: campaign) }
let(:sub) { create(:caffeinate_campaign_subscription, caffeinate_campaign: campaign) }

it 'succeeds' do
expect(sub.mailings.first.send_at.to_i).to eq(3.days.from_now.change(hour: 17, min: 2, sec: 2).to_i)
Expand Down