rails_utils 3.2.1 → 3.2.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: 5eb6e346f134dad9cadcfd495c7d487b55c1d313
4
- data.tar.gz: ae22be9cde9ae97cf0b19cb6d3f9dd96b87f76f6
3
+ metadata.gz: 7166c5b4a4b5666c7f5437f05141d887be49262d
4
+ data.tar.gz: 02cef886ad60d0c220f6c1d58fc6590136f53bde
5
5
  SHA512:
6
- metadata.gz: 99b8f9431614ae786e11c74e955d3447aca32cb3eed01241841c13442a5be0efae2bdb932c67b469c7cdc8035585e9364fe9c4daef79fafbd7127b0d12733e21
7
- data.tar.gz: 45ff6ca55f5db9dbc8c0fc04f9cdd62e841ae5b5ed6ac15ab63692ab36f56055f80cbcedd03a703e16291192a33432e9fa0948fecfe0b33dd2e7af8af106b486
6
+ metadata.gz: 2e18e7c2f93768d6657bf9a07370c4260ec9768398ef2de01a4fa7e2f30ab5a2ed60927bd1d1e87fdd3c16195c63e043d6c7124662dfdee02e904078945d7844
7
+ data.tar.gz: 5f306f45b70d3f8b1d1314f72f76efac1e82c7c4061d0b82b7d98f1e86c6f7ddf21dd5d46dcfccba5c267c32ce296fc1ac39eb40697ab666ea40bda83c2c48a9
@@ -121,10 +121,16 @@ Minitest-ed. To run all tests, just run `rake` or `rake test`.
121
121
 
122
122
  ## Changelog
123
123
 
124
+ _Version 3.2.2_
125
+
126
+ - [Pull Request 5](https://github.com/winston/rails_utils/pull/5) - Minor updates - by @JuanitoFatas.
127
+
128
+
124
129
  _Version 3.2.1_
125
130
 
126
131
  - Update `page_title` to support I18n interpolation - by @JuanitoFatas.
127
132
 
133
+
128
134
  _Version 3.2.0_
129
135
 
130
136
  - Add `page_title` that supports I18n - by @huynhquancam.
data/lib/rails_utils.rb CHANGED
@@ -33,24 +33,18 @@ module RailsUtils
33
33
  JS
34
34
  end
35
35
 
36
- def flash_messages
37
- html = ""
38
- flash.each do |key, message|
39
- html <<
40
- content_tag(:div, class: "#{flash_class(key.to_sym)} fade in") do
41
- content = ""
42
- content << content_tag(:button, "x", type: "button", class: "close", "data-dismiss" => "alert")
43
- content << message
44
- content.html_safe
45
- end
46
- end
47
- html.html_safe
36
+ def flash_messages(options = {})
37
+ flash.collect do |key, message|
38
+ next if message.blank?
39
+
40
+ content_tag(:div, content_tag(:button, "x", type: "button", class: "close", "data-dismiss" => "alert") + message, class: "#{flash_class(key)} fade in #{options[:class]}")
41
+ end.join("\n").html_safe
48
42
  end
49
43
 
50
44
  private
51
45
 
52
46
  def flash_class(key)
53
- case key
47
+ case key.to_sym
54
48
  when :success
55
49
  "alert alert-success"
56
50
  when :notice
@@ -1,3 +1,3 @@
1
1
  module RailsUtils
2
- VERSION = "3.2.1"
2
+ VERSION = "3.2.2"
3
3
  end
@@ -1,9 +1,9 @@
1
1
  require 'test_helper'
2
2
 
3
3
  describe "RailsUtils::ActionViewExtensions" do
4
- let(:controller) { ActionController::Base.new }
5
- let(:request) { ActionDispatch::Request.new(flash: {}) }
6
- let(:view) { ActionView::Base.new }
4
+ let(:controller) { ActionController::Base.new }
5
+ let(:request) { ActionDispatch::Request.new(flash: {}) }
6
+ let(:view) { ActionView::Base.new }
7
7
 
8
8
  before do
9
9
  controller.request = request
@@ -37,14 +37,14 @@ describe "RailsUtils::ActionViewExtensions" do
37
37
  describe "#page_action_class" do
38
38
  # action_name, expected
39
39
  [
40
- [ "index" , "index" ],
41
- [ "show" , "show" ],
42
- [ "new" , "new" ],
43
- [ "create" , "new" ],
44
- [ "edit" , "edit" ],
45
- [ "update" , "edit" ],
46
- [ "destroy", "destroy" ],
47
- [ "custom" , "custom" ],
40
+ [ "index" , "index" ],
41
+ [ "show" , "show" ],
42
+ [ "new" , "new" ],
43
+ [ "create" , "new" ],
44
+ [ "edit" , "edit" ],
45
+ [ "update" , "edit" ],
46
+ [ "destroy", "destroy" ],
47
+ [ "custom" , "custom" ],
48
48
  ].each do |action_name, expected|
49
49
  describe "when ##{action_name}" do
50
50
  before { controller.stubs(:action_name).returns(action_name) }
@@ -79,7 +79,7 @@ describe "RailsUtils::ActionViewExtensions" do
79
79
  end
80
80
 
81
81
  describe 'when translation is missing' do
82
- let(:action_name) { "random" }
82
+ let(:action_name) { "random" }
83
83
  let(:default_translation) { "#{controller_name.capitalize} #{action_name.capitalize}" }
84
84
 
85
85
  it "combines page_controller_class and page_action_class" do
@@ -88,22 +88,22 @@ describe "RailsUtils::ActionViewExtensions" do
88
88
  end
89
89
 
90
90
  describe 'when translation is avaiable' do
91
- let(:action_name) { 'show' }
91
+ let(:action_name) { "show" }
92
92
 
93
- before { I18n.backend.store_translations("en", {controller_name.to_sym => {action_name.to_sym => {title: "An awesome title"}}}) }
93
+ before { I18n.backend.store_translations("en", { controller_name.to_sym => { action_name.to_sym => { title: "An awesome title" } }}) }
94
94
 
95
- it 'translates page title' do
96
- view.page_title.must_equal 'An awesome title'
95
+ it "translates page title" do
96
+ view.page_title.must_equal "An awesome title"
97
97
  end
98
98
  end
99
99
 
100
- describe 'when translation is avaiable + interpolations' do
101
- let(:action_name) { 'show' }
100
+ describe "when translation is avaiable + interpolations" do
101
+ let(:action_name) { "show" }
102
102
 
103
- before { I18n.backend.store_translations("en", {controller_name.to_sym => {action_name.to_sym => {title: "An awesome title, %{name}"}}}) }
103
+ before { I18n.backend.store_translations("en", { controller_name.to_sym => { action_name.to_sym => { title: "An awesome title, %{name}" } }}) }
104
104
 
105
- it 'translates page title' do
106
- view.page_title(name: 'bro').must_equal 'An awesome title, bro'
105
+ it "translates page title" do
106
+ view.page_title(name: "bro").must_equal "An awesome title, bro"
107
107
  end
108
108
  end
109
109
  end
@@ -118,7 +118,7 @@ describe "RailsUtils::ActionViewExtensions" do
118
118
  end
119
119
 
120
120
  describe "when controller name and action name are standard" do
121
- let(:action_name) { "custom" }
121
+ let(:action_name) { "custom" }
122
122
 
123
123
  it "invokes application" do
124
124
  view.javascript_initialization.must_match "Dummy.init();"
@@ -131,7 +131,7 @@ describe "RailsUtils::ActionViewExtensions" do
131
131
  end
132
132
 
133
133
  describe "when action name is create" do
134
- let(:action_name) { "create" }
134
+ let(:action_name) { "create" }
135
135
 
136
136
  it "replaces create with new" do
137
137
  view.javascript_initialization.must_match "Dummy.#{controller_name}.init_new();"
@@ -139,7 +139,7 @@ describe "RailsUtils::ActionViewExtensions" do
139
139
  end
140
140
 
141
141
  describe "when action name is update" do
142
- let(:action_name) { "update" }
142
+ let(:action_name) { "update" }
143
143
 
144
144
  it "replaces update with create" do
145
145
  view.javascript_initialization.must_match "Dummy.#{controller_name}.init_edit();"
@@ -157,9 +157,11 @@ describe "RailsUtils::ActionViewExtensions" do
157
157
  # alert-error is for Bootstrap 2.3.2
158
158
  [
159
159
  [ :success , /alert alert-success/ , "flash is success" ],
160
+ [ "success", /alert alert-success/ , "flash is success" ],
160
161
  [ :notice , /alert alert-info/ , "flash is notice" ],
161
162
  [ "notice" , /alert alert-info/ , "flash is notice" ],
162
163
  [ :error , /alert alert-danger alert-error/ , "flash is error" ],
164
+ [ "error" , /alert alert-danger alert-error/ , "flash is error" ],
163
165
  [ :alert , /alert alert-danger alert-error/ , "flash is alert" ],
164
166
  [ "alert" , /alert alert-danger alert-error/ , "flash is alert" ],
165
167
  [ :custom , /alert alert-custom/ , "flash is custom" ],
@@ -180,12 +182,12 @@ describe "RailsUtils::ActionViewExtensions" do
180
182
 
181
183
  describe "when bootstrap is present" do
182
184
  it "can fade in and out" do
183
- set_flash :alert , "not important"
185
+ set_flash :alert, "not important"
184
186
  view.flash_messages.must_match /fade in/
185
187
  end
186
188
 
187
189
  it "can be dismissed" do
188
- set_flash :alert , "not important"
190
+ set_flash :alert, "not important"
189
191
  view.flash_messages.must_match /data-dismiss=.*alert/
190
192
  end
191
193
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.1
4
+ version: 3.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Winston Teo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-11 00:00:00.000000000 Z
11
+ date: 2014-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -75,7 +75,7 @@ extensions: []
75
75
  extra_rdoc_files: []
76
76
  files:
77
77
  - MIT-LICENSE
78
- - README.markdown
78
+ - README.md
79
79
  - Rakefile
80
80
  - lib/rails_utils.rb
81
81
  - lib/rails_utils/version.rb
@@ -129,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
129
  version: '0'
130
130
  requirements: []
131
131
  rubyforge_project:
132
- rubygems_version: 2.4.1
132
+ rubygems_version: 2.2.2
133
133
  signing_key:
134
134
  specification_version: 4
135
135
  summary: Rails helpers based on opinionated project practices.