paper_trail_manager 0.1.0
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.
- data/Gemfile +17 -0
- data/Gemfile.lock +147 -0
- data/LICENSE.txt +20 -0
- data/README.md +32 -0
- data/Rakefile +52 -0
- data/VERSION +1 -0
- data/app/controllers/paper_trail_manager/changes_controller.rb +109 -0
- data/app/helpers/paper_trail_manager/changes_helper.rb +99 -0
- data/app/views/paper_trail_manager/changes/_version.html.haml +32 -0
- data/app/views/paper_trail_manager/changes/index.atom.builder +44 -0
- data/app/views/paper_trail_manager/changes/index.html.haml +26 -0
- data/app/views/paper_trail_manager/changes/show.html.haml +8 -0
- data/lib/paper_trail_manager.rb +70 -0
- data/paper_trail_manager.gemspec +209 -0
- data/spec/controllers/paper_trail_manager/changes_controller_spec.rb +8 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +7 -0
- data/spec/dummy/app/controllers/entities_controller.rb +83 -0
- data/spec/dummy/app/controllers/platforms_controller.rb +83 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/helpers/entities_helper.rb +2 -0
- data/spec/dummy/app/helpers/platforms_helper.rb +2 -0
- data/spec/dummy/app/models/entity.rb +6 -0
- data/spec/dummy/app/models/platform.rb +6 -0
- data/spec/dummy/app/views/entities/_form.html.erb +17 -0
- data/spec/dummy/app/views/entities/edit.html.erb +6 -0
- data/spec/dummy/app/views/entities/index.html.erb +21 -0
- data/spec/dummy/app/views/entities/new.html.erb +5 -0
- data/spec/dummy/app/views/entities/show.html.erb +5 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/app/views/platforms/_form.html.erb +17 -0
- data/spec/dummy/app/views/platforms/edit.html.erb +6 -0
- data/spec/dummy/app/views/platforms/index.html.erb +21 -0
- data/spec/dummy/app/views/platforms/new.html.erb +5 -0
- data/spec/dummy/app/views/platforms/show.html.erb +5 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +45 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +22 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +26 -0
- data/spec/dummy/config/environments/production.rb +49 -0
- data/spec/dummy/config/environments/test.rb +35 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +64 -0
- data/spec/dummy/db/migrate/20110228091428_create_entities.rb +14 -0
- data/spec/dummy/db/migrate/20110228093241_create_platforms.rb +14 -0
- data/spec/dummy/db/migrate/20110228094444_create_versions.rb +18 -0
- data/spec/dummy/db/schema.rb +40 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +26 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/javascripts/application.js +2 -0
- data/spec/dummy/public/javascripts/controls.js +965 -0
- data/spec/dummy/public/javascripts/dragdrop.js +974 -0
- data/spec/dummy/public/javascripts/effects.js +1123 -0
- data/spec/dummy/public/javascripts/prototype.js +6001 -0
- data/spec/dummy/public/javascripts/rails.js +175 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/dummy/spec/controllers/entities_controller_spec.rb +125 -0
- data/spec/dummy/spec/controllers/platforms_controller_spec.rb +125 -0
- data/spec/dummy/spec/helpers/entities_helper_spec.rb +15 -0
- data/spec/dummy/spec/helpers/platforms_helper_spec.rb +15 -0
- data/spec/dummy/spec/integration/navigation_spec.rb +9 -0
- data/spec/dummy/spec/integration/paper_trail_manager_spec.rb +194 -0
- data/spec/dummy/spec/models/entity_spec.rb +14 -0
- data/spec/dummy/spec/models/platform_spec.rb +14 -0
- data/spec/dummy/spec/requests/entities_spec.rb +11 -0
- data/spec/dummy/spec/requests/platforms_spec.rb +11 -0
- data/spec/dummy/spec/routing/entities_routing_spec.rb +35 -0
- data/spec/dummy/spec/routing/platforms_routing_spec.rb +35 -0
- data/spec/dummy/spec/views/entities/edit.html.erb_spec.rb +15 -0
- data/spec/dummy/spec/views/entities/index.html.erb_spec.rb +14 -0
- data/spec/dummy/spec/views/entities/new.html.erb_spec.rb +15 -0
- data/spec/dummy/spec/views/entities/show.html.erb_spec.rb +11 -0
- data/spec/dummy/spec/views/platforms/edit.html.erb_spec.rb +15 -0
- data/spec/dummy/spec/views/platforms/index.html.erb_spec.rb +14 -0
- data/spec/dummy/spec/views/platforms/new.html.erb_spec.rb +15 -0
- data/spec/dummy/spec/views/platforms/show.html.erb_spec.rb +11 -0
- data/spec/paper_trail_manager_spec.rb +7 -0
- data/spec/spec_helper.rb +82 -0
- data/spec/support/factories.rb +12 -0
- metadata +387 -0
@@ -0,0 +1,175 @@
|
|
1
|
+
(function() {
|
2
|
+
// Technique from Juriy Zaytsev
|
3
|
+
// http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
|
4
|
+
function isEventSupported(eventName) {
|
5
|
+
var el = document.createElement('div');
|
6
|
+
eventName = 'on' + eventName;
|
7
|
+
var isSupported = (eventName in el);
|
8
|
+
if (!isSupported) {
|
9
|
+
el.setAttribute(eventName, 'return;');
|
10
|
+
isSupported = typeof el[eventName] == 'function';
|
11
|
+
}
|
12
|
+
el = null;
|
13
|
+
return isSupported;
|
14
|
+
}
|
15
|
+
|
16
|
+
function isForm(element) {
|
17
|
+
return Object.isElement(element) && element.nodeName.toUpperCase() == 'FORM'
|
18
|
+
}
|
19
|
+
|
20
|
+
function isInput(element) {
|
21
|
+
if (Object.isElement(element)) {
|
22
|
+
var name = element.nodeName.toUpperCase()
|
23
|
+
return name == 'INPUT' || name == 'SELECT' || name == 'TEXTAREA'
|
24
|
+
}
|
25
|
+
else return false
|
26
|
+
}
|
27
|
+
|
28
|
+
var submitBubbles = isEventSupported('submit'),
|
29
|
+
changeBubbles = isEventSupported('change')
|
30
|
+
|
31
|
+
if (!submitBubbles || !changeBubbles) {
|
32
|
+
// augment the Event.Handler class to observe custom events when needed
|
33
|
+
Event.Handler.prototype.initialize = Event.Handler.prototype.initialize.wrap(
|
34
|
+
function(init, element, eventName, selector, callback) {
|
35
|
+
init(element, eventName, selector, callback)
|
36
|
+
// is the handler being attached to an element that doesn't support this event?
|
37
|
+
if ( (!submitBubbles && this.eventName == 'submit' && !isForm(this.element)) ||
|
38
|
+
(!changeBubbles && this.eventName == 'change' && !isInput(this.element)) ) {
|
39
|
+
// "submit" => "emulated:submit"
|
40
|
+
this.eventName = 'emulated:' + this.eventName
|
41
|
+
}
|
42
|
+
}
|
43
|
+
)
|
44
|
+
}
|
45
|
+
|
46
|
+
if (!submitBubbles) {
|
47
|
+
// discover forms on the page by observing focus events which always bubble
|
48
|
+
document.on('focusin', 'form', function(focusEvent, form) {
|
49
|
+
// special handler for the real "submit" event (one-time operation)
|
50
|
+
if (!form.retrieve('emulated:submit')) {
|
51
|
+
form.on('submit', function(submitEvent) {
|
52
|
+
var emulated = form.fire('emulated:submit', submitEvent, true)
|
53
|
+
// if custom event received preventDefault, cancel the real one too
|
54
|
+
if (emulated.returnValue === false) submitEvent.preventDefault()
|
55
|
+
})
|
56
|
+
form.store('emulated:submit', true)
|
57
|
+
}
|
58
|
+
})
|
59
|
+
}
|
60
|
+
|
61
|
+
if (!changeBubbles) {
|
62
|
+
// discover form inputs on the page
|
63
|
+
document.on('focusin', 'input, select, texarea', function(focusEvent, input) {
|
64
|
+
// special handler for real "change" events
|
65
|
+
if (!input.retrieve('emulated:change')) {
|
66
|
+
input.on('change', function(changeEvent) {
|
67
|
+
input.fire('emulated:change', changeEvent, true)
|
68
|
+
})
|
69
|
+
input.store('emulated:change', true)
|
70
|
+
}
|
71
|
+
})
|
72
|
+
}
|
73
|
+
|
74
|
+
function handleRemote(element) {
|
75
|
+
var method, url, params;
|
76
|
+
|
77
|
+
var event = element.fire("ajax:before");
|
78
|
+
if (event.stopped) return false;
|
79
|
+
|
80
|
+
if (element.tagName.toLowerCase() === 'form') {
|
81
|
+
method = element.readAttribute('method') || 'post';
|
82
|
+
url = element.readAttribute('action');
|
83
|
+
params = element.serialize();
|
84
|
+
} else {
|
85
|
+
method = element.readAttribute('data-method') || 'get';
|
86
|
+
url = element.readAttribute('href');
|
87
|
+
params = {};
|
88
|
+
}
|
89
|
+
|
90
|
+
new Ajax.Request(url, {
|
91
|
+
method: method,
|
92
|
+
parameters: params,
|
93
|
+
evalScripts: true,
|
94
|
+
|
95
|
+
onComplete: function(request) { element.fire("ajax:complete", request); },
|
96
|
+
onSuccess: function(request) { element.fire("ajax:success", request); },
|
97
|
+
onFailure: function(request) { element.fire("ajax:failure", request); }
|
98
|
+
});
|
99
|
+
|
100
|
+
element.fire("ajax:after");
|
101
|
+
}
|
102
|
+
|
103
|
+
function handleMethod(element) {
|
104
|
+
var method = element.readAttribute('data-method'),
|
105
|
+
url = element.readAttribute('href'),
|
106
|
+
csrf_param = $$('meta[name=csrf-param]')[0],
|
107
|
+
csrf_token = $$('meta[name=csrf-token]')[0];
|
108
|
+
|
109
|
+
var form = new Element('form', { method: "POST", action: url, style: "display: none;" });
|
110
|
+
element.parentNode.insert(form);
|
111
|
+
|
112
|
+
if (method !== 'post') {
|
113
|
+
var field = new Element('input', { type: 'hidden', name: '_method', value: method });
|
114
|
+
form.insert(field);
|
115
|
+
}
|
116
|
+
|
117
|
+
if (csrf_param) {
|
118
|
+
var param = csrf_param.readAttribute('content'),
|
119
|
+
token = csrf_token.readAttribute('content'),
|
120
|
+
field = new Element('input', { type: 'hidden', name: param, value: token });
|
121
|
+
form.insert(field);
|
122
|
+
}
|
123
|
+
|
124
|
+
form.submit();
|
125
|
+
}
|
126
|
+
|
127
|
+
|
128
|
+
document.on("click", "*[data-confirm]", function(event, element) {
|
129
|
+
var message = element.readAttribute('data-confirm');
|
130
|
+
if (!confirm(message)) event.stop();
|
131
|
+
});
|
132
|
+
|
133
|
+
document.on("click", "a[data-remote]", function(event, element) {
|
134
|
+
if (event.stopped) return;
|
135
|
+
handleRemote(element);
|
136
|
+
event.stop();
|
137
|
+
});
|
138
|
+
|
139
|
+
document.on("click", "a[data-method]", function(event, element) {
|
140
|
+
if (event.stopped) return;
|
141
|
+
handleMethod(element);
|
142
|
+
event.stop();
|
143
|
+
});
|
144
|
+
|
145
|
+
document.on("submit", function(event) {
|
146
|
+
var element = event.findElement(),
|
147
|
+
message = element.readAttribute('data-confirm');
|
148
|
+
if (message && !confirm(message)) {
|
149
|
+
event.stop();
|
150
|
+
return false;
|
151
|
+
}
|
152
|
+
|
153
|
+
var inputs = element.select("input[type=submit][data-disable-with]");
|
154
|
+
inputs.each(function(input) {
|
155
|
+
input.disabled = true;
|
156
|
+
input.writeAttribute('data-original-value', input.value);
|
157
|
+
input.value = input.readAttribute('data-disable-with');
|
158
|
+
});
|
159
|
+
|
160
|
+
var element = event.findElement("form[data-remote]");
|
161
|
+
if (element) {
|
162
|
+
handleRemote(element);
|
163
|
+
event.stop();
|
164
|
+
}
|
165
|
+
});
|
166
|
+
|
167
|
+
document.on("ajax:after", "form", function(event, element) {
|
168
|
+
var inputs = element.select("input[type=submit][disabled=true][data-disable-with]");
|
169
|
+
inputs.each(function(input) {
|
170
|
+
input.value = input.readAttribute('data-original-value');
|
171
|
+
input.removeAttribute('data-original-value');
|
172
|
+
input.disabled = false;
|
173
|
+
});
|
174
|
+
});
|
175
|
+
})();
|
@@ -0,0 +1,6 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
+
|
4
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
+
require File.expand_path('../../config/boot', __FILE__)
|
6
|
+
require 'rails/commands'
|
@@ -0,0 +1,125 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# This spec was generated by rspec-rails when you ran the scaffold generator.
|
4
|
+
# It demonstrates how one might use RSpec to specify the controller code that
|
5
|
+
# was generated by the Rails when you ran the scaffold generator.
|
6
|
+
|
7
|
+
describe EntitiesController do
|
8
|
+
|
9
|
+
def mock_entity(stubs={})
|
10
|
+
@mock_entity ||= mock_model(Entity, stubs).as_null_object
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "GET index" do
|
14
|
+
it "assigns all entities as @entities" do
|
15
|
+
Entity.stub(:all) { [mock_entity] }
|
16
|
+
get :index
|
17
|
+
assigns(:entities).should eq([mock_entity])
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "GET show" do
|
22
|
+
it "assigns the requested entity as @entity" do
|
23
|
+
Entity.stub(:find).with("37") { mock_entity }
|
24
|
+
get :show, :id => "37"
|
25
|
+
assigns(:entity).should be(mock_entity)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "GET new" do
|
30
|
+
it "assigns a new entity as @entity" do
|
31
|
+
Entity.stub(:new) { mock_entity }
|
32
|
+
get :new
|
33
|
+
assigns(:entity).should be(mock_entity)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "GET edit" do
|
38
|
+
it "assigns the requested entity as @entity" do
|
39
|
+
Entity.stub(:find).with("37") { mock_entity }
|
40
|
+
get :edit, :id => "37"
|
41
|
+
assigns(:entity).should be(mock_entity)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "POST create" do
|
46
|
+
describe "with valid params" do
|
47
|
+
it "assigns a newly created entity as @entity" do
|
48
|
+
Entity.stub(:new).with({'these' => 'params'}) { mock_entity(:save => true) }
|
49
|
+
post :create, :entity => {'these' => 'params'}
|
50
|
+
assigns(:entity).should be(mock_entity)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "redirects to the created entity" do
|
54
|
+
Entity.stub(:new) { mock_entity(:save => true) }
|
55
|
+
post :create, :entity => {}
|
56
|
+
response.should redirect_to(entity_url(mock_entity))
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "with invalid params" do
|
61
|
+
it "assigns a newly created but unsaved entity as @entity" do
|
62
|
+
Entity.stub(:new).with({'these' => 'params'}) { mock_entity(:save => false) }
|
63
|
+
post :create, :entity => {'these' => 'params'}
|
64
|
+
assigns(:entity).should be(mock_entity)
|
65
|
+
end
|
66
|
+
|
67
|
+
it "re-renders the 'new' template" do
|
68
|
+
Entity.stub(:new) { mock_entity(:save => false) }
|
69
|
+
post :create, :entity => {}
|
70
|
+
response.should render_template("new")
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe "PUT update" do
|
76
|
+
describe "with valid params" do
|
77
|
+
it "updates the requested entity" do
|
78
|
+
Entity.stub(:find).with("37") { mock_entity }
|
79
|
+
mock_entity.should_receive(:update_attributes).with({'these' => 'params'})
|
80
|
+
put :update, :id => "37", :entity => {'these' => 'params'}
|
81
|
+
end
|
82
|
+
|
83
|
+
it "assigns the requested entity as @entity" do
|
84
|
+
Entity.stub(:find) { mock_entity(:update_attributes => true) }
|
85
|
+
put :update, :id => "1"
|
86
|
+
assigns(:entity).should be(mock_entity)
|
87
|
+
end
|
88
|
+
|
89
|
+
it "redirects to the entity" do
|
90
|
+
Entity.stub(:find) { mock_entity(:update_attributes => true) }
|
91
|
+
put :update, :id => "1"
|
92
|
+
response.should redirect_to(entity_url(mock_entity))
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
describe "with invalid params" do
|
97
|
+
it "assigns the entity as @entity" do
|
98
|
+
Entity.stub(:find) { mock_entity(:update_attributes => false) }
|
99
|
+
put :update, :id => "1"
|
100
|
+
assigns(:entity).should be(mock_entity)
|
101
|
+
end
|
102
|
+
|
103
|
+
it "re-renders the 'edit' template" do
|
104
|
+
Entity.stub(:find) { mock_entity(:update_attributes => false) }
|
105
|
+
put :update, :id => "1"
|
106
|
+
response.should render_template("edit")
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe "DELETE destroy" do
|
112
|
+
it "destroys the requested entity" do
|
113
|
+
Entity.stub(:find).with("37") { mock_entity }
|
114
|
+
mock_entity.should_receive(:destroy)
|
115
|
+
delete :destroy, :id => "37"
|
116
|
+
end
|
117
|
+
|
118
|
+
it "redirects to the entities list" do
|
119
|
+
Entity.stub(:find) { mock_entity }
|
120
|
+
delete :destroy, :id => "1"
|
121
|
+
response.should redirect_to(entities_url)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
@@ -0,0 +1,125 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# This spec was generated by rspec-rails when you ran the scaffold generator.
|
4
|
+
# It demonstrates how one might use RSpec to specify the controller code that
|
5
|
+
# was generated by the Rails when you ran the scaffold generator.
|
6
|
+
|
7
|
+
describe PlatformsController do
|
8
|
+
|
9
|
+
def mock_platform(stubs={})
|
10
|
+
@mock_platform ||= mock_model(Platform, stubs).as_null_object
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "GET index" do
|
14
|
+
it "assigns all platforms as @platforms" do
|
15
|
+
Platform.stub(:all) { [mock_platform] }
|
16
|
+
get :index
|
17
|
+
assigns(:platforms).should eq([mock_platform])
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "GET show" do
|
22
|
+
it "assigns the requested platform as @platform" do
|
23
|
+
Platform.stub(:find).with("37") { mock_platform }
|
24
|
+
get :show, :id => "37"
|
25
|
+
assigns(:platform).should be(mock_platform)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "GET new" do
|
30
|
+
it "assigns a new platform as @platform" do
|
31
|
+
Platform.stub(:new) { mock_platform }
|
32
|
+
get :new
|
33
|
+
assigns(:platform).should be(mock_platform)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "GET edit" do
|
38
|
+
it "assigns the requested platform as @platform" do
|
39
|
+
Platform.stub(:find).with("37") { mock_platform }
|
40
|
+
get :edit, :id => "37"
|
41
|
+
assigns(:platform).should be(mock_platform)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "POST create" do
|
46
|
+
describe "with valid params" do
|
47
|
+
it "assigns a newly created platform as @platform" do
|
48
|
+
Platform.stub(:new).with({'these' => 'params'}) { mock_platform(:save => true) }
|
49
|
+
post :create, :platform => {'these' => 'params'}
|
50
|
+
assigns(:platform).should be(mock_platform)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "redirects to the created platform" do
|
54
|
+
Platform.stub(:new) { mock_platform(:save => true) }
|
55
|
+
post :create, :platform => {}
|
56
|
+
response.should redirect_to(platform_url(mock_platform))
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "with invalid params" do
|
61
|
+
it "assigns a newly created but unsaved platform as @platform" do
|
62
|
+
Platform.stub(:new).with({'these' => 'params'}) { mock_platform(:save => false) }
|
63
|
+
post :create, :platform => {'these' => 'params'}
|
64
|
+
assigns(:platform).should be(mock_platform)
|
65
|
+
end
|
66
|
+
|
67
|
+
it "re-renders the 'new' template" do
|
68
|
+
Platform.stub(:new) { mock_platform(:save => false) }
|
69
|
+
post :create, :platform => {}
|
70
|
+
response.should render_template("new")
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe "PUT update" do
|
76
|
+
describe "with valid params" do
|
77
|
+
it "updates the requested platform" do
|
78
|
+
Platform.stub(:find).with("37") { mock_platform }
|
79
|
+
mock_platform.should_receive(:update_attributes).with({'these' => 'params'})
|
80
|
+
put :update, :id => "37", :platform => {'these' => 'params'}
|
81
|
+
end
|
82
|
+
|
83
|
+
it "assigns the requested platform as @platform" do
|
84
|
+
Platform.stub(:find) { mock_platform(:update_attributes => true) }
|
85
|
+
put :update, :id => "1"
|
86
|
+
assigns(:platform).should be(mock_platform)
|
87
|
+
end
|
88
|
+
|
89
|
+
it "redirects to the platform" do
|
90
|
+
Platform.stub(:find) { mock_platform(:update_attributes => true) }
|
91
|
+
put :update, :id => "1"
|
92
|
+
response.should redirect_to(platform_url(mock_platform))
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
describe "with invalid params" do
|
97
|
+
it "assigns the platform as @platform" do
|
98
|
+
Platform.stub(:find) { mock_platform(:update_attributes => false) }
|
99
|
+
put :update, :id => "1"
|
100
|
+
assigns(:platform).should be(mock_platform)
|
101
|
+
end
|
102
|
+
|
103
|
+
it "re-renders the 'edit' template" do
|
104
|
+
Platform.stub(:find) { mock_platform(:update_attributes => false) }
|
105
|
+
put :update, :id => "1"
|
106
|
+
response.should render_template("edit")
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe "DELETE destroy" do
|
112
|
+
it "destroys the requested platform" do
|
113
|
+
Platform.stub(:find).with("37") { mock_platform }
|
114
|
+
mock_platform.should_receive(:destroy)
|
115
|
+
delete :destroy, :id => "37"
|
116
|
+
end
|
117
|
+
|
118
|
+
it "redirects to the platforms list" do
|
119
|
+
Platform.stub(:find) { mock_platform }
|
120
|
+
delete :destroy, :id => "1"
|
121
|
+
response.should redirect_to(platforms_url)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# Specs in this file have access to a helper object that includes
|
4
|
+
# the EntitiesHelper. For example:
|
5
|
+
#
|
6
|
+
# describe EntitiesHelper do
|
7
|
+
# describe "string concat" do
|
8
|
+
# it "concats two strings with spaces" do
|
9
|
+
# helper.concat_strings("this","that").should == "this that"
|
10
|
+
# end
|
11
|
+
# end
|
12
|
+
# end
|
13
|
+
describe EntitiesHelper do
|
14
|
+
#IK# pending "add some examples to (or delete) #{__FILE__}"
|
15
|
+
end
|