Skip to content
Closed
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
2 changes: 1 addition & 1 deletion lib/split/dashboard/views/_experiment.erb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
<% if alternative.control? %>
<em>control</em>
<% end %>
<form action="<%= url('force_alternative') + '?experiment=' + experiment.name %>" method='post'>
<form action="<%= url('force_alternative') + '?experiment=' + experiment.key %>" method='post'>
<input type='hidden' name='alternative' value='<%= h alternative.name %>'>
<input type="submit" value="Force for current user" class="green">
</form>
Expand Down
40 changes: 30 additions & 10 deletions spec/dashboard_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,39 @@ def link(color)
end

describe "force alternative" do
let!(:user) do
Split::User.new(@app, { experiment.name => 'red' })
end
context "initial" do
let!(:user) do
Split::User.new(@app, { experiment.name => 'red' })
end

before do
allow(Split::User).to receive(:new).and_return(user)
before do
allow(Split::User).to receive(:new).and_return(user)
end

it "should set current user's alternative" do
blue_link.participant_count = 7
post "/force_alternative?experiment=#{experiment.key}", alternative: "blue"
expect(user[experiment.key]).to eq("blue")
expect(blue_link.participant_count).to eq(8)
end
end

it "should set current user's alternative" do
blue_link.participant_count = 7
post "/force_alternative?experiment=#{experiment.name}", alternative: "blue"
expect(user[experiment.name]).to eq("blue")
expect(blue_link.participant_count).to eq(8)
context "increment version" do
let!(:user) do
Split::User.new(@app, { "#{experiment.name}:#{experiment.version}" => 'red' })
end

before do
allow(Split::User).to receive(:new).and_return(user)
experiment.increment_version
end

it "should set current user's alternative" do
blue_link.participant_count = 7
post "/force_alternative?experiment=#{experiment.name}", alternative: "blue"
expect(user[experiment.name]).to eq("blue")
expect(blue_link.participant_count).to eq(8)
end
end
end

Expand Down