diff --git a/lib/split/dashboard/views/_controls.erb b/lib/split/dashboard/views/_controls.erb new file mode 100644 index 00000000..3be00041 --- /dev/null +++ b/lib/split/dashboard/views/_controls.erb @@ -0,0 +1,13 @@ +<% if experiment.start_time %> +
" method='post' onclick="return confirmReset()"> + +
+<% else%> +
" method='post'> + +
+<% end %> +
" method='post' onclick="return confirmDelete()"> + + +
diff --git a/lib/split/dashboard/views/_experiment.erb b/lib/split/dashboard/views/_experiment.erb index bfb060a8..f55a5332 100644 --- a/lib/split/dashboard/views/_experiment.erb +++ b/lib/split/dashboard/views/_experiment.erb @@ -14,19 +14,7 @@ <% if goal.nil? %>
<%= experiment.start_time ? experiment.start_time.strftime('%Y-%m-%d') : 'Unknown' %> - <% if experiment.start_time %> -
" method='post' onclick="return confirmReset()"> - -
- <% else%> -
" method='post'> - -
- <% end %> -
" method='post' onclick="return confirmDelete()"> - - -
+ <%= erb :_controls, :locals => {:experiment => experiment} %>
<% end %> diff --git a/lib/split/dashboard/views/_experiment_with_goal_header.erb b/lib/split/dashboard/views/_experiment_with_goal_header.erb index 24d09bcb..3149966d 100644 --- a/lib/split/dashboard/views/_experiment_with_goal_header.erb +++ b/lib/split/dashboard/views/_experiment_with_goal_header.erb @@ -2,13 +2,7 @@
<%= experiment.start_time ? experiment.start_time.strftime('%Y-%m-%d') : 'Unknown' %> -
" method='post' onclick="return confirmReset()"> - -
-
" method='post' onclick="return confirmDelete()"> - - -
+ <%= erb :_controls, :locals => {:experiment => experiment} %>
- \ No newline at end of file + diff --git a/spec/dashboard_spec.rb b/spec/dashboard_spec.rb index 9a698f5e..989c91f2 100644 --- a/spec/dashboard_spec.rb +++ b/spec/dashboard_spec.rb @@ -14,7 +14,11 @@ def link(color) end let(:experiment) { - Split::Experiment.find_or_create('link_color', 'blue', 'red') + Split::Experiment.find_or_create("link_color", "blue", "red") + } + + let(:experiment_with_goals) { + Split::Experiment.find_or_create({"link_color" => ["goal_1", "goal_2"]}, "blue", "red") } let(:red_link) { link("red") } @@ -25,15 +29,34 @@ def link(color) last_response.should be_ok end - it "should start experiment" do - Split.configuration.start_manually = true - experiment - get '/' - last_response.body.should include('Start') - - post "/start/#{experiment.name}" - get '/' - last_response.body.should include('Reset Data') + context "start experiment manually" do + before do + Split.configuration.start_manually = true + end + + context "experiment without goals" do + it "should display a Start button" do + experiment + get '/' + last_response.body.should include('Start') + + post "/start/#{experiment.name}" + get '/' + last_response.body.should include('Reset Data') + end + end + + context "with goals" do + it "should display a Start button" do + experiment_with_goals + get '/' + last_response.body.should include('Start') + + post "/start/#{experiment.name}" + get '/' + last_response.body.should include('Reset Data') + end + end end it "should reset an experiment" do