docbrown/spec/models/profile_field_group_spec.rb
Michael Kohl 7b6c5b60c1
Add feature flag for profile admin section (#11149)
* Add feature flag for profile admin section

* Fix spec description

* Also remove profile admin link from sidebar

* Disable profile admin routes based on feature flag

* Minor fixes

* Remove unnecessary object from spec

* Refactor AdminHelper

* Fix specs

* Fix remaining specs
2020-11-02 08:48:18 +07:00

30 lines
873 B
Ruby

require "rails_helper"
RSpec.describe ProfileFieldGroup, type: :model do
subject { group }
before do
allow(Flipper).to receive(:enabled?).with(:profile_admin).and_return(true)
end
let!(:group) { create(:profile_field_group) }
it { is_expected.to have_many(:profile_fields).dependent(:nullify) }
it { is_expected.to validate_presence_of(:name) }
it { is_expected.to validate_uniqueness_of(:name) }
describe ".onboarding" do
let!(:other_group) { create(:profile_field_group) }
before do
create(:profile_field, :onboarding, profile_field_group: group)
create(:profile_field, profile_field_group: other_group)
end
it "only returns groups that have fields for onboarding" do
groups = described_class.onboarding
expect(groups).to include(group)
expect(groups).not_to include(other_group)
end
end
end