show_for 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -54,23 +54,23 @@ Will generate something like:
54
54
 
55
55
  <div id="admin_1" class="show_for admin">
56
56
  <p class="wrapper admin_name">
57
- <b class="label">Name</b><br />
57
+ <strong class="label">Name</strong><br />
58
58
  José Valim
59
59
  </p>
60
60
  <p class="wrapper admin_confirmed">
61
- <b class="label">Confirmed?</b><br />
61
+ <strong class="label">Confirmed?</strong><br />
62
62
  Yes
63
63
  </p>
64
64
  <p class="wrapper admin_created_at">
65
- <b class="label">Created at</b><br />
65
+ <strong class="label">Created at</strong><br />
66
66
  13/12/2009 - 19h17
67
67
  </p>
68
68
  <p id="sign_in_timestamp" class="wrapper admin_last_sign_in_at">
69
- <b class="label">Last sign in at</b><br />
69
+ <strong class="label">Last sign in at</strong><br />
70
70
  Administrator did not access yet
71
71
  </p>
72
72
  <p class="wrapper admin_photo">
73
- <b class="label">Photo</b><br />
73
+ <strong class="label">Photo</strong><br />
74
74
  <img src="path/to/photo" />
75
75
  </p>
76
76
  </div>
@@ -14,10 +14,11 @@ module ShowFor
14
14
 
15
15
  html_options[:id] ||= dom_id(object)
16
16
  html_options[:class] = "show_for #{dom_class(object)} #{html_options[:class]}".strip
17
+ builder_class = html_options.delete(:builder) || ShowFor::Builder
17
18
 
18
- concat content_tag(tag, capture(ShowFor::Builder.new(object, self), &block), html_options)
19
+ concat content_tag(tag, capture(builder_class.new(object, self), &block), html_options)
19
20
  end
20
21
  end
21
22
  end
22
23
 
23
- ActionView::Base.send :include, ShowFor::Helper
24
+ ActionView::Base.send :include, ShowFor::Helper
@@ -2,4 +2,4 @@ en:
2
2
  show_for:
3
3
  blank: "Not specified"
4
4
  "yes": "Yes"
5
- "no": "No""
5
+ "no": "No"
@@ -1,3 +1,3 @@
1
1
  module ShowFor
2
- VERSION = "0.1.2".freeze
2
+ VERSION = "0.1.3".freeze
3
3
  end
@@ -1,5 +1,8 @@
1
1
  require "test_helper"
2
2
 
3
+ class CustomBuilder < ShowFor::Builder
4
+ end
5
+
3
6
  class HelperTest < ActionView::TestCase
4
7
  test "show for yields an instance of ShowFor::Builder" do
5
8
  show_for(@user) do |f|
@@ -7,6 +10,12 @@ class HelperTest < ActionView::TestCase
7
10
  end
8
11
  end
9
12
 
13
+ test "show for yields an instance of builder class specified by builder option" do
14
+ show_for(@user, :builder => CustomBuilder) do |f|
15
+ assert f.instance_of?(CustomBuilder)
16
+ end
17
+ end
18
+
10
19
  test "show for should add default class to form" do
11
20
  show_for(@user) do |f| end
12
21
  assert_select "div.show_for"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: show_for
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Jos\xC3\xA9 Valim"
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-09 00:00:00 +01:00
12
+ date: 2010-01-18 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies: []
15
15