2019-06-27 16:26:07 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe ChampPolicy do
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:dossier) { create(:dossier, user: user) }
|
|
|
|
let!(:champ) { create(:champ_text, dossier: dossier) }
|
|
|
|
|
2019-08-01 15:48:27 +02:00
|
|
|
let(:account) { { user: user } }
|
|
|
|
|
|
|
|
subject { Pundit.policy_scope(account, Champ) }
|
2019-06-27 16:26:07 +02:00
|
|
|
|
|
|
|
context 'when the user has only user rights' do
|
|
|
|
context 'cannot access champs for other dossiers' do
|
2019-08-01 15:48:27 +02:00
|
|
|
let(:account) { { user: create(:user) } }
|
2019-06-27 16:26:07 +02:00
|
|
|
|
|
|
|
it { expect(subject.find_by(id: champ.id)).to eq(nil) }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'can access champs for its own dossiers' do
|
|
|
|
it {
|
|
|
|
expect(subject.find(champ.id)).to eq(champ)
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|