formtastic 1.1.0 → 1.2.0.beta

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/MIT-LICENSE +1 -1
  2. data/README.textile +80 -66
  3. data/generators/form/form_generator.rb +37 -46
  4. data/generators/formtastic/formtastic_generator.rb +10 -8
  5. data/lib/formtastic.rb +318 -227
  6. data/lib/formtastic/i18n.rb +8 -6
  7. data/lib/formtastic/layout_helper.rb +6 -4
  8. data/lib/formtastic/railtie.rb +3 -1
  9. data/lib/formtastic/util.rb +2 -0
  10. data/lib/generators/formtastic/form/form_generator.rb +5 -7
  11. data/lib/generators/formtastic/install/install_generator.rb +2 -9
  12. data/lib/generators/templates/_form.html.erb +5 -0
  13. data/lib/generators/templates/_form.html.haml +4 -0
  14. data/{generators/formtastic → lib/generators}/templates/formtastic.css +25 -11
  15. data/{generators/formtastic → lib/generators}/templates/formtastic.rb +19 -2
  16. data/{generators/formtastic → lib/generators}/templates/formtastic_changes.css +0 -0
  17. metadata +58 -98
  18. data/Rakefile +0 -127
  19. data/generators/form/templates/view__form.html.erb +0 -5
  20. data/generators/form/templates/view__form.html.haml +0 -4
  21. data/generators/formtastic_stylesheets/formtastic_stylesheets_generator.rb +0 -16
  22. data/init.rb +0 -5
  23. data/rails/init.rb +0 -2
  24. data/spec/buttons_spec.rb +0 -166
  25. data/spec/commit_button_spec.rb +0 -401
  26. data/spec/custom_builder_spec.rb +0 -98
  27. data/spec/defaults_spec.rb +0 -20
  28. data/spec/error_proc_spec.rb +0 -27
  29. data/spec/errors_spec.rb +0 -105
  30. data/spec/form_helper_spec.rb +0 -142
  31. data/spec/helpers/layout_helper_spec.rb +0 -21
  32. data/spec/i18n_spec.rb +0 -152
  33. data/spec/include_blank_spec.rb +0 -74
  34. data/spec/input_spec.rb +0 -786
  35. data/spec/inputs/boolean_input_spec.rb +0 -104
  36. data/spec/inputs/check_boxes_input_spec.rb +0 -426
  37. data/spec/inputs/country_input_spec.rb +0 -118
  38. data/spec/inputs/date_input_spec.rb +0 -168
  39. data/spec/inputs/datetime_input_spec.rb +0 -310
  40. data/spec/inputs/file_input_spec.rb +0 -34
  41. data/spec/inputs/hidden_input_spec.rb +0 -78
  42. data/spec/inputs/numeric_input_spec.rb +0 -44
  43. data/spec/inputs/password_input_spec.rb +0 -46
  44. data/spec/inputs/radio_input_spec.rb +0 -243
  45. data/spec/inputs/select_input_spec.rb +0 -546
  46. data/spec/inputs/string_input_spec.rb +0 -64
  47. data/spec/inputs/text_input_spec.rb +0 -34
  48. data/spec/inputs/time_input_spec.rb +0 -206
  49. data/spec/inputs/time_zone_input_spec.rb +0 -110
  50. data/spec/inputs_spec.rb +0 -476
  51. data/spec/label_spec.rb +0 -89
  52. data/spec/semantic_errors_spec.rb +0 -98
  53. data/spec/semantic_fields_for_spec.rb +0 -45
  54. data/spec/spec.opts +0 -2
  55. data/spec/spec_helper.rb +0 -289
  56. data/spec/support/custom_macros.rb +0 -494
  57. data/spec/support/output_buffer.rb +0 -4
  58. data/spec/support/test_environment.rb +0 -45
data/spec/label_spec.rb DELETED
@@ -1,89 +0,0 @@
1
- # coding: utf-8
2
- require 'spec_helper'
3
-
4
- describe 'SemanticFormBuilder#label' do
5
-
6
- include FormtasticSpecHelper
7
-
8
- before do
9
- @output_buffer = ''
10
- mock_everything
11
- end
12
-
13
- it 'should humanize the given attribute' do
14
- semantic_form_for(@new_post) do |builder|
15
- builder.label(:login).should have_tag('label', :with => /Login/)
16
- end
17
- end
18
-
19
- describe 'when required is given' do
20
- it 'should append a required note' do
21
- semantic_form_for(@new_post) do |builder|
22
- builder.label(:login, nil, :required => true).should have_tag('label abbr')
23
- end
24
- end
25
-
26
- it 'should allow require option to be given as second argument' do
27
- semantic_form_for(@new_post) do |builder|
28
- builder.label(:login, :required => true).should have_tag('label abbr')
29
- end
30
- end
31
- end
32
-
33
- describe 'when a collection is given' do
34
- it 'should use a supplied label_method for simple collections' do
35
- form = semantic_form_for(:project, :url => 'http://test.host') do |builder|
36
- concat(builder.input(:author_id, :as => :check_boxes, :collection => [:a, :b, :c], :value_method => :to_s, :label_method => proc {|f| ('Label_%s' % [f])}))
37
- end
38
- output_buffer.concat(form) if Formtastic::Util.rails3?
39
- output_buffer.should have_tag('form li fieldset ol li label', :with => /Label_[abc]/, :count => 3)
40
- end
41
-
42
- it 'should use a supplied value_method for simple collections' do
43
- form = semantic_form_for(:project, :url => 'http://test.host') do |builder|
44
- concat(builder.input(:author_id, :as => :check_boxes, :collection => [:a, :b, :c], :value_method => proc {|f| ('Value_%s' % [f.to_s])}))
45
- end
46
- output_buffer.concat(form) if Formtastic::Util.rails3?
47
- output_buffer.should have_tag('form li fieldset ol li label input[value="Value_a"]')
48
- output_buffer.should have_tag('form li fieldset ol li label input[value="Value_b"]')
49
- output_buffer.should have_tag('form li fieldset ol li label input[value="Value_c"]')
50
- end
51
- end
52
-
53
- describe 'when label is given' do
54
- it 'should allow the text to be given as label option' do
55
- semantic_form_for(@new_post) do |builder|
56
- builder.label(:login, :required => true, :label => 'My label').should have_tag('label', :with => /My label/)
57
- end
58
- end
59
-
60
- it 'should return nil if label is false' do
61
- semantic_form_for(@new_post) do |builder|
62
- builder.label(:login, :label => false).should be_blank
63
- end
64
- end
65
-
66
- it 'should html escape the label string by default' do
67
- semantic_form_for(@new_post) do |builder|
68
- builder.label(:login, :required => false, :label => '<b>My label</b>').should == "<label for=\"post_login\">&lt;b&gt;My label&lt;/b&gt;</label>"
69
- end
70
- end
71
-
72
- it 'should not html escape the label if configured that way' do
73
- ::Formtastic::SemanticFormBuilder.escape_html_entities_in_hints_and_labels = false
74
- semantic_form_for(@new_post) do |builder|
75
- builder.label(:login, :required => false, :label => '<b>My label</b>').should == "<label for=\"post_login\"><b>My label</b></label>"
76
- end
77
- end
78
-
79
- it 'should not html escape the label string for html_safe strings' do
80
- ::Formtastic::SemanticFormBuilder.escape_html_entities_in_hints_and_labels = true
81
- semantic_form_for(@new_post) do |builder|
82
- builder.label(:login, :required => false, :label => '<b>My label</b>'.html_safe).should == "<label for=\"post_login\"><b>My label</b></label>"
83
- end
84
- end
85
-
86
- end
87
-
88
- end
89
-
@@ -1,98 +0,0 @@
1
- # coding: utf-8
2
- require 'spec_helper'
3
-
4
- describe 'SemanticFormBuilder#semantic_errors' do
5
-
6
- include FormtasticSpecHelper
7
-
8
- before do
9
- @output_buffer = ''
10
- mock_everything
11
- @title_errors = ['must not be blank', 'must be awesome']
12
- @base_errors = ['base error message', 'nasty error']
13
- @base_error = 'one base error'
14
- @errors = mock('errors')
15
- @new_post.stub!(:errors).and_return(@errors)
16
- end
17
-
18
- describe 'when there is only one error on base' do
19
- before do
20
- @errors.stub!(:[]).with(:base).and_return(@base_error)
21
- end
22
-
23
- it 'should render an unordered list' do
24
- semantic_form_for(@new_post) do |builder|
25
- builder.semantic_errors.should have_tag('ul.errors li', @base_error)
26
- end
27
- end
28
- end
29
-
30
- describe 'when there is more than one error on base' do
31
- before do
32
- @errors.stub!(:[]).with(:base).and_return(@base_errors)
33
- end
34
-
35
- it 'should render an unordered list' do
36
- semantic_form_for(@new_post) do |builder|
37
- builder.semantic_errors.should have_tag('ul.errors')
38
- @base_errors.each do |error|
39
- builder.semantic_errors.should have_tag('ul.errors li', error)
40
- end
41
- end
42
- end
43
- end
44
-
45
- describe 'when there are errors on title' do
46
- before do
47
- @errors.stub!(:[]).with(:title).and_return(@title_errors)
48
- @errors.stub!(:[]).with(:base).and_return([])
49
- end
50
-
51
- it 'should render an unordered list' do
52
- semantic_form_for(@new_post) do |builder|
53
- title_name = builder.send(:localized_string, :title, :title, :label) || builder.send(:humanized_attribute_name, :title)
54
- builder.semantic_errors(:title).should have_tag('ul.errors li', title_name << " " << @title_errors.to_sentence)
55
- end
56
- end
57
- end
58
-
59
- describe 'when there are errors on title and base' do
60
- before do
61
- @errors.stub!(:[]).with(:title).and_return(@title_errors)
62
- @errors.stub!(:[]).with(:base).and_return(@base_error)
63
- end
64
-
65
- it 'should render an unordered list' do
66
- semantic_form_for(@new_post) do |builder|
67
- title_name = builder.send(:localized_string, :title, :title, :label) || builder.send(:humanized_attribute_name, :title)
68
- builder.semantic_errors(:title).should have_tag('ul.errors li', title_name << " " << @title_errors.to_sentence)
69
- builder.semantic_errors(:title).should have_tag('ul.errors li', @base_error)
70
- end
71
- end
72
- end
73
-
74
- describe 'when there are no errors' do
75
- before do
76
- @errors.stub!(:[]).with(:title).and_return(nil)
77
- @errors.stub!(:[]).with(:base).and_return(nil)
78
- end
79
-
80
- it 'should return nil' do
81
- semantic_form_for(@new_post) do |builder|
82
- builder.semantic_errors(:title).should be_nil
83
- end
84
- end
85
- end
86
-
87
- describe 'when there is one error on base and options with class is passed' do
88
- before do
89
- @errors.stub!(:[]).with(:base).and_return(@base_error)
90
- end
91
-
92
- it 'should render an unordered list with given class' do
93
- semantic_form_for(@new_post) do |builder|
94
- builder.semantic_errors(:class => "awesome").should have_tag('ul.awesome li', @base_error)
95
- end
96
- end
97
- end
98
- end
@@ -1,45 +0,0 @@
1
- # coding: utf-8
2
- require 'spec_helper'
3
-
4
- describe 'SemanticFormBuilder#semantic_fields_for' do
5
-
6
- include FormtasticSpecHelper
7
-
8
- before do
9
- @output_buffer = ''
10
- mock_everything
11
- @new_post.stub!(:author).and_return(::Author.new)
12
- end
13
-
14
- it 'yields an instance of SemanticFormHelper.builder' do
15
- semantic_form_for(@new_post) do |builder|
16
- builder.semantic_fields_for(:author) do |nested_builder|
17
- nested_builder.class.should == ::Formtastic::SemanticFormHelper.builder
18
- end
19
- end
20
- end
21
-
22
- it 'nests the object name' do
23
- semantic_form_for(@new_post) do |builder|
24
- builder.semantic_fields_for(@bob) do |nested_builder|
25
- nested_builder.object_name.should == 'post[author]'
26
- end
27
- end
28
- end
29
-
30
- it 'should sanitize html id for li tag' do
31
- @bob.stub!(:column_for_attribute).and_return(mock('column', :type => :string, :limit => 255))
32
- form = semantic_form_for(@new_post) do |builder|
33
- concat(builder.semantic_fields_for(@bob, :index => 1) do |nested_builder|
34
- concat(nested_builder.inputs(:login))
35
- end)
36
- end
37
- output_buffer.concat(form) if Formtastic::Util.rails3?
38
- output_buffer.should have_tag('form fieldset.inputs #post_author_1_login_input')
39
- # Not valid selector, so using good ol' regex
40
- output_buffer.should_not =~ /id="post\[author\]_1_login_input"/
41
- # <=> output_buffer.should_not have_tag('form fieldset.inputs #post[author]_1_login_input')
42
- end
43
-
44
- end
45
-
data/spec/spec.opts DELETED
@@ -1,2 +0,0 @@
1
- --color
2
- --format=progress
data/spec/spec_helper.rb DELETED
@@ -1,289 +0,0 @@
1
- # coding: utf-8
2
- require 'rubygems'
3
- require 'active_support'
4
- require 'action_pack'
5
- require 'action_view'
6
- require 'action_controller'
7
- require 'action_mailer'
8
-
9
- require File.expand_path(File.join(File.dirname(__FILE__), '../lib/formtastic/util'))
10
- require File.expand_path(File.join(File.dirname(__FILE__), '../lib/formtastic'))
11
- require File.expand_path(File.join(File.dirname(__FILE__), '../lib/formtastic/layout_helper'))
12
-
13
- # Requires supporting files with custom matchers and macros, etc,
14
- # in ./support/ and its subdirectories in alphabetic order.
15
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].sort.each {|f| require f}
16
-
17
- module FormtasticSpecHelper
18
- include ActionPack
19
- include ActionView::Context if defined?(ActionView::Context)
20
- include ActionController::RecordIdentifier
21
- include ActionView::Helpers::FormHelper
22
- include ActionView::Helpers::FormTagHelper
23
- include ActionView::Helpers::FormOptionsHelper
24
- include ActionView::Helpers::UrlHelper
25
- include ActionView::Helpers::TagHelper
26
- include ActionView::Helpers::TextHelper
27
- include ActionView::Helpers::ActiveRecordHelper if defined?(ActionView::Helpers::ActiveRecordHelper)
28
- include ActionView::Helpers::ActiveModelHelper if defined?(ActionView::Helpers::ActiveModelHelper)
29
- include ActionView::Helpers::DateHelper
30
- include ActionView::Helpers::CaptureHelper
31
- include ActionView::Helpers::AssetTagHelper
32
- include ActiveSupport
33
- include ActionController::PolymorphicRoutes if defined?(ActionController::PolymorphicRoutes)
34
-
35
- include Formtastic::SemanticFormHelper
36
-
37
- def rails3?
38
- ActionPack::VERSION::MAJOR > 2
39
- end
40
-
41
- def rails2?
42
- ActionPack::VERSION::MAJOR == 2
43
- end
44
-
45
- def default_input_type(column_type, column_name = :generic_column_name)
46
- @new_post.stub!(column_name)
47
- @new_post.stub!(:column_for_attribute).and_return(mock('column', :type => column_type)) unless column_type.nil?
48
-
49
- semantic_form_for(@new_post) do |builder|
50
- @default_type = builder.send(:default_input_type, column_name)
51
- end
52
-
53
- return @default_type
54
- end
55
-
56
- def active_model_presence_validator(attributes, options = {})
57
- presence_validator = mock('ActiveModel::Validations::PresenceValidator', :attributes => attributes, :options => options)
58
- presence_validator.stub!(:kind).and_return(:presence)
59
- presence_validator
60
- end
61
-
62
- class ::Post
63
- extend ActiveModel::Naming if defined?(ActiveModel::Naming)
64
- include ActiveModel::Conversion if defined?(ActiveModel::Conversion)
65
-
66
- def id
67
- end
68
-
69
- def persisted?
70
- end
71
- end
72
- module ::Namespaced
73
- class Post
74
- extend ActiveModel::Naming if defined?(ActiveModel::Naming)
75
- include ActiveModel::Conversion if defined?(ActiveModel::Conversion)
76
-
77
- def id
78
- end
79
-
80
- def persisted?
81
- end
82
- end
83
- end
84
- class ::Author
85
- extend ActiveModel::Naming if defined?(ActiveModel::Naming)
86
- include ActiveModel::Conversion if defined?(ActiveModel::Conversion)
87
-
88
- def to_label
89
- end
90
- end
91
- class ::Continent
92
- extend ActiveModel::Naming if defined?(ActiveModel::Naming)
93
- include ActiveModel::Conversion if defined?(ActiveModel::Conversion)
94
- end
95
- class ::PostModel
96
- extend ActiveModel::Naming if defined?(ActiveModel::Naming)
97
- include ActiveModel::Conversion if defined?(ActiveModel::Conversion)
98
- end
99
-
100
- def mock_everything
101
-
102
- # Resource-oriented styles like form_for(@post) will expect a path method for the object,
103
- # so we're defining some here.
104
- def post_models_path; "/postmodels/1"; end
105
-
106
- def post_path(o); "/posts/1"; end
107
- def posts_path; "/posts"; end
108
- def new_post_path; "/posts/new"; end
109
-
110
- def author_path(o); "/authors/1"; end
111
- def authors_path; "/authors"; end
112
- def new_author_path; "/authors/new"; end
113
-
114
- @fred = mock('user')
115
- @fred.stub!(:to_ary)
116
- @fred.stub!(:class).and_return(::Author)
117
- @fred.stub!(:to_label).and_return('Fred Smith')
118
- @fred.stub!(:login).and_return('fred_smith')
119
- @fred.stub!(:id).and_return(37)
120
- @fred.stub!(:new_record?).and_return(false)
121
- @fred.stub!(:errors).and_return(mock('errors', :[] => nil))
122
- @fred.stub!(:to_key).and_return(nil)
123
- @fred.stub!(:persisted?).and_return(nil)
124
-
125
- @bob = mock('user')
126
- @bob.stub!(:to_ary)
127
- @bob.stub!(:class).and_return(::Author)
128
- @bob.stub!(:to_label).and_return('Bob Rock')
129
- @bob.stub!(:login).and_return('bob')
130
- @bob.stub!(:created_at)
131
- @bob.stub!(:id).and_return(42)
132
- @bob.stub!(:posts).and_return([])
133
- @bob.stub!(:post_ids).and_return([])
134
- @bob.stub!(:new_record?).and_return(false)
135
- @bob.stub!(:errors).and_return(mock('errors', :[] => nil))
136
- @bob.stub!(:to_key).and_return(nil)
137
- @bob.stub!(:persisted?).and_return(nil)
138
-
139
- @james = mock('user')
140
- @james.stub!(:to_ary)
141
- @james.stub!(:class).and_return(::Author)
142
- @james.stub!(:to_label).and_return('James Shock')
143
- @james.stub!(:login).and_return('james')
144
- @james.stub!(:id).and_return(75)
145
- @james.stub!(:posts).and_return([])
146
- @james.stub!(:post_ids).and_return([])
147
- @james.stub!(:new_record?).and_return(false)
148
- @james.stub!(:errors).and_return(mock('errors', :[] => nil))
149
- @james.stub!(:to_key).and_return(nil)
150
- @james.stub!(:persisted?).and_return(nil)
151
-
152
-
153
- ::Author.stub!(:find).and_return([@fred, @bob])
154
- ::Author.stub!(:all).and_return([@fred, @bob])
155
- ::Author.stub!(:to_ary)
156
- ::Author.stub!(:human_attribute_name).and_return { |column_name| column_name.humanize }
157
- ::Author.stub!(:human_name).and_return('::Author')
158
- ::Author.stub!(:reflect_on_association).and_return { |column_name| mock('reflection', :options => {}, :klass => Post, :macro => :has_many) if column_name == :posts }
159
- ::Author.stub!(:content_columns).and_return([mock('column', :name => 'login'), mock('column', :name => 'created_at')])
160
- ::Author.stub!(:to_key).and_return(nil)
161
- ::Author.stub!(:persisted?).and_return(nil)
162
-
163
- # Sometimes we need a mock @post object and some Authors for belongs_to
164
- @new_post = mock('post')
165
- @new_post.stub!(:to_ary)
166
- @new_post.stub!(:class).and_return(::Post)
167
- @new_post.stub!(:id).and_return(nil)
168
- @new_post.stub!(:new_record?).and_return(true)
169
- @new_post.stub!(:errors).and_return(mock('errors', :[] => nil))
170
- @new_post.stub!(:author).and_return(nil)
171
- @new_post.stub!(:reviewer).and_return(nil)
172
- @new_post.stub!(:main_post).and_return(nil)
173
- @new_post.stub!(:sub_posts).and_return([]) #TODO should be a mock with methods for adding sub posts
174
- @new_post.stub!(:to_key).and_return(nil)
175
- @new_post.stub!(:to_model).and_return(@new_post)
176
- @new_post.stub!(:persisted?).and_return(nil)
177
-
178
- @freds_post = mock('post')
179
- @freds_post.stub!(:to_ary)
180
- @freds_post.stub!(:class).and_return(::Post)
181
- @freds_post.stub!(:to_label).and_return('Fred Smith')
182
- @freds_post.stub!(:id).and_return(19)
183
- @freds_post.stub!(:author).and_return(@fred)
184
- @freds_post.stub!(:author_id).and_return(@fred.id)
185
- @freds_post.stub!(:authors).and_return([@fred])
186
- @freds_post.stub!(:author_ids).and_return([@fred.id])
187
- @freds_post.stub!(:new_record?).and_return(false)
188
- @freds_post.stub!(:errors).and_return(mock('errors', :[] => nil))
189
- @freds_post.stub!(:to_key).and_return(nil)
190
- @freds_post.stub!(:persisted?).and_return(nil)
191
- @fred.stub!(:posts).and_return([@freds_post])
192
- @fred.stub!(:post_ids).and_return([@freds_post.id])
193
-
194
- ::Post.stub!(:human_attribute_name).and_return { |column_name| column_name.humanize }
195
- ::Post.stub!(:human_name).and_return('Post')
196
- ::Post.stub!(:reflect_on_all_validations).and_return([])
197
- ::Post.stub!(:reflect_on_validations_for).and_return([])
198
- ::Post.stub!(:reflections).and_return({})
199
- ::Post.stub!(:reflect_on_association).and_return do |column_name|
200
- case column_name
201
- when :author, :author_status
202
- mock = mock('reflection', :options => {}, :klass => ::Author, :macro => :belongs_to)
203
- mock.stub!(:[]).with(:class_name).and_return("Author")
204
- mock
205
- when :reviewer
206
- mock = mock('reflection', :options => {:class_name => 'Author'}, :klass => ::Author, :macro => :belongs_to)
207
- mock.stub!(:[]).with(:class_name).and_return("Author")
208
- mock
209
- when :authors
210
- mock('reflection', :options => {}, :klass => ::Author, :macro => :has_and_belongs_to_many)
211
- when :sub_posts
212
- mock('reflection', :options => {}, :klass => ::Post, :macro => :has_many)
213
- when :main_post
214
- mock('reflection', :options => {}, :klass => ::Post, :macro => :belongs_to)
215
- end
216
-
217
- end
218
- ::Post.stub!(:find).and_return([@freds_post])
219
- ::Post.stub!(:all).and_return([@freds_post])
220
- ::Post.stub!(:content_columns).and_return([mock('column', :name => 'title'), mock('column', :name => 'body'), mock('column', :name => 'created_at')])
221
- ::Post.stub!(:to_key).and_return(nil)
222
- ::Post.stub!(:persisted?).and_return(nil)
223
- ::Post.stub!(:to_ary)
224
-
225
- @new_post.stub!(:title)
226
- @new_post.stub!(:to_ary)
227
- @new_post.stub!(:body)
228
- @new_post.stub!(:published)
229
- @new_post.stub!(:publish_at)
230
- @new_post.stub!(:created_at)
231
- @new_post.stub!(:secret)
232
- @new_post.stub!(:time_zone)
233
- @new_post.stub!(:category_name)
234
- @new_post.stub!(:allow_comments)
235
- @new_post.stub!(:country)
236
- @new_post.stub!(:country_subdivision)
237
- @new_post.stub!(:country_code)
238
- @new_post.stub!(:column_for_attribute).with(:meta_description).and_return(mock('column', :type => :string, :limit => 255))
239
- @new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => :string, :limit => 50))
240
- @new_post.stub!(:column_for_attribute).with(:body).and_return(mock('column', :type => :text))
241
- @new_post.stub!(:column_for_attribute).with(:published).and_return(mock('column', :type => :boolean))
242
- @new_post.stub!(:column_for_attribute).with(:publish_at).and_return(mock('column', :type => :date))
243
- @new_post.stub!(:column_for_attribute).with(:time_zone).and_return(mock('column', :type => :string))
244
- @new_post.stub!(:column_for_attribute).with(:allow_comments).and_return(mock('column', :type => :boolean))
245
- @new_post.stub!(:column_for_attribute).with(:author).and_return(mock('column', :type => :integer))
246
- @new_post.stub!(:column_for_attribute).with(:country).and_return(mock('column', :type => :string, :limit => 255))
247
- @new_post.stub!(:column_for_attribute).with(:country_subdivision).and_return(mock('column', :type => :string, :limit => 255))
248
- @new_post.stub!(:column_for_attribute).with(:country_code).and_return(mock('column', :type => :string, :limit => 255))
249
-
250
- @new_post.stub!(:author).and_return(@bob)
251
- @new_post.stub!(:author_id).and_return(@bob.id)
252
-
253
- @new_post.stub!(:reviewer).and_return(@fred)
254
- @new_post.stub!(:reviewer_id).and_return(@fred.id)
255
-
256
- @new_post.should_receive(:publish_at=).any_number_of_times
257
- @new_post.should_receive(:title=).any_number_of_times
258
- @new_post.stub!(:main_post_id).and_return(nil)
259
-
260
- end
261
-
262
- def self.included(base)
263
- base.class_eval do
264
-
265
- attr_accessor :output_buffer
266
-
267
- def protect_against_forgery?
268
- false
269
- end
270
-
271
- end
272
- end
273
-
274
- def with_config(config_method_name, value, &block)
275
- old_value = ::Formtastic::SemanticFormBuilder.send(config_method_name)
276
- ::Formtastic::SemanticFormBuilder.send(:"#{config_method_name}=", value)
277
- yield
278
- ::Formtastic::SemanticFormBuilder.send(:"#{config_method_name}=", old_value)
279
- end
280
-
281
- def with_deprecation_silenced(&block)
282
- ::ActiveSupport::Deprecation.silenced = true
283
- yield
284
- ::ActiveSupport::Deprecation.silenced = false
285
- end
286
-
287
- end
288
-
289
- ::ActiveSupport::Deprecation.silenced = false