Commit 6abd4658ce0f486cec29b70f57bd582c5d59da9d
1 parent
057e255f
Exists in
master
and in
27 other branches
rails3: fix mass-assignment errors on functional tests
Showing
38 changed files
with
173 additions
and
153 deletions
Show diff stats
app/controllers/my_profile/cms_controller.rb
@@ -166,7 +166,7 @@ class CmsController < MyProfileController | @@ -166,7 +166,7 @@ class CmsController < MyProfileController | ||
166 | end | 166 | end |
167 | if request.post? && params[:uploaded_files] | 167 | if request.post? && params[:uploaded_files] |
168 | params[:uploaded_files].each do |file| | 168 | params[:uploaded_files].each do |file| |
169 | - @uploaded_files << UploadedFile.create(:uploaded_data => file, :profile => profile, :parent => @parent, :last_changed_by => user) unless file == '' | 169 | + @uploaded_files << UploadedFile.create({:uploaded_data => file, :profile => profile, :parent => @parent, :last_changed_by => user}, :without_protection => true) unless file == '' |
170 | end | 170 | end |
171 | @errors = @uploaded_files.select { |f| f.errors.any? } | 171 | @errors = @uploaded_files.select { |f| f.errors.any? } |
172 | if @errors.any? | 172 | if @errors.any? |
app/controllers/my_profile/manage_products_controller.rb
@@ -85,7 +85,7 @@ class ManageProductsController < ApplicationController | @@ -85,7 +85,7 @@ class ManageProductsController < ApplicationController | ||
85 | @edit = true | 85 | @edit = true |
86 | @level = @category.level | 86 | @level = @category.level |
87 | if request.post? | 87 | if request.post? |
88 | - if @product.update_attributes(:product_category_id => params[:selected_category_id]) | 88 | + if @product.update_attributes({:product_category_id => params[:selected_category_id]}, :without_protection => true) |
89 | render :partial => 'shared/redirect_via_javascript', | 89 | render :partial => 'shared/redirect_via_javascript', |
90 | :locals => { :url => url_for(:controller => 'manage_products', :action => 'show', :id => @product) } | 90 | :locals => { :url => url_for(:controller => 'manage_products', :action => 'show', :id => @product) } |
91 | else | 91 | else |
app/models/article.rb
@@ -2,7 +2,7 @@ require 'hpricot' | @@ -2,7 +2,7 @@ require 'hpricot' | ||
2 | 2 | ||
3 | class Article < ActiveRecord::Base | 3 | class Article < ActiveRecord::Base |
4 | 4 | ||
5 | - attr_accessible :name, :body, :abstract, :profile, :tag_list, :parent | 5 | + attr_accessible :name, :body, :abstract, :profile, :tag_list, :parent, :allow_members_to_edit, :translation_of_id, :language, :license_id, :parent_id, :display_posts_in_current_language, :category_ids, :posts_per_page, :moderate_comments, :accept_comments, :feed, :published, :source, :highlighted |
6 | 6 | ||
7 | acts_as_having_image | 7 | acts_as_having_image |
8 | 8 |
app/models/article_block.rb
app/models/block.rb
1 | class Block < ActiveRecord::Base | 1 | class Block < ActiveRecord::Base |
2 | 2 | ||
3 | - attr_accessible :title, :display | 3 | + attr_accessible :title, :display, :limit, :box_id |
4 | 4 | ||
5 | # to be able to generate HTML | 5 | # to be able to generate HTML |
6 | include ActionView::Helpers::UrlHelper | 6 | include ActionView::Helpers::UrlHelper |
app/models/blog.rb
app/models/category.rb
app/models/comment.rb
@@ -6,6 +6,8 @@ class Comment < ActiveRecord::Base | @@ -6,6 +6,8 @@ class Comment < ActiveRecord::Base | ||
6 | :body => 2, | 6 | :body => 2, |
7 | } | 7 | } |
8 | 8 | ||
9 | + attr_accessible :body, :author, :name, :email, :title, :reply_of_id | ||
10 | + | ||
9 | validates_presence_of :body | 11 | validates_presence_of :body |
10 | 12 | ||
11 | belongs_to :source, :counter_cache => true, :polymorphic => true | 13 | belongs_to :source, :counter_cache => true, :polymorphic => true |
app/models/environment.rb
@@ -3,7 +3,7 @@ | @@ -3,7 +3,7 @@ | ||
3 | # domains. | 3 | # domains. |
4 | class Environment < ActiveRecord::Base | 4 | class Environment < ActiveRecord::Base |
5 | 5 | ||
6 | - attr_accessible :name, :is_default | 6 | + attr_accessible :name, :is_default, :signup_welcome_text_subject, :signup_welcome_text_body, :terms_of_use, :message_for_disabled_enterprise, :news_amount_by_folder, :default_language, :languages, :description, :organization_approval_method, :enabled_plugins |
7 | 7 | ||
8 | has_many :users | 8 | has_many :users |
9 | 9 |
app/models/input.rb
app/models/organization.rb
1 | # Represents any organization of the system | 1 | # Represents any organization of the system |
2 | class Organization < Profile | 2 | class Organization < Profile |
3 | 3 | ||
4 | + attr_accessible :moderated_articles | ||
5 | + | ||
4 | SEARCH_FILTERS += %w[ | 6 | SEARCH_FILTERS += %w[ |
5 | more_popular | 7 | more_popular |
6 | more_active | 8 | more_active |
app/models/person.rb
1 | # A person is the profile of an user holding all relationships with the rest of the system | 1 | # A person is the profile of an user holding all relationships with the rest of the system |
2 | class Person < Profile | 2 | class Person < Profile |
3 | 3 | ||
4 | + attr_accessible :organization | ||
5 | + | ||
4 | SEARCH_FILTERS += %w[ | 6 | SEARCH_FILTERS += %w[ |
5 | more_popular | 7 | more_popular |
6 | more_active | 8 | more_active |
app/models/product.rb
@@ -11,7 +11,7 @@ class Product < ActiveRecord::Base | @@ -11,7 +11,7 @@ class Product < ActiveRecord::Base | ||
11 | 11 | ||
12 | SEARCH_DISPLAYS = %w[map full] | 12 | SEARCH_DISPLAYS = %w[map full] |
13 | 13 | ||
14 | - attr_accessible :name, :product_category | 14 | + attr_accessible :name, :product_category, :highlighted, :price |
15 | 15 | ||
16 | def self.default_search_display | 16 | def self.default_search_display |
17 | 'full' | 17 | 'full' |
app/models/production_cost.rb
1 | class ProductionCost < ActiveRecord::Base | 1 | class ProductionCost < ActiveRecord::Base |
2 | 2 | ||
3 | + attr_accessible :name | ||
4 | + | ||
3 | belongs_to :owner, :polymorphic => true | 5 | belongs_to :owner, :polymorphic => true |
4 | validates_presence_of :owner | 6 | validates_presence_of :owner |
5 | validates_presence_of :name | 7 | validates_presence_of :name |
app/models/products_block.rb
1 | class ProductsBlock < Block | 1 | class ProductsBlock < Block |
2 | 2 | ||
3 | + attr_accessible :product_ids | ||
4 | + | ||
3 | include ActionView::Helpers::TagHelper | 5 | include ActionView::Helpers::TagHelper |
4 | include ActionView::Helpers::UrlHelper | 6 | include ActionView::Helpers::UrlHelper |
5 | include ActionView::Helpers | 7 | include ActionView::Helpers |
app/models/profile.rb
@@ -3,7 +3,7 @@ | @@ -3,7 +3,7 @@ | ||
3 | # which by default is the one returned by Environment:default. | 3 | # which by default is the one returned by Environment:default. |
4 | class Profile < ActiveRecord::Base | 4 | class Profile < ActiveRecord::Base |
5 | 5 | ||
6 | - attr_accessible :name, :identifier, :public_profile, :nickname, :custom_footer, :custom_header, :address, :zip_code, :contact_phone | 6 | + attr_accessible :name, :identifier, :public_profile, :nickname, :custom_footer, :custom_header, :address, :zip_code, :contact_phone, :image_builder, :description, :closed |
7 | 7 | ||
8 | # use for internationalizable human type names in search facets | 8 | # use for internationalizable human type names in search facets |
9 | # reimplement on subclasses | 9 | # reimplement on subclasses |
app/models/rss_feed.rb
app/models/state.rb
app/models/uploaded_file.rb
@@ -6,7 +6,7 @@ require 'short_filename' | @@ -6,7 +6,7 @@ require 'short_filename' | ||
6 | # of the file itself is kept. (FIXME?) | 6 | # of the file itself is kept. (FIXME?) |
7 | class UploadedFile < Article | 7 | class UploadedFile < Article |
8 | 8 | ||
9 | - attr_accessible :uploaded_data | 9 | + attr_accessible :uploaded_data, :title |
10 | 10 | ||
11 | def self.type_name | 11 | def self.type_name |
12 | _('File') | 12 | _('File') |
app/models/validation_info.rb
1 | class ValidationInfo < ActiveRecord::Base | 1 | class ValidationInfo < ActiveRecord::Base |
2 | + | ||
3 | + attr_accessible :validation_methodology, :restrictions | ||
4 | + | ||
2 | validates_presence_of :validation_methodology | 5 | validates_presence_of :validation_methodology |
3 | 6 | ||
4 | belongs_to :organization | 7 | belongs_to :organization |
test/functional/account_controller_test.rb
@@ -102,7 +102,7 @@ class AccountControllerTest < ActionController::TestCase | @@ -102,7 +102,7 @@ class AccountControllerTest < ActionController::TestCase | ||
102 | 102 | ||
103 | def test_shoud_not_save_without_acceptance_of_terms_of_use_on_signup | 103 | def test_shoud_not_save_without_acceptance_of_terms_of_use_on_signup |
104 | assert_no_difference 'User.count' do | 104 | assert_no_difference 'User.count' do |
105 | - Environment.default.update_attributes(:terms_of_use => 'some terms ...') | 105 | + Environment.default.update_attribute(:terms_of_use, 'some terms ...') |
106 | new_user | 106 | new_user |
107 | assert_response :success | 107 | assert_response :success |
108 | assert_nil assigns(:register_pending) | 108 | assert_nil assigns(:register_pending) |
@@ -111,7 +111,7 @@ class AccountControllerTest < ActionController::TestCase | @@ -111,7 +111,7 @@ class AccountControllerTest < ActionController::TestCase | ||
111 | 111 | ||
112 | def test_shoud_save_with_acceptance_of_terms_of_use_on_signup | 112 | def test_shoud_save_with_acceptance_of_terms_of_use_on_signup |
113 | assert_difference 'User.count' do | 113 | assert_difference 'User.count' do |
114 | - Environment.default.update_attributes(:terms_of_use => 'some terms ...') | 114 | + Environment.default.update_attribute(:terms_of_use, 'some terms ...') |
115 | new_user(:terms_accepted => '1') | 115 | new_user(:terms_accepted => '1') |
116 | assert_response :success | 116 | assert_response :success |
117 | assert_not_nil assigns(:register_pending) | 117 | assert_not_nil assigns(:register_pending) |
test/functional/admin_panel_controller_test.rb
@@ -245,7 +245,7 @@ class AdminPanelControllerTest < ActionController::TestCase | @@ -245,7 +245,7 @@ class AdminPanelControllerTest < ActionController::TestCase | ||
245 | e = Environment.default | 245 | e = Environment.default |
246 | @controller.stubs(:environment).returns(e) | 246 | @controller.stubs(:environment).returns(e) |
247 | other_e = fast_create(Environment, :name => 'other environment') | 247 | other_e = fast_create(Environment, :name => 'other environment') |
248 | - c = Community.create!(:name => 'portal community', :environment => other_e) | 248 | + c = create(Community, :name => 'portal community', :environment => other_e) |
249 | 249 | ||
250 | post :set_portal_community, :portal_community_identifier => c.identifier | 250 | post :set_portal_community, :portal_community_identifier => c.identifier |
251 | e.reload | 251 | e.reload |
test/functional/application_controller_test.rb
@@ -174,8 +174,8 @@ class ApplicationControllerTest < ActionController::TestCase | @@ -174,8 +174,8 @@ class ApplicationControllerTest < ActionController::TestCase | ||
174 | 174 | ||
175 | should 'display only some categories in menu' do | 175 | should 'display only some categories in menu' do |
176 | @controller.stubs(:get_layout).returns('application') | 176 | @controller.stubs(:get_layout).returns('application') |
177 | - c1 = Environment.default.categories.create!(:name => 'Category 1', :display_color => 1, :parent => nil, :display_in_menu => true ) | ||
178 | - c2 = Environment.default.categories.create!(:name => 'Category 2', :display_color => nil, :parent => c1, :display_in_menu => true ) | 177 | + c1 = Environment.default.categories.create!(:name => 'Category 1', :display_color => 1, :parent_id => nil, :display_in_menu => true ) |
178 | + c2 = Environment.default.categories.create!(:name => 'Category 2', :display_color => nil, :parent_id => c1.id, :display_in_menu => true ) | ||
179 | get :index | 179 | get :index |
180 | assert_tag :tag => 'a', :content => /Category 2/ | 180 | assert_tag :tag => 'a', :content => /Category 2/ |
181 | end | 181 | end |
@@ -247,8 +247,8 @@ class ApplicationControllerTest < ActionController::TestCase | @@ -247,8 +247,8 @@ class ApplicationControllerTest < ActionController::TestCase | ||
247 | 247 | ||
248 | should 'not display categories menu if categories feature disabled' do | 248 | should 'not display categories menu if categories feature disabled' do |
249 | Environment.any_instance.stubs(:enabled?).with(anything).returns(true) | 249 | Environment.any_instance.stubs(:enabled?).with(anything).returns(true) |
250 | - c1 = Environment.default.categories.create!(:name => 'Category 1', :display_color => 1, :parent => nil, :display_in_menu => true ) | ||
251 | - c2 = Environment.default.categories.create!(:name => 'Category 2', :display_color => nil, :parent => c1, :display_in_menu => true ) | 250 | + c1 = Environment.default.categories.create!(:name => 'Category 1', :display_color => 1, :parent_id => nil, :display_in_menu => true ) |
251 | + c2 = Environment.default.categories.create!(:name => 'Category 2', :display_color => nil, :parent_id => c1.id, :display_in_menu => true ) | ||
252 | get :index | 252 | get :index |
253 | assert_no_tag :tag => 'a', :content => /Category 2/ | 253 | assert_no_tag :tag => 'a', :content => /Category 2/ |
254 | end | 254 | end |
test/functional/catalog_controller_test.rb
@@ -104,10 +104,10 @@ class CatalogControllerTest < ActionController::TestCase | @@ -104,10 +104,10 @@ class CatalogControllerTest < ActionController::TestCase | ||
104 | end | 104 | end |
105 | 105 | ||
106 | should 'get categories of the right level' do | 106 | should 'get categories of the right level' do |
107 | - pc1 = ProductCategory.create!(:name => "PC1", :environment => @enterprise.environment) | ||
108 | - pc2 = ProductCategory.create!(:name => "PC2", :environment => @enterprise.environment, :parent_id => pc1.id) | ||
109 | - pc3 = ProductCategory.create!(:name => "PC3", :environment => @enterprise.environment, :parent_id => pc1.id) | ||
110 | - pc4 = ProductCategory.create!(:name => "PC4", :environment => @enterprise.environment, :parent_id => pc2.id) | 107 | + pc1 = create(ProductCategory, :name => "PC1", :environment => @enterprise.environment) |
108 | + pc2 = create(ProductCategory, :name => "PC2", :environment => @enterprise.environment, :parent_id => pc1.id) | ||
109 | + pc3 = create(ProductCategory, :name => "PC3", :environment => @enterprise.environment, :parent_id => pc1.id) | ||
110 | + pc4 = create(ProductCategory, :name => "PC4", :environment => @enterprise.environment, :parent_id => pc2.id) | ||
111 | p1 = fast_create(Product, :product_category_id => pc1.id, :enterprise_id => @enterprise.id) | 111 | p1 = fast_create(Product, :product_category_id => pc1.id, :enterprise_id => @enterprise.id) |
112 | p2 = fast_create(Product, :product_category_id => pc2.id, :enterprise_id => @enterprise.id) | 112 | p2 = fast_create(Product, :product_category_id => pc2.id, :enterprise_id => @enterprise.id) |
113 | p3 = fast_create(Product, :product_category_id => pc3.id, :enterprise_id => @enterprise.id) | 113 | p3 = fast_create(Product, :product_category_id => pc3.id, :enterprise_id => @enterprise.id) |
@@ -122,10 +122,10 @@ class CatalogControllerTest < ActionController::TestCase | @@ -122,10 +122,10 @@ class CatalogControllerTest < ActionController::TestCase | ||
122 | end | 122 | end |
123 | 123 | ||
124 | should 'filter products based on level selected' do | 124 | should 'filter products based on level selected' do |
125 | - pc1 = ProductCategory.create!(:name => "PC1", :environment => @enterprise.environment) | ||
126 | - pc2 = ProductCategory.create!(:name => "PC2", :environment => @enterprise.environment, :parent_id => pc1.id) | ||
127 | - pc3 = ProductCategory.create!(:name => "PC3", :environment => @enterprise.environment, :parent_id => pc1.id) | ||
128 | - pc4 = ProductCategory.create!(:name => "PC4", :environment => @enterprise.environment, :parent_id => pc2.id) | 125 | + pc1 = create(ProductCategory, :name => "PC1", :environment => @enterprise.environment) |
126 | + pc2 = create(ProductCategory, :name => "PC2", :environment => @enterprise.environment, :parent_id => pc1.id) | ||
127 | + pc3 = create(ProductCategory, :name => "PC3", :environment => @enterprise.environment, :parent_id => pc1.id) | ||
128 | + pc4 = create(ProductCategory, :name => "PC4", :environment => @enterprise.environment, :parent_id => pc2.id) | ||
129 | p1 = fast_create(Product, :product_category_id => pc1.id, :enterprise_id => @enterprise.id) | 129 | p1 = fast_create(Product, :product_category_id => pc1.id, :enterprise_id => @enterprise.id) |
130 | p2 = fast_create(Product, :product_category_id => pc2.id, :enterprise_id => @enterprise.id) | 130 | p2 = fast_create(Product, :product_category_id => pc2.id, :enterprise_id => @enterprise.id) |
131 | p3 = fast_create(Product, :product_category_id => pc3.id, :enterprise_id => @enterprise.id) | 131 | p3 = fast_create(Product, :product_category_id => pc3.id, :enterprise_id => @enterprise.id) |
@@ -171,10 +171,10 @@ class CatalogControllerTest < ActionController::TestCase | @@ -171,10 +171,10 @@ class CatalogControllerTest < ActionController::TestCase | ||
171 | end | 171 | end |
172 | 172 | ||
173 | should 'display categories and sub-categories link' do | 173 | should 'display categories and sub-categories link' do |
174 | - pc1 = ProductCategory.create!(:name => "PC1", :environment => @enterprise.environment) | ||
175 | - pc2 = ProductCategory.create!(:name => "PC2", :environment => @enterprise.environment, :parent_id => pc1.id) | ||
176 | - pc3 = ProductCategory.create!(:name => "PC3", :environment => @enterprise.environment, :parent_id => pc1.id) | ||
177 | - pc4 = ProductCategory.create!(:name => "PC4", :environment => @enterprise.environment, :parent_id => pc2.id) | 174 | + pc1 = create(ProductCategory, :name => "PC1", :environment => @enterprise.environment) |
175 | + pc2 = create(ProductCategory, :name => "PC2", :environment => @enterprise.environment, :parent_id => pc1.id) | ||
176 | + pc3 = create(ProductCategory, :name => "PC3", :environment => @enterprise.environment, :parent_id => pc1.id) | ||
177 | + pc4 = create(ProductCategory, :name => "PC4", :environment => @enterprise.environment, :parent_id => pc2.id) | ||
178 | p1 = fast_create(Product, :product_category_id => pc1.id, :enterprise_id => @enterprise.id) | 178 | p1 = fast_create(Product, :product_category_id => pc1.id, :enterprise_id => @enterprise.id) |
179 | p2 = fast_create(Product, :product_category_id => pc2.id, :enterprise_id => @enterprise.id) | 179 | p2 = fast_create(Product, :product_category_id => pc2.id, :enterprise_id => @enterprise.id) |
180 | p3 = fast_create(Product, :product_category_id => pc3.id, :enterprise_id => @enterprise.id) | 180 | p3 = fast_create(Product, :product_category_id => pc3.id, :enterprise_id => @enterprise.id) |
@@ -190,10 +190,10 @@ class CatalogControllerTest < ActionController::TestCase | @@ -190,10 +190,10 @@ class CatalogControllerTest < ActionController::TestCase | ||
190 | 190 | ||
191 | 191 | ||
192 | should 'display categories on breadcrumb' do | 192 | should 'display categories on breadcrumb' do |
193 | - pc1 = ProductCategory.create!(:name => "PC1", :environment => @enterprise.environment) | ||
194 | - pc2 = ProductCategory.create!(:name => "PC2", :environment => @enterprise.environment, :parent_id => pc1.id) | ||
195 | - pc3 = ProductCategory.create!(:name => "PC3", :environment => @enterprise.environment, :parent_id => pc1.id) | ||
196 | - pc4 = ProductCategory.create!(:name => "PC4", :environment => @enterprise.environment, :parent_id => pc2.id) | 193 | + pc1 = create(ProductCategory, :name => "PC1", :environment => @enterprise.environment) |
194 | + pc2 = create(ProductCategory, :name => "PC2", :environment => @enterprise.environment, :parent_id => pc1.id) | ||
195 | + pc3 = create(ProductCategory, :name => "PC3", :environment => @enterprise.environment, :parent_id => pc1.id) | ||
196 | + pc4 = create(ProductCategory, :name => "PC4", :environment => @enterprise.environment, :parent_id => pc2.id) | ||
197 | p1 = fast_create(Product, :product_category_id => pc1.id, :enterprise_id => @enterprise.id) | 197 | p1 = fast_create(Product, :product_category_id => pc1.id, :enterprise_id => @enterprise.id) |
198 | p2 = fast_create(Product, :product_category_id => pc2.id, :enterprise_id => @enterprise.id) | 198 | p2 = fast_create(Product, :product_category_id => pc2.id, :enterprise_id => @enterprise.id) |
199 | p3 = fast_create(Product, :product_category_id => pc3.id, :enterprise_id => @enterprise.id) | 199 | p3 = fast_create(Product, :product_category_id => pc3.id, :enterprise_id => @enterprise.id) |
@@ -208,7 +208,7 @@ class CatalogControllerTest < ActionController::TestCase | @@ -208,7 +208,7 @@ class CatalogControllerTest < ActionController::TestCase | ||
208 | end | 208 | end |
209 | 209 | ||
210 | should 'add product status on the class css' do | 210 | should 'add product status on the class css' do |
211 | - category = ProductCategory.create!(:name => "Cateogry", :environment => @enterprise.environment) | 211 | + category = create(ProductCategory, :name => "Cateogry", :environment => @enterprise.environment) |
212 | p1 = fast_create(Product, :product_category_id => category.id, :enterprise_id => @enterprise.id, :highlighted => true) | 212 | p1 = fast_create(Product, :product_category_id => category.id, :enterprise_id => @enterprise.id, :highlighted => true) |
213 | p2 = fast_create(Product, :product_category_id => category.id, :enterprise_id => @enterprise.id, :available => false) | 213 | p2 = fast_create(Product, :product_category_id => category.id, :enterprise_id => @enterprise.id, :available => false) |
214 | 214 | ||
@@ -221,10 +221,10 @@ class CatalogControllerTest < ActionController::TestCase | @@ -221,10 +221,10 @@ class CatalogControllerTest < ActionController::TestCase | ||
221 | should 'sort categories by name' do | 221 | should 'sort categories by name' do |
222 | environment = @enterprise.environment | 222 | environment = @enterprise.environment |
223 | environment.categories.destroy_all | 223 | environment.categories.destroy_all |
224 | - pc1 = ProductCategory.create!(:name => "Drinks", :environment => environment) | ||
225 | - pc2 = ProductCategory.create!(:name => "Bananas", :environment => environment) | ||
226 | - pc3 = ProductCategory.create!(:name => "Sodas", :environment => environment) | ||
227 | - pc4 = ProductCategory.create!(:name => "Pies", :environment => environment) | 224 | + pc1 = create(ProductCategory, :name => "Drinks", :environment => environment) |
225 | + pc2 = create(ProductCategory, :name => "Bananas", :environment => environment) | ||
226 | + pc3 = create(ProductCategory, :name => "Sodas", :environment => environment) | ||
227 | + pc4 = create(ProductCategory, :name => "Pies", :environment => environment) | ||
228 | p1 = fast_create(Product, :product_category_id => pc1.id, :enterprise_id => @enterprise.id) | 228 | p1 = fast_create(Product, :product_category_id => pc1.id, :enterprise_id => @enterprise.id) |
229 | p2 = fast_create(Product, :product_category_id => pc2.id, :enterprise_id => @enterprise.id) | 229 | p2 = fast_create(Product, :product_category_id => pc2.id, :enterprise_id => @enterprise.id) |
230 | p3 = fast_create(Product, :product_category_id => pc3.id, :enterprise_id => @enterprise.id) | 230 | p3 = fast_create(Product, :product_category_id => pc3.id, :enterprise_id => @enterprise.id) |
@@ -240,8 +240,8 @@ class CatalogControllerTest < ActionController::TestCase | @@ -240,8 +240,8 @@ class CatalogControllerTest < ActionController::TestCase | ||
240 | p2 = fast_create(Product, :product_category_id => @product_category.id, :enterprise_id => @enterprise.id) | 240 | p2 = fast_create(Product, :product_category_id => @product_category.id, :enterprise_id => @enterprise.id) |
241 | Product.any_instance.stubs(:price_described?).returns(true) | 241 | Product.any_instance.stubs(:price_described?).returns(true) |
242 | production_cost = fast_create(ProductionCost) | 242 | production_cost = fast_create(ProductionCost) |
243 | - pd1 = PriceDetail.create!(:product => p1, :production_cost => production_cost) | ||
244 | - pd2 = PriceDetail.create!(:product => p2) | 243 | + pd1 = create(PriceDetail, :product => p1, :production_cost_id => production_cost.id) |
244 | + pd2 = create(PriceDetail, :product => p2) | ||
245 | 245 | ||
246 | get :index, :profile => @enterprise.identifier | 246 | get :index, :profile => @enterprise.identifier |
247 | 247 |
test/functional/categories_controller_test.rb
@@ -74,7 +74,7 @@ class CategoriesControllerTest < ActionController::TestCase | @@ -74,7 +74,7 @@ class CategoriesControllerTest < ActionController::TestCase | ||
74 | end | 74 | end |
75 | 75 | ||
76 | def test_remove | 76 | def test_remove |
77 | - cat = Category.create!(:name => 'a category to be removed', :environment_id => env.id) | 77 | + cat = create(Category, :name => 'a category to be removed', :environment_id => env.id) |
78 | post :remove, :id => cat.id | 78 | post :remove, :id => cat.id |
79 | assert_redirected_to :action => 'index' | 79 | assert_redirected_to :action => 'index' |
80 | assert_raise ActiveRecord::RecordNotFound do | 80 | assert_raise ActiveRecord::RecordNotFound do |
@@ -90,13 +90,13 @@ class CategoriesControllerTest < ActionController::TestCase | @@ -90,13 +90,13 @@ class CategoriesControllerTest < ActionController::TestCase | ||
90 | end | 90 | end |
91 | 91 | ||
92 | should 'expire categories menu cache when some menu category is updated' do | 92 | should 'expire categories menu cache when some menu category is updated' do |
93 | - cat = Category.create!(:name => 'test category in menu', :environment => Environment.default, :display_in_menu => true) | 93 | + cat = create(Category, :name => 'test category in menu', :environment => Environment.default, :display_in_menu => true) |
94 | @controller.expects(:expire_fragment).with(:controller => 'public', :action => 'categories_menu').at_least_once | 94 | @controller.expects(:expire_fragment).with(:controller => 'public', :action => 'categories_menu').at_least_once |
95 | post :edit, :id => cat.id, :category => { :name => 'new name for category in menu' } | 95 | post :edit, :id => cat.id, :category => { :name => 'new name for category in menu' } |
96 | end | 96 | end |
97 | 97 | ||
98 | should 'not touch categories menu cache whem updated category is not in menu' do | 98 | should 'not touch categories menu cache whem updated category is not in menu' do |
99 | - cat = Category.create!(:name => 'test category not in menu', :environment => Environment.default, :display_in_menu => false) | 99 | + cat = create(Category, :name => 'test category not in menu', :environment => Environment.default, :display_in_menu => false) |
100 | @controller.expects(:expire_fragment).with(:controller => 'public', :action => 'categories_menu').never | 100 | @controller.expects(:expire_fragment).with(:controller => 'public', :action => 'categories_menu').never |
101 | post :edit, :id => cat.id, :category => { :name => 'new name for category not in menu' } | 101 | post :edit, :id => cat.id, :category => { :name => 'new name for category not in menu' } |
102 | end | 102 | end |
@@ -107,7 +107,7 @@ class CategoriesControllerTest < ActionController::TestCase | @@ -107,7 +107,7 @@ class CategoriesControllerTest < ActionController::TestCase | ||
107 | end | 107 | end |
108 | 108 | ||
109 | should 'not handle cache when viewing "edit category" screen' do | 109 | should 'not handle cache when viewing "edit category" screen' do |
110 | - cat = Category.create!(:name => 'test category in menu', :environment => Environment.default, :display_in_menu => true) | 110 | + cat = create(Category, :name => 'test category in menu', :environment => Environment.default, :display_in_menu => true) |
111 | @controller.expects(:expire_fragment).with(:controller => 'public', :action => 'categories_menu').never | 111 | @controller.expects(:expire_fragment).with(:controller => 'public', :action => 'categories_menu').never |
112 | get :edit, :id => cat.id | 112 | get :edit, :id => cat.id |
113 | end | 113 | end |
@@ -123,7 +123,7 @@ class CategoriesControllerTest < ActionController::TestCase | @@ -123,7 +123,7 @@ class CategoriesControllerTest < ActionController::TestCase | ||
123 | end | 123 | end |
124 | 124 | ||
125 | should 'not expire cache when updating fails' do | 125 | should 'not expire cache when updating fails' do |
126 | - cat = Category.create!(:name => 'test category in menu', :environment => Environment.default, :display_in_menu => true) | 126 | + cat = create(Category, :name => 'test category in menu', :environment => Environment.default, :display_in_menu => true) |
127 | @controller.expects(:expire_fragment).with(:controller => 'public', :action => 'categories_menu').never | 127 | @controller.expects(:expire_fragment).with(:controller => 'public', :action => 'categories_menu').never |
128 | 128 | ||
129 | post :edit, :id => cat.id, :category => { :name => '' } | 129 | post :edit, :id => cat.id, :category => { :name => '' } |
@@ -155,9 +155,9 @@ class CategoriesControllerTest < ActionController::TestCase | @@ -155,9 +155,9 @@ class CategoriesControllerTest < ActionController::TestCase | ||
155 | 155 | ||
156 | should 'not list regions and product categories' do | 156 | should 'not list regions and product categories' do |
157 | Environment.default.categories.destroy_all | 157 | Environment.default.categories.destroy_all |
158 | - c = Category.create!(:name => 'Regular category', :environment => Environment.default) | ||
159 | - p = ProductCategory.create!(:name => 'Product category', :environment => Environment.default) | ||
160 | - r = Region.create!(:name => 'Some region', :environment => Environment.default) | 158 | + c = create(Category, :name => 'Regular category', :environment => Environment.default) |
159 | + p = create(ProductCategory, :name => 'Product category', :environment => Environment.default) | ||
160 | + r = create(Region, :name => 'Some region', :environment => Environment.default) | ||
161 | 161 | ||
162 | get :index | 162 | get :index |
163 | assert_equal [c], assigns(:categories) | 163 | assert_equal [c], assigns(:categories) |
@@ -166,7 +166,7 @@ class CategoriesControllerTest < ActionController::TestCase | @@ -166,7 +166,7 @@ class CategoriesControllerTest < ActionController::TestCase | ||
166 | end | 166 | end |
167 | 167 | ||
168 | should 'use parent\'s type to determine subcategory\'s type' do | 168 | should 'use parent\'s type to determine subcategory\'s type' do |
169 | - parent = ProductCategory.create!(:name => 'Sample category', :environment => Environment.default) | 169 | + parent = create(ProductCategory, :name => 'Sample category', :environment => Environment.default) |
170 | post :new, :parent_id => parent.id, :parent_type => parent.class.name, :category => {:name => 'Subcategory'} | 170 | post :new, :parent_id => parent.id, :parent_type => parent.class.name, :category => {:name => 'Subcategory'} |
171 | sub = ProductCategory.find_by_name('Subcategory') | 171 | sub = ProductCategory.find_by_name('Subcategory') |
172 | assert_equal parent.class, sub.class | 172 | assert_equal parent.class, sub.class |
test/functional/cms_controller_test.rb
@@ -284,7 +284,7 @@ class CmsControllerTest < ActionController::TestCase | @@ -284,7 +284,7 @@ class CmsControllerTest < ActionController::TestCase | ||
284 | 284 | ||
285 | should 'be able to update a RSS feed' do | 285 | should 'be able to update a RSS feed' do |
286 | login_as(profile.identifier) | 286 | login_as(profile.identifier) |
287 | - feed = RssFeed.create!(:name => 'myfeed', :limit => 5, :include => 'all', :profile_id => profile.id) | 287 | + feed = create(RssFeed, :name => 'myfeed', :limit => 5, :include => 'all', :profile_id => profile.id) |
288 | post :edit, :profile => profile.identifier, :id => feed.id, :article => { :limit => 77, :include => 'parent_and_children' } | 288 | post :edit, :profile => profile.identifier, :id => feed.id, :article => { :limit => 77, :include => 'parent_and_children' } |
289 | assert_response :redirect | 289 | assert_response :redirect |
290 | 290 | ||
@@ -585,7 +585,7 @@ class CmsControllerTest < ActionController::TestCase | @@ -585,7 +585,7 @@ class CmsControllerTest < ActionController::TestCase | ||
585 | 585 | ||
586 | should 'redirect back to article after editing article inside a folder' do | 586 | should 'redirect back to article after editing article inside a folder' do |
587 | f = Folder.new(:name => 'f'); profile.articles << f; f.save! | 587 | f = Folder.new(:name => 'f'); profile.articles << f; f.save! |
588 | - a = TextileArticle.create!(:parent => f, :name => 'article-inside-folder', :profile_id => profile.id) | 588 | + a = create(TextileArticle, :parent => f, :name => 'article-inside-folder', :profile_id => profile.id) |
589 | 589 | ||
590 | post :edit, :profile => profile.identifier, :id => a.id | 590 | post :edit, :profile => profile.identifier, :id => a.id |
591 | assert_redirected_to @profile.articles.find_by_name('article-inside-folder').url | 591 | assert_redirected_to @profile.articles.find_by_name('article-inside-folder').url |
@@ -612,7 +612,7 @@ class CmsControllerTest < ActionController::TestCase | @@ -612,7 +612,7 @@ class CmsControllerTest < ActionController::TestCase | ||
612 | 612 | ||
613 | should 'point back to folder when cancelling edition of an article inside it' do | 613 | should 'point back to folder when cancelling edition of an article inside it' do |
614 | f = Folder.new(:name => 'f'); profile.articles << f; f.save! | 614 | f = Folder.new(:name => 'f'); profile.articles << f; f.save! |
615 | - a = TextileArticle.create!(:name => 'test', :parent => f, :profile_id => profile.id) | 615 | + a = create(TextileArticle, :name => 'test', :parent => f, :profile_id => profile.id) |
616 | get :edit, :profile => profile.identifier, :id => a.id | 616 | get :edit, :profile => profile.identifier, :id => a.id |
617 | 617 | ||
618 | assert_tag :tag => 'a', :attributes => { :href => "/myprofile/#{profile.identifier}/cms/view/#{f.id}" }, :descendant => { :content => /Cancel/ } | 618 | assert_tag :tag => 'a', :attributes => { :href => "/myprofile/#{profile.identifier}/cms/view/#{f.id}" }, :descendant => { :content => /Cancel/ } |
@@ -641,7 +641,7 @@ class CmsControllerTest < ActionController::TestCase | @@ -641,7 +641,7 @@ class CmsControllerTest < ActionController::TestCase | ||
641 | end | 641 | end |
642 | 642 | ||
643 | should "display properly a non-published articles' status" do | 643 | should "display properly a non-published articles' status" do |
644 | - article = profile.articles.create!(:name => 'test', :published => false) | 644 | + article = create(Article, :profile => profile, :name => 'test', :published => false) |
645 | 645 | ||
646 | get :edit, :profile => profile.identifier, :id => article.id | 646 | get :edit, :profile => profile.identifier, :id => article.id |
647 | assert_tag :tag => 'input', :attributes => { :type => 'radio', :name => 'article[published]', :id => 'article_published_true' } | 647 | assert_tag :tag => 'input', :attributes => { :type => 'radio', :name => 'article[published]', :id => 'article_published_true' } |
@@ -734,7 +734,7 @@ class CmsControllerTest < ActionController::TestCase | @@ -734,7 +734,7 @@ class CmsControllerTest < ActionController::TestCase | ||
734 | end | 734 | end |
735 | 735 | ||
736 | should 'create a private article child of private folder' do | 736 | should 'create a private article child of private folder' do |
737 | - folder = Folder.new(:name => 'my intranet', :published => false); profile.articles << folder; folder.save! | 737 | + folder = build(Folder, :name => 'my intranet', :published => false); profile.articles << folder; folder.save! |
738 | 738 | ||
739 | post :new, :profile => profile.identifier, :type => 'TextileArticle', :parent_id => folder.id, :article => { :name => 'new-private-article'} | 739 | post :new, :profile => profile.identifier, :type => 'TextileArticle', :parent_id => folder.id, :article => { :name => 'new-private-article'} |
740 | folder.reload | 740 | folder.reload |
@@ -901,7 +901,7 @@ class CmsControllerTest < ActionController::TestCase | @@ -901,7 +901,7 @@ class CmsControllerTest < ActionController::TestCase | ||
901 | end | 901 | end |
902 | 902 | ||
903 | should 'remove the image of an article' do | 903 | should 'remove the image of an article' do |
904 | - blog = Blog.create(:profile_id => profile.id, :name=>'testblog', :image_builder => { :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')}) | 904 | + blog = create(Blog, :profile_id => profile.id, :name=>'testblog', :image_builder => { :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')}) |
905 | blog.save! | 905 | blog.save! |
906 | post :edit, :profile => profile.identifier, :id => blog.id, :remove_image => 'true' | 906 | post :edit, :profile => profile.identifier, :id => blog.id, :remove_image => 'true' |
907 | blog.reload | 907 | blog.reload |
@@ -1194,7 +1194,7 @@ class CmsControllerTest < ActionController::TestCase | @@ -1194,7 +1194,7 @@ class CmsControllerTest < ActionController::TestCase | ||
1194 | should 'not allow user edit article if he is owner but has no publish permission' do | 1194 | should 'not allow user edit article if he is owner but has no publish permission' do |
1195 | c = Community.create!(:name => 'test_comm', :identifier => 'test_comm') | 1195 | c = Community.create!(:name => 'test_comm', :identifier => 'test_comm') |
1196 | u = create_user_with_permission('test_user', 'bogus_permission', c) | 1196 | u = create_user_with_permission('test_user', 'bogus_permission', c) |
1197 | - a = c.articles.create!(:name => 'test_article', :last_changed_by => u) | 1197 | + a = create(Article, :profile => c, :name => 'test_article', :last_changed_by => u) |
1198 | login_as :test_user | 1198 | login_as :test_user |
1199 | 1199 | ||
1200 | get :edit, :profile => c.identifier, :id => a.id | 1200 | get :edit, :profile => c.identifier, :id => a.id |
@@ -1205,7 +1205,7 @@ class CmsControllerTest < ActionController::TestCase | @@ -1205,7 +1205,7 @@ class CmsControllerTest < ActionController::TestCase | ||
1205 | should 'allow user edit article if he is owner and has publish permission' do | 1205 | should 'allow user edit article if he is owner and has publish permission' do |
1206 | c = Community.create!(:name => 'test_comm', :identifier => 'test_comm') | 1206 | c = Community.create!(:name => 'test_comm', :identifier => 'test_comm') |
1207 | u = create_user_with_permission('test_user', 'publish_content', c) | 1207 | u = create_user_with_permission('test_user', 'publish_content', c) |
1208 | - a = c.articles.create!(:name => 'test_article', :last_changed_by => u) | 1208 | + a = create(Article, :profile => c, :name => 'test_article', :last_changed_by => u) |
1209 | login_as :test_user | 1209 | login_as :test_user |
1210 | @controller.stubs(:user).returns(u) | 1210 | @controller.stubs(:user).returns(u) |
1211 | 1211 |
test/functional/comment_controller_test.rb
@@ -266,7 +266,7 @@ class CommentControllerTest < ActionController::TestCase | @@ -266,7 +266,7 @@ class CommentControllerTest < ActionController::TestCase | ||
266 | should 'not create ApproveComment task when the comment author is the same of article author' do | 266 | should 'not create ApproveComment task when the comment author is the same of article author' do |
267 | login_as @profile.identifier | 267 | login_as @profile.identifier |
268 | community = Community.create!(:name => 'testcomm') | 268 | community = Community.create!(:name => 'testcomm') |
269 | - page = community.articles.create!(:name => 'myarticle', :moderate_comments => true, :last_changed_by => @profile) | 269 | + page = create(Article, :profile => community, :name => 'myarticle', :moderate_comments => true, :last_changed_by => @profile) |
270 | community.add_moderator(@profile) | 270 | community.add_moderator(@profile) |
271 | 271 | ||
272 | assert_no_difference 'ApproveComment.count' do | 272 | assert_no_difference 'ApproveComment.count' do |
@@ -381,7 +381,7 @@ class CommentControllerTest < ActionController::TestCase | @@ -381,7 +381,7 @@ class CommentControllerTest < ActionController::TestCase | ||
381 | should 'touch article after adding a comment' do | 381 | should 'touch article after adding a comment' do |
382 | yesterday = Time.now.yesterday | 382 | yesterday = Time.now.yesterday |
383 | Article.record_timestamps = false | 383 | Article.record_timestamps = false |
384 | - page = profile.articles.create(:name => 'myarticle', :body => 'the body of the text', :created_at => yesterday, :updated_at => yesterday) | 384 | + page = create(Article, :profile => profile, :name => 'myarticle', :body => 'the body of the text', :created_at => yesterday, :updated_at => yesterday) |
385 | Article.record_timestamps = true | 385 | Article.record_timestamps = true |
386 | 386 | ||
387 | login_as @profile.identifier | 387 | login_as @profile.identifier |
test/functional/content_viewer_controller_test.rb
@@ -122,7 +122,7 @@ class ContentViewerControllerTest < ActionController::TestCase | @@ -122,7 +122,7 @@ class ContentViewerControllerTest < ActionController::TestCase | ||
122 | 122 | ||
123 | should 'not display forbidden articles' do | 123 | should 'not display forbidden articles' do |
124 | profile.articles.create!(:name => 'test') | 124 | profile.articles.create!(:name => 'test') |
125 | - profile.update_attributes!(:public_content => false) | 125 | + profile.update_attributes!({:public_content => false}, :without_protection => true) |
126 | 126 | ||
127 | Article.any_instance.expects(:display_to?).with(anything).returns(false) | 127 | Article.any_instance.expects(:display_to?).with(anything).returns(false) |
128 | get :view_page, :profile => profile.identifier, :page => [ 'test' ] | 128 | get :view_page, :profile => profile.identifier, :page => [ 'test' ] |
@@ -131,7 +131,7 @@ class ContentViewerControllerTest < ActionController::TestCase | @@ -131,7 +131,7 @@ class ContentViewerControllerTest < ActionController::TestCase | ||
131 | 131 | ||
132 | should 'display allowed articles' do | 132 | should 'display allowed articles' do |
133 | profile.articles.create!(:name => 'test') | 133 | profile.articles.create!(:name => 'test') |
134 | - profile.update_attributes!(:public_content => false) | 134 | + profile.update_attributes!({:public_content => false}, :without_protection => true) |
135 | 135 | ||
136 | Article.any_instance.expects(:display_to?).with(anything).returns(true) | 136 | Article.any_instance.expects(:display_to?).with(anything).returns(true) |
137 | get :view_page, :profile => profile.identifier, :page => [ 'test' ] | 137 | get :view_page, :profile => profile.identifier, :page => [ 'test' ] |
@@ -384,7 +384,7 @@ class ContentViewerControllerTest < ActionController::TestCase | @@ -384,7 +384,7 @@ class ContentViewerControllerTest < ActionController::TestCase | ||
384 | end | 384 | end |
385 | 385 | ||
386 | should 'not show a profile in an environment that is not its home environment' do | 386 | should 'not show a profile in an environment that is not its home environment' do |
387 | - p = Profile.create!(:identifier => 'mytestprofile', :name => 'My test profile', :environment => Environment.default) | 387 | + p = create(Profile, :identifier => 'mytestprofile', :name => 'My test profile', :environment => Environment.default) |
388 | 388 | ||
389 | current = fast_create(Environment, :name => 'test environment') | 389 | current = fast_create(Environment, :name => 'test environment') |
390 | current.domains.create!(:name => 'example.com') | 390 | current.domains.create!(:name => 'example.com') |
@@ -458,7 +458,7 @@ class ContentViewerControllerTest < ActionController::TestCase | @@ -458,7 +458,7 @@ class ContentViewerControllerTest < ActionController::TestCase | ||
458 | blog = Blog.create!(:name => "blog", :profile => profile) | 458 | blog = Blog.create!(:name => "blog", :profile => profile) |
459 | profile.articles << blog | 459 | profile.articles << blog |
460 | 460 | ||
461 | - past_post = TextileArticle.create!(:name => "past post", :profile => profile, :parent => blog, :published_at => blog.created_at - 1.year) | 461 | + past_post = create(TextileArticle, :name => "past post", :profile => profile, :parent => blog, :published_at => blog.created_at - 1.year) |
462 | current_post = TextileArticle.create!(:name => "current post", :profile => profile, :parent => blog) | 462 | current_post = TextileArticle.create!(:name => "current post", :profile => profile, :parent => blog) |
463 | blog.children << past_post | 463 | blog.children << past_post |
464 | blog.children << current_post | 464 | blog.children << current_post |
@@ -726,7 +726,7 @@ class ContentViewerControllerTest < ActionController::TestCase | @@ -726,7 +726,7 @@ class ContentViewerControllerTest < ActionController::TestCase | ||
726 | c = Community.create!(:name => 'test_com') | 726 | c = Community.create!(:name => 'test_com') |
727 | u = create_user_with_permission('test_user', 'publish_content', c) | 727 | u = create_user_with_permission('test_user', 'publish_content', c) |
728 | login_as u.identifier | 728 | login_as u.identifier |
729 | - a = c.articles.create!(:name => 'test-article', :last_changed_by => u, :published => false) | 729 | + a = create(Article, :profile => c, :name => 'test-article', :last_changed_by => u, :published => false) |
730 | 730 | ||
731 | get :view_page, :profile => c.identifier, :page => a.explode_path | 731 | get :view_page, :profile => c.identifier, :page => a.explode_path |
732 | 732 | ||
@@ -738,7 +738,7 @@ class ContentViewerControllerTest < ActionController::TestCase | @@ -738,7 +738,7 @@ class ContentViewerControllerTest < ActionController::TestCase | ||
738 | c = Community.create!(:name => 'test_com') | 738 | c = Community.create!(:name => 'test_com') |
739 | u = create_user_with_permission('test_user', 'publish_content', c) | 739 | u = create_user_with_permission('test_user', 'publish_content', c) |
740 | login_as u.identifier | 740 | login_as u.identifier |
741 | - a = c.articles.create!(:name => 'test-article', :last_changed_by => profile, :published => true) | 741 | + a = create(Article, :profile => c, :name => 'test-article', :last_changed_by => profile, :published => true) |
742 | 742 | ||
743 | xhr :get, :view_page, :profile => c.identifier, :page => a.explode_path, :toolbar => true | 743 | xhr :get, :view_page, :profile => c.identifier, :page => a.explode_path, :toolbar => true |
744 | 744 | ||
@@ -847,7 +847,7 @@ class ContentViewerControllerTest < ActionController::TestCase | @@ -847,7 +847,7 @@ class ContentViewerControllerTest < ActionController::TestCase | ||
847 | forum = Forum.create!(:name => "forum", :profile => profile) | 847 | forum = Forum.create!(:name => "forum", :profile => profile) |
848 | profile.articles << forum | 848 | profile.articles << forum |
849 | 849 | ||
850 | - past_post = TextileArticle.create!(:name => "past post", :profile => profile, :parent => forum, :published_at => forum.created_at - 1.year) | 850 | + past_post = create(TextileArticle, :name => "past post", :profile => profile, :parent => forum, :published_at => forum.created_at - 1.year) |
851 | current_post = TextileArticle.create!(:name => "current post", :profile => profile, :parent => forum) | 851 | current_post = TextileArticle.create!(:name => "current post", :profile => profile, :parent => forum) |
852 | forum.children << past_post | 852 | forum.children << past_post |
853 | forum.children << current_post | 853 | forum.children << current_post |
@@ -1051,7 +1051,7 @@ class ContentViewerControllerTest < ActionController::TestCase | @@ -1051,7 +1051,7 @@ class ContentViewerControllerTest < ActionController::TestCase | ||
1051 | article = profile.articles.build(:name => 'test') | 1051 | article = profile.articles.build(:name => 'test') |
1052 | article.save! | 1052 | article.save! |
1053 | Comment.destroy_all | 1053 | Comment.destroy_all |
1054 | - comment = Comment.create!(:author => profile, :title => 'a comment', :body => 'lalala', :article => article) | 1054 | + comment = article.comments.create!(:author => profile, :title => 'a comment', :body => 'lalala') |
1055 | login_as 'testuser' | 1055 | login_as 'testuser' |
1056 | get :view_page, :profile => 'testuser', :page => [ 'test' ] | 1056 | get :view_page, :profile => 'testuser', :page => [ 'test' ] |
1057 | assert_tag :tag => 'a', :attributes => { :class => /comment-actions-reply/ } | 1057 | assert_tag :tag => 'a', :attributes => { :class => /comment-actions-reply/ } |
test/functional/home_controller_test.rb
@@ -81,7 +81,7 @@ class HomeControllerTest < ActionController::TestCase | @@ -81,7 +81,7 @@ class HomeControllerTest < ActionController::TestCase | ||
81 | 81 | ||
82 | should 'display block in index page if it\'s configured to display on homepage and its an environment block' do | 82 | should 'display block in index page if it\'s configured to display on homepage and its an environment block' do |
83 | env = Environment.default | 83 | env = Environment.default |
84 | - box = Box.create(:owner_type => 'Environment', :owner_id => env.id) | 84 | + box = create(Box, :owner_type => 'Environment', :owner_id => env.id) |
85 | block = Block.create(:title => "Index Block", :box_id => box.id, :display => 'home_page_only') | 85 | block = Block.create(:title => "Index Block", :box_id => box.id, :display => 'home_page_only') |
86 | env.save! | 86 | env.save! |
87 | 87 |
test/functional/invite_controller_test.rb
@@ -185,7 +185,7 @@ class InviteControllerTest < ActionController::TestCase | @@ -185,7 +185,7 @@ class InviteControllerTest < ActionController::TestCase | ||
185 | end | 185 | end |
186 | 186 | ||
187 | should 'return hash as invitation data if contact list was fetched' do | 187 | should 'return hash as invitation data if contact list was fetched' do |
188 | - contact_list = ContactList.create(:fetched => true) | 188 | + contact_list = create(ContactList, :fetched => true) |
189 | get :invitation_data, :profile => profile.identifier, :contact_list => contact_list.id | 189 | get :invitation_data, :profile => profile.identifier, :contact_list => contact_list.id |
190 | hash = {'fetched' => true, 'contact_list' => contact_list.id, 'error' => nil} | 190 | hash = {'fetched' => true, 'contact_list' => contact_list.id, 'error' => nil} |
191 | 191 | ||
@@ -194,7 +194,7 @@ class InviteControllerTest < ActionController::TestCase | @@ -194,7 +194,7 @@ class InviteControllerTest < ActionController::TestCase | ||
194 | end | 194 | end |
195 | 195 | ||
196 | should 'render empty list of contacts' do | 196 | should 'render empty list of contacts' do |
197 | - contact_list = ContactList.create(:fetched => true) | 197 | + contact_list = create(ContactList, :fetched => true) |
198 | get :add_contact_list, :profile => profile.identifier, :contact_list => contact_list.id | 198 | get :add_contact_list, :profile => profile.identifier, :contact_list => contact_list.id |
199 | 199 | ||
200 | assert_response :success | 200 | assert_response :success |
@@ -203,7 +203,7 @@ class InviteControllerTest < ActionController::TestCase | @@ -203,7 +203,7 @@ class InviteControllerTest < ActionController::TestCase | ||
203 | end | 203 | end |
204 | 204 | ||
205 | should 'render list of contacts' do | 205 | should 'render list of contacts' do |
206 | - contact_list = ContactList.create(:fetched => true, :list => ['email1@noosfero.org', 'email2@noosfero.org']) | 206 | + contact_list = create(ContactList, :fetched => true, :list => ['email1@noosfero.org', 'email2@noosfero.org']) |
207 | get :add_contact_list, :profile => profile.identifier, :contact_list => contact_list.id | 207 | get :add_contact_list, :profile => profile.identifier, :contact_list => contact_list.id |
208 | 208 | ||
209 | assert_response :success | 209 | assert_response :success |
test/functional/manage_products_controller_test.rb
@@ -261,7 +261,7 @@ class ManageProductsControllerTest < ActionController::TestCase | @@ -261,7 +261,7 @@ class ManageProductsControllerTest < ActionController::TestCase | ||
261 | end | 261 | end |
262 | 262 | ||
263 | should 'link back to index from product show' do | 263 | should 'link back to index from product show' do |
264 | - enterprise = Enterprise.create!(:name => 'test_enterprise_1', :identifier => 'test_enterprise_1', :environment => Environment.default) | 264 | + enterprise = create(Enterprise, :name => 'test_enterprise_1', :identifier => 'test_enterprise_1', :environment => Environment.default) |
265 | prod = enterprise.products.create!(:name => 'Product test', :product_category => @product_category) | 265 | prod = enterprise.products.create!(:name => 'Product test', :product_category => @product_category) |
266 | get :show, :id => prod.id, :profile => enterprise.identifier | 266 | get :show, :id => prod.id, :profile => enterprise.identifier |
267 | assert_tag({ | 267 | assert_tag({ |
test/functional/map_balloon_controller_test.rb
@@ -17,14 +17,14 @@ class MapBalloonControllerTest < ActionController::TestCase | @@ -17,14 +17,14 @@ class MapBalloonControllerTest < ActionController::TestCase | ||
17 | end | 17 | end |
18 | 18 | ||
19 | should 'find product to show' do | 19 | should 'find product to show' do |
20 | - prod = Product.create!(:name => 'Product1', :product_category_id => fast_create(ProductCategory).id, | 20 | + prod = create(Product, :name => 'Product1', :product_category_id => fast_create(ProductCategory).id, |
21 | :enterprise_id => fast_create(Enterprise).id) | 21 | :enterprise_id => fast_create(Enterprise).id) |
22 | get :product, :id => prod.id | 22 | get :product, :id => prod.id |
23 | assert_equal prod, assigns(:product) | 23 | assert_equal prod, assigns(:product) |
24 | end | 24 | end |
25 | 25 | ||
26 | should 'find person to show' do | 26 | should 'find person to show' do |
27 | - pers = Person.create!(:name => 'Person1', :user_id => fast_create(User).id, :identifier => 'pers1') | 27 | + pers = create(Person, :name => 'Person1', :user_id => fast_create(User).id, :identifier => 'pers1') |
28 | get :person, :id => pers.id | 28 | get :person, :id => pers.id |
29 | assert_equal pers, assigns(:profile) | 29 | assert_equal pers, assigns(:profile) |
30 | end | 30 | end |
test/functional/profile_controller_test.rb
@@ -367,7 +367,7 @@ class ProfileControllerTest < ActionController::TestCase | @@ -367,7 +367,7 @@ class ProfileControllerTest < ActionController::TestCase | ||
367 | 367 | ||
368 | should 'display contact button for community if its enable in environment' do | 368 | should 'display contact button for community if its enable in environment' do |
369 | env = Environment.default | 369 | env = Environment.default |
370 | - community = Community.create!(:name => 'my test community', :environment => env) | 370 | + community = create(Community, :name => 'my test community', :environment => env) |
371 | community.boxes.first.blocks << block = ProfileInfoBlock.create! | 371 | community.boxes.first.blocks << block = ProfileInfoBlock.create! |
372 | env.disable('disable_contact_community') | 372 | env.disable('disable_contact_community') |
373 | env.save! | 373 | env.save! |
@@ -379,7 +379,7 @@ class ProfileControllerTest < ActionController::TestCase | @@ -379,7 +379,7 @@ class ProfileControllerTest < ActionController::TestCase | ||
379 | 379 | ||
380 | should 'not display contact button for community if its disable in environment' do | 380 | should 'not display contact button for community if its disable in environment' do |
381 | env = Environment.default | 381 | env = Environment.default |
382 | - community = Community.create!(:name => 'my test community', :environment => env) | 382 | + community = create(Community, :name => 'my test community', :environment => env) |
383 | community.boxes.first.blocks << block = ProfileInfoBlock.create! | 383 | community.boxes.first.blocks << block = ProfileInfoBlock.create! |
384 | env.enable('disable_contact_community') | 384 | env.enable('disable_contact_community') |
385 | env.save! | 385 | env.save! |
@@ -499,7 +499,7 @@ class ProfileControllerTest < ActionController::TestCase | @@ -499,7 +499,7 @@ class ProfileControllerTest < ActionController::TestCase | ||
499 | end | 499 | end |
500 | 500 | ||
501 | should 'show number of published posts in index' do | 501 | should 'show number of published posts in index' do |
502 | - profile.articles << blog = Blog.create(:name => 'Blog', :profile_id => profile.id) | 502 | + profile.articles << blog = create(Blog, :name => 'Blog', :profile_id => profile.id) |
503 | fast_create(TextileArticle, :name => 'Published post', :parent_id => profile.blog.id, :profile_id => profile.id) | 503 | fast_create(TextileArticle, :name => 'Published post', :parent_id => profile.blog.id, :profile_id => profile.id) |
504 | fast_create(TextileArticle, :name => 'Other published post', :parent_id => profile.blog.id, :profile_id => profile.id) | 504 | fast_create(TextileArticle, :name => 'Other published post', :parent_id => profile.blog.id, :profile_id => profile.id) |
505 | fast_create(TextileArticle, :name => 'Unpublished post', :parent_id => profile.blog.id, :profile_id => profile.id, :published => false) | 505 | fast_create(TextileArticle, :name => 'Unpublished post', :parent_id => profile.blog.id, :profile_id => profile.id, :published => false) |
@@ -574,8 +574,8 @@ class ProfileControllerTest < ActionController::TestCase | @@ -574,8 +574,8 @@ class ProfileControllerTest < ActionController::TestCase | ||
574 | end | 574 | end |
575 | 575 | ||
576 | should 'reverse the order of posts in tag feed' do | 576 | should 'reverse the order of posts in tag feed' do |
577 | - TextileArticle.create!(:name => 'First post', :profile => profile, :tag_list => 'tag1', :published_at => Time.now) | ||
578 | - TextileArticle.create!(:name => 'Second post', :profile => profile, :tag_list => 'tag1', :published_at => Time.now + 1.day) | 577 | + create(TextileArticle, :name => 'First post', :profile => profile, :tag_list => 'tag1', :published_at => Time.now) |
578 | + create(TextileArticle, :name => 'Second post', :profile => profile, :tag_list => 'tag1', :published_at => Time.now + 1.day) | ||
579 | 579 | ||
580 | get :tag_feed, :profile => profile.identifier, :id => 'tag1' | 580 | get :tag_feed, :profile => profile.identifier, :id => 'tag1' |
581 | assert_match(/Second.*First/, @response.body) | 581 | assert_match(/Second.*First/, @response.body) |
@@ -583,11 +583,11 @@ class ProfileControllerTest < ActionController::TestCase | @@ -583,11 +583,11 @@ class ProfileControllerTest < ActionController::TestCase | ||
583 | 583 | ||
584 | should 'display the most recent posts in tag feed' do | 584 | should 'display the most recent posts in tag feed' do |
585 | start = Time.now - 30.days | 585 | start = Time.now - 30.days |
586 | - first = TextileArticle.create!(:name => 'First post', :profile => profile, :tag_list => 'tag1', :published_at => start) | 586 | + first = create(TextileArticle, :name => 'First post', :profile => profile, :tag_list => 'tag1', :published_at => start) |
587 | 20.times do |i| | 587 | 20.times do |i| |
588 | - TextileArticle.create!(:name => 'Post #' + i.to_s, :profile => profile, :tag_list => 'tag1', :published_at => start + i.days) | 588 | + create(TextileArticle, :name => 'Post #' + i.to_s, :profile => profile, :tag_list => 'tag1', :published_at => start + i.days) |
589 | end | 589 | end |
590 | - last = TextileArticle.create!(:name => 'Last post', :profile => profile, :tag_list => 'tag1', :published_at => Time.now) | 590 | + last = create(TextileArticle, :name => 'Last post', :profile => profile, :tag_list => 'tag1', :published_at => Time.now) |
591 | 591 | ||
592 | get :tag_feed, :profile => profile.identifier, :id => 'tag1' | 592 | get :tag_feed, :profile => profile.identifier, :id => 'tag1' |
593 | assert_no_match(/First post/, @response.body) # First post is older than other 20 posts already | 593 | assert_no_match(/First post/, @response.body) # First post is older than other 20 posts already |
@@ -699,7 +699,7 @@ class ProfileControllerTest < ActionController::TestCase | @@ -699,7 +699,7 @@ class ProfileControllerTest < ActionController::TestCase | ||
699 | 699 | ||
700 | should "display a scrap sent" do | 700 | should "display a scrap sent" do |
701 | another_person = fast_create(Person) | 701 | another_person = fast_create(Person) |
702 | - Scrap.create!(defaults_for_scrap(:sender => another_person, :receiver => profile, :content => 'A scrap')) | 702 | + create(Scrap, defaults_for_scrap(:sender => another_person, :receiver => profile, :content => 'A scrap')) |
703 | login_as(profile.identifier) | 703 | login_as(profile.identifier) |
704 | get :index, :profile => profile.identifier | 704 | get :index, :profile => profile.identifier |
705 | assert_tag :tag => 'p', :content => 'A scrap' | 705 | assert_tag :tag => 'p', :content => 'A scrap' |
@@ -707,7 +707,7 @@ class ProfileControllerTest < ActionController::TestCase | @@ -707,7 +707,7 @@ class ProfileControllerTest < ActionController::TestCase | ||
707 | 707 | ||
708 | should "not display a scrap sent by a removed user" do | 708 | should "not display a scrap sent by a removed user" do |
709 | another_person = fast_create(Person) | 709 | another_person = fast_create(Person) |
710 | - Scrap.create!(defaults_for_scrap(:sender => another_person, :receiver => profile, :content => 'A scrap')) | 710 | + create(Scrap, defaults_for_scrap(:sender => another_person, :receiver => profile, :content => 'A scrap')) |
711 | login_as(profile.identifier) | 711 | login_as(profile.identifier) |
712 | another_person.destroy | 712 | another_person.destroy |
713 | get :index, :profile => profile.identifier | 713 | get :index, :profile => profile.identifier |
@@ -719,13 +719,13 @@ class ProfileControllerTest < ActionController::TestCase | @@ -719,13 +719,13 @@ class ProfileControllerTest < ActionController::TestCase | ||
719 | p2= fast_create(Person) | 719 | p2= fast_create(Person) |
720 | 720 | ||
721 | UserStampSweeper.any_instance.stubs(:current_user).returns(p1) | 721 | UserStampSweeper.any_instance.stubs(:current_user).returns(p1) |
722 | - scrap1 = Scrap.create!(defaults_for_scrap(:sender => p1, :receiver => p2)) | 722 | + scrap1 = create(Scrap, defaults_for_scrap(:sender => p1, :receiver => p2)) |
723 | 723 | ||
724 | UserStampSweeper.any_instance.stubs(:current_user).returns(p2) | 724 | UserStampSweeper.any_instance.stubs(:current_user).returns(p2) |
725 | - scrap2 = Scrap.create!(defaults_for_scrap(:sender => p2, :receiver => p1)) | 725 | + scrap2 = create(Scrap, defaults_for_scrap(:sender => p2, :receiver => p1)) |
726 | 726 | ||
727 | UserStampSweeper.any_instance.stubs(:current_user).returns(p1) | 727 | UserStampSweeper.any_instance.stubs(:current_user).returns(p1) |
728 | - TinyMceArticle.create!(:profile => p1, :name => 'An article about free software') | 728 | + create(TinyMceArticle, :profile => p1, :name => 'An article about free software') |
729 | a1 = ActionTracker::Record.last | 729 | a1 = ActionTracker::Record.last |
730 | 730 | ||
731 | login_as(profile.identifier) | 731 | login_as(profile.identifier) |
@@ -736,7 +736,7 @@ class ProfileControllerTest < ActionController::TestCase | @@ -736,7 +736,7 @@ class ProfileControllerTest < ActionController::TestCase | ||
736 | should 'see the activities_items paginated' do | 736 | should 'see the activities_items paginated' do |
737 | p1 = create_user('some').person | 737 | p1 = create_user('some').person |
738 | ActionTracker::Record.destroy_all | 738 | ActionTracker::Record.destroy_all |
739 | - 40.times{Scrap.create!(defaults_for_scrap(:sender => p1, :receiver => p1))} | 739 | + 40.times{create(Scrap, defaults_for_scrap(:sender => p1, :receiver => p1))} |
740 | login_as(p1.identifier) | 740 | login_as(p1.identifier) |
741 | get :index, :profile => p1.identifier | 741 | get :index, :profile => p1.identifier |
742 | assert_equal 15, assigns(:activities).count | 742 | assert_equal 15, assigns(:activities).count |
@@ -750,8 +750,8 @@ class ProfileControllerTest < ActionController::TestCase | @@ -750,8 +750,8 @@ class ProfileControllerTest < ActionController::TestCase | ||
750 | assert p3.is_a_friend?(profile) | 750 | assert p3.is_a_friend?(profile) |
751 | ActionTracker::Record.destroy_all | 751 | ActionTracker::Record.destroy_all |
752 | 752 | ||
753 | - scrap1 = Scrap.create!(defaults_for_scrap(:sender => p2, :receiver => p3)) | ||
754 | - scrap2 = Scrap.create!(defaults_for_scrap(:sender => p2, :receiver => profile)) | 753 | + scrap1 = create(Scrap, defaults_for_scrap(:sender => p2, :receiver => p3)) |
754 | + scrap2 = create(Scrap, defaults_for_scrap(:sender => p2, :receiver => profile)) | ||
755 | 755 | ||
756 | UserStampSweeper.any_instance.stubs(:current_user).returns(p3) | 756 | UserStampSweeper.any_instance.stubs(:current_user).returns(p3) |
757 | article1 = TinyMceArticle.create!(:profile => p3, :name => 'An article about free software') | 757 | article1 = TinyMceArticle.create!(:profile => p3, :name => 'An article about free software') |
@@ -773,13 +773,13 @@ class ProfileControllerTest < ActionController::TestCase | @@ -773,13 +773,13 @@ class ProfileControllerTest < ActionController::TestCase | ||
773 | p3.add_friend(p1) | 773 | p3.add_friend(p1) |
774 | assert p3.is_a_friend?(p1) | 774 | assert p3.is_a_friend?(p1) |
775 | ActionTracker::Record.destroy_all | 775 | ActionTracker::Record.destroy_all |
776 | - Scrap.create!(defaults_for_scrap(:sender => p1, :receiver => p1)) | 776 | + create(Scrap, defaults_for_scrap(:sender => p1, :receiver => p1)) |
777 | a1 = ActionTracker::Record.last | 777 | a1 = ActionTracker::Record.last |
778 | UserStampSweeper.any_instance.stubs(:current_user).returns(p2) | 778 | UserStampSweeper.any_instance.stubs(:current_user).returns(p2) |
779 | - Scrap.create!(defaults_for_scrap(:sender => p2, :receiver => p3)) | 779 | + create(Scrap, defaults_for_scrap(:sender => p2, :receiver => p3)) |
780 | a2 = ActionTracker::Record.last | 780 | a2 = ActionTracker::Record.last |
781 | UserStampSweeper.any_instance.stubs(:current_user).returns(p3) | 781 | UserStampSweeper.any_instance.stubs(:current_user).returns(p3) |
782 | - Scrap.create!(defaults_for_scrap(:sender => p3, :receiver => p1)) | 782 | + create(Scrap, defaults_for_scrap(:sender => p3, :receiver => p1)) |
783 | a3 = ActionTracker::Record.last | 783 | a3 = ActionTracker::Record.last |
784 | 784 | ||
785 | 785 | ||
@@ -805,13 +805,13 @@ class ProfileControllerTest < ActionController::TestCase | @@ -805,13 +805,13 @@ class ProfileControllerTest < ActionController::TestCase | ||
805 | p3.add_friend(p1) | 805 | p3.add_friend(p1) |
806 | assert p3.is_a_friend?(p1) | 806 | assert p3.is_a_friend?(p1) |
807 | ActionTracker::Record.destroy_all | 807 | ActionTracker::Record.destroy_all |
808 | - Scrap.create!(defaults_for_scrap(:sender => p1, :receiver => p1)) | 808 | + create(Scrap, defaults_for_scrap(:sender => p1, :receiver => p1)) |
809 | a1 = ActionTracker::Record.last | 809 | a1 = ActionTracker::Record.last |
810 | UserStampSweeper.any_instance.stubs(:current_user).returns(p2) | 810 | UserStampSweeper.any_instance.stubs(:current_user).returns(p2) |
811 | - Scrap.create!(defaults_for_scrap(:sender => p2, :receiver => p3)) | 811 | + create(Scrap, defaults_for_scrap(:sender => p2, :receiver => p3)) |
812 | a2 = ActionTracker::Record.last | 812 | a2 = ActionTracker::Record.last |
813 | UserStampSweeper.any_instance.stubs(:current_user).returns(p3) | 813 | UserStampSweeper.any_instance.stubs(:current_user).returns(p3) |
814 | - Scrap.create!(defaults_for_scrap(:sender => p3, :receiver => p1)) | 814 | + create(Scrap, defaults_for_scrap(:sender => p3, :receiver => p1)) |
815 | a3 = ActionTracker::Record.last | 815 | a3 = ActionTracker::Record.last |
816 | 816 | ||
817 | @controller.stubs(:logged_in?).returns(true) | 817 | @controller.stubs(:logged_in?).returns(true) |
@@ -854,13 +854,13 @@ class ProfileControllerTest < ActionController::TestCase | @@ -854,13 +854,13 @@ class ProfileControllerTest < ActionController::TestCase | ||
854 | p3.add_friend(p1) | 854 | p3.add_friend(p1) |
855 | assert p3.is_a_friend?(p1) | 855 | assert p3.is_a_friend?(p1) |
856 | ActionTracker::Record.destroy_all | 856 | ActionTracker::Record.destroy_all |
857 | - Scrap.create!(defaults_for_scrap(:sender => p1, :receiver => p1)) | 857 | + create(Scrap, defaults_for_scrap(:sender => p1, :receiver => p1)) |
858 | a1 = ActionTracker::Record.last | 858 | a1 = ActionTracker::Record.last |
859 | UserStampSweeper.any_instance.stubs(:current_user).returns(p2) | 859 | UserStampSweeper.any_instance.stubs(:current_user).returns(p2) |
860 | - Scrap.create!(defaults_for_scrap(:sender => p2, :receiver => p3)) | 860 | + create(Scrap, defaults_for_scrap(:sender => p2, :receiver => p3)) |
861 | a2 = ActionTracker::Record.last | 861 | a2 = ActionTracker::Record.last |
862 | UserStampSweeper.any_instance.stubs(:current_user).returns(p3) | 862 | UserStampSweeper.any_instance.stubs(:current_user).returns(p3) |
863 | - Scrap.create!(defaults_for_scrap(:sender => p3, :receiver => p1)) | 863 | + create(Scrap, defaults_for_scrap(:sender => p3, :receiver => p1)) |
864 | a3 = ActionTracker::Record.last | 864 | a3 = ActionTracker::Record.last |
865 | 865 | ||
866 | login_as(profile.identifier) | 866 | login_as(profile.identifier) |
@@ -889,10 +889,10 @@ class ProfileControllerTest < ActionController::TestCase | @@ -889,10 +889,10 @@ class ProfileControllerTest < ActionController::TestCase | ||
889 | community.add_member(p1) | 889 | community.add_member(p1) |
890 | community.add_member(p2) | 890 | community.add_member(p2) |
891 | ActionTracker::Record.destroy_all | 891 | ActionTracker::Record.destroy_all |
892 | - Article.create! :name => 'a', :profile_id => community.id | ||
893 | - Article.create! :name => 'b', :profile_id => community.id | 892 | + create(Article, :name => 'a', :profile_id => community.id) |
893 | + create(Article, :name => 'b', :profile_id => community.id) | ||
894 | UserStampSweeper.any_instance.stubs(:current_user).returns(p2) | 894 | UserStampSweeper.any_instance.stubs(:current_user).returns(p2) |
895 | - Article.create! :name => 'c', :profile_id => community.id | 895 | + create(Article, :name => 'c', :profile_id => community.id) |
896 | process_delayed_job_queue | 896 | process_delayed_job_queue |
897 | 897 | ||
898 | get :index, :profile => community.identifier | 898 | get :index, :profile => community.identifier |
@@ -916,13 +916,13 @@ class ProfileControllerTest < ActionController::TestCase | @@ -916,13 +916,13 @@ class ProfileControllerTest < ActionController::TestCase | ||
916 | p3.add_friend(p1) | 916 | p3.add_friend(p1) |
917 | assert p3.is_a_friend?(p1) | 917 | assert p3.is_a_friend?(p1) |
918 | ActionTracker::Record.destroy_all | 918 | ActionTracker::Record.destroy_all |
919 | - Scrap.create!(defaults_for_scrap(:sender => p1, :receiver => p1)) | 919 | + create(Scrap, defaults_for_scrap(:sender => p1, :receiver => p1)) |
920 | a1 = ActionTracker::Record.last | 920 | a1 = ActionTracker::Record.last |
921 | UserStampSweeper.any_instance.stubs(:current_user).returns(p2) | 921 | UserStampSweeper.any_instance.stubs(:current_user).returns(p2) |
922 | - Scrap.create!(defaults_for_scrap(:sender => p2, :receiver => p3)) | 922 | + create(Scrap, defaults_for_scrap(:sender => p2, :receiver => p3)) |
923 | a2 = ActionTracker::Record.last | 923 | a2 = ActionTracker::Record.last |
924 | UserStampSweeper.any_instance.stubs(:current_user).returns(p3) | 924 | UserStampSweeper.any_instance.stubs(:current_user).returns(p3) |
925 | - Scrap.create!(defaults_for_scrap(:sender => p3, :receiver => p1)) | 925 | + create(Scrap, defaults_for_scrap(:sender => p3, :receiver => p1)) |
926 | a3 = ActionTracker::Record.last | 926 | a3 = ActionTracker::Record.last |
927 | 927 | ||
928 | get :index, :profile => p1.identifier | 928 | get :index, :profile => p1.identifier |
@@ -1141,7 +1141,7 @@ class ProfileControllerTest < ActionController::TestCase | @@ -1141,7 +1141,7 @@ class ProfileControllerTest < ActionController::TestCase | ||
1141 | login_as(profile.identifier) | 1141 | login_as(profile.identifier) |
1142 | article = TinyMceArticle.create!(:profile => profile, :name => 'An Article about Free Software') | 1142 | article = TinyMceArticle.create!(:profile => profile, :name => 'An Article about Free Software') |
1143 | ActionTracker::Record.destroy_all | 1143 | ActionTracker::Record.destroy_all |
1144 | - 40.times{ ActionTracker::Record.create!(:user_id => profile.id, :user_type => 'Profile', :verb => 'create_article', :target_id => article.id, :target_type => 'Article', :params => {'name' => article.name, 'url' => article.url, 'lead' => article.lead, 'first_image' => article.first_image})} | 1144 | + 40.times{ create(ActionTracker::Record, :user_id => profile.id, :user_type => 'Profile', :verb => 'create_article', :target_id => article.id, :target_type => 'Article', :params => {'name' => article.name, 'url' => article.url, 'lead' => article.lead, 'first_image' => article.first_image})} |
1145 | assert_equal 40, profile.tracked_actions.count | 1145 | assert_equal 40, profile.tracked_actions.count |
1146 | assert_equal 40, profile.activities.count | 1146 | assert_equal 40, profile.activities.count |
1147 | get :view_more_activities, :profile => profile.identifier, :page => 2 | 1147 | get :view_more_activities, :profile => profile.identifier, :page => 2 |
@@ -1174,7 +1174,7 @@ class ProfileControllerTest < ActionController::TestCase | @@ -1174,7 +1174,7 @@ class ProfileControllerTest < ActionController::TestCase | ||
1174 | login_as(profile.identifier) | 1174 | login_as(profile.identifier) |
1175 | article = TinyMceArticle.create!(:profile => profile, :name => 'An Article about Free Software') | 1175 | article = TinyMceArticle.create!(:profile => profile, :name => 'An Article about Free Software') |
1176 | ActionTracker::Record.destroy_all | 1176 | ActionTracker::Record.destroy_all |
1177 | - activity = ActionTracker::Record.create!(:user_id => profile.id, :user_type => 'Profile', :verb => 'create_article', :target_id => article.id, :target_type => 'Article', :params => {'name' => article.name, 'url' => article.url, 'lead' => article.lead, 'first_image' => article.first_image}) | 1177 | + activity = create(ActionTracker::Record, :user_id => profile.id, :user_type => 'Profile', :verb => 'create_article', :target_id => article.id, :target_type => 'Article', :params => {'name' => article.name, 'url' => article.url, 'lead' => article.lead, 'first_image' => article.first_image}) |
1178 | 20.times {comment = fast_create(Comment, :source_id => article, :title => 'a comment', :body => 'lalala', :created_at => Time.now)} | 1178 | 20.times {comment = fast_create(Comment, :source_id => article, :title => 'a comment', :body => 'lalala', :created_at => Time.now)} |
1179 | article.reload | 1179 | article.reload |
1180 | get :index, :profile => profile.identifier | 1180 | get :index, :profile => profile.identifier |
@@ -1185,7 +1185,7 @@ class ProfileControllerTest < ActionController::TestCase | @@ -1185,7 +1185,7 @@ class ProfileControllerTest < ActionController::TestCase | ||
1185 | login_as(profile.identifier) | 1185 | login_as(profile.identifier) |
1186 | article = TinyMceArticle.create!(:profile => profile, :name => 'An Article about Free Software') | 1186 | article = TinyMceArticle.create!(:profile => profile, :name => 'An Article about Free Software') |
1187 | ActionTracker::Record.destroy_all | 1187 | ActionTracker::Record.destroy_all |
1188 | - activity = ActionTracker::Record.create!(:user_id => profile.id, :user_type => 'Profile', :verb => 'create_article', :target_id => article.id, :target_type => 'Article', :params => {'name' => article.name, 'url' => article.url, 'lead' => article.lead, 'first_image' => article.first_image}) | 1188 | + activity = create(ActionTracker::Record, :user_id => profile.id, :user_type => 'Profile', :verb => 'create_article', :target_id => article.id, :target_type => 'Article', :params => {'name' => article.name, 'url' => article.url, 'lead' => article.lead, 'first_image' => article.first_image}) |
1189 | 20.times {comment = fast_create(Comment, :source_id => article, :title => 'a comment', :body => 'lalala', :created_at => Time.now)} | 1189 | 20.times {comment = fast_create(Comment, :source_id => article, :title => 'a comment', :body => 'lalala', :created_at => Time.now)} |
1190 | article.reload | 1190 | article.reload |
1191 | assert_equal 20, article.comments.count | 1191 | assert_equal 20, article.comments.count |
@@ -1319,7 +1319,7 @@ class ProfileControllerTest < ActionController::TestCase | @@ -1319,7 +1319,7 @@ class ProfileControllerTest < ActionController::TestCase | ||
1319 | 1319 | ||
1320 | should 'display activities and scraps together' do | 1320 | should 'display activities and scraps together' do |
1321 | another_person = fast_create(Person) | 1321 | another_person = fast_create(Person) |
1322 | - Scrap.create!(defaults_for_scrap(:sender => another_person, :receiver => profile, :content => 'A scrap')) | 1322 | + create(Scrap, defaults_for_scrap(:sender => another_person, :receiver => profile, :content => 'A scrap')) |
1323 | 1323 | ||
1324 | UserStampSweeper.any_instance.stubs(:current_user).returns(profile) | 1324 | UserStampSweeper.any_instance.stubs(:current_user).returns(profile) |
1325 | ActionTracker::Record.destroy_all | 1325 | ActionTracker::Record.destroy_all |
@@ -1334,7 +1334,7 @@ class ProfileControllerTest < ActionController::TestCase | @@ -1334,7 +1334,7 @@ class ProfileControllerTest < ActionController::TestCase | ||
1334 | 1334 | ||
1335 | should 'have scraps and activities on activities' do | 1335 | should 'have scraps and activities on activities' do |
1336 | another_person = fast_create(Person) | 1336 | another_person = fast_create(Person) |
1337 | - scrap = Scrap.create!(defaults_for_scrap(:sender => another_person, :receiver => profile, :content => 'A scrap')) | 1337 | + scrap = create(Scrap, defaults_for_scrap(:sender => another_person, :receiver => profile, :content => 'A scrap')) |
1338 | 1338 | ||
1339 | UserStampSweeper.any_instance.stubs(:current_user).returns(profile) | 1339 | UserStampSweeper.any_instance.stubs(:current_user).returns(profile) |
1340 | ActionTracker::Record.destroy_all | 1340 | ActionTracker::Record.destroy_all |
@@ -1387,7 +1387,7 @@ class ProfileControllerTest < ActionController::TestCase | @@ -1387,7 +1387,7 @@ class ProfileControllerTest < ActionController::TestCase | ||
1387 | UserStampSweeper.any_instance.stubs(:current_user).returns(profile) | 1387 | UserStampSweeper.any_instance.stubs(:current_user).returns(profile) |
1388 | article = TinyMceArticle.create!(:profile => profile, :name => 'An article about free software') | 1388 | article = TinyMceArticle.create!(:profile => profile, :name => 'An article about free software') |
1389 | to_be_removed = create_user('removed_user').person | 1389 | to_be_removed = create_user('removed_user').person |
1390 | - comment = Comment.create!(:author => to_be_removed, :title => 'Test Comment', :body => 'My author does not exist =(', :source_id => article.id, :source_type => 'Article') | 1390 | + comment = create(Comment, :author => to_be_removed, :title => 'Test Comment', :body => 'My author does not exist =(', :source_id => article.id, :source_type => 'Article') |
1391 | to_be_removed.destroy | 1391 | to_be_removed.destroy |
1392 | 1392 | ||
1393 | login_as(profile.identifier) | 1393 | login_as(profile.identifier) |
@@ -1399,7 +1399,7 @@ class ProfileControllerTest < ActionController::TestCase | @@ -1399,7 +1399,7 @@ class ProfileControllerTest < ActionController::TestCase | ||
1399 | should 'not display spam comments in wall' do | 1399 | should 'not display spam comments in wall' do |
1400 | UserStampSweeper.any_instance.stubs(:current_user).returns(profile) | 1400 | UserStampSweeper.any_instance.stubs(:current_user).returns(profile) |
1401 | article = TinyMceArticle.create!(:profile => profile, :name => 'An article about spam\'s nutritional attributes') | 1401 | article = TinyMceArticle.create!(:profile => profile, :name => 'An article about spam\'s nutritional attributes') |
1402 | - comment = Comment.create!(:author => profile, :title => 'Test Comment', :body => 'This article makes me hungry', :source_id => article.id, :source_type => 'Article') | 1402 | + comment = create(Comment, :author => profile, :title => 'Test Comment', :body => 'This article makes me hungry', :source_id => article.id, :source_type => 'Article') |
1403 | comment.spam! | 1403 | comment.spam! |
1404 | login_as(profile.identifier) | 1404 | login_as(profile.identifier) |
1405 | get :index, :profile => profile.identifier | 1405 | get :index, :profile => profile.identifier |
@@ -1410,7 +1410,7 @@ class ProfileControllerTest < ActionController::TestCase | @@ -1410,7 +1410,7 @@ class ProfileControllerTest < ActionController::TestCase | ||
1410 | should 'display comment in wall from non logged users' do | 1410 | should 'display comment in wall from non logged users' do |
1411 | UserStampSweeper.any_instance.stubs(:current_user).returns(profile) | 1411 | UserStampSweeper.any_instance.stubs(:current_user).returns(profile) |
1412 | article = TinyMceArticle.create!(:profile => profile, :name => 'An article about free software') | 1412 | article = TinyMceArticle.create!(:profile => profile, :name => 'An article about free software') |
1413 | - comment = Comment.create!(:name => 'outside user', :email => 'outside@localhost.localdomain', :title => 'Test Comment', :body => 'My author does not exist =(', :source_id => article.id, :source_type => 'Article') | 1413 | + comment = create(Comment, :name => 'outside user', :email => 'outside@localhost.localdomain', :title => 'Test Comment', :body => 'My author does not exist =(', :source_id => article.id, :source_type => 'Article') |
1414 | 1414 | ||
1415 | login_as(profile.identifier) | 1415 | login_as(profile.identifier) |
1416 | get :index, :profile => profile.identifier | 1416 | get :index, :profile => profile.identifier |
test/functional/profile_editor_controller_test.rb
@@ -68,7 +68,7 @@ class ProfileEditorControllerTest < ActionController::TestCase | @@ -68,7 +68,7 @@ class ProfileEditorControllerTest < ActionController::TestCase | ||
68 | 68 | ||
69 | should 'display categories to choose to associate profile' do | 69 | should 'display categories to choose to associate profile' do |
70 | cat1 = Environment.default.categories.build(:display_in_menu => true, :name => 'top category'); cat1.save! | 70 | cat1 = Environment.default.categories.build(:display_in_menu => true, :name => 'top category'); cat1.save! |
71 | - cat2 = Environment.default.categories.build(:display_in_menu => true, :name => 'sub category', :parent => cat1); cat2.save! | 71 | + cat2 = Environment.default.categories.build(:display_in_menu => true, :name => 'sub category', :parent_id => cat1.id); cat2.save! |
72 | person = profile | 72 | person = profile |
73 | get :edit, :profile => profile.identifier | 73 | get :edit, :profile => profile.identifier |
74 | assert_response :success | 74 | assert_response :success |
@@ -78,7 +78,7 @@ class ProfileEditorControllerTest < ActionController::TestCase | @@ -78,7 +78,7 @@ class ProfileEditorControllerTest < ActionController::TestCase | ||
78 | 78 | ||
79 | should 'save categorization of profile' do | 79 | should 'save categorization of profile' do |
80 | cat1 = Environment.default.categories.build(:name => 'top category'); cat1.save! | 80 | cat1 = Environment.default.categories.build(:name => 'top category'); cat1.save! |
81 | - cat2 = Environment.default.categories.build(:name => 'sub category', :parent => cat1); cat2.save! | 81 | + cat2 = Environment.default.categories.build(:name => 'sub category', :parent_id => cat1.id); cat2.save! |
82 | person = profile | 82 | person = profile |
83 | post :edit, :profile => profile.identifier, :profile_data => {:category_ids => [cat2.id]} | 83 | post :edit, :profile => profile.identifier, :profile_data => {:category_ids => [cat2.id]} |
84 | assert_response :redirect | 84 | assert_response :redirect |
@@ -233,7 +233,7 @@ class ProfileEditorControllerTest < ActionController::TestCase | @@ -233,7 +233,7 @@ class ProfileEditorControllerTest < ActionController::TestCase | ||
233 | 233 | ||
234 | should 'show categories links on edit profile' do | 234 | should 'show categories links on edit profile' do |
235 | cat1 = Environment.default.categories.create!(:display_in_menu => true, :name => 'top category') | 235 | cat1 = Environment.default.categories.create!(:display_in_menu => true, :name => 'top category') |
236 | - cat2 = Environment.default.categories.create!(:display_in_menu => true, :name => 'sub category', :parent => cat1) | 236 | + cat2 = Environment.default.categories.create!(:display_in_menu => true, :name => 'sub category', :parent_id => cat1.id) |
237 | person = create_user('testuser').person | 237 | person = create_user('testuser').person |
238 | get :edit, :profile => 'testuser' | 238 | get :edit, :profile => 'testuser' |
239 | assert_tag :tag => 'input', :attributes => { :type => 'checkbox', :name => 'profile_data[category_ids][]', :value => cat2.id} | 239 | assert_tag :tag => 'input', :attributes => { :type => 'checkbox', :name => 'profile_data[category_ids][]', :value => cat2.id} |
test/functional/region_validators_controller_test.rb
@@ -51,7 +51,7 @@ class RegionValidatorsControllerTest < ActionController::TestCase | @@ -51,7 +51,7 @@ class RegionValidatorsControllerTest < ActionController::TestCase | ||
51 | region = Region.new(:name => 'my region') | 51 | region = Region.new(:name => 'my region') |
52 | environment.regions << region | 52 | environment.regions << region |
53 | assert !region.new_record? | 53 | assert !region.new_record? |
54 | - org = Organization.create!(:name => "My frufru organization", :identifier => 'frufru', :environment_id => environment.id) | 54 | + org = create(Organization, :name => "My frufru organization", :identifier => 'frufru', :environment_id => environment.id) |
55 | 55 | ||
56 | @controller.expects(:environment).returns(environment).at_least_once | 56 | @controller.expects(:environment).returns(environment).at_least_once |
57 | 57 | ||
@@ -67,7 +67,7 @@ class RegionValidatorsControllerTest < ActionController::TestCase | @@ -67,7 +67,7 @@ class RegionValidatorsControllerTest < ActionController::TestCase | ||
67 | region = Region.new(:name => 'my region') | 67 | region = Region.new(:name => 'my region') |
68 | environment.regions << region | 68 | environment.regions << region |
69 | assert !region.new_record? | 69 | assert !region.new_record? |
70 | - org = Organization.create!(:name => "My frufru organization", :identifier => 'frufru', :environment_id => environment.id) | 70 | + org = create(Organization, :name => "My frufru organization", :identifier => 'frufru', :environment_id => environment.id) |
71 | 71 | ||
72 | @controller.expects(:environment).returns(environment).at_least_once | 72 | @controller.expects(:environment).returns(environment).at_least_once |
73 | 73 | ||
@@ -84,7 +84,7 @@ class RegionValidatorsControllerTest < ActionController::TestCase | @@ -84,7 +84,7 @@ class RegionValidatorsControllerTest < ActionController::TestCase | ||
84 | region = Region.new(:name => 'my region') | 84 | region = Region.new(:name => 'my region') |
85 | environment.regions << region | 85 | environment.regions << region |
86 | assert !region.new_record? | 86 | assert !region.new_record? |
87 | - org = Organization.create!(:name => "My frufru organization", :identifier => 'frufru', :environment_id => environment.id) | 87 | + org = create(Organization, :name => "My frufru organization", :identifier => 'frufru', :environment_id => environment.id) |
88 | region.validators << org | 88 | region.validators << org |
89 | 89 | ||
90 | @controller.expects(:environment).returns(environment).at_least_once | 90 | @controller.expects(:environment).returns(environment).at_least_once |
test/functional/search_controller_test.rb
@@ -13,7 +13,7 @@ class SearchControllerTest < ActionController::TestCase | @@ -13,7 +13,7 @@ class SearchControllerTest < ActionController::TestCase | ||
13 | @request.stubs(:ssl?).returns(false) | 13 | @request.stubs(:ssl?).returns(false) |
14 | @response = ActionController::TestResponse.new | 14 | @response = ActionController::TestResponse.new |
15 | 15 | ||
16 | - @category = Category.create!(:name => 'my category', :environment => Environment.default) | 16 | + @category = create(Category, :name => 'my category', :environment => Environment.default) |
17 | 17 | ||
18 | env = Environment.default | 18 | env = Environment.default |
19 | domain = env.domains.first | 19 | domain = env.domains.first |
@@ -246,8 +246,8 @@ class SearchControllerTest < ActionController::TestCase | @@ -246,8 +246,8 @@ class SearchControllerTest < ActionController::TestCase | ||
246 | end | 246 | end |
247 | 247 | ||
248 | should 'search in category hierachy' do | 248 | should 'search in category hierachy' do |
249 | - parent = Category.create!(:name => 'Parent Category', :environment => Environment.default) | ||
250 | - child = Category.create!(:name => 'Child Category', :environment => Environment.default, :parent => parent) | 249 | + parent = create(Category, :name => 'Parent Category', :environment => Environment.default) |
250 | + child = create(Category, :name => 'Child Category', :environment => Environment.default, :parent => parent) | ||
251 | 251 | ||
252 | p = create_profile_with_optional_category(Person, 'test_profile', child) | 252 | p = create_profile_with_optional_category(Person, 'test_profile', child) |
253 | 253 | ||
@@ -277,10 +277,10 @@ class SearchControllerTest < ActionController::TestCase | @@ -277,10 +277,10 @@ class SearchControllerTest < ActionController::TestCase | ||
277 | 277 | ||
278 | should 'search all enabled assets in general search' do | 278 | should 'search all enabled assets in general search' do |
279 | ent1 = create_profile_with_optional_category(Enterprise, 'test enterprise') | 279 | ent1 = create_profile_with_optional_category(Enterprise, 'test enterprise') |
280 | - prod_cat = ProductCategory.create!(:name => 'pctest', :environment => Environment.default) | 280 | + prod_cat = create(ProductCategory, :name => 'pctest', :environment => Environment.default) |
281 | prod = ent1.products.create!(:name => 'test product', :product_category => prod_cat) | 281 | prod = ent1.products.create!(:name => 'test product', :product_category => prod_cat) |
282 | - art = Article.create!(:name => 'test article', :profile_id => fast_create(Person).id) | ||
283 | - per = Person.create!(:name => 'test person', :identifier => 'test-person', :user_id => fast_create(User).id) | 282 | + art = create(Article, :name => 'test article', :profile_id => fast_create(Person).id) |
283 | + per = create(Person, :name => 'test person', :identifier => 'test-person', :user_id => fast_create(User).id) | ||
284 | com = Community.create!(:name => 'test community') | 284 | com = Community.create!(:name => 'test community') |
285 | eve = Event.create!(:name => 'test event', :profile_id => fast_create(Person).id) | 285 | eve = Event.create!(:name => 'test event', :profile_id => fast_create(Person).id) |
286 | 286 | ||
@@ -294,8 +294,8 @@ class SearchControllerTest < ActionController::TestCase | @@ -294,8 +294,8 @@ class SearchControllerTest < ActionController::TestCase | ||
294 | end | 294 | end |
295 | 295 | ||
296 | should 'display category image while in directory' do | 296 | should 'display category image while in directory' do |
297 | - parent = Category.create!(:name => 'category1', :environment => Environment.default) | ||
298 | - cat = Category.create!(:name => 'category2', :environment => Environment.default, :parent => parent, | 297 | + parent = create(Category, :name => 'category1', :environment => Environment.default) |
298 | + cat = create(Category, :name => 'category2', :environment => Environment.default, :parent => parent, | ||
299 | :image_builder => {:uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')} | 299 | :image_builder => {:uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')} |
300 | ) | 300 | ) |
301 | 301 | ||
@@ -379,10 +379,10 @@ class SearchControllerTest < ActionController::TestCase | @@ -379,10 +379,10 @@ class SearchControllerTest < ActionController::TestCase | ||
379 | end | 379 | end |
380 | 380 | ||
381 | should 'display only within a product category when specified' do | 381 | should 'display only within a product category when specified' do |
382 | - prod_cat = ProductCategory.create!(:name => 'prod cat test', :environment => Environment.default) | 382 | + prod_cat = create(ProductCategory, :name => 'prod cat test', :environment => Environment.default) |
383 | ent = create_profile_with_optional_category(Enterprise, 'test ent') | 383 | ent = create_profile_with_optional_category(Enterprise, 'test ent') |
384 | 384 | ||
385 | - p = prod_cat.products.create!(:name => 'prod test 1', :enterprise => ent) | 385 | + p = create(Product, :product_category => prod_cat, :name => 'prod test 1', :enterprise => ent) |
386 | 386 | ||
387 | get :products, :product_category => prod_cat.id | 387 | get :products, :product_category => prod_cat.id |
388 | 388 | ||
@@ -390,12 +390,12 @@ class SearchControllerTest < ActionController::TestCase | @@ -390,12 +390,12 @@ class SearchControllerTest < ActionController::TestCase | ||
390 | end | 390 | end |
391 | 391 | ||
392 | should 'display properly in conjuntion with a category' do | 392 | should 'display properly in conjuntion with a category' do |
393 | - cat = Category.create(:name => 'cat', :environment => Environment.default) | ||
394 | - prod_cat1 = ProductCategory.create!(:name => 'prod cat test 1', :environment => Environment.default) | ||
395 | - prod_cat2 = ProductCategory.create!(:name => 'prod cat test 2', :environment => Environment.default, :parent => prod_cat1) | 393 | + cat = create(Category, :name => 'cat', :environment => Environment.default) |
394 | + prod_cat1 = create(ProductCategory, :name => 'prod cat test 1', :environment => Environment.default) | ||
395 | + prod_cat2 = create(ProductCategory, :name => 'prod cat test 2', :environment => Environment.default, :parent => prod_cat1) | ||
396 | ent = create_profile_with_optional_category(Enterprise, 'test ent', cat) | 396 | ent = create_profile_with_optional_category(Enterprise, 'test ent', cat) |
397 | 397 | ||
398 | - product = prod_cat2.products.create!(:name => 'prod test 1', :enterprise_id => ent.id) | 398 | + product = create(Product, :product_category => prod_cat2, :name => 'prod test 1', :enterprise_id => ent.id) |
399 | 399 | ||
400 | get :products, :category_path => cat.path.split('/'), :product_category => prod_cat1.id | 400 | get :products, :category_path => cat.path.split('/'), :product_category => prod_cat1.id |
401 | 401 | ||
@@ -588,7 +588,7 @@ class SearchControllerTest < ActionController::TestCase | @@ -588,7 +588,7 @@ class SearchControllerTest < ActionController::TestCase | ||
588 | 588 | ||
589 | should 'show tag cloud' do | 589 | should 'show tag cloud' do |
590 | @controller.stubs(:is_cache_expired?).returns(true) | 590 | @controller.stubs(:is_cache_expired?).returns(true) |
591 | - a = Article.create!(:name => 'my article', :profile_id => fast_create(Person).id) | 591 | + a = create(Article, :name => 'my article', :profile_id => fast_create(Person).id) |
592 | a.tag_list = ['one', 'two'] | 592 | a.tag_list = ['one', 'two'] |
593 | a.save_tags | 593 | a.save_tags |
594 | 594 | ||
@@ -600,8 +600,8 @@ class SearchControllerTest < ActionController::TestCase | @@ -600,8 +600,8 @@ class SearchControllerTest < ActionController::TestCase | ||
600 | 600 | ||
601 | should 'show tagged content' do | 601 | should 'show tagged content' do |
602 | @controller.stubs(:is_cache_expired?).returns(true) | 602 | @controller.stubs(:is_cache_expired?).returns(true) |
603 | - a = Article.create!(:name => 'my article', :profile_id => fast_create(Person).id) | ||
604 | - a2 = Article.create!(:name => 'my article 2', :profile_id => fast_create(Person).id) | 603 | + a = Article.create!(:name => 'my article', :profile => fast_create(Person)) |
604 | + a2 = Article.create!(:name => 'my article 2', :profile => fast_create(Person)) | ||
605 | a.tag_list = ['one', 'two'] | 605 | a.tag_list = ['one', 'two'] |
606 | a2.tag_list = ['two', 'three'] | 606 | a2.tag_list = ['two', 'three'] |
607 | a.save_tags | 607 | a.save_tags |
@@ -630,9 +630,9 @@ class SearchControllerTest < ActionController::TestCase | @@ -630,9 +630,9 @@ class SearchControllerTest < ActionController::TestCase | ||
630 | 630 | ||
631 | should 'order articles by more recent' do | 631 | should 'order articles by more recent' do |
632 | Article.destroy_all | 632 | Article.destroy_all |
633 | - art1 = Article.create!(:name => 'review C', :profile_id => fast_create(Person).id, :created_at => Time.now-1.days) | ||
634 | - art2 = Article.create!(:name => 'review A', :profile_id => fast_create(Person).id, :created_at => Time.now) | ||
635 | - art3 = Article.create!(:name => 'review B', :profile_id => fast_create(Person).id, :created_at => Time.now-2.days) | 633 | + art1 = create(Article, :name => 'review C', :profile_id => fast_create(Person).id, :created_at => Time.now-1.days) |
634 | + art2 = create(Article, :name => 'review A', :profile_id => fast_create(Person).id, :created_at => Time.now) | ||
635 | + art3 = create(Article, :name => 'review B', :profile_id => fast_create(Person).id, :created_at => Time.now-2.days) | ||
636 | 636 | ||
637 | get :articles, :filter => :more_recent | 637 | get :articles, :filter => :more_recent |
638 | 638 | ||
@@ -641,14 +641,14 @@ class SearchControllerTest < ActionController::TestCase | @@ -641,14 +641,14 @@ class SearchControllerTest < ActionController::TestCase | ||
641 | 641 | ||
642 | should 'add highlighted CSS class around a highlighted product' do | 642 | should 'add highlighted CSS class around a highlighted product' do |
643 | enterprise = fast_create(Enterprise) | 643 | enterprise = fast_create(Enterprise) |
644 | - product = Product.create!(:name => 'Enter Sandman', :enterprise_id => enterprise.id, :product_category_id => @product_category.id, :highlighted => true) | 644 | + product = create(Product, :name => 'Enter Sandman', :enterprise_id => enterprise.id, :product_category_id => @product_category.id, :highlighted => true) |
645 | get :products | 645 | get :products |
646 | assert_tag :tag => 'li', :attributes => { :class => 'search-product-item highlighted' }, :content => /Enter Sandman/ | 646 | assert_tag :tag => 'li', :attributes => { :class => 'search-product-item highlighted' }, :content => /Enter Sandman/ |
647 | end | 647 | end |
648 | 648 | ||
649 | should 'do not add highlighted CSS class around an ordinary product' do | 649 | should 'do not add highlighted CSS class around an ordinary product' do |
650 | enterprise = fast_create(Enterprise) | 650 | enterprise = fast_create(Enterprise) |
651 | - product = Product.create!(:name => 'Holier Than Thou', :enterprise_id => enterprise.id, :product_category_id => @product_category.id, :highlighted => false) | 651 | + product = create(Product, :name => 'Holier Than Thou', :enterprise_id => enterprise.id, :product_category_id => @product_category.id, :highlighted => false) |
652 | get :products | 652 | get :products |
653 | assert_no_tag :tag => 'li', :attributes => { :class => 'search-product-item highlighted' }, :content => /Holier Than Thou/ | 653 | assert_no_tag :tag => 'li', :attributes => { :class => 'search-product-item highlighted' }, :content => /Holier Than Thou/ |
654 | end | 654 | end |
@@ -656,7 +656,7 @@ class SearchControllerTest < ActionController::TestCase | @@ -656,7 +656,7 @@ class SearchControllerTest < ActionController::TestCase | ||
656 | protected | 656 | protected |
657 | 657 | ||
658 | def create_event(profile, options) | 658 | def create_event(profile, options) |
659 | - ev = Event.new({ :name => 'some event', :start_date => Date.new(2008,1,1) }.merge(options)) | 659 | + ev = build(Event, { :name => 'some event', :start_date => Date.new(2008,1,1) }.merge(options)) |
660 | ev.profile = profile | 660 | ev.profile = profile |
661 | ev.save! | 661 | ev.save! |
662 | ev | 662 | ev |
test/functional/tasks_controller_test.rb
@@ -59,8 +59,8 @@ class TasksControllerTest < ActionController::TestCase | @@ -59,8 +59,8 @@ class TasksControllerTest < ActionController::TestCase | ||
59 | 59 | ||
60 | should 'list processed tasks without spam' do | 60 | should 'list processed tasks without spam' do |
61 | requestor = fast_create(Person) | 61 | requestor = fast_create(Person) |
62 | - task_spam = Task.create!(:status => Task::Status::FINISHED, :requestor => requestor, :target => profile, :spam => true) | ||
63 | - task_ham = Task.create!(:status => Task::Status::FINISHED, :requestor => requestor, :target => profile, :spam => false) | 62 | + task_spam = create(Task, :status => Task::Status::FINISHED, :requestor => requestor, :target => profile, :spam => true) |
63 | + task_ham = create(Task, :status => Task::Status::FINISHED, :requestor => requestor, :target => profile, :spam => false) | ||
64 | 64 | ||
65 | get :processed | 65 | get :processed |
66 | assert_response :success | 66 | assert_response :success |
@@ -197,7 +197,7 @@ class TasksControllerTest < ActionController::TestCase | @@ -197,7 +197,7 @@ class TasksControllerTest < ActionController::TestCase | ||
197 | c = fast_create(Community) | 197 | c = fast_create(Community) |
198 | c.update_attributes(:moderated_articles => false) | 198 | c.update_attributes(:moderated_articles => false) |
199 | @controller.stubs(:profile).returns(c) | 199 | @controller.stubs(:profile).returns(c) |
200 | - folder = c.articles.create!(:name => 'test folder', :type => 'Folder') | 200 | + folder = create(Article, :profile => c, :name => 'test folder', :type => 'Folder') |
201 | c.affiliate(profile, Profile::Roles.all_roles(profile.environment.id)) | 201 | c.affiliate(profile, Profile::Roles.all_roles(profile.environment.id)) |
202 | article = profile.articles.create!(:name => 'something interesting', :body => 'ruby on rails') | 202 | article = profile.articles.create!(:name => 'something interesting', :body => 'ruby on rails') |
203 | t = ApproveArticle.create!(:name => 'test name', :article => article, :target => c, :requestor => profile) | 203 | t = ApproveArticle.create!(:name => 'test name', :article => article, :target => c, :requestor => profile) |
@@ -210,7 +210,7 @@ class TasksControllerTest < ActionController::TestCase | @@ -210,7 +210,7 @@ class TasksControllerTest < ActionController::TestCase | ||
210 | c = fast_create(Community) | 210 | c = fast_create(Community) |
211 | c.update_attributes(:moderated_articles => false) | 211 | c.update_attributes(:moderated_articles => false) |
212 | @controller.stubs(:profile).returns(c) | 212 | @controller.stubs(:profile).returns(c) |
213 | - folder = c.articles.create!(:name => 'test folder', :type => 'Folder') | 213 | + folder = create(Article, :profile => c, :name => 'test folder', :type => 'Folder') |
214 | c.affiliate(profile, Profile::Roles.all_roles(profile.environment.id)) | 214 | c.affiliate(profile, Profile::Roles.all_roles(profile.environment.id)) |
215 | article = profile.articles.create!(:name => 'something interesting', :body => 'ruby on rails') | 215 | article = profile.articles.create!(:name => 'something interesting', :body => 'ruby on rails') |
216 | t = ApproveArticle.create!(:article => article, :target => c, :requestor => profile) | 216 | t = ApproveArticle.create!(:article => article, :target => c, :requestor => profile) |
@@ -357,10 +357,10 @@ class TasksControllerTest < ActionController::TestCase | @@ -357,10 +357,10 @@ class TasksControllerTest < ActionController::TestCase | ||
357 | should 'return tasks ordered accordingly and limited by pages' do | 357 | should 'return tasks ordered accordingly and limited by pages' do |
358 | time = Time.now | 358 | time = Time.now |
359 | person = fast_create(Person) | 359 | person = fast_create(Person) |
360 | - t1 = Task.create!(:status => Task::Status::ACTIVE, :target => profile, :requestor => person, :created_at => time) | ||
361 | - t2 = Task.create!(:status => Task::Status::ACTIVE, :target => profile, :requestor => person, :created_at => time + 1.second) | ||
362 | - t3 = Task.create!(:status => Task::Status::ACTIVE, :target => profile, :requestor => person, :created_at => time + 2.seconds) | ||
363 | - t4 = Task.create!(:status => Task::Status::ACTIVE, :target => profile, :requestor => person, :created_at => time + 3.seconds) | 360 | + t1 = create(Task, :status => Task::Status::ACTIVE, :target => profile, :requestor => person, :created_at => time) |
361 | + t2 = create(Task, :status => Task::Status::ACTIVE, :target => profile, :requestor => person, :created_at => time + 1.second) | ||
362 | + t3 = create(Task, :status => Task::Status::ACTIVE, :target => profile, :requestor => person, :created_at => time + 2.seconds) | ||
363 | + t4 = create(Task, :status => Task::Status::ACTIVE, :target => profile, :requestor => person, :created_at => time + 3.seconds) | ||
364 | 364 | ||
365 | Task.stubs(:per_page).returns(2) | 365 | Task.stubs(:per_page).returns(2) |
366 | 366 |
test/functional/themes_controller_test.rb
@@ -254,7 +254,7 @@ class ThemesControllerTest < ActionController::TestCase | @@ -254,7 +254,7 @@ class ThemesControllerTest < ActionController::TestCase | ||
254 | end | 254 | end |
255 | 255 | ||
256 | should 'display links to set template' do | 256 | should 'display links to set template' do |
257 | - profile.update_attributes!(:layout_template => 'rightbar') | 257 | + profile.update_attributes!({:layout_template => 'rightbar'}, :without_protection => true) |
258 | t1 = LayoutTemplate.find('default') | 258 | t1 = LayoutTemplate.find('default') |
259 | t2 = LayoutTemplate.find('leftbar') | 259 | t2 = LayoutTemplate.find('leftbar') |
260 | LayoutTemplate.expects(:all).returns([t1, t2]) | 260 | LayoutTemplate.expects(:all).returns([t1, t2]) |
@@ -265,7 +265,7 @@ class ThemesControllerTest < ActionController::TestCase | @@ -265,7 +265,7 @@ class ThemesControllerTest < ActionController::TestCase | ||
265 | end | 265 | end |
266 | 266 | ||
267 | should 'highlight current template' do | 267 | should 'highlight current template' do |
268 | - profile.update_attributes!(:layout_template => 'default') | 268 | + profile.update_attributes!({:layout_template => 'default'}, :without_protection => true) |
269 | 269 | ||
270 | t1 = LayoutTemplate.find('default') | 270 | t1 = LayoutTemplate.find('default') |
271 | t2 = LayoutTemplate.find('leftbar') | 271 | t2 = LayoutTemplate.find('leftbar') |