Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Test reset for "All" variants working

  • Loading branch information...
commit 7252f0556493bbca0d655d9b76e39b7eacd0bd76 1 parent d76dbc3
@winton authored
View
19 lib/a_b_front_end/controller/api.rb
@@ -110,13 +110,26 @@
).to_json
end
- post '/variants/:variant_id/reset.json' do
+ get '/tests/:id/reset.json' do
+ ABPlugin::API.reset_test(
+ :id => params[:id],
+ :include => params[:include] || {
+ :variants => {
+ :methods => :for_dashboard
+ }
+ },
+ :only => params[:only],
+ :token => current_user.single_access_token
+ ).to_json
+ end
+
+ get '/variants/:id/reset.json' do
ABPlugin::API.reset_variant(
+ :id => params[:id],
:include => params[:include],
:only => params[:only],
:methods => params[:methods] || :for_dashboard,
- :token => current_user.single_access_token,
- :variant_id => params[:variant_id]
+ :token => current_user.single_access_token
).to_json
end
end
View
42 public/js/dashboard.js
@@ -303,7 +303,8 @@ window.Dashboard = function(sites) {
function testReset() {
var table = $(this).closest('table');
var id = table.attr('id').match(/\d+/)[0];
- var test = byId(currentState().category.tests, id);
+ var category = currentState().category;
+ var test = byId(category.tests, id);
var dialog = $('#tests_reset_form_template').tmpl({ test: test });
lightbox(dialog);
@@ -319,18 +320,33 @@ window.Dashboard = function(sites) {
$(submits[1]).remove();
queue.queue(function() {
- $.post(
- '/variants/' + variant_id + '/reset.json',
- function(response) {
- test.variants = $.map(test.variants, function(item) {
- return (item.id == response.id) ? response : item;
- });
- queue.dequeue();
- $('#categories .selected').click().click();
- dialog.trigger('close');
- },
- 'json'
- );
+ if (variant_id == 'All')
+ $.get(
+ '/tests/' + test.id + '/reset.json',
+ function(response) {
+ category.tests = category.tests || [];
+ category.tests = $.map(category.tests, function(item) {
+ return (item.id == id) ? response : item;
+ });
+ queue.dequeue();
+ $('#categories .selected').click().click();
+ dialog.trigger('close');
+ },
+ 'json'
+ );
+ else
+ $.get(
+ '/variants/' + variant_id + '/reset.json',
+ function(response) {
+ test.variants = $.map(test.variants, function(item) {
+ return (item.id == response.id) ? response : item;
+ });
+ queue.dequeue();
+ $('#categories .selected').click().click();
+ dialog.trigger('close');
+ },
+ 'json'
+ );
});
return false;
View
15 vendor/a_b_plugin/lib/a_b_plugin/api.rb
@@ -88,11 +88,22 @@ def self.delete_test(attributes={})
))
end
+ def self.reset_test(attributes={})
+ return unless Config.token && Config.url
+ base_uri Config.url
+ id = attributes.delete(:id)
+ post("/tests/#{id}/reset.json", :body => compress(
+ :include => attributes.delete(:include),
+ :only => attributes.delete(:only),
+ :token => attributes.delete(:token) || Config.token
+ ))
+ end
+
def self.reset_variant(attributes={})
return unless Config.token && Config.url
base_uri Config.url
- variant_id = attributes.delete(:variant_id)
- post("/variants/#{variant_id}/reset.json", :body => compress(
+ id = attributes.delete(:id)
+ post("/variants/#{id}/reset.json", :body => compress(
:include => attributes.delete(:include),
:methods => attributes.delete(:methods),
:only => attributes.delete(:only),
Please sign in to comment.
Something went wrong with that request. Please try again.