diff --git a/app/controllers/box_organizer_controller.rb b/app/controllers/box_organizer_controller.rb
index d57e429..30bec03 100644
--- a/app/controllers/box_organizer_controller.rb
+++ b/app/controllers/box_organizer_controller.rb
@@ -100,13 +100,6 @@ class BoxOrganizerController < ApplicationController
end
end
- def toggle_visibility
- @block = boxes_holder.blocks.find(params[:id])
- @block.visible = !@block.visible?
- @block.save
- redirect_to :action => 'index'
- end
-
protected :boxes_editor?
end
diff --git a/app/helpers/boxes_helper.rb b/app/helpers/boxes_helper.rb
index 671c97b..c578ff6 100644
--- a/app/helpers/boxes_helper.rb
+++ b/app/helpers/boxes_helper.rb
@@ -59,10 +59,11 @@ module BoxesHelper
end
def display_box_content(box, main_content)
- box_decorator.select_blocks(box.blocks).map { |item| display_block(item, main_content) }.join("\n") + box_decorator.block_target(box)
+ context = { :article => @page }
+ box_decorator.select_blocks(box.blocks, context).map { |item| display_block(item, main_content) }.join("\n") + box_decorator.block_target(box)
end
- def select_blocks(arr)
+ def select_blocks(arr, context)
arr
end
@@ -83,7 +84,7 @@ module BoxesHelper
end
options = {
- :class => classes = ['block', block.css_classes ].uniq.join(' '),
+ :class => classes = ['block', block_css_classes(block) ].uniq.join(' '),
:id => "block-#{block.id}"
}
if ( block.respond_to? 'help' )
@@ -134,8 +135,8 @@ module BoxesHelper
def self.block_edit_buttons(block)
''
end
- def self.select_blocks(arr)
- arr.select(&:visible?)
+ def self.select_blocks(arr, context)
+ arr.select { |block| block.visible?(context) }
end
end
@@ -201,7 +202,6 @@ module BoxesHelper
end
if !block.main?
- buttons << icon_button(:eyes, _('Toggle block visibility'), {:action => 'toggle_visibility', :id => block.id})
buttons << icon_button(:delete, _('Remove block'), { :action => 'remove', :id => block.id }, { :method => 'post', :confirm => _('Are you sure you want to remove this block?')})
end
@@ -217,8 +217,18 @@ module BoxesHelper
end
def import_blocks_stylesheets(options = {})
- @blocks_css_files ||= current_blocks.map{|b|'blocks/' + b.css_class_name}.uniq
+ @blocks_css_files ||= current_blocks.map{|b|'blocks/' + block_css_class_name(b)}.uniq
stylesheet_import(@blocks_css_files, options)
end
+ def block_css_class_name(block)
+ block.class.name.underscore.gsub('_', '-')
+ end
+ def block_css_classes(block)
+ classes = block_css_class_name(block)
+ classes += ' invisible-block' if block.display == 'never'
+ classes
+ end
+
+
end
diff --git a/app/helpers/content_viewer_helper.rb b/app/helpers/content_viewer_helper.rb
index cf7ee7b..fa4a46e 100644
--- a/app/helpers/content_viewer_helper.rb
+++ b/app/helpers/content_viewer_helper.rb
@@ -13,7 +13,7 @@ module ContentViewerHelper
end
def article_title(article, args = {})
- title = article.abstract if article.kind_of?(UploadedFile) && article.image?
+ title = article.display_title if article.kind_of?(UploadedFile) && article.image?
title = article.title if title.blank?
title = content_tag('h1', title, :class => 'title')
if article.belongs_to_blog?
@@ -35,4 +35,9 @@ module ContentViewerHelper
link_to( number_of_comments(article), article.url.merge(:anchor => 'comments_list') )
end
+ def image_label(image)
+ text = image.title || image.abstract
+ text && (text.first(40) + (text.size > 40 ? '…' : ''))
+ end
+
end
diff --git a/app/models/block.rb b/app/models/block.rb
index 77541a3..ac15c80 100644
--- a/app/models/block.rb
+++ b/app/models/block.rb
@@ -11,14 +11,46 @@ class Block < ActiveRecord::Base
belongs_to :box
acts_as_having_settings
- settings_items :visible, :type => :boolean, :default => true
named_scope :enabled, :conditions => { :enabled => true }
- def visible?
- visible
+ # Determines whether a given block must be visible. Optionally a
+ # context must be specified. context must be a hash, and
+ # may contain the following keys:
+ #
+ # * :article: the article being viewed currently
+ def visible?(context = nil)
+ if settings[:visible] == false || display == 'never'
+ return false
+ end
+ if context && context[:article] && display == 'home_page_only'
+ return context[:article] == owner.home_page
+ end
+ true
+ end
+
+ # The condition for displaying a block. It can assume the following values:
+ #
+ # * 'always': the block is always displayed
+ # * 'never': the block is hidden (it does not appear for visitors)
+ # * 'home_page_only' the block is displayed only when viewing the
+ # homepage of its owner.
+ def display
+ if settings[:visible] == false
+ 'never'
+ else
+ settings[:display] || 'always'
+ end
+ end
+
+ # Sets the value attribute.
+ def display=(value)
+ settings[:display] = value
+ # clear the old setting
+ settings[:visible] = nil
end
+
# returns the description of the block, used when the user sees a list of
# blocks to choose one to include in the design.
#
@@ -66,16 +98,6 @@ class Block < ActiveRecord::Base
box ? box.owner : nil
end
- def css_class_name
- self.class.name.underscore.gsub('_', '-')
- end
-
- def css_classes
- classes = css_class_name
- classes += ' invisible-block' unless visible?
- classes
- end
-
def default_title
''
end
diff --git a/app/models/slideshow_block.rb b/app/models/slideshow_block.rb
index 2968cc3..23cabcb 100644
--- a/app/models/slideshow_block.rb
+++ b/app/models/slideshow_block.rb
@@ -2,9 +2,11 @@ class SlideshowBlock < Block
settings_items :gallery_id, :type => 'integer'
settings_items :interval, :type => 'integer', :default => 4
+ settings_items :shuffle, :type => 'boolean', :default => false
+ settings_items :navigation, :type => 'boolean', :default => false
def self.description
- _('Display images from gallery as slideshow')
+ _('Slideshow block')
end
def gallery
@@ -12,35 +14,18 @@ class SlideshowBlock < Block
end
def content
+ block = self
if gallery
images = gallery.images
- block_id = id
- block_title = title
- lambda do
- block_title(block_title) +
- content_tag('div',
- images.map do |i|
- link_to(
- content_tag('div', '', :style => "background-image: url(#{i.public_filename(:thumb)})"),
- (i.external_link || i.view_url), :target => '_blank'
- )
- end.join("\n"),
- :class => 'slideshow-container'
- )
+ if shuffle
+ images = images.shuffle
end
- else
lambda do
- content_tag('em', _('Please select a gallery to display its images.'))
+ render :file => 'blocks/slideshow', :locals => { :block => block, :images => images }
end
- end
- end
-
- def footer
- if gallery
- block_id = id
- interval_sec = interval * 1000
+ else
lambda do
- javascript_tag("jQuery('#block-#{block_id} .slideshow-container').cycle({fx: 'fade', timeout: #{interval_sec}})")
+ render :file => 'blocks/slideshow', :locals => { :block => block, :images => nil }
end
end
end
diff --git a/app/models/uploaded_file.rb b/app/models/uploaded_file.rb
index c10ef29..e4f539d 100644
--- a/app/models/uploaded_file.rb
+++ b/app/models/uploaded_file.rb
@@ -4,6 +4,13 @@
# of the file itself is kept. (FIXME?)
class UploadedFile < Article
+ settings_items :title, :type => 'string'
+ validates_size_of :title, :maximum => 60, :if => (lambda { |file| !file.title.blank? })
+
+ def display_title
+ title.blank? ? name : title
+ end
+
def self.max_size
UploadedFile.attachment_options[:max_size]
end
@@ -74,11 +81,14 @@ class UploadedFile < Article
:class => 'gallery-navigation'
)
end.to_s +
- tag('img', :src => article.public_filename(:display), :class => article.css_class_name, :style => 'max-width: 100%')
+ tag('img', :src => article.public_filename(:display), :class => article.css_class_name, :style => 'max-width: 100%') +
+ content_tag('p', article.abstract, :class => 'uploaded-file-description')
+
end
else
lambda do
- content_tag('ul', content_tag('li', link_to(article.name, article.url, :class => article.css_class_name)))
+ content_tag('ul', content_tag('li', link_to(article.name, article.url, :class => article.css_class_name))) +
+ content_tag('p', article.abstract, :class => 'uploaded-file-description')
end
end
end
diff --git a/app/views/blocks/slideshow.rhtml b/app/views/blocks/slideshow.rhtml
new file mode 100644
index 0000000..48c0a3b
--- /dev/null
+++ b/app/views/blocks/slideshow.rhtml
@@ -0,0 +1,49 @@
+<%= block_title(block.title) %>
+<% if images %>
+ <% description = images.any? { |img| !img.abstract.blank? } %>
+
'>
+
+ <% if block.navigation %>
+
+ <%= link_to _('Previous'), '#', :class => 'icon-media-prev' %>
+ <% if block.interval > 0 %>
+ <%= link_to ' ', '#', :class => 'icon-media-pause', :onclick => "togglePlayback('#block-#{block.id} .slideshow-container', this); return false;" %>
+ <% end %>
+ <%= link_to _('Next'), '#', :class => 'icon-media-next' %>
+
+ <% end %>
+
+
+<% else %>
+ <%= _('Please, edit this block and select an image gallery.') %>
+<% end %>
+
diff --git a/app/views/box_organizer/_slideshow_block.rhtml b/app/views/box_organizer/_slideshow_block.rhtml
index 86efb91..1ae3214 100644
--- a/app/views/box_organizer/_slideshow_block.rhtml
+++ b/app/views/box_organizer/_slideshow_block.rhtml
@@ -3,4 +3,8 @@
[ _('%{gallery} (%{count} images)') % {:gallery => item.path, :count => item.images.count}, item.id ]
}) %>
-<%= labelled_form_field _('Seconds between image transitions'), select('block', 'interval', [1, 2, 3, 4, 5, 10, 20, 30, 60] ) %>
+<%= labelled_form_field _('Image transition:'), select('block', 'interval', [[_('No automatic transition'), 0]] + [1, 2, 3, 4, 5, 10, 20, 30, 60].map {|item| [n_('Every 1 second', 'Every %d seconds', item) % item, item]}) %>
+
+<%= labelled_form_field check_box(:block, :shuffle) + _('Show images in random order'), '' %>
+
+<%= labelled_form_field check_box(:block, :navigation) + _('Display navigation buttons'), '' %>
diff --git a/app/views/box_organizer/edit.rhtml b/app/views/box_organizer/edit.rhtml
index 62ce36c..165d6d4 100644
--- a/app/views/box_organizer/edit.rhtml
+++ b/app/views/box_organizer/edit.rhtml
@@ -6,6 +6,18 @@
<%= render :partial => partial_for_class(@block.class) %>
+ <%= labelled_form_field _('Display this block:'), '' %>
+
+ <%= radio_button(:block, :display, 'always') %>
+ <%= label_tag('block_display_always', _('In all pages')) %>
+
+ <%= radio_button(:block, :display, 'home_page_only') %>
+ <%= label_tag('block_display_home_page_only', _('Only in the homepage')) %>
+
+ <%= radio_button(:block, :display, 'never') %>
+ <%= label_tag('block_display_never', _("Don't display")) %>
+
+
<% button_bar do %>
<%= submit_button(:save, _('Save')) %>
<%= lightbox_close_button(_('Cancel')) %>
diff --git a/app/views/cms/_uploaded_file.rhtml b/app/views/cms/_uploaded_file.rhtml
index 2ec3852..2ceafd2 100644
--- a/app/views/cms/_uploaded_file.rhtml
+++ b/app/views/cms/_uploaded_file.rhtml
@@ -1,4 +1,5 @@
-<%= labelled_form_field(_('Describe this file:'), text_area(:article, :abstract, :rows => 3, :cols => 64)) %>
+<%= labelled_form_field(_('Title'), text_field(:article, :title, :maxlength => 60)) %>
+<%= labelled_form_field(_('Description'), text_area(:article, :abstract, :rows => 3, :cols => 64)) %>
<% if @article.image? %>
<%= f.text_field(:external_link, :size => 64) %>
<% end %>
diff --git a/app/views/content_viewer/_uploaded_file.rhtml b/app/views/content_viewer/_uploaded_file.rhtml
index 9c8b365..7aeca61 100644
--- a/app/views/content_viewer/_uploaded_file.rhtml
+++ b/app/views/content_viewer/_uploaded_file.rhtml
@@ -1,6 +1,6 @@
<% if uploaded_file.image? %>
- <%= link_to image_tag(uploaded_file.public_filename(:thumb), :alt => uploaded_file.abstract), uploaded_file.view_url %>
+ <%= link_to image_tag(uploaded_file.public_filename(:thumb), :alt => uploaded_file.display_title), uploaded_file.view_url %>
+ <%= image_label(uploaded_file) %>
<% else %>
<%= render :partial => 'article', :object => uploaded_file %>
<% end %>
-
diff --git a/app/views/content_viewer/image_gallery.rhtml b/app/views/content_viewer/image_gallery.rhtml
index 9f76954..9235536 100644
--- a/app/views/content_viewer/image_gallery.rhtml
+++ b/app/views/content_viewer/image_gallery.rhtml
@@ -8,7 +8,6 @@
<% @images.each do |a| %>
<% content_tag('li', :title => a.abstract, :class => 'image-gallery-item' ) do %>
<%= render :partial => partial_for_class(a.class), :object => a %>
- <%= a.abstract && (a.abstract.first(40) + (a.abstract.size > 40 ? '…' : ''))%>
<% end %>
<% end %>
diff --git a/app/views/content_viewer/view_page.rhtml b/app/views/content_viewer/view_page.rhtml
index 92fcd68..ee16534 100644
--- a/app/views/content_viewer/view_page.rhtml
+++ b/app/views/content_viewer/view_page.rhtml
@@ -19,7 +19,7 @@
<% end %>
-
+
>
<%= article_title(@page, :no_link => true) %>
<% if @page.allow_post_content?(user) %>
diff --git a/lib/tasks/release.rake b/lib/tasks/release.rake
index 2767675..dac6994 100644
--- a/lib/tasks/release.rake
+++ b/lib/tasks/release.rake
@@ -10,7 +10,7 @@ namespace :noosfero do
end
version = Noosfero::VERSION
- desc 'checks if there is already a tag for the curren version'
+ desc 'checks if there is already a tag for the current version'
task :check_tag do
sh "git tag | grep '^#{version}$' >/dev/null" do |ok, res|
if ok
diff --git a/public/designs/icons/tango/style.css b/public/designs/icons/tango/style.css
index 9f602aa..e301cc7 100644
--- a/public/designs/icons/tango/style.css
+++ b/public/designs/icons/tango/style.css
@@ -64,3 +64,8 @@
.icon-slideshow { background-image: url(Tango/16x16/mimetypes/x-office-presentation.png) }
.icon-photos { background-image: url(Tango/16x16/devices/camera-photo.png) }
+.icon-media-pause { background-image: url(Tango/16x16/actions/media-playback-pause.png) }
+.icon-media-play { background-image: url(Tango/16x16/actions/media-playback-start.png) }
+.icon-media-prev { background-image: url(Tango/16x16/actions/media-skip-backward.png) }
+.icon-media-next { background-image: url(Tango/16x16/actions/media-skip-forward.png) }
+
diff --git a/public/designs/themes/base/article.css b/public/designs/themes/base/article.css
index c03c3a8..d6b13f2 100644
--- a/public/designs/themes/base/article.css
+++ b/public/designs/themes/base/article.css
@@ -16,8 +16,12 @@ hr.pre-posts, hr.sep-posts {
overflow: visible;
}
+#article .logged-in h1 {
+ margin-top: 25px;
+}
+
#article-actions {
- top: -18px;
+ top: -28px;
}
#article-actions a.button,
diff --git a/public/stylesheets/blocks/slideshow-block.css b/public/stylesheets/blocks/slideshow-block.css
index 92806e9..13b84c6 100644
--- a/public/stylesheets/blocks/slideshow-block.css
+++ b/public/stylesheets/blocks/slideshow-block.css
@@ -1,15 +1,73 @@
.slideshow-block .slideshow-container {
- margin: auto;
+ margin-bottom: 10px;
+}
+
+.slideshow-block .slideshow-container a {
+ width: 100%;
+ display: block;
+ text-decoration: none;
+}
+.slideshow-block .slideshow-container a:hover {
+ text-decoration: none;
}
.slideshow-block .slideshow-container div {
- width: 130px;
height: 130px;
background-position: 50% 50%;
background-repeat: no-repeat;
- margin: auto;
+}
+
+.slideshow-block .with-descriptions {
+ border: 1px solid #ddd;
+}
+
+.slideshow-block .image-description {
+ display: block;
+ padding: 10px;
+ height: 34px;
+ overflow: hidden;
+ border-top: 1px solid #ddd;
+ background-color: white;
+ color: black;
}
.msie .slideshow-block .slideshow-container div {
cursor: pointer;
}
+
+.slideshow-block {
+ text-align: center;
+}
+
+.slideshow-block .slideshow-block-navigation {
+ margin: 8px 0px;
+}
+.slideshow-block .slideshow-block-navigation a {
+ background-color: white;
+ background-repeat: no-repeat;
+ border: 1px solid #ddd;
+ padding: 2px;
+ text-decoration: none;
+ font-variant: small-caps;
+ font-size: 10px;
+}
+.slideshow-block .slideshow-block-navigation a:hover {
+ text-decoration: none;
+ border-color: #999;
+}
+
+.slideshow-block .slideshow-block-navigation .icon-media-prev {
+ padding-left: 18px;
+ background-position: left;
+}
+.slideshow-block .slideshow-block-navigation .icon-media-next {
+ padding-right: 18px;
+ background-position: right;
+
+}
+.slideshow-block .slideshow-block-navigation .icon-media-pause,
+.slideshow-block .slideshow-block-navigation .icon-media-play {
+ background-position: 50% 50%;
+ display: inline-block;
+ width: 16px;
+}
diff --git a/public/stylesheets/controller_content_viewer.css b/public/stylesheets/controller_content_viewer.css
index 3567686..4f93055 100644
--- a/public/stylesheets/controller_content_viewer.css
+++ b/public/stylesheets/controller_content_viewer.css
@@ -65,3 +65,10 @@ div#article-parent {
#article .gallery-navigation .total-of-images {
font-weight: bold;
}
+
+#article .uploaded-file-description {
+ background: #f6f6f6;
+ border-top: 1px solid #ccc;
+ border-bottom: 1px solid #ccc;
+ padding: 1em;
+}
diff --git a/test/functional/application_controller_test.rb b/test/functional/application_controller_test.rb
index 135f8fc..b0e2c87 100644
--- a/test/functional/application_controller_test.rb
+++ b/test/functional/application_controller_test.rb
@@ -406,7 +406,7 @@ class ApplicationControllerTest < Test::Unit::TestCase
p = create_user_full('test_user').person
@controller.expects(:profile).at_least_once.returns(p)
b = p.blocks[1]
- b.expects(:visible).returns(false)
+ b.expects(:visible?).returns(false)
b.save!
get :index, :profile => p.identifier
diff --git a/test/functional/profile_design_controller_test.rb b/test/functional/profile_design_controller_test.rb
index 16c9f9e..c2af2f7 100644
--- a/test/functional/profile_design_controller_test.rb
+++ b/test/functional/profile_design_controller_test.rb
@@ -285,15 +285,6 @@ class ProfileDesignControllerTest < Test::Unit::TestCase
assert_no_tag :tag => 'input', :attributes => { :id => 'type_blogarchivesblock', :value => 'BlogArchivesBlock' }
end
- should 'toggle block visibility' do
- state = @b1.visible?
- get :toggle_visibility, :id => @b1.id, :profile => holder.identifier
- block = Block.find(@b1.id)
-
- assert_equal block, assigns(:block)
- assert_equal !state, block.visible?
- end
-
should 'offer to create feed reader block' do
get :add_block, :profile => 'designtestuser'
assert_tag :tag => 'input', :attributes => { :id => 'type_feedreaderblock', :value => 'FeedReaderBlock' }
diff --git a/test/unit/block_test.rb b/test/unit/block_test.rb
index f85d299..beca2c7 100644
--- a/test/unit/block_test.rb
+++ b/test/unit/block_test.rb
@@ -22,12 +22,6 @@ class BlockTest < Test::Unit::TestCase
assert_nil Block.new.owner
end
- should 'generate CSS class name' do
- block = Block.new
- block.class.expects(:name).returns('SomethingBlock')
- assert_equal 'something-block', block.css_class_name
- end
-
should 'provide no footer by default' do
assert_nil Block.new.footer
end
@@ -52,12 +46,18 @@ class BlockTest < Test::Unit::TestCase
assert_equal 'my title', b.view_title
end
- should 'have a visible setting' do
+ should 'be backwards compatible with old "visible" setting' do
b = Block.new
- assert b.visible?
- b.visible = false
- b.save
+ b.settings[:visible] = false
assert !b.visible?
+ assert_equal 'never', b.display
+ end
+
+ should 'clean old "visible setting" when display is set' do
+ b = Block.new
+ b.settings[:visible] = false
+ b.display = 'never'
+ assert_nil b.settings[:visible]
end
should 'be cacheable' do
@@ -80,4 +80,24 @@ class BlockTest < Test::Unit::TestCase
assert_not_includes Block.enabled, block2
end
+ should 'be displayed everywhere by default' do
+ assert_equal true, Block.new.visible?
+ end
+
+ should 'not display when set to hidden' do
+ assert_equal false, Block.new(:display => 'never').visible?
+ assert_equal false, Block.new(:display => 'never').visible?(:article => Article.new)
+ end
+
+ should 'be able to be displayed only in the homepage' do
+ profile = Profile.new
+ home_page = Article.new
+ profile.home_page = home_page
+ block = Block.new(:display => 'home_page_only')
+ block.stubs(:owner).returns(profile)
+
+ assert_equal true, block.visible?(:article => home_page)
+ assert_equal false, block.visible?(:article => Article.new)
+ end
+
end
diff --git a/test/unit/boxes_helper_test.rb b/test/unit/boxes_helper_test.rb
index 7adb36a..67805b8 100644
--- a/test/unit/boxes_helper_test.rb
+++ b/test/unit/boxes_helper_test.rb
@@ -41,7 +41,7 @@ class BoxesHelperTest < Test::Unit::TestCase
p = create_user_with_blocks
b = p.blocks.select{|bk| !bk.kind_of?(MainBlock) }[0]
- b.visible = false; b.save!
+ b.display = 'never'; b.save!
box = b.box
box.expects(:blocks).returns([b])
expects(:display_block).with(b, '')
@@ -55,7 +55,7 @@ class BoxesHelperTest < Test::Unit::TestCase
p = create_user_with_blocks
b = p.blocks.select{|bk| !bk.kind_of?(MainBlock) }[0]
- b.visible = false; b.save!
+ b.display = 'never'; b.save!
box = b.box
box.expects(:blocks).returns([b])
expects(:display_block).with(b, '').never
@@ -85,4 +85,13 @@ class BoxesHelperTest < Test::Unit::TestCase
assert_tag_in_string insert_boxes('main content'), :tag => "div", :attributes => { :id => 'profile-footer' }, :content => 'my custom footer'
end
+ should 'calculate CSS class names correctly' do
+ assert_equal 'slideshow-block', block_css_class_name(SlideshowBlock.new)
+ assert_equal 'main-block', block_css_class_name(MainBlock.new)
+ end
+
+ should 'add invisible CSS class name for invisible blocks' do
+ assert !block_css_classes(Block.new(:display => 'always')).split.any? { |item| item == 'invisible-block'}
+ assert block_css_classes(Block.new(:display => 'never')).split.any? { |item| item == 'invisible-block'}
+ end
end
diff --git a/test/unit/slideshow_block_test.rb b/test/unit/slideshow_block_test.rb
index 85dc9f9..63ce8ed 100644
--- a/test/unit/slideshow_block_test.rb
+++ b/test/unit/slideshow_block_test.rb
@@ -20,15 +20,35 @@ class SlideshowBlockTest < ActiveSupport::TestCase
assert_equal 4, slideshow.interval
end
- should 'not invoke javascript when has no gallery' do
- slideshow_block = SlideshowBlock.new()
- assert_nil slideshow_block.footer
+ should 'list in the same order' do
+ gallery = mock
+ images = []
+ images.expects(:shuffle).never
+ gallery.stubs(:images).returns(images)
+
+ block = SlideshowBlock.new
+ block.stubs(:gallery).returns(gallery)
+ block.content
end
- should 'invoke javascript when has gallery' do
- gallery = fast_create(Folder, :profile_id => profile.id)
- slideshow_block = SlideshowBlock.new(:gallery_id => gallery.id)
- assert_not_nil slideshow_block.footer
+ should 'list in random order' do
+ gallery = mock
+ images = []
+ shuffled = []
+ gallery.stubs(:images).returns(images)
+ images.expects(:shuffle).once.returns(shuffled)
+
+ block = SlideshowBlock.new(:shuffle => true)
+ block.stubs(:gallery).returns(gallery)
+ block.content
+ end
+
+ should 'not shuffle by default' do
+ assert_equal false, SlideshowBlock.new.shuffle
+ end
+
+ should 'not display navigation by default' do
+ assert_equal false, SlideshowBlock.new.navigation
end
end
diff --git a/test/unit/uploaded_file_test.rb b/test/unit/uploaded_file_test.rb
index 319a460..c604d02 100644
--- a/test/unit/uploaded_file_test.rb
+++ b/test/unit/uploaded_file_test.rb
@@ -113,10 +113,34 @@ class UploadedFileTest < Test::Unit::TestCase
p = create_user('test_user').person
file = UploadedFile.create!(:uploaded_data => fixture_file_upload('/files/test.txt', 'text/plain'), :profile => p)
- stubs(:content_tag)
+ stubs(:content_tag).returns('link')
expects(:link_to).with(file.name, file.url, :class => file.css_class_name)
instance_eval(&file.to_html)
end
+ should 'have title' do
+ assert_equal 'my title', UploadedFile.new(:title => 'my title').title
+ end
+
+ should 'limit title to 140 characters' do
+ upload = UploadedFile.new
+
+ upload.title = '+' * 61; upload.valid?
+ assert upload.errors[:title]
+
+ upload.title = '+' * 60; upload.valid?
+ assert !upload.errors[:title]
+
+ end
+
+ should 'always provide a display title' do
+ upload = UploadedFile.new(:uploaded_data => fixture_file_upload('/files/test.txt', 'text/plain'))
+ assert_equal 'test.txt', upload.display_title
+ upload.title = 'My text file'
+ assert_equal 'My text file', upload.display_title
+ upload.title = ''
+ assert_equal 'test.txt', upload.display_title
+ end
+
end
--
libgit2 0.21.2