27799_mark_default_version_in_versions_tab.patch

Marius BALTEANU, 2018-01-12 06:39

Download (2.22 KB)

View differences:

app/views/projects/settings/_versions.html.erb
16 16
<table class="list versions">
17 17
  <thead><tr>
18 18
    <th><%= l(:label_version) %></th>
19
    <th><%= l(:field_default_version) %></th>
19 20
    <th><%= l(:field_effective_date) %></th>
20 21
    <th><%= l(:field_description) %></th>
21 22
    <th><%= l(:field_status) %></th>
......
27 28
<% @versions.sort.each do |version| %>
28 29
    <tr class="version <%=h version.status %> <%= 'shared' if version.project != @project %>">
29 30
    <td class="name <%= 'icon icon-shared' if version.project != @project %>"><%= link_to_version version %></td>
31
    <td class="tick"><%= checked_image(version.id == @project.default_version_id) %></td>
30 32
    <td class="date"><%= format_date(version.effective_date) %></td>
31 33
    <td class="description"><%= version.description %></td>
32 34
    <td class="status"><%= l("version_status_#{version.status}") %></td>
test/functional/projects_controller_test.rb
641 641
    assert_select 'a#tab-versions[href=?]', '/projects/ecookbook/settings/versions?version_name=.1&version_status='
642 642
  end
643 643

  
644
  def test_settings_should_show_default_version_in_versions_tab
645
    project = Project.find(1)
646
    project.default_version_id = 3
647
    project.save!
648

  
649
    @request.session[:user_id] = 2
650

  
651
    get :settings, :params => {
652
        :id => 'ecookbook',
653
        :tab => 'versions',
654
      }
655
    assert_response :success
656

  
657
    assert_select 'table.versions tbody' do
658
      # asserts that only one version is marked as default
659
      assert_select 'td.tick span.icon-checked', 1
660
      # asserts which version is marked as default
661
      assert_select 'tr:first-child td.tick span.icon-checked', 1
662
    end
663
  end
664

  
644 665
  def test_settings_should_show_locked_members
645 666
    user = User.generate!
646 667
    member = User.add_to_project(user, Project.find(1))