Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions lib/split/dashboard/views/_controls.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<% if experiment.start_time %>
<form action="<%= url "/reset/#{experiment.name}" %>" method='post' onclick="return confirmReset()">
<input type="submit" value="Reset Data">
</form>
<% else%>
<form action="<%= url "/start/#{experiment.name}" %>" method='post'>
<input type="submit" value="Start">
</form>
<% end %>
<form action="<%= url "/#{experiment.name}" %>" method='post' onclick="return confirmDelete()">
<input type="hidden" name="_method" value="delete"/>
<input type="submit" value="Delete" class="red">
</form>
14 changes: 1 addition & 13 deletions lib/split/dashboard/views/_experiment.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,7 @@
<% if goal.nil? %>
<div class='inline-controls'>
<small><%= experiment.start_time ? experiment.start_time.strftime('%Y-%m-%d') : 'Unknown' %></small>
<% if experiment.start_time %>
<form action="<%= url "/reset/#{experiment.name}" %>" method='post' onclick="return confirmReset()">
<input type="submit" value="Reset Data">
</form>
<% else%>
<form action="<%= url "/start/#{experiment.name}" %>" method='post'>
<input type="submit" value="Start">
</form>
<% end %>
<form action="<%= url "/#{experiment.name}" %>" method='post' onclick="return confirmDelete()">
<input type="hidden" name="_method" value="delete"/>
<input type="submit" value="Delete" class="red">
</form>
<%= erb :_controls, :locals => {:experiment => experiment} %>
</div>
<% end %>
</div>
Expand Down
10 changes: 2 additions & 8 deletions lib/split/dashboard/views/_experiment_with_goal_header.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@
<div class="experiment-header">
<div class='inline-controls'>
<small><%= experiment.start_time ? experiment.start_time.strftime('%Y-%m-%d') : 'Unknown' %></small>
<form action="<%= url "/reset/#{experiment.name}" %>" method='post' onclick="return confirmReset()">
<input type="submit" value="Reset Data">
</form>
<form action="<%= url "/#{experiment.name}" %>" method='post' onclick="return confirmDelete()">
<input type="hidden" name="_method" value="delete"/>
<input type="submit" value="Delete" class="red">
</form>
<%= erb :_controls, :locals => {:experiment => experiment} %>
</div>
</div>
</div>
</div>
43 changes: 33 additions & 10 deletions spec/dashboard_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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") }
Expand All @@ -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
Expand Down