Add system spec for profile fields (#11398)

* Add system spec for profile fields

* Use FeatureFlag wrapper over Flipper
This commit is contained in:
Jacob Herrington 2020-11-13 14:51:42 -06:00 committed by GitHub
parent de5122cb52
commit 94fe355dae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 43 additions and 1 deletions

View file

@ -1,6 +1,6 @@
module FeatureFlag
class << self
delegate :enable, :enabled?, :exist?, to: Flipper
delegate :disable, :enable, :enabled?, :exist?, to: Flipper
def accessible?(feature_flag_name, *args)
feature_flag_name.blank? || !exist?(feature_flag_name) || enabled?(feature_flag_name, *args)

View file

@ -0,0 +1,42 @@
require "rails_helper"
RSpec.describe "Admin manages profile fields", type: :system do
let(:admin) { create(:user, :super_admin) }
let!(:profile_field_group) { create(:profile_field_group, name: "Delete Me!") }
let!(:profile_field) { create(:profile_field, profile_field_group: profile_field_group, label: "Delete Me Too!") }
before do
FeatureFlag.enable(:profile_admin)
sign_in admin
visit admin_profile_fields_path
end
after do
FeatureFlag.disable(:profile_admin)
end
it "adds a profile group" do
click_on "Add group"
first("input#profile_field_group_name", visible: true).set("Example group")
click_on "Create Profile field group"
expect(page).to have_text("Successfully created group: Example group")
end
it "adds a profile field" do
click_on "Add Field"
first("input#profile_field_label", visible: true).set("Example field")
click_on "Create Profile field"
expect(page).to have_text("Profile field Example field created")
end
it "deletes a profile_field_group" do
click_button "Delete Group"
expect(page).to have_text("Group #{profile_field_group.name} deleted")
end
it "deletes a profile_field" do
expect(page).to have_text(profile_field.label.to_s)
click_button "Delete Profile Field"
expect(page).to have_text("Profile field #{profile_field.label} deleted")
end
end