Commit af0cec4454138cb1e889ab976e38371a5f9b0399
1 parent
4199280a
Exists in
web_steps_improvements
and in
9 other branches
Refactor RecentDocumentsBlock footer
Showing
3 changed files
with
18 additions
and
24 deletions
Show diff stats
app/models/recent_documents_block.rb
... | ... | @@ -22,15 +22,6 @@ class RecentDocumentsBlock < Block |
22 | 22 | |
23 | 23 | settings_items :limit, :type => :integer, :default => 5 |
24 | 24 | |
25 | - def footer | |
26 | - return nil unless self.owner.is_a?(Profile) | |
27 | - | |
28 | - profile = self.owner | |
29 | - proc do | |
30 | - link_to _('All content'), :profile => profile.identifier, :controller => 'profile', :action => 'sitemap' | |
31 | - end | |
32 | - end | |
33 | - | |
34 | 25 | def docs |
35 | 26 | self.limit.nil? ? owner.recent_documents(nil, {}, false) : owner.recent_documents(self.get_limit, {}, false) |
36 | 27 | end | ... | ... |
test/unit/recent_documents_block_test.rb
... | ... | @@ -57,21 +57,6 @@ class RecentDocumentsBlockTest < ActiveSupport::TestCase |
57 | 57 | assert block.limit > 0 |
58 | 58 | end |
59 | 59 | |
60 | - should 'display a link to sitemap with title "All content"' do | |
61 | - expects(:link_to).with('All content', :controller => 'profile', :action => 'sitemap', :profile => profile.identifier) | |
62 | - expects(:_).with('All content').returns('All content') | |
63 | - | |
64 | - instance_eval(&(block.footer)) | |
65 | - end | |
66 | - | |
67 | - should 'not display link to sitemap when owner is environment' do | |
68 | - block = RecentDocumentsBlock.new | |
69 | - box = mock | |
70 | - block.expects(:box).returns(box).at_least_once | |
71 | - box.expects(:owner).returns(Environment.new).at_least_once | |
72 | - assert_equal nil, block.footer | |
73 | - end | |
74 | - | |
75 | 60 | should 'be able to update display setting' do |
76 | 61 | assert @block.update!(:display => 'always') |
77 | 62 | @block.reload |
... | ... | @@ -126,4 +111,19 @@ class RecentDocumentsBlockViewTest < ActionView::TestCase |
126 | 111 | |
127 | 112 | render_block_content(block) |
128 | 113 | end |
114 | + | |
115 | + should 'display a link to sitemap with title "All content"' do | |
116 | + ActionView::Base.any_instance.expects(:link_to).with('All content', :controller => 'profile', :action => 'sitemap', :profile => profile.identifier) | |
117 | + ActionView::Base.any_instance.expects(:_).with('All content').returns('All content') | |
118 | + | |
119 | + render_block_footer(block) | |
120 | + end | |
121 | + | |
122 | + should 'not display link to sitemap when owner is environment' do | |
123 | + block = RecentDocumentsBlock.new | |
124 | + box = mock | |
125 | + block.expects(:box).returns(box).at_least_once | |
126 | + box.expects(:owner).returns(Environment.new).at_least_once | |
127 | + assert_equal '', render_block_footer(block) | |
128 | + end | |
129 | 129 | end | ... | ... |