rmm5t-shoulda 2.0.6 → 2.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. data/README.rdoc +38 -10
  2. data/Rakefile +5 -3
  3. data/lib/shoulda.rb +7 -15
  4. data/lib/shoulda/action_mailer.rb +1 -1
  5. data/lib/shoulda/action_mailer/assertions.rb +32 -33
  6. data/lib/shoulda/active_record.rb +6 -2
  7. data/lib/shoulda/active_record/assertions.rb +62 -81
  8. data/lib/shoulda/active_record/helpers.rb +40 -0
  9. data/lib/shoulda/active_record/macros.rb +511 -640
  10. data/lib/shoulda/active_record/matchers.rb +42 -0
  11. data/lib/shoulda/active_record/matchers/allow_mass_assignment_of_matcher.rb +83 -0
  12. data/lib/shoulda/active_record/matchers/allow_value_matcher.rb +102 -0
  13. data/lib/shoulda/active_record/matchers/association_matcher.rb +226 -0
  14. data/lib/shoulda/active_record/matchers/ensure_inclusion_of_matcher.rb +87 -0
  15. data/lib/shoulda/active_record/matchers/ensure_length_of_matcher.rb +141 -0
  16. data/lib/shoulda/active_record/matchers/have_db_column_matcher.rb +169 -0
  17. data/lib/shoulda/active_record/matchers/have_index_matcher.rb +105 -0
  18. data/lib/shoulda/active_record/matchers/have_named_scope_matcher.rb +125 -0
  19. data/lib/shoulda/active_record/matchers/have_readonly_attribute_matcher.rb +59 -0
  20. data/lib/shoulda/active_record/matchers/validate_acceptance_of_matcher.rb +41 -0
  21. data/lib/shoulda/active_record/matchers/validate_numericality_of_matcher.rb +39 -0
  22. data/lib/shoulda/active_record/matchers/validate_presence_of_matcher.rb +60 -0
  23. data/lib/shoulda/active_record/matchers/validate_uniqueness_of_matcher.rb +148 -0
  24. data/lib/shoulda/active_record/matchers/validation_matcher.rb +56 -0
  25. data/lib/shoulda/assertions.rb +50 -40
  26. data/lib/shoulda/autoload_macros.rb +46 -0
  27. data/lib/shoulda/context.rb +124 -126
  28. data/lib/shoulda/helpers.rb +5 -7
  29. data/lib/shoulda/macros.rb +63 -64
  30. data/lib/shoulda/private_helpers.rb +16 -18
  31. data/lib/shoulda/rails.rb +5 -11
  32. data/lib/shoulda/rspec.rb +9 -0
  33. data/lib/shoulda/tasks/list_tests.rake +6 -1
  34. data/lib/shoulda/test_unit.rb +19 -0
  35. data/rails/init.rb +7 -1
  36. data/test/README +2 -2
  37. data/test/fail_macros.rb +16 -16
  38. data/test/functional/posts_controller_test.rb +33 -24
  39. data/test/functional/users_controller_test.rb +0 -19
  40. data/test/model_builder.rb +106 -0
  41. data/test/other/autoload_macro_test.rb +18 -0
  42. data/test/other/helpers_test.rb +58 -0
  43. data/test/other/private_helpers_test.rb +1 -1
  44. data/test/other/should_test.rb +16 -16
  45. data/test/rails_root/app/controllers/posts_controller.rb +6 -5
  46. data/test/rails_root/app/models/pets/dog.rb +10 -0
  47. data/test/rails_root/app/models/treat.rb +3 -0
  48. data/test/rails_root/app/models/user.rb +2 -2
  49. data/test/rails_root/app/views/layouts/posts.rhtml +2 -0
  50. data/test/rails_root/config/database.yml +1 -1
  51. data/test/rails_root/config/environments/{sqlite3.rb → test.rb} +0 -0
  52. data/test/rails_root/db/migrate/001_create_users.rb +3 -2
  53. data/test/rails_root/db/migrate/011_create_treats.rb +12 -0
  54. data/test/rails_root/test/shoulda_macros/custom_macro.rb +6 -0
  55. data/test/rails_root/vendor/gems/gem_with_macro-0.0.1/shoulda_macros/gem_macro.rb +6 -0
  56. data/test/rails_root/vendor/plugins/plugin_with_macro/shoulda_macros/plugin_macro.rb +6 -0
  57. data/test/test_helper.rb +3 -1
  58. data/test/unit/address_test.rb +1 -1
  59. data/test/unit/dog_test.rb +5 -2
  60. data/test/unit/post_test.rb +7 -3
  61. data/test/unit/product_test.rb +2 -2
  62. data/test/unit/tag_test.rb +2 -1
  63. data/test/unit/user_test.rb +17 -8
  64. metadata +54 -4
  65. data/lib/shoulda/controller.rb +0 -30
  66. data/lib/shoulda/controller/formats/html.rb +0 -201
  67. data/lib/shoulda/controller/formats/xml.rb +0 -170
  68. data/lib/shoulda/controller/helpers.rb +0 -64
  69. data/lib/shoulda/controller/macros.rb +0 -316
  70. data/lib/shoulda/controller/resource_options.rb +0 -236
  71. data/test/rails_root/app/models/dog.rb +0 -5
@@ -0,0 +1,6 @@
1
+ module CustomMacro
2
+ def custom_macro
3
+ end
4
+ end
5
+ Test::Unit::TestCase.extend(CustomMacro)
6
+
@@ -0,0 +1,6 @@
1
+ module GemMacro
2
+ def gem_macro
3
+ end
4
+ end
5
+ Test::Unit::TestCase.extend(GemMacro)
6
+
@@ -0,0 +1,6 @@
1
+ module PluginMacro
2
+ def plugin_macro
3
+ end
4
+ end
5
+ Test::Unit::TestCase.extend(PluginMacro)
6
+
data/test/test_helper.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'fileutils'
2
+
2
3
  # Load the environment
3
- ENV['RAILS_ENV'] = 'sqlite3'
4
+ ENV['RAILS_ENV'] = 'test'
4
5
 
5
6
  rails_root = File.dirname(__FILE__) + '/rails_root'
6
7
 
@@ -31,3 +32,4 @@ class Test::Unit::TestCase #:nodoc:
31
32
  end
32
33
 
33
34
  require 'test/fail_macros'
35
+ require 'test/model_builder'
@@ -4,7 +4,7 @@ class AddressTest < Test::Unit::TestCase
4
4
  fixtures :all
5
5
 
6
6
  should_belong_to :addressable
7
- should_require_unique_attributes :title, :scoped_to => [:addressable_id, :addressable_type]
7
+ should_validate_uniqueness_of :title, :scoped_to => [:addressable_id, :addressable_type]
8
8
  should_ensure_length_at_least :zip, 5
9
9
  should_only_allow_numeric_values_for :zip
10
10
  end
@@ -1,7 +1,10 @@
1
1
  require File.dirname(__FILE__) + '/../test_helper'
2
2
 
3
- class DogTest < Test::Unit::TestCase
3
+ class Pets::DogTest < Test::Unit::TestCase
4
4
  should_belong_to :user
5
- should_belong_to :address
5
+ should_belong_to :address, :dependent => :destroy
6
+ should_have_many :treats
6
7
  should_have_and_belong_to_many :fleas
8
+ should_require_attributes :treats, :fleas
9
+ should_validate_presence_of :owner_id
7
10
  end
@@ -9,7 +9,11 @@ class PostTest < Test::Unit::TestCase
9
9
  should_have_many :through_tags, :through => :taggings
10
10
 
11
11
  should_require_unique_attributes :title
12
- should_require_attributes :body, :message => /wtf/
13
- should_require_attributes :title
14
- should_only_allow_numeric_values_for :user_id
12
+ should_validate_presence_of :body, :message => /wtf/
13
+ should_validate_presence_of :title
14
+ should_validate_numericality_of :user_id
15
+
16
+ should_fail do
17
+ should_validate_uniqueness_of :title, :case_sensitive => false
18
+ end
15
19
  end
@@ -6,7 +6,7 @@ class ProductTest < ActiveSupport::TestCase
6
6
  @product = Product.new(:tangible => false)
7
7
  end
8
8
 
9
- should_require_attributes :title
9
+ should_validate_presence_of :title
10
10
  should_not_allow_values_for :size, "22"
11
11
  should_allow_values_for :size, "22kb"
12
12
  should_ensure_value_in_range :price, 0..99
@@ -17,7 +17,7 @@ class ProductTest < ActiveSupport::TestCase
17
17
  @product = Product.new(:tangible => true)
18
18
  end
19
19
 
20
- should_require_attributes :price
20
+ should_validate_presence_of :price
21
21
  should_ensure_value_in_range :price, 1..9999
22
22
  should_ensure_value_in_range :weight, 1..100
23
23
  should_not_allow_values_for :size, "22", "10x15"
@@ -7,8 +7,9 @@ class TagTest < Test::Unit::TestCase
7
7
  should_ensure_length_at_least :name, 2
8
8
 
9
9
  should_protect_attributes :secret
10
+ should_allow_mass_assignment_of :name
10
11
 
11
12
  should_fail do
12
- should_protect_attributes :name
13
+ should_not_allow_mass_assignment_of :name
13
14
  end
14
15
  end
@@ -12,8 +12,16 @@ class UserTest < Test::Unit::TestCase
12
12
  should_have_one :address
13
13
  should_have_one :address, :dependent => :destroy
14
14
 
15
- should_have_indices :email, :name, [:email, :name]
15
+ should_have_indices :email, :name
16
16
  should_have_index :age
17
+ should_have_index [:email, :name], :unique => true
18
+ should_have_index :age, :unique => false
19
+
20
+ should_fail do
21
+ should_have_index :phone
22
+ should_have_index :email, :unique => false
23
+ should_have_index :age, :unique => true
24
+ end
17
25
 
18
26
  should_have_named_scope :old, :conditions => "age > 50"
19
27
  should_have_named_scope :eighteen, :conditions => { :age => 18 }
@@ -31,22 +39,23 @@ class UserTest < Test::Unit::TestCase
31
39
  should_allow_values_for :email, "a@b.com", "asdf@asdf.com"
32
40
  should_ensure_length_in_range :email, 1..100
33
41
  should_ensure_value_in_range :age, 1..100
34
- should_protect_attributes :password
42
+ should_not_allow_mass_assignment_of :password
35
43
  should_have_class_methods :find, :destroy
36
44
  should_have_instance_methods :email, :age, :email=, :valid?
37
45
  should_have_db_columns :name, :email, :age
38
- should_have_db_column :id, :type => "integer", :primary => true
39
- should_have_db_column :email, :type => "string", :default => nil, :precision => nil, :limit => 255,
40
- :null => true, :primary => false, :scale => nil, :sql_type => 'varchar(255)'
46
+ should_have_db_column :id, :type => "integer"
47
+ should_have_db_column :email, :type => "string", :default => nil, :precision => nil, :limit => 255,
48
+ :null => true, :scale => nil
49
+ should_validate_acceptance_of :eula
41
50
  should_require_acceptance_of :eula
42
- should_require_unique_attributes :email, :scoped_to => :name
51
+ should_validate_uniqueness_of :email, :scoped_to => :name, :case_sensitive => false
43
52
 
44
53
  should_ensure_length_is :ssn, 9, :message => "Social Security Number is not the right length"
45
- should_only_allow_numeric_values_for :ssn
54
+ should_validate_numericality_of :ssn
46
55
 
47
56
  should_have_readonly_attributes :name
48
57
 
49
58
  should_fail do
50
- should_protect_attributes :name, :age
59
+ should_not_allow_mass_assignment_of :name, :age
51
60
  end
52
61
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rmm5t-shoulda
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.6
4
+ version: 2.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tammer Saleh
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-12-10 00:00:00 -08:00
12
+ date: 2009-02-04 00:00:00 -08:00
13
13
  default_executable: convert_to_should_syntax
14
14
  dependencies: []
15
15
 
@@ -34,9 +34,27 @@ files:
34
34
  - lib/shoulda/action_mailer.rb
35
35
  - lib/shoulda/active_record
36
36
  - lib/shoulda/active_record/assertions.rb
37
+ - lib/shoulda/active_record/helpers.rb
37
38
  - lib/shoulda/active_record/macros.rb
39
+ - lib/shoulda/active_record/matchers
40
+ - lib/shoulda/active_record/matchers/allow_mass_assignment_of_matcher.rb
41
+ - lib/shoulda/active_record/matchers/allow_value_matcher.rb
42
+ - lib/shoulda/active_record/matchers/association_matcher.rb
43
+ - lib/shoulda/active_record/matchers/ensure_inclusion_of_matcher.rb
44
+ - lib/shoulda/active_record/matchers/ensure_length_of_matcher.rb
45
+ - lib/shoulda/active_record/matchers/have_db_column_matcher.rb
46
+ - lib/shoulda/active_record/matchers/have_index_matcher.rb
47
+ - lib/shoulda/active_record/matchers/have_named_scope_matcher.rb
48
+ - lib/shoulda/active_record/matchers/have_readonly_attribute_matcher.rb
49
+ - lib/shoulda/active_record/matchers/validate_acceptance_of_matcher.rb
50
+ - lib/shoulda/active_record/matchers/validate_numericality_of_matcher.rb
51
+ - lib/shoulda/active_record/matchers/validate_presence_of_matcher.rb
52
+ - lib/shoulda/active_record/matchers/validate_uniqueness_of_matcher.rb
53
+ - lib/shoulda/active_record/matchers/validation_matcher.rb
54
+ - lib/shoulda/active_record/matchers.rb
38
55
  - lib/shoulda/active_record.rb
39
56
  - lib/shoulda/assertions.rb
57
+ - lib/shoulda/autoload_macros.rb
40
58
  - lib/shoulda/context.rb
41
59
  - lib/shoulda/controller
42
60
  - lib/shoulda/controller/formats
@@ -51,10 +69,12 @@ files:
51
69
  - lib/shoulda/private_helpers.rb
52
70
  - lib/shoulda/proc_extensions.rb
53
71
  - lib/shoulda/rails.rb
72
+ - lib/shoulda/rspec.rb
54
73
  - lib/shoulda/tasks
55
74
  - lib/shoulda/tasks/list_tests.rake
56
75
  - lib/shoulda/tasks/yaml_to_shoulda.rake
57
76
  - lib/shoulda/tasks.rb
77
+ - lib/shoulda/test_unit.rb
58
78
  - lib/shoulda.rb
59
79
  - rails/init.rb
60
80
  - test/fail_macros.rb
@@ -69,7 +89,23 @@ files:
69
89
  - test/functional
70
90
  - test/functional/posts_controller_test.rb
71
91
  - test/functional/users_controller_test.rb
92
+ - test/matchers
93
+ - test/matchers/allow_mass_assignment_of_matcher_test.rb
94
+ - test/matchers/allow_value_matcher_test.rb
95
+ - test/matchers/association_matcher_test.rb
96
+ - test/matchers/ensure_inclusion_of_matcher_test.rb
97
+ - test/matchers/ensure_length_of_matcher_test.rb
98
+ - test/matchers/have_db_column_matcher_test.rb
99
+ - test/matchers/have_index_matcher_test.rb
100
+ - test/matchers/have_named_scope_matcher_test.rb
101
+ - test/matchers/have_readonly_attributes_matcher_test.rb
102
+ - test/matchers/validate_acceptance_of_matcher_test.rb
103
+ - test/matchers/validate_numericality_of_matcher_test.rb
104
+ - test/matchers/validate_presence_of_matcher_test.rb
105
+ - test/matchers/validate_uniqueness_of_matcher_test.rb
106
+ - test/model_builder.rb
72
107
  - test/other
108
+ - test/other/autoload_macro_test.rb
73
109
  - test/other/context_test.rb
74
110
  - test/other/convert_to_should_syntax_test.rb
75
111
  - test/other/helpers_test.rb
@@ -87,13 +123,15 @@ files:
87
123
  - test/rails_root/app/helpers/users_helper.rb
88
124
  - test/rails_root/app/models
89
125
  - test/rails_root/app/models/address.rb
90
- - test/rails_root/app/models/dog.rb
91
126
  - test/rails_root/app/models/flea.rb
92
127
  - test/rails_root/app/models/friendship.rb
128
+ - test/rails_root/app/models/pets
129
+ - test/rails_root/app/models/pets/dog.rb
93
130
  - test/rails_root/app/models/post.rb
94
131
  - test/rails_root/app/models/product.rb
95
132
  - test/rails_root/app/models/tag.rb
96
133
  - test/rails_root/app/models/tagging.rb
134
+ - test/rails_root/app/models/treat.rb
97
135
  - test/rails_root/app/models/user.rb
98
136
  - test/rails_root/app/views
99
137
  - test/rails_root/app/views/layouts
@@ -115,7 +153,7 @@ files:
115
153
  - test/rails_root/config/database.yml
116
154
  - test/rails_root/config/environment.rb
117
155
  - test/rails_root/config/environments
118
- - test/rails_root/config/environments/sqlite3.rb
156
+ - test/rails_root/config/environments/test.rb
119
157
  - test/rails_root/config/initializers
120
158
  - test/rails_root/config/initializers/new_rails_defaults.rb
121
159
  - test/rails_root/config/initializers/shoulda.rb
@@ -132,9 +170,11 @@ files:
132
170
  - test/rails_root/db/migrate/008_create_dogs_fleas.rb
133
171
  - test/rails_root/db/migrate/009_create_products.rb
134
172
  - test/rails_root/db/migrate/010_create_friendships.rb
173
+ - test/rails_root/db/migrate/011_create_treats.rb
135
174
  - test/rails_root/db/schema.rb
136
175
  - test/rails_root/log
137
176
  - test/rails_root/log/sqlite3.log
177
+ - test/rails_root/log/test.log
138
178
  - test/rails_root/public
139
179
  - test/rails_root/public/404.html
140
180
  - test/rails_root/public/422.html
@@ -142,8 +182,18 @@ files:
142
182
  - test/rails_root/script
143
183
  - test/rails_root/script/console
144
184
  - test/rails_root/script/generate
185
+ - test/rails_root/test
186
+ - test/rails_root/test/shoulda_macros
187
+ - test/rails_root/test/shoulda_macros/custom_macro.rb
145
188
  - test/rails_root/vendor
189
+ - test/rails_root/vendor/gems
190
+ - test/rails_root/vendor/gems/gem_with_macro-0.0.1
191
+ - test/rails_root/vendor/gems/gem_with_macro-0.0.1/shoulda_macros
192
+ - test/rails_root/vendor/gems/gem_with_macro-0.0.1/shoulda_macros/gem_macro.rb
146
193
  - test/rails_root/vendor/plugins
194
+ - test/rails_root/vendor/plugins/plugin_with_macro
195
+ - test/rails_root/vendor/plugins/plugin_with_macro/shoulda_macros
196
+ - test/rails_root/vendor/plugins/plugin_with_macro/shoulda_macros/plugin_macro.rb
147
197
  - test/README
148
198
  - test/test_helper.rb
149
199
  - test/unit
@@ -1,30 +0,0 @@
1
- require 'shoulda'
2
- require 'shoulda/controller/helpers'
3
- require 'shoulda/controller/resource_options'
4
- require 'shoulda/controller/macros'
5
-
6
- module Test # :nodoc: all
7
- module Unit
8
- class TestCase
9
- extend ThoughtBot::Shoulda::Controller::Macros
10
- include ThoughtBot::Shoulda::Controller::Helpers
11
- ThoughtBot::Shoulda::Controller::VALID_FORMATS.each do |format|
12
- include "ThoughtBot::Shoulda::Controller::#{format.to_s.upcase}".constantize
13
- end
14
- end
15
- end
16
- end
17
-
18
- require 'shoulda/active_record/assertions'
19
- require 'shoulda/action_mailer/assertions'
20
-
21
- module ActionController #:nodoc: all
22
- module Integration
23
- class Session
24
- include ThoughtBot::Shoulda::Assertions
25
- include ThoughtBot::Shoulda::Helpers
26
- include ThoughtBot::Shoulda::ActiveRecord::Assertions
27
- include ThoughtBot::Shoulda::ActionMailer::Assertions
28
- end
29
- end
30
- end
@@ -1,201 +0,0 @@
1
- module ThoughtBot # :nodoc:
2
- module Shoulda # :nodoc:
3
- module Controller # :nodoc:
4
- module HTML # :nodoc: all
5
- def self.included(other)
6
- other.class_eval do
7
- extend ThoughtBot::Shoulda::Controller::HTML::ClassMethods
8
- end
9
- end
10
-
11
- module ClassMethods
12
- def controller_name_from_class
13
- self.name.gsub(/Test/, '')
14
- end
15
-
16
- def make_show_html_tests(res)
17
- context "on GET to #{controller_name_from_class}#show" do
18
- setup do
19
- record = get_existing_record(res)
20
- parent_params = make_parent_params(res, record)
21
- get :show, parent_params.merge({ res.identifier => record.to_param })
22
- end
23
-
24
- if res.denied.actions.include?(:show)
25
- should_not_assign_to res.object
26
- should_redirect_to res.denied.redirect
27
- should_set_the_flash_to res.denied.flash
28
- else
29
- should_assign_to res.object
30
- should_respond_with :success
31
- should_render_template :show
32
- should_not_set_the_flash
33
- end
34
- end
35
- end
36
-
37
- def make_edit_html_tests(res)
38
- context "on GET to #{controller_name_from_class}#edit" do
39
- setup do
40
- @record = get_existing_record(res)
41
- parent_params = make_parent_params(res, @record)
42
- get :edit, parent_params.merge({ res.identifier => @record.to_param })
43
- end
44
-
45
- if res.denied.actions.include?(:edit)
46
- should_not_assign_to res.object
47
- should_redirect_to res.denied.redirect
48
- should_set_the_flash_to res.denied.flash
49
- else
50
- should_assign_to res.object
51
- should_respond_with :success
52
- should_render_template :edit
53
- should_not_set_the_flash
54
- should_render_a_form
55
- should "set @#{res.object} to requested instance" do
56
- assert_equal @record, assigns(res.object)
57
- end
58
- end
59
- end
60
- end
61
-
62
- def make_index_html_tests(res)
63
- context "on GET to #{controller_name_from_class}#index" do
64
- setup do
65
- record = get_existing_record(res) rescue nil
66
- parent_params = make_parent_params(res, record)
67
- get(:index, parent_params)
68
- end
69
-
70
- if res.denied.actions.include?(:index)
71
- should_not_assign_to res.object.to_s.pluralize
72
- should_redirect_to res.denied.redirect
73
- should_set_the_flash_to res.denied.flash
74
- else
75
- should_respond_with :success
76
- should_assign_to res.object.to_s.pluralize
77
- should_render_template :index
78
- should_not_set_the_flash
79
- end
80
- end
81
- end
82
-
83
- def make_new_html_tests(res)
84
- context "on GET to #{controller_name_from_class}#new" do
85
- setup do
86
- record = get_existing_record(res) rescue nil
87
- parent_params = make_parent_params(res, record)
88
- get(:new, parent_params)
89
- end
90
-
91
- if res.denied.actions.include?(:new)
92
- should_not_assign_to res.object
93
- should_redirect_to res.denied.redirect
94
- should_set_the_flash_to res.denied.flash
95
- else
96
- should_respond_with :success
97
- should_assign_to res.object
98
- should_not_set_the_flash
99
- should_render_template :new
100
- should_render_a_form
101
- end
102
- end
103
- end
104
-
105
- def make_destroy_html_tests(res)
106
- context "on DELETE to #{controller_name_from_class}#destroy" do
107
- setup do
108
- @record = get_existing_record(res)
109
- parent_params = make_parent_params(res, @record)
110
- delete :destroy, parent_params.merge({ res.identifier => @record.to_param })
111
- end
112
-
113
- if res.denied.actions.include?(:destroy)
114
- should_redirect_to res.denied.redirect
115
- should_set_the_flash_to res.denied.flash
116
-
117
- should "not destroy record" do
118
- assert_nothing_raised { assert @record.reload }
119
- end
120
- else
121
- should_set_the_flash_to res.destroy.flash
122
- if res.destroy.redirect.is_a? Symbol
123
- should_respond_with res.destroy.redirect
124
- else
125
- should_redirect_to res.destroy.redirect
126
- end
127
-
128
- should "destroy record" do
129
- assert_raises(::ActiveRecord::RecordNotFound, "@#{res.object} was not destroyed.") do
130
- @record.reload
131
- end
132
- end
133
- end
134
- end
135
- end
136
-
137
- def make_create_html_tests(res)
138
- context "on POST to #{controller_name_from_class}#create with #{res.create.params.inspect}" do
139
- setup do
140
- record = get_existing_record(res) rescue nil
141
- parent_params = make_parent_params(res, record)
142
- @count = res.klass.count
143
- post :create, parent_params.merge(res.object => res.create.params)
144
- end
145
-
146
- if res.denied.actions.include?(:create)
147
- should_redirect_to res.denied.redirect
148
- should_set_the_flash_to res.denied.flash
149
- should_not_assign_to res.object
150
-
151
- should "not create new record" do
152
- assert_equal @count, res.klass.count
153
- end
154
- else
155
- should_assign_to res.object
156
- should_set_the_flash_to res.create.flash
157
- if res.create.redirect.is_a? Symbol
158
- should_respond_with res.create.redirect
159
- else
160
- should_redirect_to res.create.redirect
161
- end
162
-
163
- should "not have errors on @#{res.object}" do
164
- assert_equal [], pretty_error_messages(assigns(res.object)), "@#{res.object} has errors:"
165
- end
166
- end
167
- end
168
- end
169
-
170
- def make_update_html_tests(res)
171
- context "on PUT to #{controller_name_from_class}#update with #{res.create.params.inspect}" do
172
- setup do
173
- @record = get_existing_record(res)
174
- parent_params = make_parent_params(res, @record)
175
- put :update, parent_params.merge(res.identifier => @record.to_param, res.object => res.update.params)
176
- end
177
-
178
- if res.denied.actions.include?(:update)
179
- should_not_assign_to res.object
180
- should_redirect_to res.denied.redirect
181
- should_set_the_flash_to res.denied.flash
182
- else
183
- should_assign_to res.object
184
- should_set_the_flash_to(res.update.flash)
185
- if res.update.redirect.is_a? Symbol
186
- should_respond_with res.update.redirect
187
- else
188
- should_redirect_to res.update.redirect
189
- end
190
-
191
- should "not have errors on @#{res.object}" do
192
- assert_equal [], pretty_error_messages(assigns(res.object)), "@#{res.object} has errors:"
193
- end
194
- end
195
- end
196
- end
197
- end
198
- end
199
- end
200
- end
201
- end