Commit c096bbc126d7a099edd372349edce9953ea8e6d2
1 parent
16fadb1e
Exists in
master
and in
29 other branches
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
Showing
2 changed files
with
39 additions
and
0 deletions
Show diff stats
app/views/content_viewer/view_page.rhtml
| @@ -35,6 +35,7 @@ | @@ -35,6 +35,7 @@ | ||
| 35 | <%= link_to content_tag( 'span', _('Edit') ), | 35 | <%= link_to content_tag( 'span', _('Edit') ), |
| 36 | { :controller => 'cms', :action => 'edit', :id => @page }, | 36 | { :controller => 'cms', :action => 'edit', :id => @page }, |
| 37 | :class => 'button with-text icon-edit' %> | 37 | :class => 'button with-text icon-edit' %> |
| 38 | + <%= lightbox_button(:new, _('New article'), :controller => 'cms', :action => 'new', :parent_id => (@page.folder? ? @page : nil)) %> | ||
| 38 | </div> | 39 | </div> |
| 39 | <% end %> | 40 | <% end %> |
| 40 | </div> | 41 | </div> |
test/functional/content_viewer_controller_test.rb
| @@ -307,4 +307,42 @@ class ContentViewerControllerTest < Test::Unit::TestCase | @@ -307,4 +307,42 @@ class ContentViewerControllerTest < Test::Unit::TestCase | ||
| 307 | assert_equal profile, assigns(:profile) | 307 | assert_equal profile, assigns(:profile) |
| 308 | end | 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 | end | 348 | end |