before_actions 1.0.2 → 1.0.3
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 +106 -0
- data/Rakefile +13 -19
- data/app/controllers/before_actions/foo_controller.rb +8 -0
- data/lib/before_actions.rb +7 -1
- data/lib/before_actions/controller.rb +29 -20
- data/lib/before_actions/engine.rb +7 -0
- data/lib/before_actions/version.rb +1 -1
- data/spec/controllers/admin_foos_controller_spec.rb +78 -0
- data/spec/controllers/foos_controller_spec.rb +139 -0
- data/{test → spec}/dummy/README.rdoc +0 -0
- data/{test → spec}/dummy/Rakefile +0 -0
- data/{test → spec}/dummy/app/assets/javascripts/application.js +0 -3
- data/{test → spec}/dummy/app/assets/stylesheets/application.css +0 -0
- data/spec/dummy/app/controllers/admin_foos_controller.rb +53 -0
- data/{test → spec}/dummy/app/controllers/application_controller.rb +0 -0
- data/spec/dummy/app/controllers/foos_controller.rb +92 -0
- data/{test → spec}/dummy/app/helpers/application_helper.rb +0 -0
- data/spec/dummy/app/models/admin_foo.rb +2 -0
- data/spec/dummy/app/models/foo.rb +3 -0
- data/spec/dummy/app/views/admin_foos/_form.html.erb +21 -0
- data/spec/dummy/app/views/admin_foos/edit.html.erb +6 -0
- data/spec/dummy/app/views/admin_foos/index.html.erb +25 -0
- data/spec/dummy/app/views/admin_foos/new.html.erb +5 -0
- data/spec/dummy/app/views/admin_foos/show.html.erb +9 -0
- data/spec/dummy/app/views/foos/_form.html.erb +21 -0
- data/spec/dummy/app/views/foos/edit.html.erb +6 -0
- data/spec/dummy/app/views/foos/index.html.erb +25 -0
- data/spec/dummy/app/views/foos/new.html.erb +5 -0
- data/spec/dummy/app/views/foos/show.html.erb +9 -0
- data/{test → spec}/dummy/app/views/layouts/application.html.erb +0 -0
- data/{test → spec}/dummy/bin/bundle +0 -0
- data/{test → spec}/dummy/bin/rails +0 -0
- data/{test → spec}/dummy/bin/rake +0 -0
- data/{test → spec}/dummy/config.ru +0 -0
- data/{test → spec}/dummy/config/application.rb +8 -0
- data/{test → spec}/dummy/config/boot.rb +0 -0
- data/{test → spec}/dummy/config/database.yml +0 -0
- data/{test → spec}/dummy/config/environment.rb +0 -0
- data/{test → spec}/dummy/config/environments/development.rb +0 -0
- data/{test → spec}/dummy/config/environments/production.rb +0 -0
- data/{test → spec}/dummy/config/environments/test.rb +0 -0
- data/{test → spec}/dummy/config/initializers/backtrace_silencers.rb +0 -0
- data/{test → spec}/dummy/config/initializers/filter_parameter_logging.rb +0 -0
- data/{test → spec}/dummy/config/initializers/inflections.rb +0 -0
- data/{test → spec}/dummy/config/initializers/mime_types.rb +0 -0
- data/{test → spec}/dummy/config/initializers/secret_token.rb +0 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/{test → spec}/dummy/config/initializers/wrap_parameters.rb +0 -0
- data/{test → spec}/dummy/config/locales/en.yml +0 -0
- data/{test → spec}/dummy/config/routes.rb +4 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20140912040816_create_foos.rb +9 -0
- data/spec/dummy/db/migrate/20140912042735_create_admin_foos.rb +9 -0
- data/spec/dummy/db/schema.rb +28 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/lib/templates/rails/scaffold_controller/controller.rb +97 -0
- data/spec/dummy/log/development.log +15 -0
- data/spec/dummy/log/test.log +1590 -0
- data/{test → spec}/dummy/public/404.html +0 -0
- data/{test → spec}/dummy/public/422.html +0 -0
- data/{test → spec}/dummy/public/500.html +0 -0
- data/{test → spec}/dummy/public/favicon.ico +0 -0
- data/spec/rails_helper.rb +54 -0
- data/spec/spec_helper.rb +85 -0
- metadata +168 -74
- data/README.rdoc +0 -60
- data/lib/before_actions/command.rb +0 -15
- data/test/before_actions_test.rb +0 -7
- data/test/dummy/config/initializers/session_store.rb +0 -3
- data/test/integration/navigation_test.rb +0 -10
- data/test/test_helper.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e4ee37335a868dce4d6989fa8bcf2aa51211305
|
4
|
+
data.tar.gz: 04d348d389f0bf9b38a85f6a1c6280a4b28988dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c34525ee42fbf171c2b3e390f05a4a7e39643b2e76980ce1fe1303c40ae33905fa2c9f33fc70546c12f036f4f301bf884370448ea9f87480d98e224d20a68d1e
|
7
|
+
data.tar.gz: 7a5453eaddb502f232981e1c56022fab78c2b3ca0b591537b099a014af8b0eba8a61cdb64db95315eccec84bd45b542fa6e120225a2168e21617966a82831a9f
|
data/README.md
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
# Before Actions
|
2
|
+
|
3
|
+
Organize your controllers by grouping your before and after filters.
|
4
|
+
|
5
|
+
## Status
|
6
|
+
|
7
|
+
[](http://badge.fury.io/rb/before_actions)
|
8
|
+
[](https://gemnasium.com/before-actions-gem/before_actions)
|
9
|
+
[](http://inch-ci.org/github/before-actions-gem/before_actions)
|
10
|
+
[](https://codeclimate.com/github/before-actions-gem/before_actions)
|
11
|
+
[](https://codeclimate.com/github/before-actions-gem/before_actions)
|
12
|
+
[](https://github.com/before-actions-gem/before_actions/blob/master/LICENSE.md)
|
13
|
+
|
14
|
+
|
15
|
+
## References
|
16
|
+
|
17
|
+
* Home page: https://github.com/before-actions-gem/before_actions
|
18
|
+
* API Doc: http://rdoc.info/gems/before_actions
|
19
|
+
* Version: https://rubygems.org/gems/before_actions
|
20
|
+
* Trello Board: https://trello.com/b/PMRfJAqq/before-actions-gem
|
21
|
+
|
22
|
+
## Support
|
23
|
+
|
24
|
+
* Bugs/Issues: https://github.com/before-actions-gem/before_actions/issues
|
25
|
+
* Support: http://stackoverflow.com/questions/tagged/before_actions
|
26
|
+
* Support/Chat: [](https://gitter.im/before-actions-gem/before_actions)
|
27
|
+
|
28
|
+
|
29
|
+
## Installation
|
30
|
+
|
31
|
+
Add this line to your application's Gemfile:
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
gem 'before_actions'
|
35
|
+
```
|
36
|
+
|
37
|
+
And then execute:
|
38
|
+
|
39
|
+
```bash
|
40
|
+
bundle
|
41
|
+
rails g before_actions:install
|
42
|
+
```
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
## Demo
|
49
|
+
|
50
|
+
Check this gem in use: [app/controllers/contacts_controller.rb](https://github.com/before-actions-gem/before_actions/blob/master/readme_images/contacts_controller.rb)
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
class ContactsController < ApplicationController
|
54
|
+
|
55
|
+
# load and authorize resources
|
56
|
+
before_actions do
|
57
|
+
# all actions
|
58
|
+
# actions { }
|
59
|
+
|
60
|
+
# list actions
|
61
|
+
actions(:index) { @contacts = Contact.all }
|
62
|
+
|
63
|
+
# building actions
|
64
|
+
actions(:new) { @contact = Contact.new }
|
65
|
+
actions(:create) { @contact = Contact.new(contact_params) }
|
66
|
+
|
67
|
+
# member actions, will raise a 404 if the model is not found
|
68
|
+
actions(:show, :edit, :update, :destroy) { @contact = Contact.find(params[:id]) }
|
69
|
+
|
70
|
+
# all actions
|
71
|
+
# actions { }
|
72
|
+
end
|
73
|
+
|
74
|
+
...
|
75
|
+
|
76
|
+
def contact_params
|
77
|
+
params.require(:contact).permit(:name)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
```
|
81
|
+
|
82
|
+
#### Demo Resource
|
83
|
+
|
84
|
+
<img src="readme_images/controller.jpg" alt="controller.jpg" />
|
85
|
+
|
86
|
+
#### Demo Nested Resource
|
87
|
+
|
88
|
+
<img src="readme_images/nested.png" alt="nested.png" />
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
## Contributing
|
97
|
+
|
98
|
+
1. Fork it ( https://github.com/github.com/before-actions-gem/before_actions/fork )
|
99
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
100
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
101
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
102
|
+
5. Create a new Pull Request
|
103
|
+
|
104
|
+
## Versioning
|
105
|
+
|
106
|
+
__Before Actions__ uses [Semantic Versioning 2.0.0](http://semver.org)
|
data/Rakefile
CHANGED
@@ -1,34 +1,28 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
|
1
3
|
begin
|
2
4
|
require 'bundler/setup'
|
3
5
|
rescue LoadError
|
4
6
|
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
7
|
end
|
6
8
|
|
7
|
-
|
9
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
10
|
+
load 'rails/tasks/engine.rake'
|
8
11
|
|
9
|
-
|
10
|
-
rdoc.rdoc_dir = 'rdoc'
|
11
|
-
rdoc.title = 'BeforeActions'
|
12
|
-
rdoc.options << '--line-numbers'
|
13
|
-
rdoc.rdoc_files.include('README.rdoc')
|
14
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
-
end
|
12
|
+
Bundler::GemHelper.install_tasks
|
16
13
|
|
17
|
-
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
18
|
-
load 'rails/tasks/engine.rake'
|
19
14
|
|
20
15
|
|
21
16
|
|
22
|
-
Bundler::GemHelper.install_tasks
|
23
17
|
|
24
|
-
|
18
|
+
Dir[File.join(File.dirname(__FILE__), 'tasks/**/*.rake')].each {|f| load f }
|
19
|
+
|
20
|
+
require 'rspec/core'
|
21
|
+
require 'rspec/core/rake_task'
|
22
|
+
require 'rspec/rails'
|
25
23
|
|
26
|
-
Rake::TestTask.new(:test) do |t|
|
27
|
-
t.libs << 'lib'
|
28
|
-
t.libs << 'test'
|
29
|
-
t.pattern = 'test/**/*_test.rb'
|
30
|
-
t.verbose = false
|
31
|
-
end
|
32
24
|
|
25
|
+
desc "Run all specs in spec directory (excluding plugin specs)"
|
26
|
+
RSpec::Core::RakeTask.new(:spec => 'app:db:test:prepare')
|
33
27
|
|
34
|
-
task default
|
28
|
+
task :default => :spec
|
data/lib/before_actions.rb
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
require "before_actions/engine"
|
2
|
-
require "before_actions/command"
|
3
2
|
require "before_actions/controller"
|
4
3
|
|
5
4
|
module BeforeActions
|
6
5
|
end
|
6
|
+
|
7
|
+
|
8
|
+
if defined? ActionController::Base
|
9
|
+
ActionController::Base.class_eval do
|
10
|
+
include BeforeActions::Controller
|
11
|
+
end
|
12
|
+
end
|
@@ -3,36 +3,45 @@ module BeforeActions
|
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
5
|
module ClassMethods
|
6
|
-
attr_reader :before_actions_block, :after_actions_block
|
7
6
|
def before_actions(&block)
|
8
|
-
|
9
|
-
before_filter :execute_before_actions
|
7
|
+
TheBefore.new(self).instance_eval(&block)
|
10
8
|
end
|
11
9
|
def after_actions(&block)
|
12
|
-
|
13
|
-
after_filter :execute_after_actions
|
10
|
+
TheAfter.new(self).instance_eval(&block)
|
14
11
|
end
|
15
12
|
end
|
16
13
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
14
|
+
class TheBefore
|
15
|
+
|
16
|
+
def initialize(controller)
|
17
|
+
@controller = controller
|
18
|
+
end
|
19
|
+
|
20
|
+
def actions(*list, &block)
|
21
|
+
if list.empty?
|
22
|
+
@controller.before_action(&block)
|
23
|
+
else
|
24
|
+
@controller.before_action({only: list}, &block)
|
25
|
+
end
|
26
|
+
end
|
21
27
|
|
22
|
-
def execute_after_actions
|
23
|
-
block = self.class.after_actions_block
|
24
|
-
_execute_command(&block)
|
25
28
|
end
|
26
29
|
|
27
|
-
|
28
|
-
|
30
|
+
class TheAfter
|
31
|
+
|
32
|
+
def initialize(controller)
|
33
|
+
@controller = controller
|
34
|
+
end
|
35
|
+
|
36
|
+
def actions(*list, &block)
|
37
|
+
if list.empty?
|
38
|
+
@controller.after_action(&block)
|
39
|
+
else
|
40
|
+
@controller.after_action({only: list}, &block)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
29
44
|
end
|
30
45
|
|
31
46
|
end
|
32
47
|
end
|
33
|
-
|
34
|
-
if defined? ActionController::Base
|
35
|
-
ActionController::Base.class_eval do
|
36
|
-
include BeforeActions::Controller
|
37
|
-
end
|
38
|
-
end
|
@@ -1,5 +1,12 @@
|
|
1
1
|
module BeforeActions
|
2
2
|
class Engine < ::Rails::Engine
|
3
3
|
isolate_namespace BeforeActions
|
4
|
+
|
5
|
+
config.generators do |g|
|
6
|
+
g.test_framework :rspec, :view_specs => false#, :fixture => false
|
7
|
+
# g.fixture_replacement :factory_girl, :dir => 'spec/factories'
|
8
|
+
g.assets false
|
9
|
+
g.helper false
|
10
|
+
end
|
4
11
|
end
|
5
12
|
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
RSpec.describe AdminFoosController, :type => :controller do
|
4
|
+
|
5
|
+
let(:valid_attributes) {
|
6
|
+
{bar: 'cool'}
|
7
|
+
}
|
8
|
+
|
9
|
+
let(:invalid_attributes) {
|
10
|
+
{bar: ''}
|
11
|
+
}
|
12
|
+
|
13
|
+
let(:valid_session) { {} }
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
describe "read-only" do
|
19
|
+
describe "GET index" do
|
20
|
+
it "assigns all admin_foos as @admin_foos" do
|
21
|
+
admin_foo = AdminFoo.create! valid_attributes
|
22
|
+
get :index, {}, valid_session
|
23
|
+
expect(assigns(:admin_foos)).to eq([admin_foo])
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "GET show" do
|
28
|
+
it "assigns the requested admin_foo as @admin_foo" do
|
29
|
+
admin_foo = AdminFoo.create! valid_attributes
|
30
|
+
get :show, {:id => admin_foo.to_param}, valid_session
|
31
|
+
expect(assigns(:admin_foo)).to eq(admin_foo)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
after { expect(response).to have_http_status(200) }
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "writing" do
|
39
|
+
describe "GET new" do
|
40
|
+
it "does not assign @admin_foo" do
|
41
|
+
get :new, {}, valid_session
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "GET edit" do
|
46
|
+
it "does not assign @admin_foo" do
|
47
|
+
admin_foo = AdminFoo.create! valid_attributes
|
48
|
+
get :edit, {:id => admin_foo.to_param}, valid_session
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "POST create" do
|
53
|
+
it "does not assign @admin_foo" do
|
54
|
+
post :create, {:admin_foo => valid_attributes}, valid_session
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe "PUT update" do
|
59
|
+
it "does not assign @admin_foo" do
|
60
|
+
admin_foo = AdminFoo.create! valid_attributes
|
61
|
+
put :update, {:id => admin_foo.to_param, :admin_foo => valid_attributes}, valid_session
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe "DELETE destroy" do
|
66
|
+
it "does not assign @admin_foo" do
|
67
|
+
admin_foo = AdminFoo.create! valid_attributes
|
68
|
+
delete :destroy, {:id => admin_foo.to_param}, valid_session
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
after do
|
73
|
+
expect(assigns(:admin_foo)).to eq(nil)
|
74
|
+
expect(response).to have_http_status(401)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
@@ -0,0 +1,139 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
RSpec.describe FoosController, :type => :controller do
|
4
|
+
|
5
|
+
let(:valid_attributes) {
|
6
|
+
{bar: 'cool'}
|
7
|
+
}
|
8
|
+
|
9
|
+
let(:invalid_attributes) {
|
10
|
+
{bar: ''}
|
11
|
+
}
|
12
|
+
|
13
|
+
let(:valid_session) { {} }
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
describe "GET index" do
|
20
|
+
it "assigns all foos as @foos" do
|
21
|
+
foo = Foo.create! valid_attributes
|
22
|
+
get :index, {}, valid_session
|
23
|
+
expect(assigns(:foos)).to eq([foo])
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "GET show" do
|
28
|
+
it "assigns the requested foo as @foo" do
|
29
|
+
foo = Foo.create! valid_attributes
|
30
|
+
get :show, {:id => foo.to_param}, valid_session
|
31
|
+
expect(assigns(:foo)).to eq(foo)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "GET new" do
|
36
|
+
it "assigns a new foo as @foo" do
|
37
|
+
get :new, {}, valid_session
|
38
|
+
expect(assigns(:foo)).to be_a_new(Foo)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "GET edit" do
|
43
|
+
it "assigns the requested foo as @foo" do
|
44
|
+
foo = Foo.create! valid_attributes
|
45
|
+
get :edit, {:id => foo.to_param}, valid_session
|
46
|
+
expect(assigns(:foo)).to eq(foo)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "POST create" do
|
51
|
+
describe "with valid params" do
|
52
|
+
it "creates a new Foo" do
|
53
|
+
expect {
|
54
|
+
post :create, {:foo => valid_attributes}, valid_session
|
55
|
+
}.to change(Foo, :count).by(1)
|
56
|
+
end
|
57
|
+
|
58
|
+
it "assigns a newly created foo as @foo" do
|
59
|
+
post :create, {:foo => valid_attributes}, valid_session
|
60
|
+
expect(assigns(:foo)).to be_a(Foo)
|
61
|
+
expect(assigns(:foo)).to be_persisted
|
62
|
+
end
|
63
|
+
|
64
|
+
it "redirects to the created foo" do
|
65
|
+
post :create, {:foo => valid_attributes}, valid_session
|
66
|
+
expect(response).to redirect_to(Foo.last)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe "with invalid params" do
|
71
|
+
it "assigns a newly created but unsaved foo as @foo" do
|
72
|
+
post :create, {:foo => invalid_attributes}, valid_session
|
73
|
+
expect(assigns(:foo)).to be_a_new(Foo)
|
74
|
+
end
|
75
|
+
|
76
|
+
it "re-renders the 'new' template" do
|
77
|
+
post :create, {:foo => invalid_attributes}, valid_session
|
78
|
+
expect(response).to render_template("new")
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe "PUT update" do
|
84
|
+
describe "with valid params" do
|
85
|
+
let(:new_attributes) {
|
86
|
+
{bar: "yay"}
|
87
|
+
}
|
88
|
+
|
89
|
+
it "updates the requested foo" do
|
90
|
+
foo = Foo.create! valid_attributes
|
91
|
+
put :update, {:id => foo.to_param, :foo => new_attributes}, valid_session
|
92
|
+
foo.reload
|
93
|
+
expect(assigns(:foo).bar).to eq('yay')
|
94
|
+
end
|
95
|
+
|
96
|
+
it "assigns the requested foo as @foo" do
|
97
|
+
foo = Foo.create! valid_attributes
|
98
|
+
put :update, {:id => foo.to_param, :foo => valid_attributes}, valid_session
|
99
|
+
expect(assigns(:foo)).to eq(foo)
|
100
|
+
end
|
101
|
+
|
102
|
+
it "redirects to the foo" do
|
103
|
+
foo = Foo.create! valid_attributes
|
104
|
+
put :update, {:id => foo.to_param, :foo => valid_attributes}, valid_session
|
105
|
+
expect(response).to redirect_to(foo)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
describe "with invalid params" do
|
110
|
+
it "assigns the foo as @foo" do
|
111
|
+
foo = Foo.create! valid_attributes
|
112
|
+
put :update, {:id => foo.to_param, :foo => invalid_attributes}, valid_session
|
113
|
+
expect(assigns(:foo)).to eq(foo)
|
114
|
+
end
|
115
|
+
|
116
|
+
it "re-renders the 'edit' template" do
|
117
|
+
foo = Foo.create! valid_attributes
|
118
|
+
put :update, {:id => foo.to_param, :foo => invalid_attributes}, valid_session
|
119
|
+
expect(response).to render_template("edit")
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
describe "DELETE destroy" do
|
125
|
+
it "destroys the requested foo" do
|
126
|
+
foo = Foo.create! valid_attributes
|
127
|
+
expect {
|
128
|
+
delete :destroy, {:id => foo.to_param}, valid_session
|
129
|
+
}.to change(Foo, :count).by(-1)
|
130
|
+
end
|
131
|
+
|
132
|
+
it "redirects to the foos list" do
|
133
|
+
foo = Foo.create! valid_attributes
|
134
|
+
delete :destroy, {:id => foo.to_param}, valid_session
|
135
|
+
expect(response).to redirect_to(foos_url)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
end
|