specs: regroup dossier scope specs together
This commit is contained in:
parent
780cb965a5
commit
4efea77280
1 changed files with 18 additions and 24 deletions
|
@ -5,6 +5,24 @@ describe Dossier do
|
|||
|
||||
let(:user) { create(:user) }
|
||||
|
||||
describe 'scopes' do
|
||||
describe '.default_scope' do
|
||||
let!(:dossier) { create(:dossier) }
|
||||
let!(:hidden_dossier) { create(:dossier, :hidden) }
|
||||
|
||||
subject { Dossier.all }
|
||||
|
||||
it { is_expected.to match_array([dossier]) }
|
||||
end
|
||||
|
||||
describe '.without_followers' do
|
||||
let!(:dossier_with_follower) { create(:dossier, :followed, :with_entreprise, user: user) }
|
||||
let!(:dossier_without_follower) { create(:dossier, :with_entreprise, user: user) }
|
||||
|
||||
it { expect(Dossier.without_followers.to_a).to eq([dossier_without_follower]) }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'validations' do
|
||||
let(:procedure) { create(:procedure, :for_individual) }
|
||||
subject(:dossier) { create(:dossier, procedure: procedure) }
|
||||
|
@ -12,13 +30,6 @@ describe Dossier do
|
|||
it { is_expected.to validate_presence_of(:individual) }
|
||||
end
|
||||
|
||||
describe "without_followers scope" do
|
||||
let!(:dossier) { create(:dossier, :followed, :with_entreprise, user: user) }
|
||||
let!(:dossier2) { create(:dossier, :with_entreprise, user: user) }
|
||||
|
||||
it { expect(Dossier.without_followers.to_a).to eq([dossier2]) }
|
||||
end
|
||||
|
||||
describe 'with_champs' do
|
||||
let(:procedure) { create(:procedure) }
|
||||
let(:dossier) { Dossier.create(user: create(:user), groupe_instructeur: procedure.defaut_groupe_instructeur) }
|
||||
|
@ -522,23 +533,6 @@ describe Dossier do
|
|||
end
|
||||
end
|
||||
|
||||
describe ".default_scope" do
|
||||
let!(:dossier) { create(:dossier, hidden_at: hidden_at) }
|
||||
|
||||
context "when dossier is not hidden" do
|
||||
let(:hidden_at) { nil }
|
||||
|
||||
it { expect(Dossier.count).to eq(1) }
|
||||
it { expect(Dossier.all).to include(dossier) }
|
||||
end
|
||||
|
||||
context "when dossier is hidden" do
|
||||
let(:hidden_at) { 1.day.ago }
|
||||
|
||||
it { expect(Dossier.count).to eq(0) }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'updated_at' do
|
||||
let!(:dossier) { create(:dossier) }
|
||||
let(:modif_date) { Time.zone.parse('01/01/2100') }
|
||||
|
|
Loading…
Reference in a new issue