| | 192 | |
|---|
| | 193 | it "should not errorify the field for a new object" do |
|---|
| | 194 | f = form_for :obj do |
|---|
| | 195 | text_control(:foo, :bar =>"7").should_not match_tag(:input, :type => "text", :name => "fake_model[foo]", :class => "error") |
|---|
| | 196 | end |
|---|
| | 197 | end |
|---|
| | 198 | |
|---|
| | 199 | it "should errorify a field for a model with errors" do |
|---|
| | 200 | model = mock("model") |
|---|
| | 201 | model.stub!(:new_record?).and_return(true) |
|---|
| | 202 | model.stub!(:class).and_return("MyClass") |
|---|
| | 203 | model.stub!(:foo).and_return("FOO") |
|---|
| | 204 | errors = mock("errors") |
|---|
| | 205 | errors.should_receive(:on).with(:foo).and_return(true) |
|---|
| | 206 | |
|---|
| | 207 | model.stub!(:errors).and_return(errors) |
|---|
| | 208 | |
|---|
| | 209 | f = form_for model do |
|---|
| | 210 | text_control(:foo).should match_tag(:input, :class => "error") |
|---|
| | 211 | end |
|---|
| | 212 | end |
|---|
| | 251 | |
|---|
| | 252 | it "should not errorify the field for a new object" do |
|---|
| | 253 | f = form_for :obj do |
|---|
| | 254 | password_control(:foo, :bar =>"7").should_not match_tag(:input, :class => "error") |
|---|
| | 255 | end |
|---|
| | 256 | end |
|---|
| | 257 | |
|---|
| | 258 | it "should errorify a field for a model with errors" do |
|---|
| | 259 | model = mock("model") |
|---|
| | 260 | model.stub!(:new_record?).and_return(true) |
|---|
| | 261 | model.stub!(:class).and_return("MyClass") |
|---|
| | 262 | model.stub!(:foo).and_return("FOO") |
|---|
| | 263 | errors = mock("errors") |
|---|
| | 264 | errors.should_receive(:on).with(:foo).and_return(true) |
|---|
| | 265 | |
|---|
| | 266 | model.stub!(:errors).and_return(errors) |
|---|
| | 267 | |
|---|
| | 268 | f = form_for model do |
|---|
| | 269 | password_control(:foo).should match_tag(:input, :class => "error") |
|---|
| | 270 | end |
|---|
| | 271 | end |
|---|
| | 272 | |
|---|
| | 332 | |
|---|
| | 333 | it "should not errorify the field for a new object" do |
|---|
| | 334 | f = form_for :obj do |
|---|
| | 335 | checkbox_control(:foo, :bar =>"7").should_not match_tag(:input, :type => "checkbox", :class => "error checkbox") |
|---|
| | 336 | end |
|---|
| | 337 | end |
|---|
| | 338 | |
|---|
| | 339 | it "should errorify a field for a model with errors" do |
|---|
| | 340 | model = mock("model") |
|---|
| | 341 | model.stub!(:new_record?).and_return(true) |
|---|
| | 342 | model.stub!(:class).and_return("MyClass") |
|---|
| | 343 | model.stub!(:foo).and_return("FOO") |
|---|
| | 344 | errors = mock("errors") |
|---|
| | 345 | errors.should_receive(:on).with(:foo).and_return(true) |
|---|
| | 346 | |
|---|
| | 347 | model.stub!(:errors).and_return(errors) |
|---|
| | 348 | |
|---|
| | 349 | f = form_for model do |
|---|
| | 350 | checkbox_control(:foo, :bar =>"7").should match_tag(:input, :type => "checkbox", :class => "error checkbox") |
|---|
| | 351 | end |
|---|
| | 352 | end |
|---|
| | 388 | end |
|---|
| | 389 | end |
|---|
| | 390 | |
|---|
| | 391 | it "should not errorify the field for a new object" do |
|---|
| | 392 | f = form_for :obj do |
|---|
| | 393 | hidden_control(:foo, :bar =>"7").should_not match_tag(:input, :type => "hidden", :class => "error") |
|---|
| | 394 | end |
|---|
| | 395 | end |
|---|
| | 396 | |
|---|
| | 397 | it "should not errorify a field for a model with errors" do |
|---|
| | 398 | model = mock("model") |
|---|
| | 399 | model.stub!(:new_record?).and_return(true) |
|---|
| | 400 | model.stub!(:class).and_return("MyClass") |
|---|
| | 401 | model.stub!(:foo).and_return("FOO") |
|---|
| | 402 | errors = mock("errors") |
|---|
| | 403 | errors.should_receive(:on).with(:foo).and_return(true) |
|---|
| | 404 | |
|---|
| | 405 | model.stub!(:errors).and_return(errors) |
|---|
| | 406 | |
|---|
| | 407 | f = form_for model do |
|---|
| | 408 | hidden_control(:foo, :bar =>"7").should match_tag(:input, :type => "hidden", :name => "my_class[foo]", :class => "error") |
|---|