Skip to content

Commit

Permalink
extend test case to cover issue with larger arrays
Browse files Browse the repository at this point in the history
(cherry picked from commit fe62c1f)
  • Loading branch information
robinboening committed Jan 24, 2025
1 parent ff6451d commit e1ef1fa
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions spec/libraries/resource_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -314,19 +314,24 @@ module Alchemy
describe "#sorted_attributes" do
subject { resource.sorted_attributes }

let(:random_attrs) do
20.times.map do
double(:column, {name: "some_title", type: :string})
end
end

let(:columns) do
[
double(:column, {name: "title", type: :string}),
random_attrs + [
double(:column, {name: "name", type: :string}),
double(:column, {name: "updated_at", type: :datetime}),
double(:column, {name: "public", type: :boolean})
]
end

it "sorts by name, and updated_at" do
is_expected.to eq([
it "sorts by name, booleans and updated_at" do
expect(subject.uniq!).to eq([
{name: "name", type: :string},
{name: "title", type: :string},
{name: "some_title", type: :string},
{name: "public", type: :boolean},
{name: "updated_at", type: :datetime}
])
Expand Down

0 comments on commit e1ef1fa

Please sign in to comment.