diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 6c40a73..e64f026 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -901,7 +901,7 @@ module ApplicationHelper end def page_title - (@page ? @page.name + ' - ' : '') + + (@page ? @page.title + ' - ' : '') + (profile ? profile.short_name + ' - ' : '') + (@topic ? @topic.title + ' - ' : '') + (@section ? @section.title + ' - ' : '') + diff --git a/app/helpers/content_viewer_helper.rb b/app/helpers/content_viewer_helper.rb index c4774d3..f990035 100644 --- a/app/helpers/content_viewer_helper.rb +++ b/app/helpers/content_viewer_helper.rb @@ -30,7 +30,7 @@ module ContentViewerHelper end def image_label(image) - text = image.title || image.abstract + text = image.abstract || image.title text && (text.first(40) + (text.size > 40 ? '…' : '')) end diff --git a/app/models/uploaded_file.rb b/app/models/uploaded_file.rb index e56a01b..0c8681a 100644 --- a/app/models/uploaded_file.rb +++ b/app/models/uploaded_file.rb @@ -5,6 +5,11 @@ class UploadedFile < Article settings_items :title, :type => 'string' + def title_with_default + title_without_default || name + end + alias_method_chain :title, :default + validates_size_of :title, :maximum => 60, :if => (lambda { |file| !file.title.blank? }) def display_title diff --git a/features/gallery_navigation.feature b/features/gallery_navigation.feature index ae32851..321ee2e 100644 --- a/features/gallery_navigation.feature +++ b/features/gallery_navigation.feature @@ -63,3 +63,12 @@ Feature: gallery_navigation Then I should see "Go back to my-gallery" When I follow "Go back to my-gallery" Then I should be on /marciopunk/my-gallery + + Scenario: image title in window title + Given I am logged in as "marciopunk" + And I go to /marciopunk/my-gallery/rails.png?view=true + When I follow "Edit" + And I fill in "Title" with "Rails is cool" + And I press "Save" + And I go to /marciopunk/my-gallery/rails.png?view=true + And The page title should contain "Rails is cool" diff --git a/features/step_definitions/noosfero_steps.rb b/features/step_definitions/noosfero_steps.rb index 1a28815..f779e1f 100644 --- a/features/step_definitions/noosfero_steps.rb +++ b/features/step_definitions/noosfero_steps.rb @@ -202,4 +202,6 @@ Given /^(.+) is disabled$/ do |enterprise_name| enterprise.save end - +Then /^The page title should contain "(.*)"$/ do |text| + response.should have_selector("title:contains('#{text}')") +end diff --git a/test/unit/uploaded_file_test.rb b/test/unit/uploaded_file_test.rb index 1ea94d0..515e561 100644 --- a/test/unit/uploaded_file_test.rb +++ b/test/unit/uploaded_file_test.rb @@ -143,4 +143,11 @@ class UploadedFileTest < Test::Unit::TestCase assert_equal 'test.txt', upload.display_title end + should 'use name as title by default' do + upload = UploadedFile.new + upload.stubs(:name).returns('test.txt') + + assert_equal 'test.txt', upload.title + end + end -- libgit2 0.21.2