Skip to content

Commit

Permalink
Adds variant details to split_details endpoint (#45)
Browse files Browse the repository at this point in the history
add variant details to respective feature tests and modify split show
page view
  • Loading branch information
agirlnamedsophia committed Apr 11, 2017
1 parent 8a133fe commit bc1f00c
Show file tree
Hide file tree
Showing 11 changed files with 70 additions and 27 deletions.
16 changes: 11 additions & 5 deletions app/assets/stylesheets/components/_tables.scss
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
.BasicTable {
@include standard-table(100%, 40%, 25%);
max-width: $app-width;
margin-top: 0;
}

thead tr th {
text-transform: capitalize;
}
.DescriptionTable {
@include standard-table(100%, 15%, 45%);
}

.EmptyTable {
&--centered {
text-align: center;
}
}

table {
max-width: $app-width;
margin-top: 0;
thead tr th {
text-transform: capitalize;
}
}
2 changes: 1 addition & 1 deletion app/models/split_detail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class SplitDetail
include DelegateAttribute

attr_accessor :split
delegate :name, to: :split
delegate :name, :variant_details, to: :split
delegate_attribute :hypothesis, :assignment_criteria, :description, :owner, :location, :platform, to: :split

validates :hypothesis, :assignment_criteria, :description, :owner, :location, :platform, presence: true
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/splits/_test_overview.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<hr class="InfoCard-divider">
<% if split.has_details? %>
<table class="BasicTable borderless bottom">
<table class="DescriptionTable borderless bottom">
<tr>
<td>Squad Owner</td>
<td><%= split.owner %></td>
Expand Down
13 changes: 6 additions & 7 deletions app/views/admin/splits/_variants.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,19 @@
</div>
<hr class="InfoCard-divider">
<div class="InfoCard-description">
<table class="fs-VariantsTable BasicTable">
<table class="fs-VariantsTable DescriptionTable">
<thead>
<th>Name</th>
<th>Weight</th>
<th>Assignee Count</th>
<th>Description</th>
<th>Weight (Assignee Count)</th>
<th></th>
</thead>
<tbody>
<% split.variant_details.each do |variant_detail| %>
<tr>
<td><%= variant_detail.variant %></td>
<td><%= variant_detail.weight %>%</td>
<td>
<%= variant_detail.assignment_count %>
<td><%= variant_detail.display_name %></td>
<td><%= variant_detail.description %></td>
<td><%= variant_detail.weight %>%(<%= variant_detail.assignment_count %>)
<% if variant_detail.retirable? %>
(<%= link_to "Retire variant", admin_split_variant_retirement_path(split, variant_detail.variant),
class: "retire-variant-link",
Expand Down
2 changes: 2 additions & 0 deletions app/views/api/v1/split_details/_variant_detail.json.jbuilder
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
json.name variant_detail.display_name
json.description variant_detail.description
1 change: 1 addition & 0 deletions app/views/api/v1/split_details/show.json.jbuilder
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
json.(@split_detail, :name, :hypothesis, :assignment_criteria, :description, :owner, :location, :platform)
json.variant_details @split_detail.variant_details, partial: 'variant_detail', as: :variant_detail
4 changes: 2 additions & 2 deletions spec/features/admin_split_config_create_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
it 'allows admins to change the weights of a split' do
split_page.load split_id: split.id
expect(split_page).to be_displayed
expect(split_page.variants_table).to have_content "red 100% 0 edit blue 0% 0 edit"
expect(split_page.variants_table).to have_content "red 100%(0) edit blue 0%(0) edit"

split_page.change_weights.click

Expand Down Expand Up @@ -46,6 +46,6 @@
end
form.submit_button.click
end
expect(split_page.variants_table).to have_content "red 50% 0 edit blue 50% 0 edit"
expect(split_page.variants_table).to have_content "red 50%(0) edit blue 50%(0) edit"
end
end
2 changes: 2 additions & 0 deletions spec/features/admin_variant_details_edit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@

expect(split_page).to be_displayed
expect(split_page).to have_content 'Details for enabled have been saved'
expect(split_page.variants.first.name).to have_content "Variant name"
expect(split_page.variants.first.description).to have_content "Super great variant"
end
end
4 changes: 2 additions & 2 deletions spec/features/admin_variant_retirement_create_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
it 'allows admins to retire a variant' do
split_page.load split_id: split.id
expect(split_page).to be_displayed
expect(split_page.variants_table).to have_content "blue 0% 8 (Retire variant)"
expect(split_page.variants_table).to have_content "blue 0%(8) (Retire variant)"

split_page.retire_variant.click

expect(split_page.variants_table).to have_content "blue 0% 0"
expect(split_page.variants_table).to have_content "blue 0%(0)"
expect(split_page.variants_table).not_to have_content "Retire variant"
end
end
36 changes: 33 additions & 3 deletions spec/requests/api/v1/split_details_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,26 @@
describe 'GET /api/v1/split_details/:id' do
let(:default_app) { FactoryGirl.create :app, name: "default_app", auth_secret: "6Sd6T7T6Q8hKcoo0t8CTzV0IdN1EEHqXB2Ig4raZsOf" }
let(:split_with_no_details) { FactoryGirl.create :split, name: "fantastic_split" }
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
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

let!(:variant_detail_a) do
FactoryGirl.create(
:variant_detail,
split: split_with_details,
variant: 'enabled',
display_name: 'fantastic_split_with_information is on',
description: 'This awesome feature makes cool stuff happen.'
)
end
let!(:variant_detail_b) do
FactoryGirl.create(
:variant_detail,
split: split_with_details,
variant: 'disabled',
display_name: 'fantastic_split_with_information is off',
description: 'This feature makes nothing happen.'
)
end

before do
http_authenticate username: default_app.name, password: default_app.auth_secret
Expand All @@ -20,7 +39,8 @@
"assignment_criteria" => nil,
"platform" => nil,
"description" => nil,
"owner" => nil
"owner" => nil,
"variant_details" => []
)
end

Expand All @@ -34,7 +54,17 @@
"assignment_criteria" => split_with_details.assignment_criteria,
"platform" => split_with_details.platform,
"description" => split_with_details.description,
"owner" => split_with_details.owner
"owner" => split_with_details.owner,
"variant_details" => [
{
"name" => "fantastic_split_with_information is on",
"description" => 'This awesome feature makes cool stuff happen.'
},
{
"name" => "fantastic_split_with_information is off",
"description" => "This feature makes nothing happen."
}
]
)
end

Expand Down
15 changes: 9 additions & 6 deletions spec/support/pages/admin/split_show_page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,21 @@ class AdminSplitShowPage < SitePrism::Page

element :population_count, "tr.population-row span.population"

element :variants_table, ".fs-VariantsTable"
sections :variants, ".fs-VariantsTable tbody tr" do
element :edit_link, 'td:nth-of-type(4) a'
end

element :change_weights, ".change-weights-link"
element :retire_variant, ".retire-variant-link"
element :add_details, ".add-details-link"
element :decide_split, ".decide-split-link"
element :upload_new_assignments, ".upload-new-assignments-link"

section :test_overview, ".TestOverview" do
element :table, ".BasicTable"
element :table, ".DescriptionTable"
end

element :variants_table, ".fs-VariantsTable"
sections :variants, ".fs-VariantsTable tbody tr" do
element :name, 'td:nth-of-type(1)'
element :description, 'td:nth-of-type(2)'
element :weight, 'td:nth-of-type(3)'
element :edit_link, 'td:nth-of-type(4) a'
end
end

0 comments on commit bc1f00c

Please sign in to comment.