From dd172119ee4cd20a0f9b3d87702fb9bacff4ff3a Mon Sep 17 00:00:00 2001 From: Victor Costa Date: Thu, 13 Feb 2014 18:33:55 -0300 Subject: [PATCH] rails3: fix controller tests --- app/controllers/public/content_viewer_controller.rb | 2 +- app/models/article.rb | 2 +- test/functional/cms_controller_test.rb | 6 +++--- test/functional/content_viewer_controller_test.rb | 4 ++-- test/functional/environment_themes_controller_test.rb | 4 ++-- test/functional/profile_design_controller_test.rb | 4 ++-- test/functional/users_controller_test.rb | 4 ++-- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/controllers/public/content_viewer_controller.rb b/app/controllers/public/content_viewer_controller.rb index d8b2961..01c4b44 100644 --- a/app/controllers/public/content_viewer_controller.rb +++ b/app/controllers/public/content_viewer_controller.rb @@ -32,7 +32,7 @@ class ContentViewerController < ApplicationController return render_access_denied unless @page.display_versions? @versioned_article = @page.versions.find_by_version(@version) if @versioned_article && @page.versions.latest.version != @versioned_article.version - render :template => 'content_viewer/versioned_article.rhtml' + render :template => 'content_viewer/versioned_article.html.erb' return end end diff --git a/app/models/article.rb b/app/models/article.rb index ba3241b..4dac0b5 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -2,7 +2,7 @@ require 'hpricot' class Article < ActiveRecord::Base - 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 + 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 acts_as_having_image diff --git a/test/functional/cms_controller_test.rb b/test/functional/cms_controller_test.rb index 5ee69a5..454724c 100644 --- a/test/functional/cms_controller_test.rb +++ b/test/functional/cms_controller_test.rb @@ -1353,7 +1353,7 @@ class CmsControllerTest < ActionController::TestCase end should 'back to forum after config forum' do - assert_difference Forum, :count do + assert_difference 'Forum.count' do post :new, :type => Forum.name, :profile => profile.identifier, :article => { :name => 'my-forum' }, :back_to => 'control_panel' end post :edit, :type => Forum.name, :profile => profile.identifier, :article => { :name => 'my forum' }, :id => profile.forum.id @@ -1738,11 +1738,11 @@ class CmsControllerTest < ActionController::TestCase end should 'remove users that agreed with forum terms after removing terms' do - forum = Forum.create(:name => 'Forum test', :profile_id => profile.id, :has_terms_of_use => true) + forum = Forum.create(:name => 'Forum test', :profile => profile, :has_terms_of_use => true) person = fast_create(Person) forum.users_with_agreement << person - assert_difference Forum.find(forum.id).users_with_agreement, :count, -1 do + assert_difference 'Forum.find(forum.id).users_with_agreement.count', -1 do post :edit, :profile => profile.identifier, :id => forum.id, :article => { :has_terms_of_use => 'false' } end end diff --git a/test/functional/content_viewer_controller_test.rb b/test/functional/content_viewer_controller_test.rb index e098f72..1d0b20c 100644 --- a/test/functional/content_viewer_controller_test.rb +++ b/test/functional/content_viewer_controller_test.rb @@ -1339,14 +1339,14 @@ class ContentViewerControllerTest < ActionController::TestCase should 'add extra content on article header from plugins' do class Plugin1 < Noosfero::Plugin def article_header_extra_contents(args) - lambda { + proc { content_tag('div', '', :class => 'plugin1') } end end class Plugin2 < Noosfero::Plugin def article_header_extra_contents(args) - lambda { + proc { content_tag('div', '', :class => 'plugin2') } end diff --git a/test/functional/environment_themes_controller_test.rb b/test/functional/environment_themes_controller_test.rb index 5e8965a..a4c19f4 100644 --- a/test/functional/environment_themes_controller_test.rb +++ b/test/functional/environment_themes_controller_test.rb @@ -91,7 +91,7 @@ class EnvironmentThemesControllerTest < ActionController::TestCase LayoutTemplate.expects(:all).returns(all) get :index - assert_same all, assigns(:layout_templates) + assert_equivalent all, assigns(:layout_templates) end should 'display links to set template' do @@ -109,7 +109,7 @@ class EnvironmentThemesControllerTest < ActionController::TestCase should 'highlight current template' do env = Environment.default - env.update_attributes!(:layout_template => 'default') + env.update_attribute(:layout_template, 'default') env.layout_template = 'default' t1 = LayoutTemplate.find('default') diff --git a/test/functional/profile_design_controller_test.rb b/test/functional/profile_design_controller_test.rb index 04f36a9..cc7ba13 100644 --- a/test/functional/profile_design_controller_test.rb +++ b/test/functional/profile_design_controller_test.rb @@ -737,8 +737,8 @@ class ProfileDesignControllerTest < ActionController::TestCase end should 'clone a block' do - block = ProfileImageBlock.create!(:box => profile.boxes.first) - assert_difference ProfileImageBlock, :count, 1 do + block = create(ProfileImageBlock, :box => profile.boxes.first) + assert_difference 'ProfileImageBlock.count', 1 do post :clone, :id => block.id, :profile => profile.identifier assert_response :redirect end diff --git a/test/functional/users_controller_test.rb b/test/functional/users_controller_test.rb index 8bf9d89..8bea29d 100644 --- a/test/functional/users_controller_test.rb +++ b/test/functional/users_controller_test.rb @@ -69,7 +69,7 @@ class UsersControllerTest < ActionController::TestCase should 'set admin role' do person = create_user.person - Role.create!(:name => 'Admin', :key => 'environment_administrator', :environment_id => environment.id, :permissions => ['view_environment_admin_panel']) + Role.create!(:name => 'Admin', :key => 'environment_administrator', :environment => environment, :permissions => ['view_environment_admin_panel']) assert_equal false, person.is_admin? post :set_admin_role, :id => person.id, :q => '' person.reload @@ -78,7 +78,7 @@ class UsersControllerTest < ActionController::TestCase should 'reset admin role' do person = create_user.person - Role.create!(:name => 'Admin', :key => 'environment_administrator', :environment_id => environment.id, :permissions => ['view_environment_admin_panel']) + Role.create!(:name => 'Admin', :key => 'environment_administrator', :environment => environment, :permissions => ['view_environment_admin_panel']) environment.add_admin(person) assert person.is_admin? -- libgit2 0.21.2