From 487423592929980848172d4ddf95b402b707c611 Mon Sep 17 00:00:00 2001 From: Antonio Terceiro Date: Mon, 25 May 2009 20:37:30 -0300 Subject: [PATCH] ActionItem1049: last round of code/test fixing --- app/views/content_viewer/view_page.rhtml | 2 +- test/functional/application_controller_test.rb | 1 + test/functional/cms_controller_test.rb | 12 ++++++------ test/functional/content_viewer_controller_test.rb | 1 - test/functional/profile_controller_test.rb | 2 -- test/functional/profile_editor_controller_test.rb | 2 +- test/functional/themes_controller_test.rb | 4 ++++ test/integration/editing_person_info_test.rb | 2 +- 8 files changed, 14 insertions(+), 12 deletions(-) diff --git a/app/views/content_viewer/view_page.rhtml b/app/views/content_viewer/view_page.rhtml index be87cb6..095eb81 100644 --- a/app/views/content_viewer/view_page.rhtml +++ b/app/views/content_viewer/view_page.rhtml @@ -44,7 +44,7 @@ <% if !@page.display_as_gallery? %> <%= lightbox_button(:new, label_for_new_article(@page), profile.admin_url.merge(:controller => 'cms', :action => 'new', :parent_id => (@page.folder? ? @page : (@page.parent.nil? ? nil : @page.parent)))) %> <% end %> - <% if @page.folder? %> + <% if @page.folder? || (@page.parent && @page.parent.folder?) %> <%= button('upload-file', _('Upload files'), profile.admin_url.merge(:controller => 'cms', :action => 'upload_files', :parent_id => (@page.folder? ? @page : @page.parent))) %> <% end %> <% end %> diff --git a/test/functional/application_controller_test.rb b/test/functional/application_controller_test.rb index bfc1fe1..5c175eb 100644 --- a/test/functional/application_controller_test.rb +++ b/test/functional/application_controller_test.rb @@ -260,6 +260,7 @@ class ApplicationControllerTest < Test::Unit::TestCase env = Environment.default Environment.stubs(:default).returns(env) env.stubs(:terminology).returns(term) + env.stubs(:id).returns(-9999) Noosfero.expects(:terminology=).with(term) get :index diff --git a/test/functional/cms_controller_test.rb b/test/functional/cms_controller_test.rb index ec9286e..2085930 100644 --- a/test/functional/cms_controller_test.rb +++ b/test/functional/cms_controller_test.rb @@ -705,8 +705,9 @@ class CmsControllerTest < Test::Unit::TestCase end should 'display posts per page input with default value on edit blog' do + n = Blog.new.posts_per_page.to_s get :new, :profile => profile.identifier, :type => 'Blog' - assert_tag :tag => 'select', :attributes => { :name => 'article[posts_per_page]' }, :child => { :tag => 'option', :attributes => {:value => '20', :selected => 'selected'} } + assert_tag :tag => 'select', :attributes => { :name => 'article[posts_per_page]' }, :child => { :tag => 'option', :attributes => {:value => n, :selected => 'selected'} } end should 'not offer to create special article types' do @@ -1054,13 +1055,12 @@ class CmsControllerTest < Test::Unit::TestCase should 'display pagination links of images' do @controller.stubs(:per_page).returns(1) - image = UploadedFile.create!(:profile => profile, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) - fixture_filename = '/files/other-pic.jpg' filename = RAILS_ROOT + '/test/fixtures' + fixture_filename system('echo "image for test" | convert -background yellow -page 32x32 text:- %s' % filename) + image = UploadedFile.create!(:profile => profile, :uploaded_data => fixture_file_upload(fixture_filename, 'image/jpg')) - image2 = UploadedFile.create!(:profile => profile, :uploaded_data => fixture_file_upload(fixture_filename, 'image/jpg')) + image2 = UploadedFile.create!(:profile => profile, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) get :media_listing, :profile => profile.identifier @@ -1072,8 +1072,8 @@ class CmsControllerTest < Test::Unit::TestCase should 'display pagination links of documents' do @controller.stubs(:per_page).returns(1) - file = UploadedFile.create!(:profile => profile, :uploaded_data => fixture_file_upload('/files/test.txt', 'text/plain')) - file2 = UploadedFile.create!(:profile => profile, :uploaded_data => fixture_file_upload('/files/feed.xml', 'text/xml')) + file = UploadedFile.create!(:profile => profile, :uploaded_data => fixture_file_upload('/files/feed.xml', 'text/xml')) + file2 = UploadedFile.create!(:profile => profile, :uploaded_data => fixture_file_upload('/files/test.txt', 'text/plain')) get :media_listing, :profile => profile.identifier diff --git a/test/functional/content_viewer_controller_test.rb b/test/functional/content_viewer_controller_test.rb index 7f77e60..2e8cc47 100644 --- a/test/functional/content_viewer_controller_test.rb +++ b/test/functional/content_viewer_controller_test.rb @@ -734,7 +734,6 @@ class ContentViewerControllerTest < Test::Unit::TestCase folder1.children << folder2 = Folder.new(:name => 'gallery2', :profile => profile) get :view_page, :profile => profile.identifier, :page => folder2.explode_path - assert_no_tag :tag => 'a', :content => 'Upload files', :attributes => {:href => /parent_id=#{folder2.id}/} assert_tag :tag => 'a', :content => 'New article', :attributes => {:href =>/parent_id=#{folder2.id}/} end diff --git a/test/functional/profile_controller_test.rb b/test/functional/profile_controller_test.rb index ef22be7..ef7acf5 100644 --- a/test/functional/profile_controller_test.rb +++ b/test/functional/profile_controller_test.rb @@ -123,14 +123,12 @@ class ProfileControllerTest < Test::Unit::TestCase should 'not show enterprises link to enterprise' do ent = Enterprise.create!(:identifier => 'test_enterprise1', :name => 'Test enteprise1') get :index, :profile => ent.identifier - assert_tag :tag => 'h2', :content => "#{ent.identifier}'s profile" assert_no_tag :tag => 'a', :content => 'Enterprises', :attributes => { :href => /profile\/#{ent.identifier}\/enterprises$/ } end should 'not show members link to person' do person = create_user('person_1').person get :index, :profile => person.identifier - assert_tag :tag => 'h2', :content => "#{person.identifier}'s profile" assert_no_tag :tag => 'a', :content => 'Members', :attributes => { :href => /profile\/#{person.identifier}\/members$/ } end diff --git a/test/functional/profile_editor_controller_test.rb b/test/functional/profile_editor_controller_test.rb index d739069..ec4d926 100644 --- a/test/functional/profile_editor_controller_test.rb +++ b/test/functional/profile_editor_controller_test.rb @@ -253,7 +253,7 @@ class ProfileEditorControllerTest < Test::Unit::TestCase should 'show edit profile button' do person = create_user('testuser').person get :index, :profile => 'testuser' - assert_tag :tag => 'div', :attributes => { :class => 'file-manager-button' }, :child => { :tag => 'a', :attributes => { :href => '/myprofile/testuser/profile_editor/edit' } } + assert_tag :tag => 'a', :attributes => { :href => '/myprofile/testuser/profile_editor/edit' } end should 'show image field on edit profile' do diff --git a/test/functional/themes_controller_test.rb b/test/functional/themes_controller_test.rb index f9c6e02..43637e1 100644 --- a/test/functional/themes_controller_test.rb +++ b/test/functional/themes_controller_test.rb @@ -15,6 +15,10 @@ class ThemesControllerTest < Test::Unit::TestCase @profile = create_user('testinguser').person login_as('testinguser') + + env = Environment.default + env.enable('user_themes') + env.save! end attr_reader :profile diff --git a/test/integration/editing_person_info_test.rb b/test/integration/editing_person_info_test.rb index 047d86b..3701773 100644 --- a/test/integration/editing_person_info_test.rb +++ b/test/integration/editing_person_info_test.rb @@ -13,7 +13,7 @@ class EditingPersonInfoTest < ActionController::IntegrationTest get "/myprofile/#{profile.identifier}" assert_response :success - assert_tag :tag => 'a', :content => 'Info and settings' + assert_tag :tag => 'a', :attributes => { :href => "/myprofile/#{profile.identifier}/profile_editor/edit" } get "/myprofile/#{profile.identifier}/profile_editor/edit" assert_response :success -- libgit2 0.21.2