Skip to content

Commit

Permalink
Merge pull request #17625 from eclarizio/BZ1593874
Browse files Browse the repository at this point in the history
Ensure sorting does not happen when sort_by is set to "none"
  • Loading branch information
gmcculloug authored Jun 21, 2018
2 parents 762abcf + 145052a commit 8e109d6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/dialog_field_sorted_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def initialize_with_values(dialog_values)
end

def sort_by
options[:sort_by] || :description
options[:sort_by].try(:to_sym) || :description
end

def sort_by=(value)
Expand Down
11 changes: 11 additions & 0 deletions spec/models/dialog_field_sorted_item_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,17 @@
it "returns the values with the first option being a nil 'None' option" do
expect(dialog_field.values).to eq([[nil, "<None>"], %w(test test), %w(abc abc)])
end

context "when the values are in a seemingly random order" do
let(:values) { [%w(3 Three), %w(1 One), %w(2 Two)] }
before do
dialog_field.options[:sort_by] = "none"
end

it "does not attempt to sort them" do
expect(dialog_field.values).to eq([[nil, "<None>"], %w(3 Three), %w(1 One), %w(2 Two)])
end
end
end
end
end
Expand Down

0 comments on commit 8e109d6

Please sign in to comment.