Skip to content

Commit

Permalink
Merge 1ad48b9 into 9b77ff4
Browse files Browse the repository at this point in the history
  • Loading branch information
ameyagv committed Aug 30, 2023
2 parents 9b77ff4 + 1ad48b9 commit 9652782
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
18 changes: 9 additions & 9 deletions app/mailers/mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

class Mailer < ActionMailer::Base
if Rails.env.development? || Rails.env.test?
default from: 'expertiza.debugging@gmail.com'
default from: 'expertiza.mailer@gmail.com'
else
default from: 'expertiza-support@lists.ncsu.edu'
default from: 'expertiza.mailer@gmail.com'
end

def email_author_reviewers(subject, body, email)
Rails.env.development? || Rails.env.test? ? @email = 'expertiza.debugging@gmail.com' : @email = email
Rails.env.development? || Rails.env.test? ? @email = 'expertiza.mailer@gmail.com' : @email = email
mail(to: @email,
body: body,
content_type: 'text/html',
Expand All @@ -26,7 +26,7 @@ def generic_message(defn)
@conference_variable = defn[:body][:conference_variable]

if Rails.env.development? || Rails.env.test?
defn[:to] = 'expertiza.debugging@gmail.com'
defn[:to] = 'expertiza.mailer@gmail.com'
end
mail(subject: defn[:subject],
to: defn[:to],
Expand All @@ -42,7 +42,7 @@ def request_user_message(defn)
@assignment = defn[:body][:assignment]

if Rails.env.development? || Rails.env.test?
defn[:to] = 'expertiza.debugging@gmail.com'
defn[:to] = 'expertiza.mailer@gmail.com'
end
mail(subject: defn[:subject],
to: defn[:to],
Expand All @@ -58,7 +58,7 @@ def sync_message(defn)
@partial_name = defn[:body][:partial_name]

if Rails.env.development? || Rails.env.test?
defn[:to] = 'expertiza.debugging@gmail.com'
defn[:to] = 'expertiza.mailer@gmail.com'
end
mail(subject: defn[:subject],
to: defn[:to])
Expand All @@ -78,7 +78,7 @@ def suggested_topic_approved_message(defn)
@proposer = defn[:body][:proposer]

if Rails.env.development? || Rails.env.test?
defn[:to] = 'expertiza.debugging@gmail.com'
defn[:to] = 'expertiza.mailer@gmail.com'
end
mail(subject: defn[:subject],
to: defn[:to],
Expand All @@ -98,7 +98,7 @@ def notify_grade_conflict_message(defn)
@assignment_edit_url = @body[:assignment_edit_url]

if Rails.env.development? || Rails.env.test?
defn[:to] = 'expertiza.debugging@gmail.com'
defn[:to] = 'expertiza.mailer@gmail.com'
end
mail(subject: defn[:subject],
to: defn[:to])
Expand All @@ -111,7 +111,7 @@ def notify_review_rubric_change(defn)
@name = defn[:body][:name]
@assignment_name = defn[:body][:assignment_name]
if Rails.env.development? || Rails.env.test?
defn[:to] = 'expertiza.debugging@gmail.com'
defn[:to] = 'expertiza.mailer@gmail.com'
end
mail(subject: defn[:subject],
to: defn[:to])
Expand Down
13 changes: 0 additions & 13 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,6 @@
config.action_controller.perform_caching = false
# config.active_record.whitelist_attributes = false # need protected_attributes gem

config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
address: 'smtp.gmail.com',
port: 587,
domain: 'gmail.com',
user_name: 'expertiza.mailer@gmail.com',
password: 'xdgmnehqevkevkqy',
authentication: 'plain',
enable_starttls_auto: true
}

# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
# Print development logs
Expand Down
13 changes: 13 additions & 0 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@
config.consider_all_requests_local = false
config.action_controller.perform_caching = true

config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
address: 'smtp.gmail.com',
port: 587,
domain: 'gmail.com',
user_name: 'expertiza.mailer@gmail.com',
password: 'xdgmnehqevkevkqy',
authentication: 'plain',
enable_starttls_auto: true
}

# Enable Rack::Cache to put a simple HTTP cache in front of your application
# Add `rack-cache` to your Gemfile before enabling this.
# For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
Expand Down
4 changes: 2 additions & 2 deletions spec/models/mailer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
}
).deliver_now

expect(email.from[0]).to eq('expertiza.debugging@gmail.com')
expect(email.to[0]).to eq('expertiza.debugging@gmail.com')
expect(email.from[0]).to eq('expertiza.mailer@gmail.com')
expect(email.to[0]).to eq('expertiza.mailer@gmail.com')
expect(email.subject).to eq('Test')
end
end

0 comments on commit 9652782

Please sign in to comment.