Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jl - Status sorting bug #1426

Merged
merged 2 commits into from
Jul 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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