Use Flipflop instead of Feature

This commit is contained in:
Paul Chavard 2018-04-18 12:24:37 +02:00
parent 7dd0611a28
commit 45019ce75c
22 changed files with 46 additions and 44 deletions

View file

@ -2,19 +2,22 @@ require 'rails_helper'
RSpec.describe TypeDeChampHelper, type: :helper do
describe ".tdc_options" do
let(:current_administrateur) { create(:administrateur) }
let(:pj_option) { ["Pièce justificative", "piece_justificative"] }
subject { tdc_options(current_administrateur) }
subject { tdc_options }
context "when the champ_pj_allowed_for_admin_id matches the current_administrateur's id" do
before { allow(Features).to receive(:champ_pj_allowed_for_admin_ids).and_return([current_administrateur.id]) }
context "when the champ_pj is enabled" do
before do
Flipflop::FeatureSet.current.test!.switch!(:champ_pj, true)
end
it { is_expected.to include(pj_option) }
end
context "when the champ_pj_allowed_for_admin_id does not match the current_administrateur's id" do
before { allow(Features).to receive(:champ_pj_allowed_for_admin_ids).and_return([1000]) }
context "when the champ_pj is disabled" do
before do
Flipflop::FeatureSet.current.test!.switch!(:champ_pj, false)
end
it { is_expected.not_to include(pj_option) }
end