gallery_block_test.rb
1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
require 'test_helper'
class GalleryBlockTest < ActiveSupport::TestCase
def setup
@community = fast_create(Community)
end
attr_reader :community
should 'refer to a gallery' do
gallery = fast_create(Gallery, :profile_id => community.id)
gallery_block = create(GalleryBlock, :gallery_id => gallery.id)
gallery_block.stubs(:owner).returns(community)
assert_equal gallery, gallery_block.gallery
end
should 'default interval between transitions is 10 seconds' do
block = GalleryBlock.new
assert_equal 10, block.interval
end
end
require 'boxes_helper'
class GalleryBlockViewTest < ActionView::TestCase
include BoxesHelper
def setup
@community = fast_create(Community)
end
should 'display the default message for empty gallery' do
block = GalleryBlock.new
block.stubs(:owner).returns(@community)
ActionView::Base.any_instance.expects(:block_title).returns("")
content = render_block_content(block)
assert_match /#{_('Please, edit this block and choose some gallery')}/, content
end
should "display the gallery's content" do
gallery = fast_create(Gallery, :profile_id => @community.id)
image = create(UploadedFile, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'), :parent => gallery, :profile => @community)
block = create(GalleryBlock, :gallery_id => gallery.id)
block.stubs(:owner).returns(@community)
ActionView::Base.any_instance.expects(:block_title).returns("")
content = render_block_content(block)
assert_tag_in_string content, tag: 'img', attributes: {src: image.public_filename(:thumb)}
assert_tag_in_string content, tag: 'span', content: _('Next')
end
end