Commit dd172119ee4cd20a0f9b3d87702fb9bacff4ff3a

Authored by Victor Costa
1 parent e201637a

rails3: fix controller tests

app/controllers/public/content_viewer_controller.rb
... ... @@ -32,7 +32,7 @@ class ContentViewerController < ApplicationController
32 32 return render_access_denied unless @page.display_versions?
33 33 @versioned_article = @page.versions.find_by_version(@version)
34 34 if @versioned_article && @page.versions.latest.version != @versioned_article.version
35   - render :template => 'content_viewer/versioned_article.rhtml'
  35 + render :template => 'content_viewer/versioned_article.html.erb'
36 36 return
37 37 end
38 38 end
... ...
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, :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, :notify_comments, :display_hits, :slug, :external_feed_builder
  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, :notify_comments, :display_hits, :slug, :external_feed_builder, :display_versions
6 6  
7 7 acts_as_having_image
8 8  
... ...
test/functional/cms_controller_test.rb
... ... @@ -1353,7 +1353,7 @@ class CmsControllerTest &lt; ActionController::TestCase
1353 1353 end
1354 1354  
1355 1355 should 'back to forum after config forum' do
1356   - assert_difference Forum, :count do
  1356 + assert_difference 'Forum.count' do
1357 1357 post :new, :type => Forum.name, :profile => profile.identifier, :article => { :name => 'my-forum' }, :back_to => 'control_panel'
1358 1358 end
1359 1359 post :edit, :type => Forum.name, :profile => profile.identifier, :article => { :name => 'my forum' }, :id => profile.forum.id
... ... @@ -1738,11 +1738,11 @@ class CmsControllerTest &lt; ActionController::TestCase
1738 1738 end
1739 1739  
1740 1740 should 'remove users that agreed with forum terms after removing terms' do
1741   - forum = Forum.create(:name => 'Forum test', :profile_id => profile.id, :has_terms_of_use => true)
  1741 + forum = Forum.create(:name => 'Forum test', :profile => profile, :has_terms_of_use => true)
1742 1742 person = fast_create(Person)
1743 1743 forum.users_with_agreement << person
1744 1744  
1745   - assert_difference Forum.find(forum.id).users_with_agreement, :count, -1 do
  1745 + assert_difference 'Forum.find(forum.id).users_with_agreement.count', -1 do
1746 1746 post :edit, :profile => profile.identifier, :id => forum.id, :article => { :has_terms_of_use => 'false' }
1747 1747 end
1748 1748 end
... ...
test/functional/content_viewer_controller_test.rb
... ... @@ -1339,14 +1339,14 @@ class ContentViewerControllerTest &lt; ActionController::TestCase
1339 1339 should 'add extra content on article header from plugins' do
1340 1340 class Plugin1 < Noosfero::Plugin
1341 1341 def article_header_extra_contents(args)
1342   - lambda {
  1342 + proc {
1343 1343 content_tag('div', '', :class => 'plugin1')
1344 1344 }
1345 1345 end
1346 1346 end
1347 1347 class Plugin2 < Noosfero::Plugin
1348 1348 def article_header_extra_contents(args)
1349   - lambda {
  1349 + proc {
1350 1350 content_tag('div', '', :class => 'plugin2')
1351 1351 }
1352 1352 end
... ...
test/functional/environment_themes_controller_test.rb
... ... @@ -91,7 +91,7 @@ class EnvironmentThemesControllerTest &lt; ActionController::TestCase
91 91  
92 92 LayoutTemplate.expects(:all).returns(all)
93 93 get :index
94   - assert_same all, assigns(:layout_templates)
  94 + assert_equivalent all, assigns(:layout_templates)
95 95 end
96 96  
97 97 should 'display links to set template' do
... ... @@ -109,7 +109,7 @@ class EnvironmentThemesControllerTest &lt; ActionController::TestCase
109 109  
110 110 should 'highlight current template' do
111 111 env = Environment.default
112   - env.update_attributes!(:layout_template => 'default')
  112 + env.update_attribute(:layout_template, 'default')
113 113 env.layout_template = 'default'
114 114  
115 115 t1 = LayoutTemplate.find('default')
... ...
test/functional/profile_design_controller_test.rb
... ... @@ -737,8 +737,8 @@ class ProfileDesignControllerTest &lt; ActionController::TestCase
737 737 end
738 738  
739 739 should 'clone a block' do
740   - block = ProfileImageBlock.create!(:box => profile.boxes.first)
741   - assert_difference ProfileImageBlock, :count, 1 do
  740 + block = create(ProfileImageBlock, :box => profile.boxes.first)
  741 + assert_difference 'ProfileImageBlock.count', 1 do
742 742 post :clone, :id => block.id, :profile => profile.identifier
743 743 assert_response :redirect
744 744 end
... ...
test/functional/users_controller_test.rb
... ... @@ -69,7 +69,7 @@ class UsersControllerTest &lt; ActionController::TestCase
69 69  
70 70 should 'set admin role' do
71 71 person = create_user.person
72   - Role.create!(:name => 'Admin', :key => 'environment_administrator', :environment_id => environment.id, :permissions => ['view_environment_admin_panel'])
  72 + Role.create!(:name => 'Admin', :key => 'environment_administrator', :environment => environment, :permissions => ['view_environment_admin_panel'])
73 73 assert_equal false, person.is_admin?
74 74 post :set_admin_role, :id => person.id, :q => ''
75 75 person.reload
... ... @@ -78,7 +78,7 @@ class UsersControllerTest &lt; ActionController::TestCase
78 78  
79 79 should 'reset admin role' do
80 80 person = create_user.person
81   - Role.create!(:name => 'Admin', :key => 'environment_administrator', :environment_id => environment.id, :permissions => ['view_environment_admin_panel'])
  81 + Role.create!(:name => 'Admin', :key => 'environment_administrator', :environment => environment, :permissions => ['view_environment_admin_panel'])
82 82  
83 83 environment.add_admin(person)
84 84 assert person.is_admin?
... ...