Commit 2e8d0153 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Pass on arguments passed to the FeatureConstrainer

All arguments passed to the `FeatureConstrainer` will be passed on to
the `Feature.enabled?` check.
parent 744f6ed1
constraints(::Constraints::FeatureConstrainer.new(:graphql, nil, true)) do
constraints(::Constraints::FeatureConstrainer.new(:graphql, default_enabled: true)) do
post '/api/graphql', to: 'graphql#execute'
mount GraphiQL::Rails::Engine, at: '/-/graphql-explorer', graphql_path: '/api/graphql'
end
......
......@@ -2,14 +2,14 @@
module Constraints
class FeatureConstrainer
attr_reader :feature, :thing, :default_enabled
attr_reader :args
def initialize(feature, thing, default_enabled)
@feature, @thing, @default_enabled = feature, thing, default_enabled
def initialize(*args)
@args = args
end
def matches?(_request)
Feature.enabled?(feature, @thing, default_enabled: true)
Feature.enabled?(*args)
end
end
end
require 'spec_helper'
describe Constraints::FeatureConstrainer do
describe '#matches' do
it 'calls Feature.enabled? with the correct arguments' do
expect(Feature).to receive(:enabled?).with(:feature_name, "an object", default_enabled: true)
described_class.new(:feature_name, "an object", default_enabled: true).matches?(double('request'))
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment