Skip to content

Commit

Permalink
Sort trackers in position order (agileware-jp#6)
Browse files Browse the repository at this point in the history
* Add test to GlobalIssueTemplatesControllerTest

* Sort trackers in position order

* Sort trackers in position order
  • Loading branch information
yui-har authored Jun 3, 2021
1 parent 86fbfc1 commit eb167c3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/controllers/global_issue_templates_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class GlobalIssueTemplatesController < ApplicationController
# Action for global template : Admin right is required.
#
def index
trackers = Tracker.all
trackers = Tracker.sorted
template_map = {}
trackers.each do |tracker|
tracker_id = tracker.id
Expand Down Expand Up @@ -135,7 +135,7 @@ def template_params
end

def render_form_params
trackers = Tracker.all
trackers = Tracker.sorted
projects = Project.all
tracker_id = @global_issue_template.tracker_id
custom_fields = core_fields_map_by_tracker_id(tracker_id: tracker_id)
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/global_note_templates_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class GlobalNoteTemplatesController < ApplicationController
# Action for global template : Admin right is required.
#
def index
trackers = Tracker.all
trackers = Tracker.sorted
template_map = {}
trackers.each do |tracker|
tracker_id = tracker.id
Expand Down Expand Up @@ -94,7 +94,7 @@ def template_params
end

def render_form_params
trackers = Tracker.all
trackers = Tracker.sorted
projects = Project.all

{ layout: !request.xhr?,
Expand Down
17 changes: 17 additions & 0 deletions test/functional/global_issue_templates_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,23 @@ def test_get_index
assert_response :success
end

def test_get_index_should_sort_trackers_in_position_order
[
['Feature request', 1],
['Support request', 2],
['Bug', 3],
].each do |name, position|
tracker = Tracker.find_by(name: name)
tracker.position = position
tracker.save!(validate: false)
end
get :index
assert_response :success
assert_select 'div.template_box:nth-of-type(1) h3.template_tracker', 'Feature request'
assert_select 'div.template_box:nth-of-type(2) h3.template_tracker', 'Support request'
assert_select 'div.template_box:nth-of-type(3) h3.template_tracker', 'Bug'
end

def test_update_template
put :update, params: { id: 2, global_issue_template:
{ description: 'Update Test Global template2' } }
Expand Down

0 comments on commit eb167c3

Please sign in to comment.