Skip to content

Commit

Permalink
Merge pull request #1426 from sparc-request/jl-status-sorting-bug
Browse files Browse the repository at this point in the history
Jl - Status sorting bug
  • Loading branch information
Stuart-Johnson committed Jul 23, 2018
2 parents 433d6c1 + 64d4ee3 commit e8ce70f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
17 changes: 15 additions & 2 deletions app/helpers/dashboard/sub_service_requests_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,8 @@ def ssr_select_options(ssr)
private

def statuses_with_classes(ssr)
ssr.organization.get_available_statuses.invert.map do |status|

sorted_by_permissible_values(ssr.organization.get_available_statuses).invert.map do |status|
if in_finished_status?(status)
status.push(:class=> 'finished-status')
else
Expand All @@ -288,7 +289,7 @@ def statuses_with_classes(ssr)

def finished_statuses(ssr)
new_statuses = []
ssr.organization.get_available_statuses.invert.map do |status|
sorted_by_permissible_values(ssr.organization.get_available_statuses).invert.map do |status|
if in_finished_status?(status)
new_statuses << status
end
Expand All @@ -302,5 +303,17 @@ def finished_statuses(ssr)
def in_finished_status?(status)
Setting.find_by_key("finished_statuses").value.include?(status.last)
end

def sorted_by_permissible_values(statuses)
values = PermissibleValue.order(:sort_order).get_hash('status')
sorted_hash = {}
values.each do |k, v|
if statuses.has_key?(k)
sorted_hash[k] = v
end
end

sorted_hash
end
end

Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

expect(response).to have_tag("select#sub_service_request_status") do
with_option("Draft")
with_option("NotDraft")
with_option("Invoiced")
end
end
end
Expand Down Expand Up @@ -254,7 +254,7 @@ def stub_sub_service_request(opts = {})
end

def stub_organization(opts = {})
default_statuses = { "draft" => "Draft", "not_draft" => "NotDraft" }
default_statuses = { "draft" => "Draft", "invoiced" => "Invoiced" }
instance_double(Organization,
name: "MegaCorp",
abbreviation: "MC",
Expand Down

0 comments on commit e8ce70f

Please sign in to comment.