content_viewer_controller_test.rb
2.11 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
require 'test_helper'
class ContentViewerController
append_view_path File.join(File.dirname(__FILE__) + '/../../views')
def rescue_action(e)
raise e
end
end
class ContentViewerControllerTest < ActionController::TestCase
def setup
@profile = fast_create(Community)
@page = fast_create(Folder, :profile_id => @profile.id)
box = Box.create!(:owner => @profile)
@block = ContextContentPlugin::ContextContentBlock.new(:box_id => box.id)
@block.types = ['TinyMceArticle']
@block.limit = 1
@block.save!
end
should 'do not display context content block if it has no contents' do
get :view_page, @page.url
assert_no_tag 'div', :attributes => {:id => "context_content_#{@block.id}", :class => 'contents'}
assert_no_tag 'div', :attributes => {:id => "context_content_more_#{@block.id}", :class => 'more_button'}
end
should 'display context content block if it has contents' do
article = fast_create(TinyMceArticle, :parent_id => @page.id, :profile_id => @profile.id, :name => 'article1')
get :view_page, @page.url
assert_tag 'div', :attributes => {:id => "context_content_#{@block.id}", :class => 'contents'}
assert_no_tag 'div', :attributes => {:id => "context_content_more_#{@block.id}", :class => 'more_button'}, :descendant => {:tag => 'a'}
assert_match /article1/, @response.body
end
should 'display context content block with pagination' do
article1 = fast_create(TinyMceArticle, :parent_id => @page.id, :profile_id => @profile.id)
article2 = fast_create(TinyMceArticle, :parent_id => @page.id, :profile_id => @profile.id)
get :view_page, @page.url
assert_tag 'div', :attributes => {:id => "context_content_#{@block.id}", :class => 'contents'}
assert_tag 'div', :attributes => {:id => "context_content_more_#{@block.id}", :class => 'more_button'}, :descendant => {:tag => 'a', :attributes => {:class => 'button icon-button icon-left disabled'} }
assert_tag 'div', :attributes => {:id => "context_content_more_#{@block.id}", :class => 'more_button'}, :descendant => {:tag => 'a', :attributes => {:class => 'button icon-button icon-right'} }
end
end