docbrown/spec/controllers/application_controller_spec.rb
Joshua Wehner c5731ac91a
FeatureFlag.enabled_for_user(_id) (#19929)
* FeatureFlag can work with user_id

* Use the new methods

* No thank you, rubocop

* Some tests would be nice

* Try to appease codecov

---------

Co-authored-by: Ben Halpern <bendhalpern@gmail.com>
2023-08-15 12:02:44 -04:00

19 lines
575 B
Ruby

require "rails_helper"
RSpec.describe "ApplicationController", type: :request do
let!(:user) { create(:user) }
let!(:controller) { ApplicationController.new }
before do
allow(controller).to receive(:current_user).and_return(user)
end
describe "#feature_flag_enabled?" do
it "calls FeatureFlag.enabled_for_user with current_user" do
allow(FeatureFlag).to receive(:enabled_for_user?)
controller.feature_flag_enabled?("flag_name")
expect(FeatureFlag).to have_received(:enabled_for_user?)
.with("flag_name", user)
end
end
end