-
Notifications
You must be signed in to change notification settings - Fork 0
Implement postmark #28
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
Open
Azfletch
wants to merge
15
commits into
develop
Choose a base branch
from
feature/implement_postmark
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
59e43ca
added postmark gem
Azfletch dd79dc5
added postmark config to application.rb
Azfletch 636e066
updated notification mailer and spec
Azfletch 3be7eca
updated smtp settings and .env
Azfletch 2fa3c4e
reimplemented config.action_mailer.asset_host as specs failing without
Azfletch c18ab4f
added MAILER_HOST to .env
Azfletch f053763
fixed smtp settings
Azfletch cb5eb7a
added .env to .gitignore, removed postmark gem, copied smtp settings …
Azfletch 102bc54
[WIP] adding unit spec for sending out email when article is created
Azfletch ad2b8a0
fixed article_spec.rb
Azfletch 8ede1f9
updated articles_spec.rb
Azfletch d054598
attempt to fix codeship
Azfletch 9243ec9
delete .env
Azfletch 4d10fb1
removed unwanted comment from application.rb, deleted .env
Azfletch fae9b9a
Merge branch 'feature/implement_postmark' of github.com:Azfletch/blog…
Azfletch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,4 +33,7 @@ | |
procoders-unit1.md | ||
|
||
# Ignore Ruby Style Guide | ||
STYLEGUIDE.md | ||
STYLEGUIDE.md | ||
|
||
# Ignore .env | ||
.env |
Binary file not shown.
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
class NotificationMailer < ApplicationMailer | ||
default from: "notifications@example.com" | ||
|
||
def notification_email(article) | ||
@article = article | ||
notifications = Notification.all | ||
notifications.each do |notification| | ||
mail(to: notification.email, subject: "New blog post!!!") | ||
|
||
Notification.in_batches.each_record do |notification| | ||
mail( | ||
to: notification.email, | ||
subject: "Arrons blog has been updated!", | ||
from: "arron.fletcher@shiftcommerce.com", | ||
) | ||
end | ||
end | ||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,18 @@ class Application < Rails::Application | |
# Application configuration can go into files in config/initializers | ||
# -- all .rb files in that directory are automatically loaded after loading | ||
# the framework and any gems in your application. | ||
config.action_mailer.default_url_options = { host: "localhost:4000" } | ||
config.action_mailer.asset_host = "http://localhost:4000" | ||
config.action_mailer.default_url_options = { host: ENV.fetch("MAILER_HOST") } | ||
Azfletch marked this conversation as resolved.
Show resolved
Hide resolved
|
||
config.action_mailer.asset_host = ENV.fetch("MAILER_HOST") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would remove all this stuff from |
||
config.action_mailer.delivery_method = :smtp | ||
|
||
# implemented settings based on https://postmarkapp.com/developer/user-guide/sending-email/sending-with-smtp | ||
config.action_mailer.smtp_settings = { | ||
address: "smtp.postmarkapp.com", | ||
port: 25, | ||
user_name: ENV.fetch("SMTP_NAME"), | ||
password: ENV.fetch("SMTP_PASSWORD"), | ||
authentication: "plain", | ||
enable_starttls_auto: true | ||
} | ||
end | ||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,36 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe Article, :type => :model do | ||
it "creates new article" do | ||
expect(Article.new(title: "Testing", text: "Test" )).to be_valid | ||
RSpec.describe Article, type: :model do | ||
describe "creating a new valid article" do | ||
let(:article) { build(:article) } | ||
|
||
it "should be valid" do | ||
expect(article).to be_valid | ||
end | ||
end | ||
end | ||
|
||
RSpec.describe Article, :type => :model do | ||
it "wont create article because of article params" do | ||
expect(Article.new(title: "Test", text: "Test" )).not_to be_valid | ||
describe "creating an article" do | ||
it "sends out an email when an article is created" do | ||
create(:notification) | ||
expect{create(:article)}.to change{ActionMailer::Base.deliveries.count}.by(1) | ||
end | ||
end | ||
end | ||
|
||
RSpec.describe Article, :type => :model do | ||
it "edit article" do | ||
@article = Article.new(title: "Testing", text:"test123") | ||
@article.update(title: "Testing123", text: "123121231") | ||
expect(@article).to have_attributes(title: "Testing123") | ||
describe "creating an invalid article" do | ||
let(:article) { build(:article, title: "Test") } | ||
|
||
it "should be invalid" do | ||
expect(article).not_to be_valid | ||
end | ||
end | ||
|
||
describe "editing an article with valid data" do | ||
let!(:article) { create(:article) } | ||
|
||
it "should update" do | ||
article.update(title: "Testing123", text: "123121231") | ||
|
||
expect(article).to have_attributes(title: "Testing123") | ||
end | ||
end | ||
end | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would change this to a personal email address