Skip to content

Commit

Permalink
Expand split representation
Browse files Browse the repository at this point in the history
  • Loading branch information
jmileham committed Jun 7, 2018
1 parent 2e63f86 commit a2145bd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
5 changes: 4 additions & 1 deletion app/views/api/v2/split_registries/show.json.jbuilder
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
json.splits do
@split_registry.splits.each do |split|
json.set! split.name, split.registry
json.set! split.name do
json.weights split.registry
json.feature_gate split.feature_gate?
end
end
json.merge!({})
end
Expand Down
12 changes: 9 additions & 3 deletions spec/controllers/api/v2/split_registries_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
RSpec.describe Api::V2::SplitRegistriesController, type: :controller do
let(:split_1) { FactoryBot.create :split, name: "one", finished_at: Time.zone.now, registry: { all: 100 } }
let(:split_2) { FactoryBot.create :split, name: "two", registry: { on: 50, off: 50 } }
let(:split_3) { FactoryBot.create :split, name: "three", registry: { true: 99, false: 1 } }
let(:split_3) { FactoryBot.create :split, name: "three_enabled", registry: { true: 99, false: 1 }, feature_gate: true }

describe "#show" do
before do
Expand Down Expand Up @@ -31,8 +31,14 @@

expect(response).to have_http_status :ok
expect(response_json['splits']).to eq(
"two" => { "on" => 50, "off" => 50 },
"three" => { "true" => 99, "false" => 1 }
"two" => {
"weights" => { "on" => 50, "off" => 50 },
"feature_gate" => false
},
"three_enabled" => {
"weights" => { "true" => 99, "false" => 1 },
"feature_gate" => true
}
)
end
end
Expand Down

0 comments on commit a2145bd

Please sign in to comment.