diff --git a/plugins/profile_members_headlines/lib/profile_members_headlines_block.rb b/plugins/profile_members_headlines/lib/profile_members_headlines_block.rb index c3d6c01..a687dd7 100644 --- a/plugins/profile_members_headlines/lib/profile_members_headlines_block.rb +++ b/plugins/profile_members_headlines/lib/profile_members_headlines_block.rb @@ -35,12 +35,4 @@ class ProfileMembersHeadlinesBlock < Block result.select{ |p| p.has_headline? }.slice(0..limit-1) end - def content(args={}) - block = self - members = authors_list - proc do - render :file => 'blocks/headlines', :locals => { :block => block, :members => members } - end - end - end diff --git a/plugins/profile_members_headlines/test/unit/profile_members_headlines_block_test.rb b/plugins/profile_members_headlines/test/unit/profile_members_headlines_block_test.rb index 6d05d84..96df07c 100644 --- a/plugins/profile_members_headlines/test/unit/profile_members_headlines_block_test.rb +++ b/plugins/profile_members_headlines/test/unit/profile_members_headlines_block_test.rb @@ -1,8 +1,10 @@ require 'test_helper' +require 'boxes_helper' class ProfileMembersHeadlinesBlockTest < ActiveSupport::TestCase include Noosfero::Plugin::HotSpot + include BoxesHelper def setup @environment = fast_create(Environment) @@ -32,8 +34,8 @@ class ProfileMembersHeadlinesBlockTest < ActiveSupport::TestCase block = ProfileMembersHeadlinesBlock.create block.stubs(:owner).returns(community) - self.expects(:render).with(:file => 'blocks/headlines', :locals => { :block => block, :members => []}).returns('file-without-authors-and-headlines') - assert_equal 'file-without-authors-and-headlines', instance_eval(&block.content) + self.expects(:render).with(:template => 'blocks/profile_members_headlines', :locals => { :block => block }).returns('file-without-authors-and-headlines') + assert_equal 'file-without-authors-and-headlines', render_block_content(block) end should 'display headlines file' do @@ -41,8 +43,8 @@ class ProfileMembersHeadlinesBlockTest < ActiveSupport::TestCase block.stubs(:owner).returns(community) blog = fast_create(Blog, :profile_id => member1.id) post = fast_create(TinyMceArticle, :name => 'headlines', :profile_id => member1.id, :parent_id => blog.id) - self.expects(:render).with(:file => 'blocks/headlines', :locals => { :block => block, :members => []}).returns('file-with-authors-and-headlines') - assert_equal 'file-with-authors-and-headlines', instance_eval(&block.content) + self.expects(:render).with(:template => 'blocks/profile_members_headlines', :locals => { :block => block }).returns('file-with-authors-and-headlines') + assert_equal 'file-with-authors-and-headlines', render_block_content(block) end should 'select only authors with articles and selected roles to display' do diff --git a/plugins/profile_members_headlines/views/blocks/headlines.html.erb b/plugins/profile_members_headlines/views/blocks/headlines.html.erb deleted file mode 100644 index 342f5bf..0000000 --- a/plugins/profile_members_headlines/views/blocks/headlines.html.erb +++ /dev/null @@ -1,39 +0,0 @@ -<%= block_title(block.title, block.subtitle) %> - -<% unless members.empty? %> -
- <% members.each do |member| %> -
- <% headline = member.headline %> - <%= link_to_profile(profile_image(member, :big) + content_tag(:p, member.short_name), member.identifier, {:class => 'author'}) %> -
-

<%= link_to(headline.title, headline.url, :class => 'title') %>

-
- <%= headline.short_lead %> -
-
- <%= show_date(headline.published_at) %> -
-
- <%= safe_join(headline.tags.map { |t| link_to(t, :controller => 'profile', :profile => member.identifier, :action => 'tags', :id => t.name ) }, "\n") %> -
-
-
- <% end %> -
- <% if block.navigation %> -
-
- <% end %> - - -<% else %> - <%= _('No headlines to be shown.') %> -<% end %> - diff --git a/plugins/profile_members_headlines/views/blocks/profile_members_headlines.html.erb b/plugins/profile_members_headlines/views/blocks/profile_members_headlines.html.erb new file mode 100644 index 0000000..b63fab2 --- /dev/null +++ b/plugins/profile_members_headlines/views/blocks/profile_members_headlines.html.erb @@ -0,0 +1,40 @@ +<%= block_title(block.title, block.subtitle) %> +<% members = block.authors_list %> + +<% unless members.empty? %> +
+ <% members.each do |member| %> +
+ <% headline = member.headline %> + <%= link_to_profile(profile_image(member, :big) + content_tag(:p, member.short_name), member.identifier, {:class => 'author'}) %> +
+

<%= link_to(headline.title, headline.url, :class => 'title') %>

+
+ <%= headline.short_lead %> +
+
+ <%= show_date(headline.published_at) %> +
+
+ <%= safe_join(headline.tags.map { |t| link_to(t, :controller => 'profile', :profile => member.identifier, :action => 'tags', :id => t.name ) }, "\n") %> +
+
+
+ <% end %> +
+ <% if block.navigation %> +
+
+ <% end %> + + +<% else %> + <%= _('No headlines to be shown.') %> +<% end %> + -- libgit2 0.21.2