Skip to content

Commit 4da0dca

Browse files
committed
backlog bucket order alphabetically
1 parent fd683f1 commit 4da0dca

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

modules/backlogs/app/models/agile/backlog_bucket.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,7 @@ class Agile::BacklogBucket < ApplicationRecord
3434
belongs_to :project
3535
has_many :work_packages, -> { order_by_position }, inverse_of: :backlog_bucket, dependent: :nullify
3636

37+
scope :order_alphabetically, -> { order(:name) }
38+
3739
validates :name, :project, presence: true
3840
end

modules/backlogs/spec/models/agile/backlog_bucket_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,14 @@
6969
expect(backlog_bucket.work_packages.reload.to_a).to eq([work_package1, work_package2, work_package_nil])
7070
end
7171
end
72+
73+
describe ".order_alphabetically" do
74+
it "returns buckets sorted by name" do
75+
bucket3 = create(:backlog_bucket, project:, name: "foo")
76+
bucket1 = create(:backlog_bucket, project:, name: "bar")
77+
bucket2 = create(:backlog_bucket, project:, name: "baz")
78+
79+
expect(described_class.order_alphabetically).to eq([bucket1, bucket2, bucket3])
80+
end
81+
end
7282
end

0 commit comments

Comments
 (0)