Defect #35308 » add_test.patch
| app/views/news/index.html.erb | ||
|---|---|---|
|
<div class="contextual">
|
||
|
<%= link_to(l(:label_news_new),
|
||
|
(@project ? project_news_index_path(@project) : news_index_path),
|
||
|
:class => 'icon icon-add',
|
||
|
:onclick => 'showAndScrollTo("add-news", "news_title"); return false;') if (@project.nil? || (@project && User.current.allowed_to?(:manage_news, @project))) %>
|
||
|
:class => 'icon icon-add add-news-link',
|
||
|
:onclick => 'showAndScrollTo("add-news", "news_title"); return false;') if User.current.allowed_to?(:manage_news, @project, global: true) %>
|
||
|
<%= watcher_link(@project.enabled_module('news'), User.current) if @project && User.current.logged? %>
|
||
|
</div>
|
||
| test/functional/news_controller_test.rb | ||
|---|---|---|
|
assert_response 403
|
||
|
end
|
||
|
def test_index_without_global_manage_news_permission_should_not_display_add_news_link
|
||
|
user = User.find(2)
|
||
|
@request.session[:user_id] = user.id
|
||
|
Role.all.each {|r| r.remove_permission! :manage_news}
|
||
|
get :index
|
||
|
assert_select '.add-news-link', count: 0
|
||
|
user.members.first.roles.first.add_permission! :manage_news
|
||
|
get :index
|
||
|
assert_select '.add-news-link', count: 1
|
||
|
end
|
||
|
def test_show
|
||
|
get(:show, :params => {:id => 1})
|
||
|
assert_response :success
|
||
- « Previous
- 1
- 2
- Next »