decent_exposure 3.0.1 → 3.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2c22278ff98a7439d7b4a8b1f6cde9f9a1dc9a9a
4
- data.tar.gz: 7a781674c590dbf7d1d200895babf9633b49c733
3
+ metadata.gz: 4c9a6c2a86d5405d34833d333e2786a9a020880a
4
+ data.tar.gz: 8f0b11451440f2cf4fda457e664fa428b632e4a9
5
5
  SHA512:
6
- metadata.gz: 8aa99377c24ced53c356cbb1fbf7c37b261085011de8eb0c104c2fdbfef54f3befed765f5aabf3bffaee6e900b948e640b84891c9b51b22378a98b9a3ffcdddc
7
- data.tar.gz: 97a5d39339fd28c51c003e1aa216c1174bcfbaa85d80f25c0ce87db98ecaf82dac2521ae3a89c6b271d470d5dcb460d795acc5f5c33b5194756a10ac1d4341a8
6
+ metadata.gz: 7d3ab21ece1e48a834ccca316a055918c71c93540a7da92ead194b418bc13892be81fa0aa989d8c923b729148f03def10380e59a7c1280638cf641055135269b
7
+ data.tar.gz: e8fe7a63933c623650566b27b937a772faafde5b2933955c6789f2fc06f1af3b4b4ebf7467003452ee3a5737942b90af270e5baf59a2100a79ed8578f460bad9
@@ -3,6 +3,9 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project adheres to [Semantic Versioning](http://semver.org/).
5
5
 
6
+ ## 3.0.2
7
+
8
+ * Fix mailers when arguments are not a hash.
6
9
 
7
10
  ## 3.0.1
8
11
 
@@ -5,7 +5,8 @@ module DecentExposure
5
5
  attr_accessor :params
6
6
 
7
7
  def process_action(*args)
8
- self.params = args.second.stringify_keys() if args.second
8
+ arg = args.second
9
+ self.params = arg.stringify_keys() if arg && Hash === arg
9
10
  super
10
11
  end
11
12
  end
@@ -1,3 +1,3 @@
1
1
  module DecentExposure
2
- VERSION = "3.0.1"
2
+ VERSION = "3.0.2"
3
3
  end
@@ -6,19 +6,29 @@ require "action_mailer"
6
6
  class BirdsMailer < ActionMailer::Base
7
7
  end
8
8
 
9
+ class BirdsMailer
10
+ expose(:birds, -> { Bird.all })
11
+ expose(:bird)
12
+
13
+ def hello_birds
14
+ mail { |format| format.text { render plain: "Hello #{birds}" } }
15
+ end
16
+
17
+ def hello_bird(id:)
18
+ mail { |format| format.text { render plain: "Hello #{bird}" } }
19
+ end
20
+
21
+ def hello_bird_by_id(id)
22
+ bird = Bird.find(id)
23
+ mail { |format| format.text { render plain: "Hello #{bird}" } }
24
+ end
25
+ end
26
+
9
27
  RSpec.describe BirdsMailer, type: :mailer do
10
28
  let(:bird){ double :bird }
11
29
  let(:birds) { double :birds }
12
30
 
13
31
  context "when birds relation is exposed" do
14
- class BirdsMailer
15
- expose(:birds, -> { Bird.all })
16
-
17
- def hello_birds
18
- mail { |format| format.text { render plain: "Hello #{birds}" } }
19
- end
20
- end
21
-
22
32
  it "sends the email with exposed birds" do
23
33
  expect(Bird).to receive(:all).and_return(birds)
24
34
  expect(described_class.hello_birds.body.to_s)
@@ -27,18 +37,18 @@ RSpec.describe BirdsMailer, type: :mailer do
27
37
  end
28
38
 
29
39
  context "when bird is exposed" do
30
- class BirdsMailer
31
- expose(:bird)
32
-
33
- def hello_bird(id:)
34
- mail { |format| format.text { render plain: "Hello #{bird}" } }
35
- end
36
- end
37
-
38
40
  it "sends the email with exposed bird" do
39
41
  expect(Bird).to receive(:find).with('some-id').and_return(bird)
40
42
  expect(described_class.hello_bird(id: 'some-id').body.to_s)
41
43
  .to include("Hello #{bird}")
42
44
  end
43
45
  end
46
+
47
+ context "with non hash argument" do
48
+ it "does not set params" do
49
+ expect(Bird).to receive(:find).with('some-id').and_return(bird)
50
+ expect(described_class.hello_bird_by_id('some-id').body.to_s)
51
+ .to include("Hello #{bird}")
52
+ end
53
+ end
44
54
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decent_exposure
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Pravosud
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-10-26 00:00:00.000000000 Z
12
+ date: 2016-10-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport