Commit 8ccaa1b3cd12599bdca412709d58d88e34690fa1
Exists in
staging
and in
1 other branch
Merge branch 'master' into staging
Showing
15 changed files
with
75 additions
and
27 deletions
Show diff stats
app/views/cms/edit.html.erb
... | ... | @@ -4,7 +4,7 @@ |
4 | 4 | <%= render :partial => 'archived_warning', :locals => {:article => @article} %> |
5 | 5 | <% end %> |
6 | 6 | <div class='<%= (@article.display_media_panel? ? 'with_media_panel' : 'no_media_panel') %>'> |
7 | -<%= labelled_form_for 'article', :html => { :multipart => true, :class => @type } do |f| %> | |
7 | +<%= labelled_form_for 'article', :html => { :multipart => true, :class => "#{@type} #{@type.to_css_class}" } do |f| %> | |
8 | 8 | |
9 | 9 | <%= hidden_field_tag("type", @type) if @type %> |
10 | 10 | ... | ... |
lib/noosfero/api/entities.rb
... | ... | @@ -204,7 +204,7 @@ module Noosfero |
204 | 204 | root 'articles', 'article' |
205 | 205 | expose :parent, :using => ArticleBase |
206 | 206 | expose :children, :using => ArticleBase do |article, options| |
207 | - article.children.limit(Noosfero::API::V1::Articles::MAX_PER_PAGE) | |
207 | + article.children.published.limit(Noosfero::API::V1::Articles::MAX_PER_PAGE) | |
208 | 208 | end |
209 | 209 | end |
210 | 210 | ... | ... |
plugins/metadata/lib/ext/article.rb
... | ... | @@ -23,14 +23,14 @@ class Article |
23 | 23 | 'locale:locale' => proc{ |a, c| a.language || a.environment.default_language }, |
24 | 24 | 'locale:alternate' => proc{ |a, c| a.alternate_languages }, |
25 | 25 | |
26 | - description: proc{ |a, plugin| ActionView::Base.full_sanitizer.sanitize a.body }, | |
26 | + description: proc{ |a, plugin| ActionView::Base.full_sanitizer.sanitize a.lead }, | |
27 | 27 | rich_attachment: "", |
28 | 28 | } |
29 | 29 | |
30 | 30 | metadata_spec namespace: :twitter, key_attr: :name, tags: { |
31 | 31 | card: 'summary', |
32 | 32 | description: proc do |a, plugin| |
33 | - description = a.body.to_s || a.environment.name | |
33 | + description = a.lead.to_s || a.environment.name | |
34 | 34 | plugin.helpers.truncate plugin.helpers.strip_tags(description), length: 200 |
35 | 35 | end, |
36 | 36 | title: proc{ |a, plugin| "#{a.title} - #{a.profile.name}" }, | ... | ... |
plugins/metadata/test/functional/content_viewer_controller_test.rb
... | ... | @@ -23,18 +23,18 @@ class ContentViewerControllerTest < ActionController::TestCase |
23 | 23 | end |
24 | 24 | |
25 | 25 | should 'add meta tags with article info' do |
26 | - a = TinyMceArticle.create(name: 'Article to be shared', body: 'This article should be shared with all social networks', profile: profile) | |
26 | + a = TinyMceArticle.create(name: 'Article to be shared', body: '<p>This article should be shared with all social networks</p>', profile: profile) | |
27 | 27 | |
28 | 28 | get :view_page, profile: profile.identifier, page: [ a.name.to_slug ] |
29 | 29 | |
30 | 30 | assert_tag tag: 'meta', attributes: { name: 'twitter:title', content: /#{a.name} - #{a.profile.name}/ } |
31 | - assert_tag tag: 'meta', attributes: { name: 'twitter:description', content: a.body } | |
31 | + assert_tag tag: 'meta', attributes: { name: 'twitter:description', content: a.lead.gsub(/<\/?p>/,'') } | |
32 | 32 | assert_no_tag tag: 'meta', attributes: { name: 'twitter:image' } |
33 | 33 | assert_tag tag: 'meta', attributes: { property: 'og:type', content: 'article' } |
34 | 34 | assert_tag tag: 'meta', attributes: { property: 'og:url', content: /\/#{profile.identifier}\/#{a.name.to_slug}/ } |
35 | 35 | assert_tag tag: 'meta', attributes: { property: 'og:title', content: /#{a.name} - #{a.profile.name}/ } |
36 | 36 | assert_tag tag: 'meta', attributes: { property: 'og:site_name', content: a.profile.name } |
37 | - assert_tag tag: 'meta', attributes: { property: 'og:description', content: a.body } | |
37 | + assert_tag tag: 'meta', attributes: { property: 'og:description', content: a.lead.gsub(/<\/?p>/,'') } | |
38 | 38 | assert_no_tag tag: 'meta', attributes: { property: 'og:image' } |
39 | 39 | end |
40 | 40 | ... | ... |
plugins/video/db/migrate/20160115185550_rename_video_block.rb
0 → 100644
plugins/video/public/style.css
plugins/video/test/unit/video_galery_block_test.rb
... | ... | @@ -21,7 +21,7 @@ class VideoGalleryBlockViewTest < ActionView::TestCase |
21 | 21 | |
22 | 22 | content = render_block_content(block) |
23 | 23 | |
24 | - assert_equal content, "\n" | |
24 | + assert_equal content, "" | |
25 | 25 | end |
26 | 26 | |
27 | 27 | should 'render nothing with an empty gallery message when there are no children' do |
... | ... | @@ -51,7 +51,7 @@ class VideoGalleryBlockViewTest < ActionView::TestCase |
51 | 51 | |
52 | 52 | content = render_block_content(block) |
53 | 53 | |
54 | - assert_tag_in_string content, tag: 'div', content: "\n #{body}\n " | |
54 | + assert_match body, content | |
55 | 55 | assert_tag_in_string content, tag: 'em', content: _('(empty video gallery)') |
56 | 56 | end |
57 | 57 | end | ... | ... |
plugins/video/test/unit/video_galery_test.rb
... | ... | @@ -13,4 +13,25 @@ class VideoGaleryTest < ActiveSupport::TestCase |
13 | 13 | assert_equal VideoPlugin::VideoGallery.description, _('A gallery of link to videos that are hosted elsewhere.') |
14 | 14 | end |
15 | 15 | |
16 | + should 'render nothing with an empty gallery message when there are no children' do | |
17 | + video_gallery = VideoPlugin::VideoGallery.new | |
18 | + video_gallery.children = [] | |
19 | + video_gallery.stubs(:body).returns('Video gallery body') | |
20 | + | |
21 | + content = instance_eval(&video_gallery.to_html) | |
22 | + assert_tag_in_string content, tag: 'em', content: _('(empty video gallery)') | |
23 | + end | |
24 | + | |
25 | + should 'render the body and a empty gallery message when there are no children' do | |
26 | + body = "Video Gallery Body" | |
27 | + video_gallery = VideoPlugin::VideoGallery.new | |
28 | + video_gallery.children = [] | |
29 | + video_gallery.expects(:body).twice.returns(body) | |
30 | + | |
31 | + content = instance_eval(&video_gallery.to_html) | |
32 | + | |
33 | + assert_match body, content | |
34 | + assert_tag_in_string content, tag: 'em', content: _('(empty video gallery)') | |
35 | + end | |
36 | + | |
16 | 37 | end | ... | ... |
plugins/video/views/blocks/video_gallery.html.erb
1 | -<% extend VideoPlugin::VideoGalleryHelper %> | |
2 | - | |
3 | 1 | <% if block.video_gallery_id.present? |
4 | 2 | video_gallery = VideoPlugin::VideoGallery.find(block.video_gallery_id) %> |
5 | 3 | |
6 | - <% unless video_gallery.body.blank? %> | |
7 | - <div> | |
8 | - <%= video_gallery.body %> | |
9 | - </div> | |
10 | - <hr/> | |
11 | - <% end %> | |
4 | + <%= render :partial => 'shared/video_gallery', :locals => {:video_gallery => video_gallery} %> | |
12 | 5 | |
13 | - <% if video_gallery.children.empty? %> | |
14 | - <em><%= _('(empty video gallery)') %></em> | |
15 | - <% else %> | |
16 | - <%= list_videos(:contents=>video_gallery.children) %> | |
17 | - <% end %> | |
18 | 6 | <% end %> | ... | ... |
plugins/video/views/cms/video_plugin/_video.html.erb
1 | 1 | <%= required_fields_message %> |
2 | 2 | |
3 | 3 | <div> |
4 | -<%= required f.text_field('name', :size => '64', :maxlength => 150) %> | |
5 | -<%= required labelled_form_field _('URL of the video'), text_field(:article, :video_url, :size => 80) %> | |
4 | +<%= required f.text_field('name') %> | |
5 | +<%= required labelled_form_field _('URL of the video'), text_field(:article, :video_url) %> | |
6 | 6 | <%= labelled_form_field(_('Description:'), text_area(:article, :body, :rows => 3, :cols => 64)) %> |
7 | 7 | <%= render :partial => 'general_fields' %> |
8 | 8 | <%= render :partial => 'translatable' %> | ... | ... |
plugins/video/views/cms/video_plugin/_video_gallery.html.erb
1 | 1 | <%= required_fields_message %> |
2 | 2 | |
3 | -<%= required f.text_field('name', :size => '64', :maxlength => 150) %> | |
3 | +<%= required f.text_field('name', :maxlength => 150) %> | |
4 | 4 | <%= render :partial => 'general_fields' %> |
5 | 5 | |
6 | 6 | <%= labelled_form_field(_('Description:'), text_area(:article, :body, :rows => 3, :cols => 64)) %> | ... | ... |
plugins/video/views/content_viewer/video_plugin/_video_gallery.html.erb
0 → 100644
... | ... | @@ -0,0 +1 @@ |
1 | +<%= render :partial => 'shared/video_gallery', :locals => {:video_gallery => video_gallery} %> | ... | ... |
... | ... | @@ -0,0 +1,14 @@ |
1 | +<% extend VideoPlugin::VideoGalleryHelper %> | |
2 | + | |
3 | +<% unless video_gallery.body.blank? %> | |
4 | + <div> | |
5 | + <%= video_gallery.body %> | |
6 | + </div> | |
7 | + <hr/> | |
8 | +<% end %> | |
9 | + | |
10 | +<% if video_gallery.children.empty? %> | |
11 | + <em><%= _('(empty video gallery)') %></em> | |
12 | +<% else %> | |
13 | + <%= list_videos(:contents=>video_gallery.children) %> | |
14 | +<% end %> | ... | ... |
test/api/articles_test.rb
... | ... | @@ -739,4 +739,13 @@ class ArticlesTest < ActiveSupport::TestCase |
739 | 739 | assert_not_includes json["article"].keys, "comments" |
740 | 740 | end |
741 | 741 | |
742 | + should 'not list private child when get the parent article' do | |
743 | + person = fast_create(Person, :environment_id => environment.id) | |
744 | + article = fast_create(Article, :profile_id => person.id, :name => "Some thing") | |
745 | + child = fast_create(Article, :parent_id => article.id, :profile_id => person.id, :name => "Some thing", :published => false) | |
746 | + get "/api/v1/articles/#{article.id}?#{params.to_query}" | |
747 | + json = JSON.parse(last_response.body) | |
748 | + assert_not_includes json['article']['children'].map {|a| a['id']}, child.id | |
749 | + end | |
750 | + | |
742 | 751 | end | ... | ... |
test/functional/cms_controller_test.rb
... | ... | @@ -1738,7 +1738,7 @@ class CmsControllerTest < ActionController::TestCase |
1738 | 1738 | [Blog, TinyMceArticle, Forum].each do |klass| |
1739 | 1739 | a = fast_create(klass, :profile_id => profile.id) |
1740 | 1740 | get :edit, :profile => profile.identifier, :id => a.id |
1741 | - assert_tag :tag => 'form', :attributes => {:class => klass.to_s} | |
1741 | + assert_tag :tag => 'form', :attributes => {:class => "#{a.type} #{a.type.to_css_class}"} | |
1742 | 1742 | end |
1743 | 1743 | end |
1744 | 1744 | ... | ... |