Commit e343595316eb5c6fc9c0471c322f22460ea46f7a

Authored by Daniela Feitosa
Committed by Antonio Terceiro
1 parent 004ccd76

Adding edit button when viewing a blog

(ActionItem1641)
app/helpers/blog_helper.rb
... ... @@ -11,7 +11,7 @@ module BlogHelper
11 11 end
12 12  
13 13 def cms_label_for_edit
14   - _('Edit blog')
  14 + _('Configure blog')
15 15 end
16 16  
17 17 def list_posts(user, articles, format = 'full')
... ...
app/views/content_viewer/view_page.rhtml
... ... @@ -12,11 +12,9 @@
12 12 <%= article_title(@page, :no_link => true) %>
13 13 <div id="article-actions">
14 14 <% if @page.allow_post_content?(user) %>
15   - <% unless @page.blog? %>
16 15 <%= link_to content_tag( 'span', label_for_edit_article(@page) ),
17 16 profile.admin_url.merge({ :controller => 'cms', :action => 'edit', :id => @page.id }),
18 17 :class => 'button with-text icon-edit' %>
19   - <% end %>
20 18 <% if !(profile.kind_of?(Enterprise) && environment.enabled?('disable_cms')) %>
21 19 <% if @page != profile.home_page && !@page.blog? %>
22 20 <%= link_to content_tag( 'span', _('Delete') ),
... ...
features/blog.feature
... ... @@ -78,6 +78,14 @@ Feature: blog
78 78 When I follow "Configure blog"
79 79 Then I should be on edit "Blog One" by joaosilva
80 80  
  81 + Scenario: configure blog when viewing it
  82 + Given the following blogs
  83 + | owner | name |
  84 + | joaosilva | Blog One |
  85 + And I go to /joaosilva/blog-one
  86 + When I follow "Configure blog"
  87 + Then I should be on edit "Blog One" by joaosilva
  88 +
81 89 Scenario: change address of blog
82 90 Given the following blogs
83 91 | owner | name |
... ...
test/functional/content_viewer_controller_test.rb
... ... @@ -902,4 +902,11 @@ class ContentViewerControllerTest &lt; Test::Unit::TestCase
902 902 assert_no_tag :tag => 'div', :attributes => { :class => 'short-post'}, :content => /Anything/
903 903 end
904 904  
  905 + should 'display link to edit blog for allowed' do
  906 + blog = fast_create(Blog, :profile_id => profile.id, :path => 'blog')
  907 + login_as(profile.identifier)
  908 + get :view_page, :profile => profile.identifier, :page => blog.explode_path
  909 + assert_tag :tag => 'div', :attributes => { :class => /main-block/ }, :descendant => { :tag => 'a', :attributes => { :href => "/myprofile/testinguser/cms/edit/#{blog.id}" }, :content => 'Configure blog' }
  910 + end
  911 +
905 912 end
... ...