Commit 5fa9d6a1 authored by Rémy Coutable's avatar Rémy Coutable

Rename FLippable to FeatureGate and make `flipper_group` and `user` mutually exclusive

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent b4d325c8
module Flippable
module FeatureGate
def flipper_id
return nil if new_record?
......
......@@ -11,7 +11,7 @@ class User < ActiveRecord::Base
include CaseSensitivity
include TokenAuthenticatable
include IgnorableColumn
include Flippable
include FeatureGate
DEFAULT_NOTIFICATION_LEVEL = :participating
......
......@@ -61,6 +61,8 @@ POST /features/:name
| `flipper_group` | string | no | A Flipper group name |
| `user` | string | no | A GitLab username |
Note that `flipper_group` and `user` are mutually exclusive.
```bash
curl --data "value=30" --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/features/new_library
```
......
......@@ -42,6 +42,7 @@ module API
requires :value, type: String, desc: '`true` or `false` to enable/disable, an integer for percentage of time'
optional :flipper_group, type: String, desc: 'A Flipper group name'
optional :user, type: String, desc: 'A GitLab username'
mutually_exclusive :flipper_group, :user
end
post ':name' do
feature = Feature.get(params[:name])
......
require 'spec_helper'
describe FeatureGate do
describe 'User' do
describe '#flipper_id' do
context 'when user is not persisted' do
let(:user) { build(:user) }
it { expect(user.flipper_id).to be_nil }
end
context 'when user is persisted' do
let(:user) { create(:user) }
it { expect(user.flipper_id).to eq "User:#{user.id}" }
end
end
end
end
......@@ -430,20 +430,6 @@ describe User, models: true do
end
end
describe '#flipper_id' do
context 'when user is not persisted' do
let(:user) { build(:user) }
it { expect(user.flipper_id).to be_nil }
end
context 'when user is persisted' do
let(:user) { create(:user) }
it { expect(user.flipper_id).to eq "User:#{user.id}" }
end
end
describe '#generate_password' do
it "does not generate password by default" do
user = create(:user, password: 'abcdefghe')
......
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