Project

General

Profile

Feature #36370 » feature-36370-v2.patch

Mizuki ISHIKAWA, 2022-01-07 05:29

View differences:

app/controllers/projects_controller.rb
240 240
    respond_to do |format|
241 241
      format.html do
242 242
        flash[:error] = error if error
243
        redirect_to_referer_or admin_projects_path(:status => params[:status])
243
        redirect_to admin_projects_path(:status => params[:status])
244 244
      end
245 245
      format.api do
246 246
        if error
app/views/projects/show.html.erb
5 5
  <% if User.current.allowed_to?(:add_subprojects, @project) %>
6 6
    <%= link_to l(:label_subproject_new), new_project_path(:parent_id => @project), :class => 'icon icon-add' %>
7 7
  <% end %>
8
  <% if User.current.admin? %>
9
    <%= link_to l(:button_copy), copy_project_path(@project), :class => 'icon icon-copy' %>
10
  <% end %>
8 11
  <% if User.current.allowed_to?(:close_project, @project) %>
9 12
    <% if @project.active? %>
10 13
      <%= link_to l(:button_close), close_project_path(@project), :data => {:confirm => l(:text_are_you_sure)}, :method => :post, :class => 'icon icon-lock' %>
......
12 15
      <%= link_to l(:button_reopen), reopen_project_path(@project), :data => {:confirm => l(:text_are_you_sure)}, :method => :post, :class => 'icon icon-unlock' %>
13 16
    <% end %>
14 17
  <% end %>
18
  <% if User.current.admin? %>
19
    <%= 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' %>
20
  <% end %>
15 21
  <% if @project.deletable? %>
16 22
    <%= link_to l(:button_delete), project_path(@project), :method => :delete, :class => 'icon icon-del' %>
17 23
  <% end %>
test/functional/projects_controller_test.rb
801 801
    end
802 802
  end
803 803

  
804
  def test_show_should_show_actions
805
    @request.session[:user_id] = 1
806
    get(:show, params: {id: 'ecookbook'})
807
    assert_select 'div.drdn-items' do
808
      assert_select 'a.icon-add[href=?]', new_project_path(parent_id: 'ecookbook')
809
      assert_select 'a.icon-copy[href=?]', copy_project_path('ecookbook')
810
      assert_select 'a.icon-lock[href=?]', close_project_path('ecookbook')
811
      assert_select 'a.icon-lock[href=?]', archive_project_path('ecookbook', status: Project::STATUS_ARCHIVED)
812
      assert_select 'a.icon-del[href=?]', project_path('ecookbook')
813
      assert_select 'a.icon-settings[href=?]', settings_project_path('ecookbook')
814
    end
815

  
816
    @request.session[:user_id] = 2
817
    get(:show, params: {id: 'ecookbook'})
818
    assert_select 'div.drdn-items' do
819
      assert_select 'a.icon-add[href=?]', new_project_path(parent_id: 'ecookbook'), count: 0
820
      assert_select 'a.icon-copy[href=?]', copy_project_path('ecookbook'), count: 0
821
      assert_select 'a.icon-lock[href=?]', close_project_path('ecookbook')
822
      assert_select 'a.icon-lock[href=?]', archive_project_path('ecookbook', status: Project::STATUS_ARCHIVED), count: 0
823
      assert_select 'a.icon-del[href=?]', project_path('ecookbook'), count: 0
824
      assert_select 'a.icon-settings[href=?]', settings_project_path('ecookbook')
825
    end
826
  end
827

  
804 828
  def test_settings
805 829
    @request.session[:user_id] = 2 # manager
806 830
    get(:settings, :params => {:id => 1})
(4-4/4)