Commit 880fbdcaad374fc964aff6ab64db60965256b4b3
1 parent
6148ec49
Exists in
web_steps_improvements
and in
9 other branches
Fix recent document block helper unit test
By removing the content method, it is now necessary to turn the test into a view one. This was inspired by the same conversion made by commit 23cca52cdaea5cc3b46e4982f30ad3426891e2f2 on MyNetworkBlock test.
Showing
1 changed file
with
38 additions
and
11 deletions
Show diff stats
test/unit/recent_documents_block_test.rb
... | ... | @@ -35,17 +35,6 @@ class RecentDocumentsBlockTest < ActiveSupport::TestCase |
35 | 35 | assert_equivalent block.docs, articles |
36 | 36 | end |
37 | 37 | |
38 | - should 'link to documents' do | |
39 | - articles.each do |a| | |
40 | - expects(:link_to).with(a.title, a.url) | |
41 | - end | |
42 | - stubs(:block_title).returns("") | |
43 | - stubs(:content_tag).returns("") | |
44 | - stubs(:li).returns("") | |
45 | - | |
46 | - instance_eval(&block.content) | |
47 | - end | |
48 | - | |
49 | 38 | should 'respect the maximum number of items as configured' do |
50 | 39 | block.limit = 3 |
51 | 40 | |
... | ... | @@ -100,3 +89,41 @@ class RecentDocumentsBlockTest < ActiveSupport::TestCase |
100 | 89 | assert_equal 0, block.get_limit |
101 | 90 | end |
102 | 91 | end |
92 | + | |
93 | +require 'boxes_helper' | |
94 | + | |
95 | +class RecentDocumentsBlockViewTest < ActionView::TestCase | |
96 | + include BoxesHelper | |
97 | + | |
98 | + def setup | |
99 | + @articles = [] | |
100 | + @profile = create_user('testinguser').person | |
101 | + @profile.articles.destroy_all | |
102 | + ['first', 'second', 'third', 'fourth', 'fifth'].each do |name| | |
103 | + article = @profile.articles.create!(:name => name) | |
104 | + @articles << article | |
105 | + end | |
106 | + | |
107 | + box = Box.new | |
108 | + box.owner = profile | |
109 | + box.save! | |
110 | + | |
111 | + | |
112 | + @block = RecentDocumentsBlock.new | |
113 | + @block.box_id = box.id | |
114 | + @block.save! | |
115 | + | |
116 | + end | |
117 | + attr_reader :block, :profile, :articles | |
118 | + | |
119 | + should 'link to documents' do | |
120 | + articles.each do |a| | |
121 | + ActionView::Base.any_instance.expects(:link_to).with(a.title, a.url) | |
122 | + end | |
123 | + ActionView::Base.any_instance.stubs(:block_title).returns("") | |
124 | + ActionView::Base.any_instance.stubs(:content_tag).returns("") | |
125 | + ActionView::Base.any_instance.stubs(:li).returns("") | |
126 | + | |
127 | + render_block_content(block) | |
128 | + end | |
129 | +end | ... | ... |