maily 0.6.0 → 0.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9b143eb37ea922863a831b9cd11c6dea69114477
4
- data.tar.gz: 9ad22c49d8c49ce3d064c5f29e01f56fa3aa4f7d
3
+ metadata.gz: d1e9bad7d3c7b7eb13ed1a089389af4d831cfacc
4
+ data.tar.gz: 9c4fcf7c4c73886dcdab225b0502063f7c580873
5
5
  SHA512:
6
- metadata.gz: 940fbdebbb81ebba521d6a6cfbd09a1dc40970711447f94f50245dabcb0e1bfe9fdca319b0ad304bfe17d6d820695847da4d52b71813f0081b02d1b463bfb6bc
7
- data.tar.gz: 9d0307a2ef4e1c8728927b755837701fb02d657220fbbe702e9ca83e7d2ebd4438d200b85800228ef95106b65e5ff15a0914723b04b1c3ee6454d1641c37fc99
6
+ metadata.gz: 13ed37c28422b6fc3e9212fd3f44abcec459d10bcf36a7d050547f7f92b834e4883d9b7c3f2a57b8389585191f66ebd08cb529295a787621006e9e716eec5223
7
+ data.tar.gz: 49dc5c0869782d4f58dd7d28f20640832a5aa7cf136bef7af807ac86e6298fdba07351cca58309554efa946aa63ff26c48adfecf3b12d7d345d28305b71a22a8
@@ -10,7 +10,13 @@ module Maily
10
10
 
11
11
  def show
12
12
  if !@maily_email.correct_number_of_arguments?
13
- alert = "#{@maily_email.required_arguments.size} arguments needed for #{@maily_email.name} email"
13
+ alert = if @maily_email.optional_arguments.size > 0
14
+ "#{@maily_email.name} email requires #{@maily_email.required_arguments.size} \
15
+ to #{@maily_email.required_arguments.size + @maily_email.optional_arguments.size} arguments"
16
+ else
17
+ "#{@maily_email.required_arguments.size} arguments needed for #{@maily_email.name} email"
18
+ end
19
+
14
20
  redirect_to(root_path, alert: alert)
15
21
  end
16
22
  end
@@ -1,9 +1,9 @@
1
1
  <aside class="sidebar">
2
- <% @mailers.each do |mailer| %>
2
+ <% @mailers.sort_by(&:name).each do |mailer| %>
3
3
  <section class="nav_list">
4
4
  <h3 class="title nav_title"><%= "#{mailer.name.humanize} (#{mailer.emails.length})" %></h3>
5
5
  <ul>
6
- <% mailer.emails.each do |email| %>
6
+ <% mailer.emails.sort_by(&:name).each do |email| %>
7
7
  <li><%= link_to email.name.humanize, maily_email_path(mailer: mailer.name, email: email.name), class: sidebar_class(mailer, email) %></li>
8
8
  <% end %>
9
9
  </ul>
@@ -21,6 +21,8 @@ module Maily
21
21
  end
22
22
 
23
23
  def build_hooks
24
+ Maily.init!
25
+
24
26
  fixtures = []
25
27
  hooks = []
26
28
 
@@ -19,11 +19,18 @@ module Maily
19
19
  end
20
20
 
21
21
  def required_arguments
22
- parameters.map(&:last)
22
+ parameters.select{ |param| param.first == :req }.map(&:last)
23
+ end
24
+
25
+ def optional_arguments
26
+ parameters.select{ |param| param.first == :opt }.map(&:last)
23
27
  end
24
28
 
25
29
  def correct_number_of_arguments?
26
- required_arguments.size == arguments.size
30
+ from = required_arguments.size
31
+ to = from + optional_arguments.size
32
+
33
+ (from..to).cover?(arguments.size)
27
34
  end
28
35
 
29
36
  def register_hook(*args)
@@ -1,3 +1,3 @@
1
1
  module Maily
2
- VERSION = "0.6.0"
2
+ VERSION = "0.6.1"
3
3
  end
@@ -5,7 +5,7 @@ class Notifier < ActionMailer::Base
5
5
  mail
6
6
  end
7
7
 
8
- def invitation(email)
8
+ def invitation(email, opt_arg = nil)
9
9
  mail
10
10
  end
11
11
 
@@ -49,4 +49,20 @@ describe Maily::Email do
49
49
  email = mailer.find_email('recommendation')
50
50
  expect(email.description).to eq('description')
51
51
  end
52
+
53
+ describe 'correct_number_of_arguments?' do
54
+ let (:email) { mailer.find_email('invitation') }
55
+
56
+ it 'when it lacks of arguments' do
57
+ allow_any_instance_of(Maily::Email).to receive(:parameters).and_return([])
58
+
59
+ expect(email.correct_number_of_arguments?).to be(false)
60
+ end
61
+
62
+ it 'when there is a correct number of arguments' do
63
+ allow_any_instance_of(Maily::Email).to receive(:parameters).and_return([[:req, 'email'], [:opt, 'optional']])
64
+
65
+ expect(email.correct_number_of_arguments?).to be(true)
66
+ end
67
+ end
52
68
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maily
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - markets
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-24 00:00:00.000000000 Z
11
+ date: 2017-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -196,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
196
196
  version: '0'
197
197
  requirements: []
198
198
  rubyforge_project:
199
- rubygems_version: 2.5.2
199
+ rubygems_version: 2.5.1
200
200
  signing_key:
201
201
  specification_version: 4
202
202
  summary: Rails Engine to preview emails in the browser.