2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-12-14 17:10:13 +01:00
|
|
|
RSpec.describe CommentaireHelper, type: :helper do
|
2018-09-06 18:13:14 +02:00
|
|
|
let(:commentaire) { create(:commentaire, email: "michel@pref.fr") }
|
2017-12-14 17:10:13 +01:00
|
|
|
|
2018-09-06 18:13:14 +02:00
|
|
|
describe ".commentaire_is_from_me_class" do
|
2017-12-14 17:10:13 +01:00
|
|
|
subject { commentaire_is_from_me_class(commentaire, me) }
|
|
|
|
|
|
|
|
context "when commentaire is from me" do
|
2018-09-11 18:40:10 +02:00
|
|
|
let(:me) { User.new(email: "michel@pref.fr") }
|
2017-12-14 17:10:13 +01:00
|
|
|
it { is_expected.to eq("from-me") }
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when commentaire is not from me" do
|
2018-09-11 18:40:10 +02:00
|
|
|
let(:me) { User.new(email: "roger@usager.fr") }
|
2017-12-14 17:10:13 +01:00
|
|
|
it { is_expected.to eq nil }
|
|
|
|
end
|
|
|
|
end
|
2018-09-06 15:04:43 +02:00
|
|
|
|
2018-09-11 18:40:10 +02:00
|
|
|
describe '.commentaire_answer_action' do
|
|
|
|
subject { commentaire_answer_action(commentaire, me) }
|
|
|
|
|
|
|
|
context "when commentaire is from me" do
|
|
|
|
let(:me) { User.new(email: "michel@pref.fr") }
|
|
|
|
it { is_expected.to include('Envoyer') }
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when commentaire is not from me" do
|
|
|
|
let(:me) { User.new(email: "roger@usager.fr") }
|
|
|
|
it { is_expected.to include('Répondre') }
|
|
|
|
end
|
|
|
|
end
|
2017-12-14 17:10:13 +01:00
|
|
|
end
|