Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow feature names to end with "features" in UI #353

Merged
merged 3 commits into from
Apr 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/flipper/ui/middleware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ def initialize(app, options = {})
@action_collection = ActionCollection.new

# UI
@action_collection.add UI::Actions::Features
@action_collection.add UI::Actions::AddFeature
@action_collection.add UI::Actions::Feature
@action_collection.add UI::Actions::ActorsGate
Expand All @@ -25,6 +24,7 @@ def initialize(app, options = {})
@action_collection.add UI::Actions::PercentageOfTimeGate
@action_collection.add UI::Actions::PercentageOfActorsGate
@action_collection.add UI::Actions::Gate
@action_collection.add UI::Actions::Features

# Static Assets/Files
@action_collection.add UI::Actions::File
Expand Down
44 changes: 44 additions & 0 deletions spec/flipper/api/v1/actions/feature_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,50 @@
expect(json_response).to eq(expected)
end
end

context 'feature with name that ends in "features"' do
before do
flipper[:search_features].enable
get '/features/search_features'
end

it 'responds with correct attributes' do
response_body = {
'key' => 'search_features',
'state' => 'on',
'gates' => [
{
'key' => 'boolean',
'name' => 'boolean',
'value' => 'true',
},
{
'key' => 'groups',
'name' => 'group',
'value' => [],
},
{
'key' => 'actors',
'name' => 'actor',
'value' => [],
},
{
'key' => 'percentage_of_actors',
'name' => 'percentage_of_actors',
'value' => nil,
},
{
'key' => 'percentage_of_time',
'name' => 'percentage_of_time',
'value' => nil,
},
],
}

expect(last_response.status).to eq(200)
expect(json_response).to eq(response_body)
end
end
end

describe 'delete' do
Expand Down
20 changes: 20 additions & 0 deletions spec/flipper/ui/actions/feature_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,24 @@
expect(last_response.body).to include('Percentage of Actors')
end
end

describe 'GET /features/:feature with _features in feature name' do
before do
get '/features/search_features'
end

it 'responds with success' do
expect(last_response.status).to be(200)
end

it 'renders template' do
expect(last_response.body).to include('search_features')
expect(last_response.body).to include('Enable')
expect(last_response.body).to include('Disable')
expect(last_response.body).to include('Actors')
expect(last_response.body).to include('Groups')
expect(last_response.body).to include('Percentage of Time')
expect(last_response.body).to include('Percentage of Actors')
end
end
end