Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -80,32 +80,32 @@ GEM
american_date (1.3.0)
ast (2.4.3)
aws-eventstream (1.4.0)
aws-partitions (1.1177.0)
aws-sdk-core (3.235.0)
aws-partitions (1.1211.0)
aws-sdk-core (3.241.4)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.992.0)
aws-sigv4 (~> 1.9)
base64
bigdecimal
jmespath (~> 1, >= 1.6.1)
logger
aws-sdk-kms (1.115.0)
aws-sdk-core (~> 3, >= 3.234.0)
aws-sdk-kms (1.121.0)
aws-sdk-core (~> 3, >= 3.241.4)
aws-sigv4 (~> 1.5)
aws-sdk-s3 (1.201.0)
aws-sdk-core (~> 3, >= 3.234.0)
aws-sdk-s3 (1.213.0)
aws-sdk-core (~> 3, >= 3.241.4)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.5)
aws-sigv4 (1.12.1)
aws-eventstream (~> 1, >= 1.0.2)
base64 (0.3.0)
bcrypt (3.1.20)
benchmark (0.5.0)
bigdecimal (3.3.1)
bigdecimal (4.0.1)
bindex (0.8.1)
bootsnap (1.18.6)
msgpack (~> 1.2)
brakeman (7.1.0)
brakeman (8.0.1)
racc
builder (3.3.0)
bundler-audit (0.9.2)
Expand Down
2 changes: 2 additions & 0 deletions app/models/song.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ class Song < ApplicationRecord
congregational_hymn: 2,
musical_number: 3,
closing_hymn: 4,
prelude: 5,
postlude: 6,
}

validates :song_type, :title, presence: true
Expand Down
1 change: 1 addition & 0 deletions app/models/unit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def song_last_sung(title, date)

songs.where("songs.title ilike ?", title)
.where(meetings: { date: ...date })
.where.not(song_type: [:prelude, :postlude])
.order("meetings.date desc")
.first
end
Expand Down
10 changes: 9 additions & 1 deletion spec/models/unit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,15 @@
let(:date) { "2022-04-10".to_date }

context "when the song was sung previously" do
it { expect(result).to eq(songs(:song_1)) }
context "when sung as an opening song" do
it { expect(result).to eq(songs(:song_1)) }
end

context "when played as a prelude song" do
before { songs(:song_1).update(song_type: :prelude) }

it { expect(result).to be_nil }
end
end

context "when the song was sung after but not previously" do
Expand Down