blocks_test.rb
2.07 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
require "#{File.dirname(__FILE__)}/../test_helper"
class BlocksTest < ActionController::IntegrationTest
  def blog_on_article_block_bootstrap
    profile = fast_create(Profile)
    blog = fast_create(Blog, :name => 'Blog', :profile_id => profile.id)
    fast_create(TinyMceArticle, :name => "First Post", :profile_id => profile.id, :parent_id => blog.id, :body => '<p> Wasserstoffbombe </p>')
    fast_create(TinyMceArticle, :name => "A Post", :profile_id => profile.id, :parent_id => blog.id, :body => '<p>Lorem ipsum dolor sit amet</p> <p>Second paragraph</p>')
    block = ArticleBlock.new
    block.article = blog
    profile.boxes << Box.new
    profile.boxes.first.blocks << block
    return block
  end
  should 'allow blog as article block content' do
    block = blog_on_article_block_bootstrap
    get "/profile/#{block.owner.identifier}"
    assert_match(/Lorem ipsum dolor sit amet/, @response.body)
  end
  should 'display short version for block posts on article block' do
    block = blog_on_article_block_bootstrap
    get "/profile/#{block.owner.identifier}"
    assert_no_match(/Second paragraph/, @response.body)
  end
  should 'display full version for block posts on article block' do
    block = blog_on_article_block_bootstrap
    block.visualization_format = 'full'
    block.save!
    get "/profile/#{block.owner.identifier}"
    assert_match(/Second paragraph/, @response.body)
  end
  should 'display configured number of blog posts on article block' do
    block = blog_on_article_block_bootstrap
    block.posts_per_page = 2
    block.save!
    get "/profile/#{block.owner.identifier}"
    assert_match(/Lorem ipsum dolor sit amet/, @response.body)
    assert_match(/Wasserstoffbombe/, @response.body)
  end
  should 'link correctly in pagination' do
    block = blog_on_article_block_bootstrap
    p = block.owner
    b = block.article
    f = Folder.create!(:name => 'Folder1', :profile => p)
    b.parent = f
    b.save!
    get "/profile/#{block.owner.identifier}"
    assert_tag :tag => 'a', :attributes => { :href => "/#{p.identifier}/#{f.slug}/#{b.slug}?npage=2" }
  end
end