Project

General

Profile

Feature #35044 » 0001-Add-test.patch

Mizuki ISHIKAWA, 2021-05-08 09:23

View differences:

app/views/projects/_members_box.html.erb
4 4
    <% @principals_by_role.keys.sort.each do |role| %>
5 5
      <p><span class="label"><%= role %>:</span> <%= @principals_by_role[role].sort.collect{|p| link_to_user p}.join(", ").html_safe %></p>
6 6
    <% end %>
7
    <% if @project.is_public %>
8
      <hr>
9
      <div id="is-public-project-notice">
10
        <p span class="label"><%= l(:field_is_public) %>:</span> <%= l(:general_text_Yes) %>
11
        <em class="info"><%= Setting.login_required? ? l(:text_project_is_public_non_member) : l(:text_project_is_public_anonymous) %></em>
12
      </div>
13
    <% end -%>
7 14
  </div>
8 15
  <% end %>
test/functional/projects_controller_test.rb
673 673
    assert_select '#main.nosidebar'
674 674
  end
675 675

  
676
  def test_show_should_display_is_public_project_notice
677
    p = Project.find('ecookbook')
678
    assert p.is_public?
679

  
680
    with_settings :login_required => '0' do
681
      get(:show, :params => {:id => p.identifier})
682
      assert_response :success
683
      assert_select '#is-public-project-notice .info', :text => l(:text_project_is_public_anonymous)
684
    end
685

  
686
    with_settings :login_required => '1' do
687
      @request.session[:user_id] = 1
688
      get(:show, :params => {:id => p.identifier})
689
      assert_response :success
690
      assert_select '#is-public-project-notice .info', :text => l(:text_project_is_public_non_member)
691
    end
692
  end
693

  
694
  def test_show_should_display_is_private_project_notice
695
    @request.session[:user_id] = 1
696
    p = Project.find('private-child')
697
    assert_not p.is_public?
698
    get(:show, :params => {:id => p.identifier})
699
    assert_response :success
700
    assert_select '#is-public-project-notice', :count => 0
701
  end
702

  
676 703
  def test_show_should_display_visible_custom_fields
677 704
    ProjectCustomField.find_by_name('Development status').update_attribute :visible, true
678 705
    get(:show, :params => {:id => 'ecookbook'})
(2-2/4)