formtastic-bootstrap 1.0.3 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -24,11 +24,16 @@ And install it with <tt>bundle install</tt>.
24
24
 
25
25
  #### Configuration
26
26
 
27
- You will then need to add the following line to your Formtastic initialization file:
27
+ Add the following line to your Formtastic initialization file:
28
28
 
29
29
  # config/initializers/formtastic.rb
30
30
  Formtastic::Helpers::FormHelper.builder = FormtasticBootstrap::FormBuilder
31
31
 
32
+ Add the following line to the top of your <tt>application.css</tt> file:
33
+
34
+ # app/assets/stylesheets/application.css
35
+ *= require formtastic-bootstrap
36
+
32
37
  Make sure you've already downloaded and installed Formtastic!
33
38
 
34
39
 
@@ -119,11 +124,17 @@ In particular:
119
124
 
120
125
  ### What's Missing
121
126
 
122
- * Formtastic's <tt>:country</tt> and <tt>:time_zone</tt> have not yet been implemented.
127
+ Contributions are welcome!
128
+
129
+ * Formtastic's <tt>:country</tt> has not yet been implemented.
123
130
  * Twitter Bootstrap's Date Range, Prepend Text, Prepend Checkbox and Appended Checkbox controls have not yet been implemented.
124
131
 
125
- ## Contributing to formtastic-bootstrap
132
+ ## Contributing
126
133
 
134
+ ### Contributors
135
+
136
+ A big thank you [to all contributors](https://github.com/mjbellantoni/formtastic-bootstrap/contributors)!
137
+
127
138
  ### Submitting Issues
128
139
 
129
140
  If you're filing a bug, thank you! Secondly, in the report please include:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.3
1
+ 1.1.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "formtastic-bootstrap"
8
- s.version = "1.0.3"
8
+ s.version = "1.1.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Matthew Bellantoni"]
12
- s.date = "2011-12-08"
12
+ s.date = "2011-12-18"
13
13
  s.description = "Formtastic form builder to generate Twitter Bootstrap-friendly markup."
14
14
  s.email = "mjbellantoni@yahoo.com"
15
15
  s.extra_rdoc_files = [
@@ -62,6 +62,7 @@ Gem::Specification.new do |s|
62
62
  "lib/formtastic-bootstrap/inputs/string_input.rb",
63
63
  "lib/formtastic-bootstrap/inputs/text_input.rb",
64
64
  "lib/formtastic-bootstrap/inputs/time_input.rb",
65
+ "lib/formtastic-bootstrap/inputs/time_zone_input.rb",
65
66
  "lib/formtastic-bootstrap/inputs/url_input.rb",
66
67
  "spec/builder/errors_spec.rb",
67
68
  "spec/builder/semantic_fields_for_spec.rb",
@@ -85,6 +86,7 @@ Gem::Specification.new do |s|
85
86
  "spec/inputs/string_input_spec.rb",
86
87
  "spec/inputs/text_input_spec.rb",
87
88
  "spec/inputs/time_input_spec.rb",
89
+ "spec/inputs/time_zone_input_spec.rb",
88
90
  "spec/inputs/url_input_spec.rb",
89
91
  "spec/spec_helper.rb",
90
92
  "spec/support/custom_macros.rb",
@@ -16,6 +16,7 @@ require "formtastic-bootstrap/inputs/select_input"
16
16
  require "formtastic-bootstrap/inputs/string_input"
17
17
  require "formtastic-bootstrap/inputs/text_input"
18
18
  require "formtastic-bootstrap/inputs/time_input"
19
+ require "formtastic-bootstrap/inputs/time_zone_input"
19
20
  require "formtastic-bootstrap/inputs/url_input"
20
21
 
21
22
  module FormtasticBootstrap
@@ -0,0 +1,14 @@
1
+ module FormtasticBootstrap
2
+ module Inputs
3
+ class TimeZoneInput < Formtastic::Inputs::TimeZoneInput
4
+ include Base
5
+
6
+ def to_html
7
+ generic_input_wrapping do
8
+ builder.time_zone_select(method, priority_zones, input_options, input_html_options)
9
+ end
10
+ end
11
+
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,120 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe 'time_zone input' do
5
+
6
+ include FormtasticSpecHelper
7
+
8
+ before do
9
+ @output_buffer = ''
10
+ mock_everything
11
+ Formtastic::Helpers::FormHelper.builder = FormtasticBootstrap::FormBuilder
12
+
13
+ concat(semantic_form_for(@new_post) do |builder|
14
+ concat(builder.input(:time_zone))
15
+ end)
16
+ end
17
+
18
+ it_should_have_input_wrapper_with_class("time_zone")
19
+ it_should_have_input_wrapper_with_class(:clearfix)
20
+ it_should_have_input_wrapper_with_id("post_time_zone_input")
21
+ it_should_apply_error_logic_for_input_type(:time_zone)
22
+
23
+ it 'should generate a label for the input' do
24
+ output_buffer.should have_tag('form div label')
25
+ output_buffer.should have_tag('form div label[@for="post_time_zone"]')
26
+ output_buffer.should have_tag('form div label', /Time zone/)
27
+ end
28
+
29
+ it "should generate a select" do
30
+ output_buffer.should have_tag("form div select")
31
+ output_buffer.should have_tag("form div select#post_time_zone")
32
+ output_buffer.should have_tag("form div select[@name=\"post[time_zone]\"]")
33
+ end
34
+
35
+ it 'should use input_html to style inputs' do
36
+ concat(semantic_form_for(@new_post) do |builder|
37
+ concat(builder.input(:time_zone, :input_html => { :class => 'myclass' }))
38
+ end)
39
+ output_buffer.should have_tag("form div select.myclass")
40
+ end
41
+
42
+ describe "when namespace is provided" do
43
+
44
+ before do
45
+ @output_buffer = ''
46
+ mock_everything
47
+ Formtastic::Helpers::FormHelper.builder = FormtasticBootstrap::FormBuilder
48
+
49
+ concat(semantic_form_for(@new_post, :namespace => 'context2') do |builder|
50
+ concat(builder.input(:time_zone))
51
+ end)
52
+ end
53
+
54
+ it_should_have_input_wrapper_with_id("context2_post_time_zone_input")
55
+ it_should_have_select_with_id("context2_post_time_zone")
56
+ it_should_have_label_for("context2_post_time_zone")
57
+
58
+ end
59
+
60
+ describe "when index is provided" do
61
+
62
+ before do
63
+ @output_buffer = ''
64
+ mock_everything
65
+ Formtastic::Helpers::FormHelper.builder = FormtasticBootstrap::FormBuilder
66
+
67
+ concat(semantic_form_for(@new_post) do |builder|
68
+ concat(builder.fields_for(:author, :index => 3) do |author|
69
+ concat(author.input(:name, :as => :time_zone))
70
+ end)
71
+ end)
72
+ end
73
+
74
+ it 'should index the id of the wrapper' do
75
+ output_buffer.should have_tag("div#post_author_attributes_3_name_input")
76
+ end
77
+
78
+ it 'should index the id of the select tag' do
79
+ output_buffer.should have_tag("select#post_author_attributes_3_name")
80
+ end
81
+
82
+ it 'should index the name of the select tag' do
83
+ output_buffer.should have_tag("select[@name='post[author_attributes][3][name]']")
84
+ end
85
+
86
+ end
87
+
88
+
89
+ describe 'when no object is given' do
90
+ before(:each) do
91
+ concat(semantic_form_for(:project, :url => 'http://test.host/') do |builder|
92
+ concat(builder.input(:time_zone, :as => :time_zone))
93
+ end)
94
+ end
95
+
96
+ it 'should generate labels' do
97
+ output_buffer.should have_tag('form div label')
98
+ output_buffer.should have_tag('form div label[@for="project_time_zone"]')
99
+ output_buffer.should have_tag('form div label', /Time zone/)
100
+ end
101
+
102
+ it 'should generate select inputs' do
103
+ output_buffer.should have_tag("form div select")
104
+ output_buffer.should have_tag("form div select#project_time_zone")
105
+ output_buffer.should have_tag("form div select[@name=\"project[time_zone]\"]")
106
+ end
107
+ end
108
+
109
+ context "when required" do
110
+ it "should add the required attribute to the input's html options" do
111
+ with_config :use_required_attribute, true do
112
+ concat(semantic_form_for(@new_post) do |builder|
113
+ concat(builder.input(:title, :as => :time_zone, :required => true))
114
+ end)
115
+ output_buffer.should have_tag("select[@required]")
116
+ end
117
+ end
118
+ end
119
+
120
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: formtastic-bootstrap
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.3
5
+ version: 1.1.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Matthew Bellantoni
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-12-08 00:00:00 Z
13
+ date: 2011-12-18 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: formtastic
@@ -144,6 +144,7 @@ files:
144
144
  - lib/formtastic-bootstrap/inputs/string_input.rb
145
145
  - lib/formtastic-bootstrap/inputs/text_input.rb
146
146
  - lib/formtastic-bootstrap/inputs/time_input.rb
147
+ - lib/formtastic-bootstrap/inputs/time_zone_input.rb
147
148
  - lib/formtastic-bootstrap/inputs/url_input.rb
148
149
  - spec/builder/errors_spec.rb
149
150
  - spec/builder/semantic_fields_for_spec.rb
@@ -167,6 +168,7 @@ files:
167
168
  - spec/inputs/string_input_spec.rb
168
169
  - spec/inputs/text_input_spec.rb
169
170
  - spec/inputs/time_input_spec.rb
171
+ - spec/inputs/time_zone_input_spec.rb
170
172
  - spec/inputs/url_input_spec.rb
171
173
  - spec/spec_helper.rb
172
174
  - spec/support/custom_macros.rb
@@ -186,7 +188,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
186
188
  requirements:
187
189
  - - ">="
188
190
  - !ruby/object:Gem::Version
189
- hash: 590107616495540574
191
+ hash: 1118750897900617587
190
192
  segments:
191
193
  - 0
192
194
  version: "0"