Commit ef0730ccc6e1269eb7b55281780fc7dd6a33ce72
1 parent
59d5b8f6
Exists in
master
and in
29 other branches
rails3: fix unit tests
Showing
18 changed files
with
63 additions
and
74 deletions
Show diff stats
app/helpers/application_helper.rb
@@ -295,7 +295,7 @@ module ApplicationHelper | @@ -295,7 +295,7 @@ module ApplicationHelper | ||
295 | search_name = "_" + search_name | 295 | search_name = "_" + search_name |
296 | end | 296 | end |
297 | 297 | ||
298 | - path = defined?(params) && params[:controller] ? File.join(view_path, params[:controller], search_name + 'html.erb') : File.join(view_path, search_name + 'html.erb') | 298 | + path = defined?(params) && params[:controller] ? File.join(view_path, params[:controller], search_name + '.html.erb') : File.join(view_path, search_name + '.html.erb') |
299 | return name if File.exists?(File.join(path)) | 299 | return name if File.exists?(File.join(path)) |
300 | 300 | ||
301 | partial_for_class_in_view_path(klass.superclass, view_path, prefix, suffix) | 301 | partial_for_class_in_view_path(klass.superclass, view_path, prefix, suffix) |
@@ -403,7 +403,7 @@ module ApplicationHelper | @@ -403,7 +403,7 @@ module ApplicationHelper | ||
403 | def theme_view_file(template) | 403 | def theme_view_file(template) |
404 | # Since we cannot control what people are doing in external themes, we | 404 | # Since we cannot control what people are doing in external themes, we |
405 | # will keep looking for the deprecated .rhtml extension here. | 405 | # will keep looking for the deprecated .rhtml extension here. |
406 | - file = Rails.root.join('public', theme_path[1..-1], template + 'html.erb') | 406 | + file = Rails.root.join('public', theme_path[1..-1], template + '.html.erb') |
407 | return file if File.exists?(file) | 407 | return file if File.exists?(file) |
408 | nil | 408 | nil |
409 | end | 409 | end |
app/models/block.rb
@@ -167,10 +167,10 @@ class Block < ActiveRecord::Base | @@ -167,10 +167,10 @@ class Block < ActiveRecord::Base | ||
167 | end | 167 | end |
168 | 168 | ||
169 | DISPLAY_OPTIONS = { | 169 | DISPLAY_OPTIONS = { |
170 | - 'always' => __('In all pages'), | ||
171 | - 'home_page_only' => __('Only in the homepage'), | ||
172 | - 'except_home_page' => __('In all pages, except in the homepage'), | ||
173 | - 'never' => __('Don\'t display'), | 170 | + 'always' => _('In all pages'), |
171 | + 'home_page_only' => _('Only in the homepage'), | ||
172 | + 'except_home_page' => _('In all pages, except in the homepage'), | ||
173 | + 'never' => _('Don\'t display'), | ||
174 | } | 174 | } |
175 | 175 | ||
176 | def display_options | 176 | def display_options |
@@ -182,7 +182,7 @@ class Block < ActiveRecord::Base | @@ -182,7 +182,7 @@ class Block < ActiveRecord::Base | ||
182 | end | 182 | end |
183 | 183 | ||
184 | def duplicate | 184 | def duplicate |
185 | - duplicated_block = self.clone | 185 | + duplicated_block = self.dup |
186 | duplicated_block.display = 'never' | 186 | duplicated_block.display = 'never' |
187 | duplicated_block.created_at = nil | 187 | duplicated_block.created_at = nil |
188 | duplicated_block.updated_at = nil | 188 | duplicated_block.updated_at = nil |
app/models/forum.rb
@@ -3,6 +3,8 @@ class Forum < Folder | @@ -3,6 +3,8 @@ class Forum < Folder | ||
3 | acts_as_having_posts :order => 'updated_at DESC' | 3 | acts_as_having_posts :order => 'updated_at DESC' |
4 | include PostsLimit | 4 | include PostsLimit |
5 | 5 | ||
6 | + attr_accessible :has_terms_of_use | ||
7 | + | ||
6 | settings_items :terms_of_use, :type => :string, :default => "" | 8 | settings_items :terms_of_use, :type => :string, :default => "" |
7 | settings_items :has_terms_of_use, :type => :boolean, :default => false | 9 | settings_items :has_terms_of_use, :type => :boolean, :default => false |
8 | has_and_belongs_to_many :users_with_agreement, :class_name => 'Person', :join_table => 'terms_forum_people' | 10 | has_and_belongs_to_many :users_with_agreement, :class_name => 'Person', :join_table => 'terms_forum_people' |
app/models/product_categories_block.rb
@@ -33,7 +33,7 @@ class ProductCategoriesBlock < Block | @@ -33,7 +33,7 @@ class ProductCategoriesBlock < Block | ||
33 | end | 33 | end |
34 | end | 34 | end |
35 | 35 | ||
36 | - DISPLAY_OPTIONS['catalog_only'] = __('Only on the catalog') | 36 | + DISPLAY_OPTIONS['catalog_only'] = _('Only on the catalog') |
37 | 37 | ||
38 | def display | 38 | def display |
39 | settings[:display].nil? ? 'catalog_only' : super | 39 | settings[:display].nil? ? 'catalog_only' : super |
app/models/profile.rb
@@ -92,21 +92,8 @@ class Profile < ActiveRecord::Base | @@ -92,21 +92,8 @@ class Profile < ActiveRecord::Base | ||
92 | def members | 92 | def members |
93 | scopes = plugins.dispatch_scopes(:organization_members, self) | 93 | scopes = plugins.dispatch_scopes(:organization_members, self) |
94 | scopes << Person.members_of(self) | 94 | scopes << Person.members_of(self) |
95 | -# FIXME Review this change after the refactoring on or_scopes, now done through the ScopeTool. | ||
96 | -#<<<<<<< HEAD | ||
97 | -# | ||
98 | -# clauses = scopes.map do |relation| | ||
99 | -# clause = relation.arel.where_clauses.map { |clause| "(#{clause})" }.join(' AND ') | ||
100 | -# "(#{clause})" | ||
101 | -# end.join(' OR ') | ||
102 | -# | ||
103 | -# joins = scopes.map { |relation| relation.joins_values }.flatten.uniq | ||
104 | -# selects = scopes.map { |relation| relation.select_values }.flatten.uniq | ||
105 | -# Person.select(selects).joins(joins).where(clauses) | ||
106 | -#======= | ||
107 | return scopes.first if scopes.size == 1 | 95 | return scopes.first if scopes.size == 1 |
108 | ScopeTool.union *scopes | 96 | ScopeTool.union *scopes |
109 | -#>>>>>>> master | ||
110 | end | 97 | end |
111 | 98 | ||
112 | def members_count | 99 | def members_count |
@@ -0,0 +1,22 @@ | @@ -0,0 +1,22 @@ | ||
1 | +<ul> | ||
2 | + <% if !links_submenu.empty? %> | ||
3 | + <div class="comment-actions"> | ||
4 | + <li class="vcard"> | ||
5 | + <%= link_to(content_tag(:span, _('Contents menu')), '#', :onclick => "toggleSubmenu(this,'',#{j links_submenu.to_json}); return false", :class => 'menu-submenu-trigger comment-trigger', :url => url) %> | ||
6 | + </li> | ||
7 | + </div> | ||
8 | + <% end %> | ||
9 | +</ul> | ||
10 | +<div class="comments-action-bar"> | ||
11 | + <% unless comment.spam? %> | ||
12 | + <%= link_to_function '', | ||
13 | + "var f = add_comment_reply_form(this, %s); f.find('comment_title, textarea').val(''); return false" % comment.id, | ||
14 | + :class => 'comment-footer comment-footer-link comment-footer-hide comment-actions-reply button', | ||
15 | + :id => 'comment-reply-to-' + comment.id.to_s, | ||
16 | + :title => _('Reply') | ||
17 | + %> | ||
18 | + <% end %> | ||
19 | + <% links_action_bar.collect do |link| %> | ||
20 | + <%= link[:link] %> | ||
21 | + <% end %> | ||
22 | +</div> |
app/views/comment/_comment_actions.rhtml
@@ -1,22 +0,0 @@ | @@ -1,22 +0,0 @@ | ||
1 | -<ul> | ||
2 | - <% if !links_submenu.empty? %> | ||
3 | - <div class="comment-actions"> | ||
4 | - <li class="vcard"> | ||
5 | - <%= link_to(content_tag(:span, _('Contents menu')), '#', :onclick => "toggleSubmenu(this,'',#{j links_submenu.to_json}); return false", :class => 'menu-submenu-trigger comment-trigger', :url => url) %> | ||
6 | - </li> | ||
7 | - </div> | ||
8 | - <% end %> | ||
9 | -</ul> | ||
10 | -<div class="comments-action-bar"> | ||
11 | - <% unless comment.spam? %> | ||
12 | - <%= link_to_function '', | ||
13 | - "var f = add_comment_reply_form(this, %s); f.find('comment_title, textarea').val(''); return false" % comment.id, | ||
14 | - :class => 'comment-footer comment-footer-link comment-footer-hide comment-actions-reply button', | ||
15 | - :id => 'comment-reply-to-' + comment.id.to_s, | ||
16 | - :title => _('Reply') | ||
17 | - %> | ||
18 | - <% end %> | ||
19 | - <% links_action_bar.collect do |link| %> | ||
20 | - <%= link[:link] %> | ||
21 | - <% end %> | ||
22 | -</div> |
app/views/search/_sellers_form.html.erb
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | 4 | ||
5 | <div class="search-in-opt"><%= _('Search in:') %> | 5 | <div class="search-in-opt"><%= _('Search in:') %> |
6 | <dir> | 6 | <dir> |
7 | - <%= labelled_radio_button __('Enterprises'), 'asset', 'enterprises', true %><br /> | 7 | + <%= labelled_radio_button _('Enterprises'), 'asset', 'enterprises', true %><br /> |
8 | <%= labelled_radio_button _('Products'), 'asset', 'products', false %> | 8 | <%= labelled_radio_button _('Products'), 'asset', 'products', false %> |
9 | </dir> | 9 | </dir> |
10 | </div> | 10 | </div> |
lib/scope_tool.rb
@@ -2,7 +2,7 @@ module ScopeTool | @@ -2,7 +2,7 @@ module ScopeTool | ||
2 | 2 | ||
3 | # Sum scope results by SQL, allowing post filtering of the group. | 3 | # Sum scope results by SQL, allowing post filtering of the group. |
4 | def union(*scopes) | 4 | def union(*scopes) |
5 | - model = scopes.first.class_name.constantize | 5 | + model = scopes.first.klass.name.constantize |
6 | scopes = scopes.map &:to_sql | 6 | scopes = scopes.map &:to_sql |
7 | model.from "(\n#{scopes.join("\nUNION\n")}\n) as #{model.table_name}" | 7 | model.from "(\n#{scopes.join("\nUNION\n")}\n) as #{model.table_name}" |
8 | end | 8 | end |
lib/tasks/plugins.rake
1 | require 'active_record' | 1 | require 'active_record' |
2 | -require_dependency 'active_record/migration' | 2 | +#require_dependency 'active_record/migration' |
3 | 3 | ||
4 | class ActiveRecord::Migrator | 4 | class ActiveRecord::Migrator |
5 | alias_method :orig_initialize, :initialize | 5 | alias_method :orig_initialize, :initialize |
test/factories.rb
@@ -42,7 +42,11 @@ module Noosfero::Factory | @@ -42,7 +42,11 @@ module Noosfero::Factory | ||
42 | attrs[:slug] = attrs[:name].to_slug if attrs[:name].present? && attrs[:slug].blank? && defaults[:slug].present? | 42 | attrs[:slug] = attrs[:name].to_slug if attrs[:name].present? && attrs[:slug].blank? && defaults[:slug].present? |
43 | data = defaults_for(name).merge(attrs) | 43 | data = defaults_for(name).merge(attrs) |
44 | object = name.to_s.camelize.constantize.new | 44 | object = name.to_s.camelize.constantize.new |
45 | - object.assign_attributes(data, :without_protection => true) | 45 | + if object.respond_to?(:assign_attributes) |
46 | + object.assign_attributes(data, :without_protection => true) | ||
47 | + else | ||
48 | + data.each { |attribute, value| object.send(attribute.to_s+'=', value) } | ||
49 | + end | ||
46 | object | 50 | object |
47 | end | 51 | end |
48 | 52 |
test/unit/application_helper_test.rb
@@ -18,7 +18,7 @@ class ApplicationHelperTest < ActionView::TestCase | @@ -18,7 +18,7 @@ class ApplicationHelperTest < ActionView::TestCase | ||
18 | self.stubs(:params).returns({:controller => 'test'}) | 18 | self.stubs(:params).returns({:controller => 'test'}) |
19 | File.stubs(:exists?).returns(false) | 19 | File.stubs(:exists?).returns(false) |
20 | 20 | ||
21 | - File.expects(:exists?).with(p1+"test/_integer.rhtml").returns(true) | 21 | + File.expects(:exists?).with(p1+"test/_integer.html.erb").returns(true) |
22 | assert_equal 'integer', partial_for_class(Integer) | 22 | assert_equal 'integer', partial_for_class(Integer) |
23 | 23 | ||
24 | File.expects(:exists?).with(p1+"test/_numeric.html.erb").returns(true) | 24 | File.expects(:exists?).with(p1+"test/_numeric.html.erb").returns(true) |
@@ -38,7 +38,7 @@ class ApplicationHelperTest < ActionView::TestCase | @@ -38,7 +38,7 @@ class ApplicationHelperTest < ActionView::TestCase | ||
38 | class School; class Project; end; end | 38 | class School; class Project; end; end |
39 | 39 | ||
40 | File.stubs(:exists?).returns(false) | 40 | File.stubs(:exists?).returns(false) |
41 | - File.expects(:exists?).with(p+"test/application_helper_test/school/_project.rhtml").returns(true) | 41 | + File.expects(:exists?).with(p+"test/application_helper_test/school/_project.html.erb").returns(true) |
42 | 42 | ||
43 | assert_equal 'test/application_helper_test/school/project', partial_for_class(School::Project) | 43 | assert_equal 'test/application_helper_test/school/project', partial_for_class(School::Project) |
44 | end | 44 | end |
@@ -175,7 +175,7 @@ class ApplicationHelperTest < ActionView::TestCase | @@ -175,7 +175,7 @@ class ApplicationHelperTest < ActionView::TestCase | ||
175 | 175 | ||
176 | should 'render theme footer' do | 176 | should 'render theme footer' do |
177 | stubs(:theme_path).returns('/user_themes/mytheme') | 177 | stubs(:theme_path).returns('/user_themes/mytheme') |
178 | - footer_path = Rails.root.join('public', 'user_themes', 'mytheme', 'footer.rhtml') | 178 | + footer_path = Rails.root.join('public', 'user_themes', 'mytheme', 'footer.html.erb') |
179 | 179 | ||
180 | File.expects(:exists?).with(footer_path).returns(true) | 180 | File.expects(:exists?).with(footer_path).returns(true) |
181 | expects(:render).with(:file => footer_path, :use_full_path => false).returns("BLI") | 181 | expects(:render).with(:file => footer_path, :use_full_path => false).returns("BLI") |
@@ -185,11 +185,9 @@ class ApplicationHelperTest < ActionView::TestCase | @@ -185,11 +185,9 @@ class ApplicationHelperTest < ActionView::TestCase | ||
185 | 185 | ||
186 | should 'ignore unexisting theme footer' do | 186 | should 'ignore unexisting theme footer' do |
187 | stubs(:theme_path).returns('/user_themes/mytheme') | 187 | stubs(:theme_path).returns('/user_themes/mytheme') |
188 | - footer_path = Rails.root.join('public', 'user_themes', 'mytheme', 'footer.rhtml') | ||
189 | - alternate_footer_path = Rails.root.join('public', 'user_themes', 'mytheme', 'footer.html.erb') | 188 | + footer_path = Rails.root.join('public', 'user_themes', 'mytheme', 'footer.html.erb') |
190 | 189 | ||
191 | File.expects(:exists?).with(footer_path).returns(false) | 190 | File.expects(:exists?).with(footer_path).returns(false) |
192 | - File.expects(:exists?).with(alternate_footer_path).returns(false) | ||
193 | expects(:render).with(:file => footer).never | 191 | expects(:render).with(:file => footer).never |
194 | 192 | ||
195 | assert_nil theme_footer | 193 | assert_nil theme_footer |
@@ -197,7 +195,7 @@ class ApplicationHelperTest < ActionView::TestCase | @@ -197,7 +195,7 @@ class ApplicationHelperTest < ActionView::TestCase | ||
197 | 195 | ||
198 | should 'render theme site title' do | 196 | should 'render theme site title' do |
199 | stubs(:theme_path).returns('/user_themes/mytheme') | 197 | stubs(:theme_path).returns('/user_themes/mytheme') |
200 | - site_title_path = Rails.root.join('public', 'user_themes', 'mytheme', 'site_title.rhtml') | 198 | + site_title_path = Rails.root.join('public', 'user_themes', 'mytheme', 'site_title.html.erb') |
201 | 199 | ||
202 | File.expects(:exists?).with(site_title_path).returns(true) | 200 | File.expects(:exists?).with(site_title_path).returns(true) |
203 | expects(:render).with(:file => site_title_path, :use_full_path => false).returns("Site title") | 201 | expects(:render).with(:file => site_title_path, :use_full_path => false).returns("Site title") |
@@ -207,11 +205,9 @@ class ApplicationHelperTest < ActionView::TestCase | @@ -207,11 +205,9 @@ class ApplicationHelperTest < ActionView::TestCase | ||
207 | 205 | ||
208 | should 'ignore unexisting theme site title' do | 206 | should 'ignore unexisting theme site title' do |
209 | stubs(:theme_path).returns('/user_themes/mytheme') | 207 | stubs(:theme_path).returns('/user_themes/mytheme') |
210 | - site_title_path = Rails.root.join('public', 'user_themes', 'mytheme', 'site_title.rhtml') | ||
211 | - alternate_site_title_path = Rails.root.join('public', 'user_themes', 'mytheme', 'site_title.html.erb') | 208 | + site_title_path = Rails.root.join('public', 'user_themes', 'mytheme', 'site_title.html.erb') |
212 | 209 | ||
213 | File.expects(:exists?).with(site_title_path).returns(false) | 210 | File.expects(:exists?).with(site_title_path).returns(false) |
214 | - File.expects(:exists?).with(alternate_site_title_path).returns(false) | ||
215 | expects(:render).with(:file => site_title_path).never | 211 | expects(:render).with(:file => site_title_path).never |
216 | 212 | ||
217 | assert_nil theme_site_title | 213 | assert_nil theme_site_title |
test/unit/article_test.rb
@@ -1697,7 +1697,7 @@ class ArticleTest < ActiveSupport::TestCase | @@ -1697,7 +1697,7 @@ class ArticleTest < ActiveSupport::TestCase | ||
1697 | should 'return license from a specific version' do | 1697 | should 'return license from a specific version' do |
1698 | cc = License.create!(:name => 'CC (by)', :environment => Environment.default) | 1698 | cc = License.create!(:name => 'CC (by)', :environment => Environment.default) |
1699 | gpl = License.create!(:name => 'GPLv3', :environment => Environment.default) | 1699 | gpl = License.create!(:name => 'GPLv3', :environment => Environment.default) |
1700 | - article = Article.create!(:name => 'first version', :profile => profile, :license => cc) | 1700 | + article = create(Article, :name => 'first version', :profile => profile, :license => cc) |
1701 | article.license = gpl | 1701 | article.license = gpl |
1702 | article.save | 1702 | article.save |
1703 | assert_equal cc, article.version_license(1) | 1703 | assert_equal cc, article.version_license(1) |
@@ -1766,7 +1766,7 @@ class ArticleTest < ActiveSupport::TestCase | @@ -1766,7 +1766,7 @@ class ArticleTest < ActiveSupport::TestCase | ||
1766 | should "return the author of a specific version" do | 1766 | should "return the author of a specific version" do |
1767 | author1 = fast_create(Person) | 1767 | author1 = fast_create(Person) |
1768 | author2 = fast_create(Person) | 1768 | author2 = fast_create(Person) |
1769 | - article = Article.create!(:name => 'first version', :profile => profile, :last_changed_by => author1) | 1769 | + article = create(Article, :name => 'first version', :profile => profile, :last_changed_by => author1) |
1770 | article.name = 'second version' | 1770 | article.name = 'second version' |
1771 | article.last_changed_by = author2 | 1771 | article.last_changed_by = author2 |
1772 | article.save | 1772 | article.save |
@@ -1777,7 +1777,7 @@ class ArticleTest < ActiveSupport::TestCase | @@ -1777,7 +1777,7 @@ class ArticleTest < ActiveSupport::TestCase | ||
1777 | should "return the author_name of a specific version" do | 1777 | should "return the author_name of a specific version" do |
1778 | author1 = fast_create(Person) | 1778 | author1 = fast_create(Person) |
1779 | author2 = fast_create(Person) | 1779 | author2 = fast_create(Person) |
1780 | - article = Article.create!(:name => 'first version', :profile => profile, :last_changed_by => author1) | 1780 | + article = create(Article, :name => 'first version', :profile => profile, :last_changed_by => author1) |
1781 | article.name = 'second version' | 1781 | article.name = 'second version' |
1782 | article.last_changed_by = author2 | 1782 | article.last_changed_by = author2 |
1783 | article.save | 1783 | article.save |
test/unit/block_test.rb
@@ -169,14 +169,14 @@ class BlockTest < ActiveSupport::TestCase | @@ -169,14 +169,14 @@ class BlockTest < ActiveSupport::TestCase | ||
169 | 169 | ||
170 | should 'create a cloned block' do | 170 | should 'create a cloned block' do |
171 | block = fast_create(Block, :title => 'test 1', :position => 1) | 171 | block = fast_create(Block, :title => 'test 1', :position => 1) |
172 | - assert_difference Block, :count, 1 do | 172 | + assert_difference 'Block.count', 1 do |
173 | block.duplicate | 173 | block.duplicate |
174 | end | 174 | end |
175 | end | 175 | end |
176 | 176 | ||
177 | should 'clone and keep some fields' do | 177 | should 'clone and keep some fields' do |
178 | box = fast_create(Box, :owner_id => fast_create(Profile).id) | 178 | box = fast_create(Box, :owner_id => fast_create(Profile).id) |
179 | - block = TagsBlock.create!(:title => 'test 1', :box_id => box.id, :settings => {:test => 'test'}) | 179 | + block = create(TagsBlock, :title => 'test 1', :box_id => box.id, :settings => {:test => 'test'}) |
180 | duplicated = block.duplicate | 180 | duplicated = block.duplicate |
181 | [:title, :box_id, :type].each do |f| | 181 | [:title, :box_id, :type].each do |f| |
182 | assert_equal duplicated.send(f), block.send(f) | 182 | assert_equal duplicated.send(f), block.send(f) |
@@ -186,8 +186,8 @@ class BlockTest < ActiveSupport::TestCase | @@ -186,8 +186,8 @@ class BlockTest < ActiveSupport::TestCase | ||
186 | 186 | ||
187 | should 'clone block and set fields' do | 187 | should 'clone block and set fields' do |
188 | box = fast_create(Box, :owner_id => fast_create(Profile).id) | 188 | box = fast_create(Box, :owner_id => fast_create(Profile).id) |
189 | - block = TagsBlock.create!(:title => 'test 1', :box_id => box.id, :settings => {:test => 'test'}, :position => 1) | ||
190 | - block2 = TagsBlock.create!(:title => 'test 2', :box_id => box.id, :settings => {:test => 'test'}, :position => 2) | 189 | + block = create(TagsBlock, :title => 'test 1', :box_id => box.id, :settings => {:test => 'test'}, :position => 1) |
190 | + block2 = create(TagsBlock, :title => 'test 2', :box_id => box.id, :settings => {:test => 'test'}, :position => 2) | ||
191 | duplicated = block.duplicate | 191 | duplicated = block.duplicate |
192 | block2.reload | 192 | block2.reload |
193 | block.reload | 193 | block.reload |
@@ -198,8 +198,8 @@ class BlockTest < ActiveSupport::TestCase | @@ -198,8 +198,8 @@ class BlockTest < ActiveSupport::TestCase | ||
198 | end | 198 | end |
199 | 199 | ||
200 | should 'not clone date creation and update attributes' do | 200 | should 'not clone date creation and update attributes' do |
201 | - box = fast_create(Box, :owner_id => fast_create(Profile).id) | ||
202 | - block = TagsBlock.create!(:title => 'test 1', :box_id => box.id, :settings => {:test => 'test'}, :position => 1) | 201 | + box = fast_create(Box, :owner_id => fast_create(Profile).id) |
202 | + block = create(TagsBlock, :title => 'test 1', :box_id => box.id, :settings => {:test => 'test'}, :position => 1) | ||
203 | duplicated = block.duplicate | 203 | duplicated = block.duplicate |
204 | 204 | ||
205 | assert_not_equal block.created_at, duplicated.created_at | 205 | assert_not_equal block.created_at, duplicated.created_at |
test/unit/box_test.rb
@@ -96,7 +96,7 @@ class BoxTest < ActiveSupport::TestCase | @@ -96,7 +96,7 @@ class BoxTest < ActiveSupport::TestCase | ||
96 | end | 96 | end |
97 | end | 97 | end |
98 | class PluginBlock < Block | 98 | class PluginBlock < Block |
99 | - def self.name; 'plugin-block'; end | 99 | + def self.to_s; 'plugin-block'; end |
100 | end | 100 | end |
101 | Noosfero::Plugin::Manager.any_instance.stubs(:enabled_plugins).returns([SomePlugin.new]) | 101 | Noosfero::Plugin::Manager.any_instance.stubs(:enabled_plugins).returns([SomePlugin.new]) |
102 | 102 | ||
@@ -111,7 +111,7 @@ class BoxTest < ActiveSupport::TestCase | @@ -111,7 +111,7 @@ class BoxTest < ActiveSupport::TestCase | ||
111 | end | 111 | end |
112 | end | 112 | end |
113 | class PluginBlock < Block | 113 | class PluginBlock < Block |
114 | - def self.name; 'plugin-block'; end | 114 | + def self.to_s; 'plugin-block'; end |
115 | end | 115 | end |
116 | Noosfero::Plugin::Manager.any_instance.stubs(:enabled_plugins).returns([SomePlugin.new]) | 116 | Noosfero::Plugin::Manager.any_instance.stubs(:enabled_plugins).returns([SomePlugin.new]) |
117 | 117 | ||
@@ -130,13 +130,13 @@ class BoxTest < ActiveSupport::TestCase | @@ -130,13 +130,13 @@ class BoxTest < ActiveSupport::TestCase | ||
130 | end | 130 | end |
131 | Noosfero::Plugin::Manager.any_instance.stubs(:enabled_plugins).returns([SomePlugin.new]) | 131 | Noosfero::Plugin::Manager.any_instance.stubs(:enabled_plugins).returns([SomePlugin.new]) |
132 | 132 | ||
133 | - blocks = Box.new(:position => 1, :owner => Person.new).acceptable_blocks | 133 | + blocks = build(Box, :position => 1, :owner => Person.new).acceptable_blocks |
134 | assert blocks.include?('box-test_plugin-block') | 134 | assert blocks.include?('box-test_plugin-block') |
135 | 135 | ||
136 | - blocks = Box.new(:position => 1, :owner => Enterprise.new).acceptable_blocks | 136 | + blocks = build(Box, :position => 1, :owner => Enterprise.new).acceptable_blocks |
137 | assert blocks.include?('box-test_plugin-block') | 137 | assert blocks.include?('box-test_plugin-block') |
138 | 138 | ||
139 | - blocks = Box.new(:position => 1, :owner => Community.new).acceptable_blocks | 139 | + blocks = build(Box, :position => 1, :owner => Community.new).acceptable_blocks |
140 | assert !blocks.include?('box-test_plugin-block') | 140 | assert !blocks.include?('box-test_plugin-block') |
141 | end | 141 | end |
142 | 142 |
test/unit/catalog_helper_test.rb
@@ -6,7 +6,7 @@ class CatalogHelperTest < ActiveSupport::TestCase | @@ -6,7 +6,7 @@ class CatalogHelperTest < ActiveSupport::TestCase | ||
6 | include ActionView::Helpers::TextHelper | 6 | include ActionView::Helpers::TextHelper |
7 | include ActionView::Helpers::UrlHelper | 7 | include ActionView::Helpers::UrlHelper |
8 | include ActionView::Helpers::TagHelper | 8 | include ActionView::Helpers::TagHelper |
9 | - include ActionController::Assertions::SelectorAssertions | 9 | + include ActionDispatch::Assertions::SelectorAssertions |
10 | 10 | ||
11 | def url_for(opts) | 11 | def url_for(opts) |
12 | #{:controller => 'catalog', :action => 'index', :level => category.id} | 12 | #{:controller => 'catalog', :action => 'index', :level => category.id} |
test/unit/forum_test.rb
@@ -137,7 +137,7 @@ class ForumTest < ActiveSupport::TestCase | @@ -137,7 +137,7 @@ class ForumTest < ActiveSupport::TestCase | ||
137 | should 'include user that changes a forum as agreed with terms' do | 137 | should 'include user that changes a forum as agreed with terms' do |
138 | author = fast_create(Person) | 138 | author = fast_create(Person) |
139 | editor = fast_create(Person) | 139 | editor = fast_create(Person) |
140 | - forum = Forum.create(:profile => author, :name => 'Forum test', :body => 'Forum test', :has_terms_of_use => true, :last_changed_by => author) | 140 | + forum = create(Forum, :profile => author, :name => 'Forum test', :body => 'Forum test', :has_terms_of_use => true, :last_changed_by => author) |
141 | forum.last_changed_by = editor | 141 | forum.last_changed_by = editor |
142 | forum.save | 142 | forum.save |
143 | 143 |
test/unit/person_test.rb
@@ -1444,7 +1444,7 @@ class PersonTest < ActiveSupport::TestCase | @@ -1444,7 +1444,7 @@ class PersonTest < ActiveSupport::TestCase | ||
1444 | assert_includes original_person.memberships, original_cmm | 1444 | assert_includes original_person.memberships, original_cmm |
1445 | assert_includes original_person.memberships, plugin1_cmm | 1445 | assert_includes original_person.memberships, plugin1_cmm |
1446 | assert_includes original_person.memberships, plugin2_cmm | 1446 | assert_includes original_person.memberships, plugin2_cmm |
1447 | - assert 3, original_person.memberships.count | 1447 | + assert_equal 3, original_person.memberships.count |
1448 | end | 1448 | end |
1449 | 1449 | ||
1450 | end | 1450 | end |