app.kluk.fr/spec/models/user_spec.rb
Christophe Robillard 7a7fa4c095
Some checks are pending
CI / scan_ruby (push) Waiting to run
CI / scan_js (push) Waiting to run
CI / lint (push) Waiting to run
CI / test (push) Waiting to run
redesign app on top of the kluk.fr charte
- drop Bulma and Font Awesome, plain CSS built on charte.css
- dashboard: GitHub-like calendar grouped by year, selected day panel
  (sticky side column on desktop, bottom bar on mobile), keyboard navigation
- public page: today's mood and last months fit in one screen, journal hidden
- day log page: mode picker as pills, illustration follows the chosen mode
- login, password and invitation screens in French, global flash messages
- add User#current_mode_since

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 07:35:53 +02:00

21 lines
775 B
Ruby

require 'rails_helper'
RSpec.describe User, type: :model do
describe "#current_mode_since" do
let(:user) { create(:user) }
let(:croisiere) { create(:mode, user: user) }
let(:creatif) { create(:mode, user: user) }
it "returns nil without moods" do
expect(user.current_mode_since).to be_nil
end
it "returns the first day of the latest run of the current mode" do
create(:mood, user: user, mode: croisiere, recorded_at: DateTime.parse("2026-01-10 08:00"))
create(:mood, user: user, mode: creatif, recorded_at: DateTime.parse("2026-01-12 08:00"))
create(:mood, user: user, mode: creatif, recorded_at: DateTime.parse("2026-01-14 08:00"))
expect(user.current_mode_since).to eq(Date.parse("2026-01-12"))
end
end
end