show_for 0.3.0.rc → 0.3.0

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: a197ce44c9dfc514f8efba3aed8446e9c92a77b9
4
- data.tar.gz: 06cdd44e843b9c1902f8756937b9be90ff4cd753
3
+ metadata.gz: 4e66b71c090111795d5eefc080a133ef63f3c752
4
+ data.tar.gz: 6751105eb644a59ced4b9f3e96ce94c3ad791dc3
5
5
  SHA512:
6
- metadata.gz: 0ac8cbc74a5cf716f98c42b014c3fb7d3dc11ac657d6defa52705f928992999e22b3b66a64aa9a8577f68865502363de6c5032b4e940373a91ea3931d4ff8c2c
7
- data.tar.gz: 3658bddd5ba20a9ad7e8c23611f22d80556522477f4df60bd125102c17d186b75a32dae834629fcb55eed6266d05f36157fa5c01139fbf919d34ccffe1186440
6
+ metadata.gz: 0e139c076881532aca65b6678797499cd4fafe74e32d620a993d17bc6ac4cfa734988f44b445b2ac245ae4cd86c5949ded1afad7fe5b12c2b3f4078b6f62936a
7
+ data.tar.gz: 4626283fc1e8e5f72b987f986010e8f591e20a25cfb95a77553e0b9c9f86af356bc7670a610f310b1c9c73048f33e408b9a04aef0585b0801817896bfe0043db
@@ -1,3 +1,8 @@
1
+ == 0.3.0
2
+
3
+ * bug fix
4
+ * Fix blank value not being applied when using a block. (by github.com/tfwright)
5
+
1
6
  == 0.3.0.rc
2
7
 
3
8
  * enhancements
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012 PlataformaTec http://blog.plataformatec.com.br/
1
+ Copyright (c) 2012-2014 PlataformaTec http://blog.plataformatec.com.br/
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -44,7 +44,7 @@ module ShowFor
44
44
  when Symbol
45
45
  block_from_symbol(attribute_name, options)
46
46
  else
47
- lambda { options[:value] }
47
+ lambda { options[:value].to_s }
48
48
  end
49
49
  end
50
50
 
@@ -5,10 +5,6 @@ module ShowFor
5
5
  # cache value for apply_wrapper_options!
6
6
  sample_value = value
7
7
 
8
- if value.blank? && value != false
9
- value = blank_value(options)
10
- end
11
-
12
8
  # We need to convert value to_a because when dealing with ActiveRecord
13
9
  # Array proxies, the follow statement Array# === value return false
14
10
  value = value.to_a if value.is_a?(Array)
@@ -34,6 +30,10 @@ module ShowFor
34
30
  end
35
31
  end
36
32
 
33
+ if content.blank?
34
+ content = blank_value(options)
35
+ end
36
+
37
37
  options[:content_html] = options.except(:content_tag) if apply_options
38
38
  wrap_with(:content, content, apply_wrapper_options!(:content, options, sample_value) )
39
39
  end
@@ -1,3 +1,3 @@
1
1
  module ShowFor
2
- VERSION = "0.3.0.rc".freeze
2
+ VERSION = "0.3.0".freeze
3
3
  end
@@ -133,6 +133,13 @@ class AttributeTest < ActionView::TestCase
133
133
  assert_select "div.show_for p.wrapper", /This description/
134
134
  end
135
135
 
136
+ test "show_for uses :if_blank if the block content is blank" do
137
+ with_attribute_for @user, :description, :if_blank => "No description provided" do
138
+ ""
139
+ end
140
+ assert_select "div.show_for p.wrapper", /No description provided/
141
+ end
142
+
136
143
  test "show_for#content given a block should be wrapped in the result" do
137
144
  with_attribute_for @user, :name do |name|
138
145
  "<div class='block'>#{name}</div>".html_safe
@@ -158,6 +165,11 @@ class AttributeTest < ActionView::TestCase
158
165
  assert_select "div.show_for p.wrapper", /Calculated Value/
159
166
  end
160
167
 
168
+ test "show_for uses :value and casts to string if supplied" do
169
+ with_attribute_for @user, :name, :value => 123
170
+ assert_select "div.show_for p.wrapper", /123/
171
+ end
172
+
161
173
  test "show_for ignores :value if a block is supplied" do
162
174
  with_attribute_for @user, :name, :value => "Calculated Value" do
163
175
  @user.name.upcase
@@ -1,4 +1,3 @@
1
- require 'rubygems'
2
1
  require 'bundler/setup'
3
2
 
4
3
  require 'test/unit'
@@ -16,6 +15,7 @@ $:.unshift File.expand_path("../../lib", __FILE__)
16
15
  require 'show_for'
17
16
 
18
17
  Dir["#{File.dirname(__FILE__)}/support/*.rb"].each { |f| require f }
18
+ I18n.enforce_available_locales = true
19
19
  I18n.default_locale = :en
20
20
 
21
21
  class ActionView::TestCase
metadata CHANGED
@@ -1,53 +1,53 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: show_for
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0.rc
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - José Valim
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-08 00:00:00.000000000 Z
11
+ date: 2014-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '3.2'
20
- - - <
20
+ - - "<"
21
21
  - !ruby/object:Gem::Version
22
22
  version: '5'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - '>='
27
+ - - ">="
28
28
  - !ruby/object:Gem::Version
29
29
  version: '3.2'
30
- - - <
30
+ - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '5'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: actionpack
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - '>='
37
+ - - ">="
38
38
  - !ruby/object:Gem::Version
39
39
  version: '3.2'
40
- - - <
40
+ - - "<"
41
41
  - !ruby/object:Gem::Version
42
42
  version: '5'
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
46
46
  requirements:
47
- - - '>='
47
+ - - ">="
48
48
  - !ruby/object:Gem::Version
49
49
  version: '3.2'
50
- - - <
50
+ - - "<"
51
51
  - !ruby/object:Gem::Version
52
52
  version: '5'
53
53
  description: Wrap your objects with a helper to easily show them
@@ -58,12 +58,13 @@ extra_rdoc_files: []
58
58
  files:
59
59
  - CHANGELOG.rdoc
60
60
  - MIT-LICENSE
61
+ - lib/generators/show_for/USAGE
61
62
  - lib/generators/show_for/install_generator.rb
62
63
  - lib/generators/show_for/templates/en.yml
63
64
  - lib/generators/show_for/templates/show.html.erb
64
65
  - lib/generators/show_for/templates/show.html.haml
65
66
  - lib/generators/show_for/templates/show_for.rb
66
- - lib/generators/show_for/USAGE
67
+ - lib/show_for.rb
67
68
  - lib/show_for/association.rb
68
69
  - lib/show_for/attribute.rb
69
70
  - lib/show_for/builder.rb
@@ -71,7 +72,6 @@ files:
71
72
  - lib/show_for/helper.rb
72
73
  - lib/show_for/label.rb
73
74
  - lib/show_for/version.rb
74
- - lib/show_for.rb
75
75
  - test/association_test.rb
76
76
  - test/attribute_test.rb
77
77
  - test/builder_test.rb
@@ -92,17 +92,17 @@ require_paths:
92
92
  - lib
93
93
  required_ruby_version: !ruby/object:Gem::Requirement
94
94
  requirements:
95
- - - '>='
95
+ - - ">="
96
96
  - !ruby/object:Gem::Version
97
97
  version: '0'
98
98
  required_rubygems_version: !ruby/object:Gem::Requirement
99
99
  requirements:
100
- - - '>'
100
+ - - ">="
101
101
  - !ruby/object:Gem::Version
102
- version: 1.3.1
102
+ version: '0'
103
103
  requirements: []
104
104
  rubyforge_project: show_for
105
- rubygems_version: 2.0.3
105
+ rubygems_version: 2.2.2
106
106
  signing_key:
107
107
  specification_version: 4
108
108
  summary: Wrap your objects with a helper to easily show them