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 | 166 | end |
167 | 167 | if request.post? && params[:uploaded_files] |
168 | 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 | 170 | end |
171 | 171 | @errors = @uploaded_files.select { |f| f.errors.any? } |
172 | 172 | if @errors.any? | ... | ... |
app/controllers/my_profile/manage_products_controller.rb
... | ... | @@ -85,7 +85,7 @@ class ManageProductsController < ApplicationController |
85 | 85 | @edit = true |
86 | 86 | @level = @category.level |
87 | 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 | 89 | render :partial => 'shared/redirect_via_javascript', |
90 | 90 | :locals => { :url => url_for(:controller => 'manage_products', :action => 'show', :id => @product) } |
91 | 91 | else | ... | ... |
app/models/article.rb
... | ... | @@ -2,7 +2,7 @@ require 'hpricot' |
2 | 2 | |
3 | 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 | 7 | acts_as_having_image |
8 | 8 | ... | ... |
app/models/article_block.rb
app/models/block.rb
app/models/blog.rb
app/models/category.rb
app/models/comment.rb
app/models/environment.rb
... | ... | @@ -3,7 +3,7 @@ |
3 | 3 | # domains. |
4 | 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 | 8 | has_many :users |
9 | 9 | ... | ... |
app/models/input.rb
app/models/organization.rb
app/models/person.rb
app/models/product.rb
app/models/production_cost.rb
app/models/products_block.rb
app/models/profile.rb
... | ... | @@ -3,7 +3,7 @@ |
3 | 3 | # which by default is the one returned by Environment:default. |
4 | 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 | 8 | # use for internationalizable human type names in search facets |
9 | 9 | # reimplement on subclasses | ... | ... |
app/models/rss_feed.rb
app/models/state.rb
app/models/uploaded_file.rb
app/models/validation_info.rb
test/functional/account_controller_test.rb
... | ... | @@ -102,7 +102,7 @@ class AccountControllerTest < ActionController::TestCase |
102 | 102 | |
103 | 103 | def test_shoud_not_save_without_acceptance_of_terms_of_use_on_signup |
104 | 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 | 106 | new_user |
107 | 107 | assert_response :success |
108 | 108 | assert_nil assigns(:register_pending) |
... | ... | @@ -111,7 +111,7 @@ class AccountControllerTest < ActionController::TestCase |
111 | 111 | |
112 | 112 | def test_shoud_save_with_acceptance_of_terms_of_use_on_signup |
113 | 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 | 115 | new_user(:terms_accepted => '1') |
116 | 116 | assert_response :success |
117 | 117 | assert_not_nil assigns(:register_pending) | ... | ... |
test/functional/admin_panel_controller_test.rb
... | ... | @@ -245,7 +245,7 @@ class AdminPanelControllerTest < ActionController::TestCase |
245 | 245 | e = Environment.default |
246 | 246 | @controller.stubs(:environment).returns(e) |
247 | 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 | 250 | post :set_portal_community, :portal_community_identifier => c.identifier |
251 | 251 | e.reload | ... | ... |
test/functional/application_controller_test.rb
... | ... | @@ -174,8 +174,8 @@ class ApplicationControllerTest < ActionController::TestCase |
174 | 174 | |
175 | 175 | should 'display only some categories in menu' do |
176 | 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 | 179 | get :index |
180 | 180 | assert_tag :tag => 'a', :content => /Category 2/ |
181 | 181 | end |
... | ... | @@ -247,8 +247,8 @@ class ApplicationControllerTest < ActionController::TestCase |
247 | 247 | |
248 | 248 | should 'not display categories menu if categories feature disabled' do |
249 | 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 | 252 | get :index |
253 | 253 | assert_no_tag :tag => 'a', :content => /Category 2/ |
254 | 254 | end | ... | ... |
test/functional/catalog_controller_test.rb
... | ... | @@ -104,10 +104,10 @@ class CatalogControllerTest < ActionController::TestCase |
104 | 104 | end |
105 | 105 | |
106 | 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 | 111 | p1 = fast_create(Product, :product_category_id => pc1.id, :enterprise_id => @enterprise.id) |
112 | 112 | p2 = fast_create(Product, :product_category_id => pc2.id, :enterprise_id => @enterprise.id) |
113 | 113 | p3 = fast_create(Product, :product_category_id => pc3.id, :enterprise_id => @enterprise.id) |
... | ... | @@ -122,10 +122,10 @@ class CatalogControllerTest < ActionController::TestCase |
122 | 122 | end |
123 | 123 | |
124 | 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 | 129 | p1 = fast_create(Product, :product_category_id => pc1.id, :enterprise_id => @enterprise.id) |
130 | 130 | p2 = fast_create(Product, :product_category_id => pc2.id, :enterprise_id => @enterprise.id) |
131 | 131 | p3 = fast_create(Product, :product_category_id => pc3.id, :enterprise_id => @enterprise.id) |
... | ... | @@ -171,10 +171,10 @@ class CatalogControllerTest < ActionController::TestCase |
171 | 171 | end |
172 | 172 | |
173 | 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 | 178 | p1 = fast_create(Product, :product_category_id => pc1.id, :enterprise_id => @enterprise.id) |
179 | 179 | p2 = fast_create(Product, :product_category_id => pc2.id, :enterprise_id => @enterprise.id) |
180 | 180 | p3 = fast_create(Product, :product_category_id => pc3.id, :enterprise_id => @enterprise.id) |
... | ... | @@ -190,10 +190,10 @@ class CatalogControllerTest < ActionController::TestCase |
190 | 190 | |
191 | 191 | |
192 | 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 | 197 | p1 = fast_create(Product, :product_category_id => pc1.id, :enterprise_id => @enterprise.id) |
198 | 198 | p2 = fast_create(Product, :product_category_id => pc2.id, :enterprise_id => @enterprise.id) |
199 | 199 | p3 = fast_create(Product, :product_category_id => pc3.id, :enterprise_id => @enterprise.id) |
... | ... | @@ -208,7 +208,7 @@ class CatalogControllerTest < ActionController::TestCase |
208 | 208 | end |
209 | 209 | |
210 | 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 | 212 | p1 = fast_create(Product, :product_category_id => category.id, :enterprise_id => @enterprise.id, :highlighted => true) |
213 | 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 | 221 | should 'sort categories by name' do |
222 | 222 | environment = @enterprise.environment |
223 | 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 | 228 | p1 = fast_create(Product, :product_category_id => pc1.id, :enterprise_id => @enterprise.id) |
229 | 229 | p2 = fast_create(Product, :product_category_id => pc2.id, :enterprise_id => @enterprise.id) |
230 | 230 | p3 = fast_create(Product, :product_category_id => pc3.id, :enterprise_id => @enterprise.id) |
... | ... | @@ -240,8 +240,8 @@ class CatalogControllerTest < ActionController::TestCase |
240 | 240 | p2 = fast_create(Product, :product_category_id => @product_category.id, :enterprise_id => @enterprise.id) |
241 | 241 | Product.any_instance.stubs(:price_described?).returns(true) |
242 | 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 | 246 | get :index, :profile => @enterprise.identifier |
247 | 247 | ... | ... |
test/functional/categories_controller_test.rb
... | ... | @@ -74,7 +74,7 @@ class CategoriesControllerTest < ActionController::TestCase |
74 | 74 | end |
75 | 75 | |
76 | 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 | 78 | post :remove, :id => cat.id |
79 | 79 | assert_redirected_to :action => 'index' |
80 | 80 | assert_raise ActiveRecord::RecordNotFound do |
... | ... | @@ -90,13 +90,13 @@ class CategoriesControllerTest < ActionController::TestCase |
90 | 90 | end |
91 | 91 | |
92 | 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 | 94 | @controller.expects(:expire_fragment).with(:controller => 'public', :action => 'categories_menu').at_least_once |
95 | 95 | post :edit, :id => cat.id, :category => { :name => 'new name for category in menu' } |
96 | 96 | end |
97 | 97 | |
98 | 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 | 100 | @controller.expects(:expire_fragment).with(:controller => 'public', :action => 'categories_menu').never |
101 | 101 | post :edit, :id => cat.id, :category => { :name => 'new name for category not in menu' } |
102 | 102 | end |
... | ... | @@ -107,7 +107,7 @@ class CategoriesControllerTest < ActionController::TestCase |
107 | 107 | end |
108 | 108 | |
109 | 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 | 111 | @controller.expects(:expire_fragment).with(:controller => 'public', :action => 'categories_menu').never |
112 | 112 | get :edit, :id => cat.id |
113 | 113 | end |
... | ... | @@ -123,7 +123,7 @@ class CategoriesControllerTest < ActionController::TestCase |
123 | 123 | end |
124 | 124 | |
125 | 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 | 127 | @controller.expects(:expire_fragment).with(:controller => 'public', :action => 'categories_menu').never |
128 | 128 | |
129 | 129 | post :edit, :id => cat.id, :category => { :name => '' } |
... | ... | @@ -155,9 +155,9 @@ class CategoriesControllerTest < ActionController::TestCase |
155 | 155 | |
156 | 156 | should 'not list regions and product categories' do |
157 | 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 | 162 | get :index |
163 | 163 | assert_equal [c], assigns(:categories) |
... | ... | @@ -166,7 +166,7 @@ class CategoriesControllerTest < ActionController::TestCase |
166 | 166 | end |
167 | 167 | |
168 | 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 | 170 | post :new, :parent_id => parent.id, :parent_type => parent.class.name, :category => {:name => 'Subcategory'} |
171 | 171 | sub = ProductCategory.find_by_name('Subcategory') |
172 | 172 | assert_equal parent.class, sub.class | ... | ... |
test/functional/cms_controller_test.rb
... | ... | @@ -284,7 +284,7 @@ class CmsControllerTest < ActionController::TestCase |
284 | 284 | |
285 | 285 | should 'be able to update a RSS feed' do |
286 | 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 | 288 | post :edit, :profile => profile.identifier, :id => feed.id, :article => { :limit => 77, :include => 'parent_and_children' } |
289 | 289 | assert_response :redirect |
290 | 290 | |
... | ... | @@ -585,7 +585,7 @@ class CmsControllerTest < ActionController::TestCase |
585 | 585 | |
586 | 586 | should 'redirect back to article after editing article inside a folder' do |
587 | 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 | 590 | post :edit, :profile => profile.identifier, :id => a.id |
591 | 591 | assert_redirected_to @profile.articles.find_by_name('article-inside-folder').url |
... | ... | @@ -612,7 +612,7 @@ class CmsControllerTest < ActionController::TestCase |
612 | 612 | |
613 | 613 | should 'point back to folder when cancelling edition of an article inside it' do |
614 | 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 | 616 | get :edit, :profile => profile.identifier, :id => a.id |
617 | 617 | |
618 | 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 | 641 | end |
642 | 642 | |
643 | 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 | 646 | get :edit, :profile => profile.identifier, :id => article.id |
647 | 647 | assert_tag :tag => 'input', :attributes => { :type => 'radio', :name => 'article[published]', :id => 'article_published_true' } |
... | ... | @@ -734,7 +734,7 @@ class CmsControllerTest < ActionController::TestCase |
734 | 734 | end |
735 | 735 | |
736 | 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 | 739 | post :new, :profile => profile.identifier, :type => 'TextileArticle', :parent_id => folder.id, :article => { :name => 'new-private-article'} |
740 | 740 | folder.reload |
... | ... | @@ -901,7 +901,7 @@ class CmsControllerTest < ActionController::TestCase |
901 | 901 | end |
902 | 902 | |
903 | 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 | 905 | blog.save! |
906 | 906 | post :edit, :profile => profile.identifier, :id => blog.id, :remove_image => 'true' |
907 | 907 | blog.reload |
... | ... | @@ -1194,7 +1194,7 @@ class CmsControllerTest < ActionController::TestCase |
1194 | 1194 | should 'not allow user edit article if he is owner but has no publish permission' do |
1195 | 1195 | c = Community.create!(:name => 'test_comm', :identifier => 'test_comm') |
1196 | 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 | 1198 | login_as :test_user |
1199 | 1199 | |
1200 | 1200 | get :edit, :profile => c.identifier, :id => a.id |
... | ... | @@ -1205,7 +1205,7 @@ class CmsControllerTest < ActionController::TestCase |
1205 | 1205 | should 'allow user edit article if he is owner and has publish permission' do |
1206 | 1206 | c = Community.create!(:name => 'test_comm', :identifier => 'test_comm') |
1207 | 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 | 1209 | login_as :test_user |
1210 | 1210 | @controller.stubs(:user).returns(u) |
1211 | 1211 | ... | ... |
test/functional/comment_controller_test.rb
... | ... | @@ -266,7 +266,7 @@ class CommentControllerTest < ActionController::TestCase |
266 | 266 | should 'not create ApproveComment task when the comment author is the same of article author' do |
267 | 267 | login_as @profile.identifier |
268 | 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 | 270 | community.add_moderator(@profile) |
271 | 271 | |
272 | 272 | assert_no_difference 'ApproveComment.count' do |
... | ... | @@ -381,7 +381,7 @@ class CommentControllerTest < ActionController::TestCase |
381 | 381 | should 'touch article after adding a comment' do |
382 | 382 | yesterday = Time.now.yesterday |
383 | 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 | 385 | Article.record_timestamps = true |
386 | 386 | |
387 | 387 | login_as @profile.identifier | ... | ... |
test/functional/content_viewer_controller_test.rb
... | ... | @@ -122,7 +122,7 @@ class ContentViewerControllerTest < ActionController::TestCase |
122 | 122 | |
123 | 123 | should 'not display forbidden articles' do |
124 | 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 | 127 | Article.any_instance.expects(:display_to?).with(anything).returns(false) |
128 | 128 | get :view_page, :profile => profile.identifier, :page => [ 'test' ] |
... | ... | @@ -131,7 +131,7 @@ class ContentViewerControllerTest < ActionController::TestCase |
131 | 131 | |
132 | 132 | should 'display allowed articles' do |
133 | 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 | 136 | Article.any_instance.expects(:display_to?).with(anything).returns(true) |
137 | 137 | get :view_page, :profile => profile.identifier, :page => [ 'test' ] |
... | ... | @@ -384,7 +384,7 @@ class ContentViewerControllerTest < ActionController::TestCase |
384 | 384 | end |
385 | 385 | |
386 | 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 | 389 | current = fast_create(Environment, :name => 'test environment') |
390 | 390 | current.domains.create!(:name => 'example.com') |
... | ... | @@ -458,7 +458,7 @@ class ContentViewerControllerTest < ActionController::TestCase |
458 | 458 | blog = Blog.create!(:name => "blog", :profile => profile) |
459 | 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 | 462 | current_post = TextileArticle.create!(:name => "current post", :profile => profile, :parent => blog) |
463 | 463 | blog.children << past_post |
464 | 464 | blog.children << current_post |
... | ... | @@ -726,7 +726,7 @@ class ContentViewerControllerTest < ActionController::TestCase |
726 | 726 | c = Community.create!(:name => 'test_com') |
727 | 727 | u = create_user_with_permission('test_user', 'publish_content', c) |
728 | 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 | 731 | get :view_page, :profile => c.identifier, :page => a.explode_path |
732 | 732 | |
... | ... | @@ -738,7 +738,7 @@ class ContentViewerControllerTest < ActionController::TestCase |
738 | 738 | c = Community.create!(:name => 'test_com') |
739 | 739 | u = create_user_with_permission('test_user', 'publish_content', c) |
740 | 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 | 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 | 847 | forum = Forum.create!(:name => "forum", :profile => profile) |
848 | 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 | 851 | current_post = TextileArticle.create!(:name => "current post", :profile => profile, :parent => forum) |
852 | 852 | forum.children << past_post |
853 | 853 | forum.children << current_post |
... | ... | @@ -1051,7 +1051,7 @@ class ContentViewerControllerTest < ActionController::TestCase |
1051 | 1051 | article = profile.articles.build(:name => 'test') |
1052 | 1052 | article.save! |
1053 | 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 | 1055 | login_as 'testuser' |
1056 | 1056 | get :view_page, :profile => 'testuser', :page => [ 'test' ] |
1057 | 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 | 81 | |
82 | 82 | should 'display block in index page if it\'s configured to display on homepage and its an environment block' do |
83 | 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 | 85 | block = Block.create(:title => "Index Block", :box_id => box.id, :display => 'home_page_only') |
86 | 86 | env.save! |
87 | 87 | ... | ... |
test/functional/invite_controller_test.rb
... | ... | @@ -185,7 +185,7 @@ class InviteControllerTest < ActionController::TestCase |
185 | 185 | end |
186 | 186 | |
187 | 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 | 189 | get :invitation_data, :profile => profile.identifier, :contact_list => contact_list.id |
190 | 190 | hash = {'fetched' => true, 'contact_list' => contact_list.id, 'error' => nil} |
191 | 191 | |
... | ... | @@ -194,7 +194,7 @@ class InviteControllerTest < ActionController::TestCase |
194 | 194 | end |
195 | 195 | |
196 | 196 | should 'render empty list of contacts' do |
197 | - contact_list = ContactList.create(:fetched => true) | |
197 | + contact_list = create(ContactList, :fetched => true) | |
198 | 198 | get :add_contact_list, :profile => profile.identifier, :contact_list => contact_list.id |
199 | 199 | |
200 | 200 | assert_response :success |
... | ... | @@ -203,7 +203,7 @@ class InviteControllerTest < ActionController::TestCase |
203 | 203 | end |
204 | 204 | |
205 | 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 | 207 | get :add_contact_list, :profile => profile.identifier, :contact_list => contact_list.id |
208 | 208 | |
209 | 209 | assert_response :success | ... | ... |
test/functional/manage_products_controller_test.rb
... | ... | @@ -261,7 +261,7 @@ class ManageProductsControllerTest < ActionController::TestCase |
261 | 261 | end |
262 | 262 | |
263 | 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 | 265 | prod = enterprise.products.create!(:name => 'Product test', :product_category => @product_category) |
266 | 266 | get :show, :id => prod.id, :profile => enterprise.identifier |
267 | 267 | assert_tag({ | ... | ... |
test/functional/map_balloon_controller_test.rb
... | ... | @@ -17,14 +17,14 @@ class MapBalloonControllerTest < ActionController::TestCase |
17 | 17 | end |
18 | 18 | |
19 | 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 | 21 | :enterprise_id => fast_create(Enterprise).id) |
22 | 22 | get :product, :id => prod.id |
23 | 23 | assert_equal prod, assigns(:product) |
24 | 24 | end |
25 | 25 | |
26 | 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 | 28 | get :person, :id => pers.id |
29 | 29 | assert_equal pers, assigns(:profile) |
30 | 30 | end | ... | ... |
test/functional/profile_controller_test.rb
... | ... | @@ -367,7 +367,7 @@ class ProfileControllerTest < ActionController::TestCase |
367 | 367 | |
368 | 368 | should 'display contact button for community if its enable in environment' do |
369 | 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 | 371 | community.boxes.first.blocks << block = ProfileInfoBlock.create! |
372 | 372 | env.disable('disable_contact_community') |
373 | 373 | env.save! |
... | ... | @@ -379,7 +379,7 @@ class ProfileControllerTest < ActionController::TestCase |
379 | 379 | |
380 | 380 | should 'not display contact button for community if its disable in environment' do |
381 | 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 | 383 | community.boxes.first.blocks << block = ProfileInfoBlock.create! |
384 | 384 | env.enable('disable_contact_community') |
385 | 385 | env.save! |
... | ... | @@ -499,7 +499,7 @@ class ProfileControllerTest < ActionController::TestCase |
499 | 499 | end |
500 | 500 | |
501 | 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 | 503 | fast_create(TextileArticle, :name => 'Published post', :parent_id => profile.blog.id, :profile_id => profile.id) |
504 | 504 | fast_create(TextileArticle, :name => 'Other published post', :parent_id => profile.blog.id, :profile_id => profile.id) |
505 | 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 | 574 | end |
575 | 575 | |
576 | 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 | 580 | get :tag_feed, :profile => profile.identifier, :id => 'tag1' |
581 | 581 | assert_match(/Second.*First/, @response.body) |
... | ... | @@ -583,11 +583,11 @@ class ProfileControllerTest < ActionController::TestCase |
583 | 583 | |
584 | 584 | should 'display the most recent posts in tag feed' do |
585 | 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 | 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 | 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 | 592 | get :tag_feed, :profile => profile.identifier, :id => 'tag1' |
593 | 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 | 699 | |
700 | 700 | should "display a scrap sent" do |
701 | 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 | 703 | login_as(profile.identifier) |
704 | 704 | get :index, :profile => profile.identifier |
705 | 705 | assert_tag :tag => 'p', :content => 'A scrap' |
... | ... | @@ -707,7 +707,7 @@ class ProfileControllerTest < ActionController::TestCase |
707 | 707 | |
708 | 708 | should "not display a scrap sent by a removed user" do |
709 | 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 | 711 | login_as(profile.identifier) |
712 | 712 | another_person.destroy |
713 | 713 | get :index, :profile => profile.identifier |
... | ... | @@ -719,13 +719,13 @@ class ProfileControllerTest < ActionController::TestCase |
719 | 719 | p2= fast_create(Person) |
720 | 720 | |
721 | 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 | 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 | 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 | 729 | a1 = ActionTracker::Record.last |
730 | 730 | |
731 | 731 | login_as(profile.identifier) |
... | ... | @@ -736,7 +736,7 @@ class ProfileControllerTest < ActionController::TestCase |
736 | 736 | should 'see the activities_items paginated' do |
737 | 737 | p1 = create_user('some').person |
738 | 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 | 740 | login_as(p1.identifier) |
741 | 741 | get :index, :profile => p1.identifier |
742 | 742 | assert_equal 15, assigns(:activities).count |
... | ... | @@ -750,8 +750,8 @@ class ProfileControllerTest < ActionController::TestCase |
750 | 750 | assert p3.is_a_friend?(profile) |
751 | 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 | 756 | UserStampSweeper.any_instance.stubs(:current_user).returns(p3) |
757 | 757 | article1 = TinyMceArticle.create!(:profile => p3, :name => 'An article about free software') |
... | ... | @@ -773,13 +773,13 @@ class ProfileControllerTest < ActionController::TestCase |
773 | 773 | p3.add_friend(p1) |
774 | 774 | assert p3.is_a_friend?(p1) |
775 | 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 | 777 | a1 = ActionTracker::Record.last |
778 | 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 | 780 | a2 = ActionTracker::Record.last |
781 | 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 | 783 | a3 = ActionTracker::Record.last |
784 | 784 | |
785 | 785 | |
... | ... | @@ -805,13 +805,13 @@ class ProfileControllerTest < ActionController::TestCase |
805 | 805 | p3.add_friend(p1) |
806 | 806 | assert p3.is_a_friend?(p1) |
807 | 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 | 809 | a1 = ActionTracker::Record.last |
810 | 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 | 812 | a2 = ActionTracker::Record.last |
813 | 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 | 815 | a3 = ActionTracker::Record.last |
816 | 816 | |
817 | 817 | @controller.stubs(:logged_in?).returns(true) |
... | ... | @@ -854,13 +854,13 @@ class ProfileControllerTest < ActionController::TestCase |
854 | 854 | p3.add_friend(p1) |
855 | 855 | assert p3.is_a_friend?(p1) |
856 | 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 | 858 | a1 = ActionTracker::Record.last |
859 | 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 | 861 | a2 = ActionTracker::Record.last |
862 | 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 | 864 | a3 = ActionTracker::Record.last |
865 | 865 | |
866 | 866 | login_as(profile.identifier) |
... | ... | @@ -889,10 +889,10 @@ class ProfileControllerTest < ActionController::TestCase |
889 | 889 | community.add_member(p1) |
890 | 890 | community.add_member(p2) |
891 | 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 | 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 | 896 | process_delayed_job_queue |
897 | 897 | |
898 | 898 | get :index, :profile => community.identifier |
... | ... | @@ -916,13 +916,13 @@ class ProfileControllerTest < ActionController::TestCase |
916 | 916 | p3.add_friend(p1) |
917 | 917 | assert p3.is_a_friend?(p1) |
918 | 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 | 920 | a1 = ActionTracker::Record.last |
921 | 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 | 923 | a2 = ActionTracker::Record.last |
924 | 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 | 926 | a3 = ActionTracker::Record.last |
927 | 927 | |
928 | 928 | get :index, :profile => p1.identifier |
... | ... | @@ -1141,7 +1141,7 @@ class ProfileControllerTest < ActionController::TestCase |
1141 | 1141 | login_as(profile.identifier) |
1142 | 1142 | article = TinyMceArticle.create!(:profile => profile, :name => 'An Article about Free Software') |
1143 | 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 | 1145 | assert_equal 40, profile.tracked_actions.count |
1146 | 1146 | assert_equal 40, profile.activities.count |
1147 | 1147 | get :view_more_activities, :profile => profile.identifier, :page => 2 |
... | ... | @@ -1174,7 +1174,7 @@ class ProfileControllerTest < ActionController::TestCase |
1174 | 1174 | login_as(profile.identifier) |
1175 | 1175 | article = TinyMceArticle.create!(:profile => profile, :name => 'An Article about Free Software') |
1176 | 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 | 1178 | 20.times {comment = fast_create(Comment, :source_id => article, :title => 'a comment', :body => 'lalala', :created_at => Time.now)} |
1179 | 1179 | article.reload |
1180 | 1180 | get :index, :profile => profile.identifier |
... | ... | @@ -1185,7 +1185,7 @@ class ProfileControllerTest < ActionController::TestCase |
1185 | 1185 | login_as(profile.identifier) |
1186 | 1186 | article = TinyMceArticle.create!(:profile => profile, :name => 'An Article about Free Software') |
1187 | 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 | 1189 | 20.times {comment = fast_create(Comment, :source_id => article, :title => 'a comment', :body => 'lalala', :created_at => Time.now)} |
1190 | 1190 | article.reload |
1191 | 1191 | assert_equal 20, article.comments.count |
... | ... | @@ -1319,7 +1319,7 @@ class ProfileControllerTest < ActionController::TestCase |
1319 | 1319 | |
1320 | 1320 | should 'display activities and scraps together' do |
1321 | 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 | 1324 | UserStampSweeper.any_instance.stubs(:current_user).returns(profile) |
1325 | 1325 | ActionTracker::Record.destroy_all |
... | ... | @@ -1334,7 +1334,7 @@ class ProfileControllerTest < ActionController::TestCase |
1334 | 1334 | |
1335 | 1335 | should 'have scraps and activities on activities' do |
1336 | 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 | 1339 | UserStampSweeper.any_instance.stubs(:current_user).returns(profile) |
1340 | 1340 | ActionTracker::Record.destroy_all |
... | ... | @@ -1387,7 +1387,7 @@ class ProfileControllerTest < ActionController::TestCase |
1387 | 1387 | UserStampSweeper.any_instance.stubs(:current_user).returns(profile) |
1388 | 1388 | article = TinyMceArticle.create!(:profile => profile, :name => 'An article about free software') |
1389 | 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 | 1391 | to_be_removed.destroy |
1392 | 1392 | |
1393 | 1393 | login_as(profile.identifier) |
... | ... | @@ -1399,7 +1399,7 @@ class ProfileControllerTest < ActionController::TestCase |
1399 | 1399 | should 'not display spam comments in wall' do |
1400 | 1400 | UserStampSweeper.any_instance.stubs(:current_user).returns(profile) |
1401 | 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 | 1403 | comment.spam! |
1404 | 1404 | login_as(profile.identifier) |
1405 | 1405 | get :index, :profile => profile.identifier |
... | ... | @@ -1410,7 +1410,7 @@ class ProfileControllerTest < ActionController::TestCase |
1410 | 1410 | should 'display comment in wall from non logged users' do |
1411 | 1411 | UserStampSweeper.any_instance.stubs(:current_user).returns(profile) |
1412 | 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 | 1415 | login_as(profile.identifier) |
1416 | 1416 | get :index, :profile => profile.identifier | ... | ... |
test/functional/profile_editor_controller_test.rb
... | ... | @@ -68,7 +68,7 @@ class ProfileEditorControllerTest < ActionController::TestCase |
68 | 68 | |
69 | 69 | should 'display categories to choose to associate profile' do |
70 | 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 | 72 | person = profile |
73 | 73 | get :edit, :profile => profile.identifier |
74 | 74 | assert_response :success |
... | ... | @@ -78,7 +78,7 @@ class ProfileEditorControllerTest < ActionController::TestCase |
78 | 78 | |
79 | 79 | should 'save categorization of profile' do |
80 | 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 | 82 | person = profile |
83 | 83 | post :edit, :profile => profile.identifier, :profile_data => {:category_ids => [cat2.id]} |
84 | 84 | assert_response :redirect |
... | ... | @@ -233,7 +233,7 @@ class ProfileEditorControllerTest < ActionController::TestCase |
233 | 233 | |
234 | 234 | should 'show categories links on edit profile' do |
235 | 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 | 237 | person = create_user('testuser').person |
238 | 238 | get :edit, :profile => 'testuser' |
239 | 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 | 51 | region = Region.new(:name => 'my region') |
52 | 52 | environment.regions << region |
53 | 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 | 56 | @controller.expects(:environment).returns(environment).at_least_once |
57 | 57 | |
... | ... | @@ -67,7 +67,7 @@ class RegionValidatorsControllerTest < ActionController::TestCase |
67 | 67 | region = Region.new(:name => 'my region') |
68 | 68 | environment.regions << region |
69 | 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 | 72 | @controller.expects(:environment).returns(environment).at_least_once |
73 | 73 | |
... | ... | @@ -84,7 +84,7 @@ class RegionValidatorsControllerTest < ActionController::TestCase |
84 | 84 | region = Region.new(:name => 'my region') |
85 | 85 | environment.regions << region |
86 | 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 | 88 | region.validators << org |
89 | 89 | |
90 | 90 | @controller.expects(:environment).returns(environment).at_least_once | ... | ... |
test/functional/search_controller_test.rb
... | ... | @@ -13,7 +13,7 @@ class SearchControllerTest < ActionController::TestCase |
13 | 13 | @request.stubs(:ssl?).returns(false) |
14 | 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 | 18 | env = Environment.default |
19 | 19 | domain = env.domains.first |
... | ... | @@ -246,8 +246,8 @@ class SearchControllerTest < ActionController::TestCase |
246 | 246 | end |
247 | 247 | |
248 | 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 | 252 | p = create_profile_with_optional_category(Person, 'test_profile', child) |
253 | 253 | |
... | ... | @@ -277,10 +277,10 @@ class SearchControllerTest < ActionController::TestCase |
277 | 277 | |
278 | 278 | should 'search all enabled assets in general search' do |
279 | 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 | 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 | 284 | com = Community.create!(:name => 'test community') |
285 | 285 | eve = Event.create!(:name => 'test event', :profile_id => fast_create(Person).id) |
286 | 286 | |
... | ... | @@ -294,8 +294,8 @@ class SearchControllerTest < ActionController::TestCase |
294 | 294 | end |
295 | 295 | |
296 | 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 | 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 | 379 | end |
380 | 380 | |
381 | 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 | 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 | 387 | get :products, :product_category => prod_cat.id |
388 | 388 | |
... | ... | @@ -390,12 +390,12 @@ class SearchControllerTest < ActionController::TestCase |
390 | 390 | end |
391 | 391 | |
392 | 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 | 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 | 400 | get :products, :category_path => cat.path.split('/'), :product_category => prod_cat1.id |
401 | 401 | |
... | ... | @@ -588,7 +588,7 @@ class SearchControllerTest < ActionController::TestCase |
588 | 588 | |
589 | 589 | should 'show tag cloud' do |
590 | 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 | 592 | a.tag_list = ['one', 'two'] |
593 | 593 | a.save_tags |
594 | 594 | |
... | ... | @@ -600,8 +600,8 @@ class SearchControllerTest < ActionController::TestCase |
600 | 600 | |
601 | 601 | should 'show tagged content' do |
602 | 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 | 605 | a.tag_list = ['one', 'two'] |
606 | 606 | a2.tag_list = ['two', 'three'] |
607 | 607 | a.save_tags |
... | ... | @@ -630,9 +630,9 @@ class SearchControllerTest < ActionController::TestCase |
630 | 630 | |
631 | 631 | should 'order articles by more recent' do |
632 | 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 | 637 | get :articles, :filter => :more_recent |
638 | 638 | |
... | ... | @@ -641,14 +641,14 @@ class SearchControllerTest < ActionController::TestCase |
641 | 641 | |
642 | 642 | should 'add highlighted CSS class around a highlighted product' do |
643 | 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 | 645 | get :products |
646 | 646 | assert_tag :tag => 'li', :attributes => { :class => 'search-product-item highlighted' }, :content => /Enter Sandman/ |
647 | 647 | end |
648 | 648 | |
649 | 649 | should 'do not add highlighted CSS class around an ordinary product' do |
650 | 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 | 652 | get :products |
653 | 653 | assert_no_tag :tag => 'li', :attributes => { :class => 'search-product-item highlighted' }, :content => /Holier Than Thou/ |
654 | 654 | end |
... | ... | @@ -656,7 +656,7 @@ class SearchControllerTest < ActionController::TestCase |
656 | 656 | protected |
657 | 657 | |
658 | 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 | 660 | ev.profile = profile |
661 | 661 | ev.save! |
662 | 662 | ev | ... | ... |
test/functional/tasks_controller_test.rb
... | ... | @@ -59,8 +59,8 @@ class TasksControllerTest < ActionController::TestCase |
59 | 59 | |
60 | 60 | should 'list processed tasks without spam' do |
61 | 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 | 65 | get :processed |
66 | 66 | assert_response :success |
... | ... | @@ -197,7 +197,7 @@ class TasksControllerTest < ActionController::TestCase |
197 | 197 | c = fast_create(Community) |
198 | 198 | c.update_attributes(:moderated_articles => false) |
199 | 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 | 201 | c.affiliate(profile, Profile::Roles.all_roles(profile.environment.id)) |
202 | 202 | article = profile.articles.create!(:name => 'something interesting', :body => 'ruby on rails') |
203 | 203 | t = ApproveArticle.create!(:name => 'test name', :article => article, :target => c, :requestor => profile) |
... | ... | @@ -210,7 +210,7 @@ class TasksControllerTest < ActionController::TestCase |
210 | 210 | c = fast_create(Community) |
211 | 211 | c.update_attributes(:moderated_articles => false) |
212 | 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 | 214 | c.affiliate(profile, Profile::Roles.all_roles(profile.environment.id)) |
215 | 215 | article = profile.articles.create!(:name => 'something interesting', :body => 'ruby on rails') |
216 | 216 | t = ApproveArticle.create!(:article => article, :target => c, :requestor => profile) |
... | ... | @@ -357,10 +357,10 @@ class TasksControllerTest < ActionController::TestCase |
357 | 357 | should 'return tasks ordered accordingly and limited by pages' do |
358 | 358 | time = Time.now |
359 | 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 | 365 | Task.stubs(:per_page).returns(2) |
366 | 366 | ... | ... |
test/functional/themes_controller_test.rb
... | ... | @@ -254,7 +254,7 @@ class ThemesControllerTest < ActionController::TestCase |
254 | 254 | end |
255 | 255 | |
256 | 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 | 258 | t1 = LayoutTemplate.find('default') |
259 | 259 | t2 = LayoutTemplate.find('leftbar') |
260 | 260 | LayoutTemplate.expects(:all).returns([t1, t2]) |
... | ... | @@ -265,7 +265,7 @@ class ThemesControllerTest < ActionController::TestCase |
265 | 265 | end |
266 | 266 | |
267 | 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 | 270 | t1 = LayoutTemplate.find('default') |
271 | 271 | t2 = LayoutTemplate.find('leftbar') | ... | ... |