Project

General

Profile

Feature #36370 » feature-36370-v2.patch

Mizuki ISHIKAWA, 2022-01-07 05:29

View differences:

app/controllers/projects_controller.rb
respond_to do |format|
format.html do
flash[:error] = error if error
redirect_to_referer_or admin_projects_path(:status => params[:status])
redirect_to admin_projects_path(:status => params[:status])
end
format.api do
if error
app/views/projects/show.html.erb
<% if User.current.allowed_to?(:add_subprojects, @project) %>
<%= link_to l(:label_subproject_new), new_project_path(:parent_id => @project), :class => 'icon icon-add' %>
<% end %>
<% if User.current.admin? %>
<%= link_to l(:button_copy), copy_project_path(@project), :class => 'icon icon-copy' %>
<% end %>
<% if User.current.allowed_to?(:close_project, @project) %>
<% if @project.active? %>
<%= link_to l(:button_close), close_project_path(@project), :data => {:confirm => l(:text_are_you_sure)}, :method => :post, :class => 'icon icon-lock' %>
......
<%= link_to l(:button_reopen), reopen_project_path(@project), :data => {:confirm => l(:text_are_you_sure)}, :method => :post, :class => 'icon icon-unlock' %>
<% end %>
<% end %>
<% if User.current.admin? %>
<%= link_to l(:button_archive), archive_project_path(@project, status: Project::STATUS_ARCHIVED), :data => {:confirm => l(:text_are_you_sure)}, :method => :post, :class => 'icon icon-lock' %>
<% end %>
<% if @project.deletable? %>
<%= link_to l(:button_delete), project_path(@project), :method => :delete, :class => 'icon icon-del' %>
<% end %>
test/functional/projects_controller_test.rb
end
end
def test_show_should_show_actions
@request.session[:user_id] = 1
get(:show, params: {id: 'ecookbook'})
assert_select 'div.drdn-items' do
assert_select 'a.icon-add[href=?]', new_project_path(parent_id: 'ecookbook')
assert_select 'a.icon-copy[href=?]', copy_project_path('ecookbook')
assert_select 'a.icon-lock[href=?]', close_project_path('ecookbook')
assert_select 'a.icon-lock[href=?]', archive_project_path('ecookbook', status: Project::STATUS_ARCHIVED)
assert_select 'a.icon-del[href=?]', project_path('ecookbook')
assert_select 'a.icon-settings[href=?]', settings_project_path('ecookbook')
end
@request.session[:user_id] = 2
get(:show, params: {id: 'ecookbook'})
assert_select 'div.drdn-items' do
assert_select 'a.icon-add[href=?]', new_project_path(parent_id: 'ecookbook'), count: 0
assert_select 'a.icon-copy[href=?]', copy_project_path('ecookbook'), count: 0
assert_select 'a.icon-lock[href=?]', close_project_path('ecookbook')
assert_select 'a.icon-lock[href=?]', archive_project_path('ecookbook', status: Project::STATUS_ARCHIVED), count: 0
assert_select 'a.icon-del[href=?]', project_path('ecookbook'), count: 0
assert_select 'a.icon-settings[href=?]', settings_project_path('ecookbook')
end
end
def test_settings
@request.session[:user_id] = 2 # manager
get(:settings, :params => {:id => 1})
(4-4/4)