Commit 496d5a24c7fa5c8ec87ccf327079e5b3f64e43fd
1 parent
2de692cd
Exists in
master
and in
28 other branches
join_button: removing footer content from model
- leaving code to be displayed on views (MVC) (ActionItem2844)
Showing
5 changed files
with
16 additions
and
21 deletions
Show diff stats
app/models/members_block.rb
... | ... | @@ -15,15 +15,10 @@ class MembersBlock < ProfileListBlock |
15 | 15 | |
16 | 16 | def footer |
17 | 17 | profile = self.owner |
18 | - show_button_block = show_join_leave_button | |
18 | + s = show_join_leave_button | |
19 | 19 | |
20 | 20 | lambda do |
21 | - if show_button_block | |
22 | - @view_all = link_to _('View all'), :profile => profile.identifier, :controller => 'profile', :action => 'members' | |
23 | - render "blocks/profile_info_actions/join_leave_community" | |
24 | - else | |
25 | - link_to _('View all'), :profile => profile.identifier, :controller => 'profile', :action => 'members' | |
26 | - end | |
21 | + render :file => 'blocks/members', :locals => { :profile => profile, :show_join_leave_button => s} | |
27 | 22 | end |
28 | 23 | end |
29 | 24 | |
... | ... | @@ -41,4 +36,4 @@ class MembersBlock < ProfileListBlock |
41 | 36 | } |
42 | 37 | end |
43 | 38 | |
44 | -end | |
45 | 39 | \ No newline at end of file |
40 | +end | ... | ... |
app/models/profile_list_block.rb
app/views/blocks/profile_info_actions/_join_leave_community.rhtml
1 | -<%= @view_all unless @view_all.nil? %> | |
2 | - | |
3 | 1 | <% if logged_in? %> |
4 | 2 | <% if profile.members.include?(user) %> |
5 | 3 | <%= button(:delete, content_tag('span', __('Leave community')), profile.leave_url, |
... | ... | @@ -26,4 +24,4 @@ |
26 | 24 | <%= link_to content_tag('span', _('Join')), profile.join_not_logged_url, |
27 | 25 | :class => 'button with-text icon-add', |
28 | 26 | :title => _('Join this community') %> |
29 | -<% end %> | |
30 | 27 | \ No newline at end of file |
28 | +<% end %> | ... | ... |
test/unit/members_block_test.rb
... | ... | @@ -14,16 +14,13 @@ class MembersBlockTest < ActiveSupport::TestCase |
14 | 14 | assert_not_equal ProfileListBlock.new.default_title, MembersBlock.new.default_title |
15 | 15 | end |
16 | 16 | |
17 | - should 'link to "all members" page' do | |
18 | - profile = create_user('mytestuser').person | |
19 | - block = MembersBlock.new | |
20 | - block.box = profile.boxes.first | |
21 | - block.save! | |
22 | - | |
23 | - expects(:_).with('View all').returns('View all') | |
24 | - expects(:link_to).with('View all' , :profile => 'mytestuser', :controller => 'profile', :action => 'members').returns('link-to-members') | |
17 | + should 'display members file' do | |
18 | + community = fast_create(Community) | |
19 | + block = MembersBlock.create | |
20 | + block.expects(:owner).returns(community) | |
25 | 21 | |
26 | - assert_equal 'link-to-members', instance_eval(&block.footer) | |
22 | + self.expects(:render).with(:file => 'blocks/members', :locals => { :profile => community, :show_join_leave_button => false}).returns('file-with-members-list') | |
23 | + assert_equal 'file-with-members-list', instance_eval(&block.footer) | |
27 | 24 | end |
28 | 25 | |
29 | 26 | should 'pick random members' do | ... | ... |