Skip to content

Commit bc1f00c

Browse files
Adds variant details to split_details endpoint (#45)
add variant details to respective feature tests and modify split show page view
1 parent 8a133fe commit bc1f00c

11 files changed

Lines changed: 70 additions & 27 deletions

File tree

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
.BasicTable {
22
@include standard-table(100%, 40%, 25%);
3-
max-width: $app-width;
4-
margin-top: 0;
3+
}
54

6-
thead tr th {
7-
text-transform: capitalize;
8-
}
5+
.DescriptionTable {
6+
@include standard-table(100%, 15%, 45%);
97
}
108

119
.EmptyTable {
1210
&--centered {
1311
text-align: center;
1412
}
1513
}
14+
15+
table {
16+
max-width: $app-width;
17+
margin-top: 0;
18+
thead tr th {
19+
text-transform: capitalize;
20+
}
21+
}

app/models/split_detail.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class SplitDetail
44
include DelegateAttribute
55

66
attr_accessor :split
7-
delegate :name, to: :split
7+
delegate :name, :variant_details, to: :split
88
delegate_attribute :hypothesis, :assignment_criteria, :description, :owner, :location, :platform, to: :split
99

1010
validates :hypothesis, :assignment_criteria, :description, :owner, :location, :platform, presence: true

app/views/admin/splits/_test_overview.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
<hr class="InfoCard-divider">
1313
<% if split.has_details? %>
14-
<table class="BasicTable borderless bottom">
14+
<table class="DescriptionTable borderless bottom">
1515
<tr>
1616
<td>Squad Owner</td>
1717
<td><%= split.owner %></td>

app/views/admin/splits/_variants.html.erb

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,19 @@
55
</div>
66
<hr class="InfoCard-divider">
77
<div class="InfoCard-description">
8-
<table class="fs-VariantsTable BasicTable">
8+
<table class="fs-VariantsTable DescriptionTable">
99
<thead>
1010
<th>Name</th>
11-
<th>Weight</th>
12-
<th>Assignee Count</th>
11+
<th>Description</th>
12+
<th>Weight (Assignee Count)</th>
1313
<th></th>
1414
</thead>
1515
<tbody>
1616
<% split.variant_details.each do |variant_detail| %>
1717
<tr>
18-
<td><%= variant_detail.variant %></td>
19-
<td><%= variant_detail.weight %>%</td>
20-
<td>
21-
<%= variant_detail.assignment_count %>
18+
<td><%= variant_detail.display_name %></td>
19+
<td><%= variant_detail.description %></td>
20+
<td><%= variant_detail.weight %>%(<%= variant_detail.assignment_count %>)
2221
<% if variant_detail.retirable? %>
2322
(<%= link_to "Retire variant", admin_split_variant_retirement_path(split, variant_detail.variant),
2423
class: "retire-variant-link",
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
json.name variant_detail.display_name
2+
json.description variant_detail.description
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
json.(@split_detail, :name, :hypothesis, :assignment_criteria, :description, :owner, :location, :platform)
2+
json.variant_details @split_detail.variant_details, partial: 'variant_detail', as: :variant_detail

spec/features/admin_split_config_create_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
it 'allows admins to change the weights of a split' do
1515
split_page.load split_id: split.id
1616
expect(split_page).to be_displayed
17-
expect(split_page.variants_table).to have_content "red 100% 0 edit blue 0% 0 edit"
17+
expect(split_page.variants_table).to have_content "red 100%(0) edit blue 0%(0) edit"
1818

1919
split_page.change_weights.click
2020

@@ -46,6 +46,6 @@
4646
end
4747
form.submit_button.click
4848
end
49-
expect(split_page.variants_table).to have_content "red 50% 0 edit blue 50% 0 edit"
49+
expect(split_page.variants_table).to have_content "red 50%(0) edit blue 50%(0) edit"
5050
end
5151
end

spec/features/admin_variant_details_edit_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,7 @@
2525

2626
expect(split_page).to be_displayed
2727
expect(split_page).to have_content 'Details for enabled have been saved'
28+
expect(split_page.variants.first.name).to have_content "Variant name"
29+
expect(split_page.variants.first.description).to have_content "Super great variant"
2830
end
2931
end

spec/features/admin_variant_retirement_create_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
it 'allows admins to retire a variant' do
1818
split_page.load split_id: split.id
1919
expect(split_page).to be_displayed
20-
expect(split_page.variants_table).to have_content "blue 0% 8 (Retire variant)"
20+
expect(split_page.variants_table).to have_content "blue 0%(8) (Retire variant)"
2121

2222
split_page.retire_variant.click
2323

24-
expect(split_page.variants_table).to have_content "blue 0% 0"
24+
expect(split_page.variants_table).to have_content "blue 0%(0)"
2525
expect(split_page.variants_table).not_to have_content "Retire variant"
2626
end
2727
end

spec/requests/api/v1/split_details_spec.rb

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,26 @@
44
describe 'GET /api/v1/split_details/:id' do
55
let(:default_app) { FactoryGirl.create :app, name: "default_app", auth_secret: "6Sd6T7T6Q8hKcoo0t8CTzV0IdN1EEHqXB2Ig4raZsOf" }
66
let(:split_with_no_details) { FactoryGirl.create :split, name: "fantastic_split" }
7-
let(:split_with_details) { FactoryGirl.create :split, name: "fantastic_split_with_information", platform: 'mobile', description: 'Greatest Split', assignment_criteria: "Must love problem solvers", hypothesis: 'Will solve all problems', location: 'Everywhere', owner: 'Me' } # rubocop:disable Metrics/LineLength
7+
let(:split_with_details) { FactoryGirl.create :split, registry: { enabled: 99, disabled: 1 }, name: "fantastic_split_with_information", platform: 'mobile', description: 'Greatest Split', assignment_criteria: "Must love problem solvers", hypothesis: 'Will solve all problems', location: 'Everywhere', owner: 'Me' } # rubocop:disable Metrics/LineLength
8+
9+
let!(:variant_detail_a) do
10+
FactoryGirl.create(
11+
:variant_detail,
12+
split: split_with_details,
13+
variant: 'enabled',
14+
display_name: 'fantastic_split_with_information is on',
15+
description: 'This awesome feature makes cool stuff happen.'
16+
)
17+
end
18+
let!(:variant_detail_b) do
19+
FactoryGirl.create(
20+
:variant_detail,
21+
split: split_with_details,
22+
variant: 'disabled',
23+
display_name: 'fantastic_split_with_information is off',
24+
description: 'This feature makes nothing happen.'
25+
)
26+
end
827

928
before do
1029
http_authenticate username: default_app.name, password: default_app.auth_secret
@@ -20,7 +39,8 @@
2039
"assignment_criteria" => nil,
2140
"platform" => nil,
2241
"description" => nil,
23-
"owner" => nil
42+
"owner" => nil,
43+
"variant_details" => []
2444
)
2545
end
2646

@@ -34,7 +54,17 @@
3454
"assignment_criteria" => split_with_details.assignment_criteria,
3555
"platform" => split_with_details.platform,
3656
"description" => split_with_details.description,
37-
"owner" => split_with_details.owner
57+
"owner" => split_with_details.owner,
58+
"variant_details" => [
59+
{
60+
"name" => "fantastic_split_with_information is on",
61+
"description" => 'This awesome feature makes cool stuff happen.'
62+
},
63+
{
64+
"name" => "fantastic_split_with_information is off",
65+
"description" => "This feature makes nothing happen."
66+
}
67+
]
3868
)
3969
end
4070

0 commit comments

Comments
 (0)