Commit c096bbc126d7a099edd372349edce9953ea8e6d2

Authored by AntonioTerceiro
1 parent 16fadb1e

ActionItem609: creating new articles from the public view

git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@2350 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/views/content_viewer/view_page.rhtml
... ... @@ -35,6 +35,7 @@
35 35 <%= link_to content_tag( 'span', _('Edit') ),
36 36 { :controller => 'cms', :action => 'edit', :id => @page },
37 37 :class => 'button with-text icon-edit' %>
  38 + <%= lightbox_button(:new, _('New article'), :controller => 'cms', :action => 'new', :parent_id => (@page.folder? ? @page : nil)) %>
38 39 </div>
39 40 <% end %>
40 41 </div>
... ...
test/functional/content_viewer_controller_test.rb
... ... @@ -307,4 +307,42 @@ class ContentViewerControllerTest &lt; Test::Unit::TestCase
307 307 assert_equal profile, assigns(:profile)
308 308 end
309 309  
  310 + should 'give link to edit the article for owner ' do
  311 + login_as('testinguser')
  312 + get :view_page, :profile => 'testinguser', :page => []
  313 + assert_tag :tag => 'div', :attributes => { :class => /main-block/ }, :descendant => { :tag => 'a', :attributes => { :href => "/myprofile/testinguser/cms/edit/#{@profile.home_page.id}" } }
  314 + end
  315 + should 'not give link to edit the article for non-logged-in people' do
  316 + get :view_page, :profile => 'testinguser', :page => []
  317 + assert_no_tag :tag => 'div', :attributes => { :class => /main-block/ }, :descendant => { :tag => 'a', :attributes => { :href => "/myprofile/testinguser/cms/edit/#{@profile.home_page.id}" } }
  318 + end
  319 + should 'not give link to edit article for other people' do
  320 + login_as(create_user('anotheruser').login)
  321 +
  322 + get :view_page, :profile => 'testinguser', :page => []
  323 + assert_no_tag :tag => 'div', :attributes => { :class => /main-block/ }, :descendant => { :tag => 'a', :attributes => { :href => "/myprofile/testinguser/cms/edit/#{@profile.home_page.id}" } }
  324 + end
  325 +
  326 + should 'give link to create new article' do
  327 + login_as('testinguser')
  328 + get :view_page, :profile => 'testinguser', :page => []
  329 + assert_tag :tag => 'div', :attributes => { :class => /main-block/ }, :descendant => { :tag => 'a', :attributes => { :href => "/myprofile/testinguser/cms/new" } }
  330 + end
  331 + should 'give no link to create new article for non-logged in people ' do
  332 + get :view_page, :profile => 'testinguser', :page => []
  333 + assert_no_tag :tag => 'div', :attributes => { :class => /main-block/ }, :descendant => { :tag => 'a', :attributes => { :href => "/myprofile/testinguser/cms/new" } }
  334 + end
  335 + should 'give no link to create new article for other people' do
  336 + login_as(create_user('anotheruser').login)
  337 + get :view_page, :profile => 'testinguser', :page => []
  338 + assert_no_tag :tag => 'div', :attributes => { :class => /main-block/ }, :descendant => { :tag => 'a', :attributes => { :href => "/myprofile/testinguser/cms/new" } }
  339 + end
  340 +
  341 + should 'give link to create new article inside folder' do
  342 + login_as('testinguser')
  343 + folder = Folder.create!(:name => 'myfolder', :profile => @profile)
  344 + get :view_page, :profile => 'testinguser', :page => [ 'myfolder' ]
  345 + assert_tag :tag => 'div', :attributes => { :class => /main-block/ }, :descendant => { :tag => 'a', :attributes => { :href => "/myprofile/testinguser/cms/new?parent_id=#{folder.id}" } }
  346 + end
  347 +
310 348 end
... ...