oprah 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +17 -0
- data/lib/oprah/controller_helpers.rb +2 -2
- data/lib/oprah/railtie.rb +6 -0
- data/lib/oprah/version.rb +1 -1
- data/test/dummy/app/mailers/application_mailer.rb +2 -0
- data/test/dummy/app/mailers/post_mailer.rb +8 -0
- data/test/dummy/app/views/post_mailer/notification.html.erb +3 -0
- data/test/mailers/post_mailer_test.rb +13 -0
- data/test/oprah/railtie_test.rb +1 -0
- metadata +9 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26a96344756574d8119d0171b91825dc5d2cd53f
|
4
|
+
data.tar.gz: 9ab78bcdfb45de66e8421ab5eba4f6f97af438b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3becf1ce157b8ada831fe4c016b2135a266fb09ed1d9a1beebf23c06edd571c19ecfd6fe118b54a79029656213c79b281606c7037e69aaa8eaac72d874fe316
|
7
|
+
data.tar.gz: 159bd51082ddfb1d43ab193d692d1aecb2db132c9101929d613aebaa90c4d84d82e8a3bb46c6aa9ba5bd5caae9a4a7a00dbfde8478bf842c76bcd7086e08358c
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -13,6 +13,7 @@ Opinionated presenters for Rails 5 - without the cruft.
|
|
13
13
|
* [Installation](#installation)
|
14
14
|
* [Getting started](#getting-started)
|
15
15
|
+ [ActionController integration](#actioncontroller-integration)
|
16
|
+
+ [ActionMailer integration](#actionmailer-integration)
|
16
17
|
* [Collections](#collections)
|
17
18
|
* [Associations](#associations)
|
18
19
|
* [Composition](#composition)
|
@@ -122,6 +123,22 @@ This will also take care of passing the correct view context to the presenter,
|
|
122
123
|
which you can access with the `#view_context` (or shorter, `#h`) instance
|
123
124
|
method.
|
124
125
|
|
126
|
+
### ActionMailer integration
|
127
|
+
|
128
|
+
Oprah will make the same helpers you have in ActionController available to
|
129
|
+
ActionMailer:
|
130
|
+
|
131
|
+
``` ruby
|
132
|
+
class UserMailer < ApplicationMailer
|
133
|
+
default from: 'notifications@example.com'
|
134
|
+
|
135
|
+
def welcome_email(user)
|
136
|
+
@user = present user
|
137
|
+
mail(to: @user.email, subject: 'Welcome to My Awesome Site')
|
138
|
+
end
|
139
|
+
end
|
140
|
+
```
|
141
|
+
|
125
142
|
## Collections
|
126
143
|
|
127
144
|
Oprah has basic support for collections with `.present_many`. It will simply
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Oprah
|
2
|
-
# Helpers that will be mixed into `ActionController::Base`
|
3
|
-
# the {Oprah::Railtie}.
|
2
|
+
# Helpers that will be mixed into `ActionController::Base` and
|
3
|
+
# `ActionMailer::Base` by the {Oprah::Railtie}.
|
4
4
|
module ControllerHelpers
|
5
5
|
# A proxy class to delegate method calls to view contexts in presenters
|
6
6
|
# to the most recently created view context by
|
data/lib/oprah/railtie.rb
CHANGED
@@ -17,5 +17,11 @@ module Oprah
|
|
17
17
|
ActionController::Base.include(Oprah::ControllerHelpers)
|
18
18
|
end
|
19
19
|
end
|
20
|
+
|
21
|
+
initializer "oprah.configure_action_mailer_helpers" do
|
22
|
+
ActiveSupport.on_load :action_mailer do
|
23
|
+
ActionMailer::Base.include(Oprah::ControllerHelpers)
|
24
|
+
end
|
25
|
+
end
|
20
26
|
end
|
21
27
|
end
|
data/lib/oprah/version.rb
CHANGED
@@ -0,0 +1,13 @@
|
|
1
|
+
class PostMailerTest < ActionMailer::TestCase
|
2
|
+
def test_invite
|
3
|
+
post = Post.new
|
4
|
+
email = PostMailer.notification(Post.new)
|
5
|
+
|
6
|
+
assert_emails 1 do
|
7
|
+
email.deliver_now
|
8
|
+
end
|
9
|
+
|
10
|
+
expected = "<p>\n Hello!\n</p>"
|
11
|
+
assert_equal expected, email.body.to_s
|
12
|
+
end
|
13
|
+
end
|
data/test/oprah/railtie_test.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oprah
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tobias Svensson
|
@@ -165,14 +165,18 @@ files:
|
|
165
165
|
- test/controllers/posts_controller_test.rb
|
166
166
|
- test/dummy/app/controllers/application_controller.rb
|
167
167
|
- test/dummy/app/controllers/posts_controller.rb
|
168
|
+
- test/dummy/app/mailers/application_mailer.rb
|
169
|
+
- test/dummy/app/mailers/post_mailer.rb
|
168
170
|
- test/dummy/app/models/post.rb
|
169
171
|
- test/dummy/app/presenters/post_presenter.rb
|
172
|
+
- test/dummy/app/views/post_mailer/notification.html.erb
|
170
173
|
- test/dummy/app/views/posts/show.html.erb
|
171
174
|
- test/dummy/config/database.yml
|
172
175
|
- test/dummy/config/routes.rb
|
173
176
|
- test/dummy/init.rb
|
174
177
|
- test/dummy/tmp/.gitkeep
|
175
178
|
- test/helper.rb
|
179
|
+
- test/mailers/post_mailer_test.rb
|
176
180
|
- test/oprah/controller_helpers_test.rb
|
177
181
|
- test/oprah/oprah_test.rb
|
178
182
|
- test/oprah/presenter_test.rb
|
@@ -205,14 +209,18 @@ test_files:
|
|
205
209
|
- test/controllers/posts_controller_test.rb
|
206
210
|
- test/dummy/app/controllers/application_controller.rb
|
207
211
|
- test/dummy/app/controllers/posts_controller.rb
|
212
|
+
- test/dummy/app/mailers/application_mailer.rb
|
213
|
+
- test/dummy/app/mailers/post_mailer.rb
|
208
214
|
- test/dummy/app/models/post.rb
|
209
215
|
- test/dummy/app/presenters/post_presenter.rb
|
216
|
+
- test/dummy/app/views/post_mailer/notification.html.erb
|
210
217
|
- test/dummy/app/views/posts/show.html.erb
|
211
218
|
- test/dummy/config/database.yml
|
212
219
|
- test/dummy/config/routes.rb
|
213
220
|
- test/dummy/init.rb
|
214
221
|
- test/dummy/tmp/.gitkeep
|
215
222
|
- test/helper.rb
|
223
|
+
- test/mailers/post_mailer_test.rb
|
216
224
|
- test/oprah/controller_helpers_test.rb
|
217
225
|
- test/oprah/oprah_test.rb
|
218
226
|
- test/oprah/presenter_test.rb
|