split_cat 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +21 -11
- data/app/controllers/split_cat/experiments_controller.rb +45 -7
- data/app/helpers/split_cat/experiments_helper.rb +1 -4
- data/app/models/split_cat/experiment.rb +3 -21
- data/app/views/split_cat/experiments/_form.html.erb +31 -12
- data/app/views/split_cat/experiments/_search.html.erb +8 -0
- data/app/views/split_cat/experiments/edit.html.erb +6 -0
- data/app/views/split_cat/experiments/index.html.erb +4 -0
- data/app/views/split_cat/experiments/new.html.erb +5 -0
- data/config/locales/en.yml +0 -2
- data/config/routes.rb +1 -1
- data/lib/split_cat/helpers.rb +8 -0
- data/lib/split_cat/version.rb +1 -1
- data/spec/controllers/split_cat/experiments_controller_spec.rb +146 -50
- data/spec/data/helpers/experiment_info.html +1 -1
- data/spec/data/helpers/experiment_info.html.tmp +1 -1
- data/spec/data/helpers/experiment_table.html +1 -1
- data/spec/data/helpers/experiment_table.html.tmp +1 -1
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/log/development.log +1008 -0
- data/spec/dummy/log/test.log +58637 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/spec/dummy/tmp/pids/server.pid +1 -0
- data/spec/helpers/split_cat/experiments_helper_spec.rb +1 -1
- data/spec/models/split_cat/experiment_spec.rb +5 -44
- data/spec/routing/split_cat/experiments_routing_spec.rb +39 -0
- data/spec/spec_helper.rb +6 -0
- data/spec/support/stub_view_routes.rb +3 -1
- data/spec/views/split_cat/experiments/edit.html.erb_spec.rb +16 -0
- data/spec/views/split_cat/experiments/index.html.erb_spec.rb +8 -7
- data/spec/views/split_cat/experiments/new.html.erb_spec.rb +16 -0
- data/spec/views/split_cat/experiments/show.html.erb_spec.rb +6 -8
- metadata +24 -55
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4880681278c9fc6b8581039569aee279d717ca70
|
4
|
+
data.tar.gz: 4ec902b130f34eded678960ed766897ad2514726
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc167cf4abce19f129ff514b18faa9a3ba5d34ebcdf7ddf92b5ddfb855e7bbc716678901a791786a128d45790e7878f27c473402030848e95e7cd587ac652d7e
|
7
|
+
data.tar.gz: 73600eff04eeb93dc395332a2eff862fa6dbb43e82a5af05715e9c378b5c6c397149c4b43b8482b9571373891bccd2f20db94140e62d9e27cc8d4bb2bfcde4a0
|
data/README.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
[](http://badge.fury.io/rb/split_cat)
|
2
|
+
[](https://travis-ci.org/schrodingersbox/split_cat)
|
3
|
+
[](https://gemnasium.com/schrodingersbox/split_cat)
|
4
|
+
[](https://codeclimate.com/github/schrodingersbox/split_cat)
|
5
|
+
[](https://coveralls.io/r/schrodingersbox/split_cat)
|
6
|
+
|
1
7
|
# schrodingersbox/split_cat
|
2
8
|
|
3
9
|
This Rails engine provides a framework for split testing.
|
@@ -43,6 +49,16 @@ See [The one line split-test, or how to A/B all the time](http://www.startupless
|
|
43
49
|
|
44
50
|
## How To
|
45
51
|
|
52
|
+
### Apply Security To Reports
|
53
|
+
|
54
|
+
Modify `config.application.rb` to inject your authorization filter into the controller:
|
55
|
+
|
56
|
+
config.after_initialize do
|
57
|
+
SplitCat::ExperimentsController.instance_eval do
|
58
|
+
before_filter :require_login
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
46
62
|
### Create A New Experiment
|
47
63
|
|
48
64
|
Create or add to `config/initializers/split_cat.rb`:
|
@@ -67,7 +83,7 @@ Create partials for each hypothesis. e.g. `button_a.html.erb` and `button_b.htm
|
|
67
83
|
|
68
84
|
When rendering the partial, scope it with the experiment:
|
69
85
|
|
70
|
-
render :partial => split_cat_scoped( :my_first_experiment, token
|
86
|
+
render :partial => split_cat_scoped( 'button', :my_first_experiment, token )
|
71
87
|
|
72
88
|
This will cause the partial to use the hypothesis assigned for the user/token.
|
73
89
|
|
@@ -93,16 +109,6 @@ To use an externally defined token:
|
|
93
109
|
|
94
110
|
split_cat_token( external_token )
|
95
111
|
|
96
|
-
### Apply Security To Reports
|
97
|
-
|
98
|
-
Modify `config.application.rb` to inject your authorization filter into the controller:
|
99
|
-
|
100
|
-
config.after_initialize do
|
101
|
-
SplitCat::ExperimentsController.instance_eval do
|
102
|
-
before_filter :require_login
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
112
|
## Best Practices
|
107
113
|
|
108
114
|
### Use A Constant Experiment ID
|
@@ -159,12 +165,16 @@ using multiple user accounts.
|
|
159
165
|
* [FactoryGirl](https://github.com/thoughtbot/factory_girl)
|
160
166
|
* [Shoulda](https://github.com/thoughtbot/shoulda-matchers)
|
161
167
|
* [The one line split-test, or how to A/B all the time](http://www.startuplessonslearned.com/2008/09/one-line-split-test-or-how-to-ab-all.html)
|
168
|
+
* [Add Achievement Badges to Your Gem README](http://elgalu.github.io/2013/add-achievement-badges-to-your-gem-readme/)
|
162
169
|
|
163
170
|
## TODO
|
164
171
|
|
172
|
+
* Rework Experiment::factory to use template over DB, but fall back to DB
|
173
|
+
|
165
174
|
* Spec rake tasks
|
166
175
|
|
167
176
|
* As needed
|
177
|
+
* Add pagination to admin
|
168
178
|
* Add a goals controller with action to record goal and redirect
|
169
179
|
* Add split test probability calculator
|
170
180
|
* hypo.control - boolean flag to determine which is baseline
|
@@ -1,18 +1,17 @@
|
|
1
1
|
module SplitCat
|
2
2
|
class ExperimentsController < ApplicationController
|
3
|
+
before_action :set_experiment, only: [:show, :edit, :update, :destroy]
|
3
4
|
|
4
|
-
|
5
|
-
|
5
|
+
# GET /experiments
|
6
6
|
def index
|
7
7
|
@name = params[ :name ]
|
8
8
|
@active = ( params[ :active ] == '1' )
|
9
9
|
|
10
10
|
@experiments = Experiment.order( 'id desc' )
|
11
11
|
@experiments = @experiments.where( 'name like ?', '%' + @name + '%') if @name
|
12
|
-
|
13
|
-
@experiments = @experiments.map { |e| e.active? ? e : nil }.compact if @active
|
14
12
|
end
|
15
13
|
|
14
|
+
# GET /experiments/1
|
16
15
|
def show
|
17
16
|
respond_to do |format|
|
18
17
|
format.html
|
@@ -20,11 +19,50 @@ module SplitCat
|
|
20
19
|
end
|
21
20
|
end
|
22
21
|
|
23
|
-
|
22
|
+
# GET /experiments/new
|
23
|
+
def new
|
24
|
+
@experiment = Experiment.new
|
25
|
+
end
|
26
|
+
|
27
|
+
# GET /experiments/1/edit
|
28
|
+
def edit
|
29
|
+
end
|
30
|
+
|
31
|
+
# POST /experiments
|
32
|
+
def create
|
33
|
+
@experiment = Experiment.new(experiment_params)
|
24
34
|
|
25
|
-
|
26
|
-
|
35
|
+
if @experiment.save
|
36
|
+
redirect_to @experiment, notice: 'Experiment was successfully created.'
|
37
|
+
else
|
38
|
+
render action: 'new'
|
39
|
+
end
|
27
40
|
end
|
28
41
|
|
42
|
+
# PATCH/PUT /experiments/1
|
43
|
+
def update
|
44
|
+
if @experiment.update(experiment_params)
|
45
|
+
redirect_to @experiment, notice: 'Experiment was successfully updated.'
|
46
|
+
else
|
47
|
+
render action: 'edit'
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# DELETE /experiments/1
|
52
|
+
def destroy
|
53
|
+
@experiment.destroy
|
54
|
+
redirect_to experiments_url, notice: 'Experiment was successfully destroyed.'
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
# Use callbacks to share common setup or constraints between actions.
|
59
|
+
def set_experiment
|
60
|
+
@experiment = Experiment.includes( :goals, :hypotheses ).find(params[:id])
|
61
|
+
end
|
62
|
+
|
63
|
+
# Only allow a trusted parameter "white list" through.
|
64
|
+
def experiment_params
|
65
|
+
params[:experiment].permit( Experiment.new.attributes.keys )
|
66
|
+
end
|
29
67
|
end
|
30
68
|
end
|
@@ -60,7 +60,6 @@ module SplitCat
|
|
60
60
|
concat experiment_info_row( :name, experiment.name )
|
61
61
|
concat experiment_info_row( :description, experiment.description )
|
62
62
|
concat experiment_info_row( :created, experiment.created_at )
|
63
|
-
concat experiment_info_row( :active, experiment.active? )
|
64
63
|
concat experiment_info_row( :subjects, number_with_delimiter( experiment.total_subjects ) )
|
65
64
|
end
|
66
65
|
end
|
@@ -117,7 +116,7 @@ module SplitCat
|
|
117
116
|
end
|
118
117
|
|
119
118
|
def experiment_search_form( name, active)
|
120
|
-
render :partial => '
|
119
|
+
render :partial => 'search', :locals => { :name => name, :active => active }
|
121
120
|
end
|
122
121
|
|
123
122
|
def experiment_table( experiments )
|
@@ -125,7 +124,6 @@ module SplitCat
|
|
125
124
|
output = content_tag( :tr ) do
|
126
125
|
concat content_tag( :th, t( :id, :scope => :split_cat ) )
|
127
126
|
concat content_tag( :th, t( :name, :scope => :split_cat ) )
|
128
|
-
concat content_tag( :th, t( :active, :scope => :split_cat ) )
|
129
127
|
end
|
130
128
|
|
131
129
|
show = t( :show, :scope => :split_cat )
|
@@ -134,7 +132,6 @@ module SplitCat
|
|
134
132
|
output += content_tag( :tr ) do
|
135
133
|
concat content_tag( :td, experiment.id )
|
136
134
|
concat content_tag( :td, experiment.name )
|
137
|
-
concat content_tag( :td, experiment.active? )
|
138
135
|
concat content_tag( :td, link_to( show, { :controller => :experiments, :action => :show, :id => experiment.id } ) )
|
139
136
|
end
|
140
137
|
end
|
@@ -12,13 +12,6 @@ module SplitCat
|
|
12
12
|
|
13
13
|
belongs_to :winner, :class_name => Hypothesis
|
14
14
|
|
15
|
-
# An experiment is only valid if it matches the current configuration
|
16
|
-
|
17
|
-
def active?
|
18
|
-
return false unless template = SplitCat.config.template( name )
|
19
|
-
return !!same_structure?( template )
|
20
|
-
end
|
21
|
-
|
22
15
|
# Returns a memoized array of goal name => hypothesis_name => subject counts
|
23
16
|
|
24
17
|
def goal_counts
|
@@ -154,22 +147,11 @@ module SplitCat
|
|
154
147
|
return experiment
|
155
148
|
end
|
156
149
|
|
157
|
-
|
158
|
-
Rails.logger.error( "Experiment.factory not configured for experiment: #{name}" )
|
159
|
-
return nil
|
160
|
-
end
|
161
|
-
|
150
|
+
template = SplitCat.config.template( name )
|
162
151
|
if experiment = Experiment.includes( :goals, :hypotheses ).find_by_name( name )
|
163
|
-
|
164
|
-
experiment = nil
|
165
|
-
Rails.logger.error( "Experiment.factory mismatched experiment: #{name}" )
|
166
|
-
end
|
152
|
+
return nil if template && !experiment.same_structure?( template )
|
167
153
|
else
|
168
|
-
if template.save
|
169
|
-
experiment = template
|
170
|
-
else
|
171
|
-
Rails.logger.error( "Experiment.factory failed to save experiment: #{name}" )
|
172
|
-
end
|
154
|
+
experiment = template if template && template.save
|
173
155
|
end
|
174
156
|
|
175
157
|
@@cache[ name.to_sym ] = experiment
|
@@ -1,13 +1,32 @@
|
|
1
|
-
<%=
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
1
|
+
<%= form_for(@experiment) do |f| %>
|
2
|
+
<% if @experiment.errors.any? %>
|
3
|
+
<div id="error_explanation">
|
4
|
+
<h2><%= pluralize(@experiment.errors.count, "error") %> prohibited this experiment from being saved:</h2>
|
5
|
+
|
6
|
+
<ul>
|
7
|
+
<% @experiment.errors.full_messages.each do |msg| %>
|
8
|
+
<li><%= msg %></li>
|
9
|
+
<% end %>
|
10
|
+
</ul>
|
11
|
+
</div>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<div class="form-group">
|
15
|
+
<%= f.label( :name ) %>
|
16
|
+
<%= f.text_field( :name, :size => 32 ) %>
|
17
|
+
</div>
|
18
|
+
|
19
|
+
<div class="form-group">
|
20
|
+
<%= f.label( :description ) %>
|
21
|
+
<%= f.text_area( :description, :size => "60x10" ) %>
|
22
|
+
</div>
|
23
|
+
|
24
|
+
<div class="form-group">
|
25
|
+
<%= f.label( :winner_id ) %>
|
26
|
+
<%= f.text_field( :winner_id, :size => 8 ) %>
|
27
|
+
</div>
|
28
|
+
|
29
|
+
<div class="actions">
|
30
|
+
<%= f.submit %>
|
31
|
+
</div>
|
13
32
|
<% end %>
|
data/config/locales/en.yml
CHANGED
data/config/routes.rb
CHANGED
data/lib/split_cat/helpers.rb
CHANGED
@@ -45,6 +45,14 @@ module SplitCat
|
|
45
45
|
# #set_split_cat_cookie
|
46
46
|
|
47
47
|
def set_split_cat_cookie( options = {} )
|
48
|
+
|
49
|
+
# Create a Subject for the cookie token, if it doesn't exist
|
50
|
+
|
51
|
+
if cookies[ :split_cat_token ] && cookies[ :split_cat_token ][ :value ] &&
|
52
|
+
!Subject.where( :token => cookies[ :split_cat_token ][ :value ] ).first
|
53
|
+
split_cat_token( cookies[ :split_cat_token ] )
|
54
|
+
end
|
55
|
+
|
48
56
|
if options[ :force ] || !cookies[ :split_cat_token ]
|
49
57
|
expires = SplitCat.config.cookie_expiration.from_now
|
50
58
|
cookies[ :split_cat_token ] = { :value => split_cat_token, :expires => expires }
|
data/lib/split_cat/version.rb
CHANGED
@@ -1,80 +1,176 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
3
|
+
module SplitCat
|
4
|
+
describe ExperimentsController do
|
4
5
|
|
5
|
-
|
6
|
+
routes { SplitCat::Engine.routes }
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
before( :each ) do
|
12
|
-
@experiment = FactoryGirl.create( :experiment_full )
|
13
|
-
controller.stub( :require_login )
|
14
|
-
end
|
15
|
-
|
16
|
-
describe '/index' do
|
8
|
+
let( :experiment ) { FactoryGirl.create( :experiment_full ) }
|
9
|
+
let(:valid_attributes) { { :name => 'valid' } }
|
10
|
+
let(:valid_session) { {} }
|
17
11
|
|
18
|
-
it '
|
19
|
-
|
20
|
-
response.should be_success
|
12
|
+
it 'is a subclass of ApplicationController' do
|
13
|
+
@controller.should be_a_kind_of( ApplicationController )
|
21
14
|
end
|
22
15
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
expect( assigns( :experiments ) ).to be_present
|
16
|
+
before( :each ) do
|
17
|
+
controller.stub( :require_login )
|
18
|
+
expect( experiment ).to be_present
|
27
19
|
end
|
28
20
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
21
|
+
describe "GET index" do
|
22
|
+
it "assigns all experiments as @experiments" do
|
23
|
+
get :index, {}, valid_session
|
24
|
+
assigns(:experiments).should eq([experiment])
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'accepts name and active params' do
|
28
|
+
name = experiment.name
|
29
|
+
active = '1'
|
30
|
+
get :index, :name => name, :active => active
|
33
31
|
|
34
|
-
|
35
|
-
|
32
|
+
expect( assigns( :name ) ).to be( name )
|
33
|
+
expect( assigns( :active ) ).to eql( active == '1' )
|
34
|
+
end
|
36
35
|
end
|
37
36
|
|
38
|
-
|
37
|
+
describe "GET show" do
|
38
|
+
it "assigns the requested experiment as @experiment" do
|
39
|
+
get :show, {:id => experiment.to_param}, valid_session
|
40
|
+
assigns(:experiment).should eq(experiment)
|
41
|
+
end
|
39
42
|
|
40
|
-
|
43
|
+
context 'formatting CSV' do
|
41
44
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
45
|
+
it 'renders CSV' do
|
46
|
+
get :show, :id => experiment.id, :format => 'csv'
|
47
|
+
response.should be_success
|
48
|
+
response.content_type.should eql( 'text/csv' )
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'turns the requested experiment into CSV' do
|
52
|
+
get :show, :id => experiment.id, :format => 'csv'
|
53
|
+
response.body.should eql( experiment.to_csv )
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
46
57
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
58
|
+
context 'formatting HTML' do
|
59
|
+
|
60
|
+
it 'renders HTML' do
|
61
|
+
get :show, :id => experiment.id, :format => 'html'
|
62
|
+
response.should be_success
|
63
|
+
response.content_type.should eql( 'text/html' )
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
51
67
|
end
|
52
68
|
|
53
|
-
|
69
|
+
describe "GET new" do
|
70
|
+
it "assigns a new experiment as @experiment" do
|
71
|
+
get :new, {}, valid_session
|
72
|
+
assigns(:experiment).should be_a_new(Experiment)
|
73
|
+
end
|
74
|
+
end
|
54
75
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
76
|
+
describe "GET edit" do
|
77
|
+
it "assigns the requested experiment as @experiment" do
|
78
|
+
get :edit, {:id => experiment.to_param}, valid_session
|
79
|
+
assigns(:experiment).should eq(experiment)
|
59
80
|
end
|
81
|
+
end
|
60
82
|
|
61
|
-
|
62
|
-
|
63
|
-
|
83
|
+
describe "POST create" do
|
84
|
+
describe "with valid params" do
|
85
|
+
it "creates a new Experiment" do
|
86
|
+
expect {
|
87
|
+
post :create, {:experiment => valid_attributes}, valid_session
|
88
|
+
}.to change(Experiment, :count).by(1)
|
89
|
+
end
|
90
|
+
|
91
|
+
it "assigns a newly created experiment as @experiment" do
|
92
|
+
post :create, {:experiment => valid_attributes}, valid_session
|
93
|
+
assigns(:experiment).should be_a(Experiment)
|
94
|
+
assigns(:experiment).should be_persisted
|
95
|
+
end
|
96
|
+
|
97
|
+
it "redirects to the created experiment" do
|
98
|
+
post :create, {:experiment => valid_attributes}, valid_session
|
99
|
+
response.should redirect_to(Experiment.last)
|
100
|
+
end
|
64
101
|
end
|
65
102
|
|
103
|
+
describe "with invalid params" do
|
104
|
+
it "assigns a newly created but unsaved experiment as @experiment" do
|
105
|
+
# Trigger the behavior that occurs when invalid params are submitted
|
106
|
+
Experiment.any_instance.stub(:save).and_return(false)
|
107
|
+
post :create, {:experiment => { }}, valid_session
|
108
|
+
assigns(:experiment).should be_a_new(Experiment)
|
109
|
+
end
|
110
|
+
|
111
|
+
it "re-renders the 'new' template" do
|
112
|
+
# Trigger the behavior that occurs when invalid params are submitted
|
113
|
+
Experiment.any_instance.stub(:save).and_return(false)
|
114
|
+
post :create, {:experiment => { }}, valid_session
|
115
|
+
response.should render_template("new")
|
116
|
+
end
|
117
|
+
end
|
66
118
|
end
|
67
119
|
|
68
|
-
|
120
|
+
describe "PUT update" do
|
121
|
+
describe "with valid params" do
|
122
|
+
it "updates the requested experiment" do
|
123
|
+
experiment = Experiment.create! valid_attributes
|
124
|
+
# Assuming there are no other experiments in the database, this
|
125
|
+
# specifies that the Experiment created on the previous line
|
126
|
+
# receives the :update_attributes message with whatever params are
|
127
|
+
# submitted in the request.
|
128
|
+
Experiment.any_instance.should_receive(:update).with({ "name" => "params" })
|
129
|
+
put :update, {:id => experiment.to_param, :experiment => { "name" => "params" }}, valid_session
|
130
|
+
end
|
131
|
+
|
132
|
+
it "assigns the requested experiment as @experiment" do
|
133
|
+
put :update, {:id => experiment.to_param, :experiment => valid_attributes}, valid_session
|
134
|
+
assigns(:experiment).should eq(experiment)
|
135
|
+
end
|
136
|
+
|
137
|
+
it "redirects to the experiment" do
|
138
|
+
put :update, {:id => experiment.to_param, :experiment => valid_attributes}, valid_session
|
139
|
+
response.should redirect_to(experiment)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
describe "with invalid params" do
|
144
|
+
it "assigns the experiment as @experiment" do
|
145
|
+
experiment = Experiment.create! valid_attributes
|
146
|
+
# Trigger the behavior that occurs when invalid params are submitted
|
147
|
+
Experiment.any_instance.stub(:save).and_return(false)
|
148
|
+
put :update, {:id => experiment.to_param, :experiment => { }}, valid_session
|
149
|
+
assigns(:experiment).should eq(experiment)
|
150
|
+
end
|
151
|
+
|
152
|
+
it "re-renders the 'edit' template" do
|
153
|
+
experiment = Experiment.create! valid_attributes
|
154
|
+
# Trigger the behavior that occurs when invalid params are submitted
|
155
|
+
Experiment.any_instance.stub(:save).and_return(false)
|
156
|
+
put :update, {:id => experiment.to_param, :experiment => { }}, valid_session
|
157
|
+
response.should render_template("edit")
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
69
161
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
162
|
+
describe "DELETE destroy" do
|
163
|
+
it "destroys the requested experiment" do
|
164
|
+
expect {
|
165
|
+
delete :destroy, {:id => experiment.to_param}, valid_session
|
166
|
+
}.to change(Experiment, :count).by(-1)
|
74
167
|
end
|
75
168
|
|
169
|
+
it "redirects to the experiments list" do
|
170
|
+
delete :destroy, {:id => experiment.to_param}, valid_session
|
171
|
+
response.should redirect_to(experiments_url)
|
172
|
+
end
|
76
173
|
end
|
77
174
|
|
78
175
|
end
|
79
|
-
|
80
|
-
end
|
176
|
+
end
|
@@ -1 +1 @@
|
|
1
|
-
<table><tr><th>id</th><td>1</td></tr><tr><th>name</th><td>test</td></tr><tr><th>description</th><td>this is only a test</td></tr><tr><th>created</th><td>2013-09-12 07:08:58 UTC</td></tr><tr><th>
|
1
|
+
<table><tr><th>id</th><td>1</td></tr><tr><th>name</th><td>test</td></tr><tr><th>description</th><td>this is only a test</td></tr><tr><th>created</th><td>2013-09-12 07:08:58 UTC</td></tr><tr><th>subjects</th><td>0</td></tr></table>
|
@@ -1 +1 @@
|
|
1
|
-
<table><tr><th>id</th><td>1</td></tr><tr><th>name</th><td>test</td></tr><tr><th>description</th><td>this is only a test</td></tr><tr><th>created</th><td>2013-09-12 07:08:58 UTC</td></tr><tr><th>
|
1
|
+
<table><tr><th>id</th><td>1</td></tr><tr><th>name</th><td>test</td></tr><tr><th>description</th><td>this is only a test</td></tr><tr><th>created</th><td>2013-09-12 07:08:58 UTC</td></tr><tr><th>subjects</th><td>0</td></tr></table>
|
@@ -1 +1 @@
|
|
1
|
-
<table border="1"><tr><th>id</th><th>name</th
|
1
|
+
<table border="1"><tr><th>id</th><th>name</th></tr><tr><td>1</td><td>test</td><td><a href="/experiments/show/1">Show</a></td></tr></table>
|
@@ -1 +1 @@
|
|
1
|
-
<table border="1"><tr><th>id</th><th>name</th
|
1
|
+
<table border="1"><tr><th>id</th><th>name</th></tr><tr><td>1</td><td>test</td><td><a href="/experiments/show/1">Show</a></td></tr></table>
|
Binary file
|