subelsky_power_tools 1.2.3 → 1.2.4
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.lock
CHANGED
@@ -0,0 +1,141 @@
|
|
1
|
+
# https://www.relishapp.com/rspec/rspec-core/v/2-10/docs/example-groups/shared-examples
|
2
|
+
shared_examples "a protected plural controller" do
|
3
|
+
describe "new", :if => described_class.instance_methods.include?(:new) do
|
4
|
+
it "requires signin" do
|
5
|
+
get :new
|
6
|
+
response.should redirect_to signin_redirect
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "edit", :if => described_class.instance_methods.include?(:edit) do
|
11
|
+
def simple_get(obj_id = 1)
|
12
|
+
get :edit, { id: obj_id }
|
13
|
+
end
|
14
|
+
|
15
|
+
it "requires signin" do
|
16
|
+
simple_get
|
17
|
+
response.should redirect_to signin_redirect
|
18
|
+
end
|
19
|
+
|
20
|
+
it "only allowed for objects owned by the signed-in user" do
|
21
|
+
user_sign_in_proc.call
|
22
|
+
simple_get(object_not_owned_by_user.id)
|
23
|
+
response.should redirect_to not_found_redirect
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "show", :if => described_class.instance_methods.include?(:show) do
|
28
|
+
def simple_get(obj_id = 1)
|
29
|
+
get :show, { id: obj_id }
|
30
|
+
end
|
31
|
+
|
32
|
+
it "requires signin" do
|
33
|
+
simple_get
|
34
|
+
response.should redirect_to signin_redirect
|
35
|
+
end
|
36
|
+
|
37
|
+
it "only allowed for objects owned by the signed-in user" do
|
38
|
+
user_sign_in_proc.call
|
39
|
+
simple_get(object_not_owned_by_user.id)
|
40
|
+
response.should redirect_to not_found_redirect
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "index", :if => described_class.instance_methods.include?(:index) do
|
45
|
+
it "requires signin" do
|
46
|
+
get :index
|
47
|
+
response.should redirect_to signin_redirect
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "create", :if => described_class.instance_methods.include?(:create) do
|
52
|
+
it "requires signin" do
|
53
|
+
post :create
|
54
|
+
response.should redirect_to signin_redirect
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe "update", :if => described_class.instance_methods.include?(:update) do
|
59
|
+
def simple_put(obj_id = 1,params = {})
|
60
|
+
put :update, params.merge(id: obj_id)
|
61
|
+
end
|
62
|
+
|
63
|
+
it "requires signin" do
|
64
|
+
simple_put
|
65
|
+
response.should redirect_to signin_redirect
|
66
|
+
end
|
67
|
+
|
68
|
+
it "only allowed for objects owned by the signed-in user" do
|
69
|
+
user_sign_in_proc.call
|
70
|
+
expect {
|
71
|
+
simple_put(object_not_owned_by_user.id,valid_change_params)
|
72
|
+
}.not_to change {
|
73
|
+
object_not_owned_by_user.reload.attributes.values_at(valid_change_params.keys)
|
74
|
+
}
|
75
|
+
|
76
|
+
response.should redirect_to not_found_redirect
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe "delete", :if => described_class.instance_methods.include?(:destroy) do
|
81
|
+
def simple_delete(obj_id = 1)
|
82
|
+
delete :destroy, id: obj_id
|
83
|
+
end
|
84
|
+
|
85
|
+
it "requires signin" do
|
86
|
+
simple_delete
|
87
|
+
response.should redirect_to signin_redirect
|
88
|
+
end
|
89
|
+
|
90
|
+
it "only allowed for objects owned by the signed-in user" do
|
91
|
+
user_sign_in_proc.call
|
92
|
+
simple_delete(object_not_owned_by_user.id)
|
93
|
+
expect { object_not_owned_by_user.reload }.not_to raise_error
|
94
|
+
response.should redirect_to not_found_redirect
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
shared_examples "a protected singular controller" do
|
100
|
+
describe "new", :if => described_class.instance_methods.include?(:new) do
|
101
|
+
it "requires signin" do
|
102
|
+
get :new
|
103
|
+
response.should redirect_to signin_redirect
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
describe "edit", :if => described_class.instance_methods.include?(:edit) do
|
108
|
+
it "requires signin" do
|
109
|
+
get :edit
|
110
|
+
response.should redirect_to signin_redirect
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
describe "show", :if => described_class.instance_methods.include?(:show) do
|
115
|
+
it "requires signin" do
|
116
|
+
get :show
|
117
|
+
response.should redirect_to signin_redirect
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
describe "create", :if => described_class.instance_methods.include?(:create) do
|
122
|
+
it "requires signin" do
|
123
|
+
post :create
|
124
|
+
response.should redirect_to signin_redirect
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
describe "update", :if => described_class.instance_methods.include?(:update) do
|
129
|
+
it "requires signin" do
|
130
|
+
put :update
|
131
|
+
response.should redirect_to signin_redirect
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
describe "delete", :if => described_class.instance_methods.include?(:destroy) do
|
136
|
+
it "requires signin" do
|
137
|
+
delete :destroy
|
138
|
+
response.should redirect_to signin_redirect
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: subelsky_power_tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,12 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
13
|
-
default_executable:
|
12
|
+
date: 2012-05-14 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: rspec
|
17
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
18
17
|
none: false
|
19
18
|
requirements:
|
20
19
|
- - ! '>='
|
@@ -22,7 +21,12 @@ dependencies:
|
|
22
21
|
version: '0'
|
23
22
|
type: :development
|
24
23
|
prerelease: false
|
25
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
26
30
|
description: ! "This is a collection of Ruby extensions and utilities I've been carting
|
27
31
|
around from project to project. \nMany are taken from the Facets project (I just
|
28
32
|
don't want to include that whole gem in my codebases).\n"
|
@@ -43,6 +47,7 @@ files:
|
|
43
47
|
- README.md
|
44
48
|
- Rakefile
|
45
49
|
- lib/subelsky_power_tools.rb
|
50
|
+
- lib/subelsky_power_tools/controller_shared_behavior.rb
|
46
51
|
- lib/subelsky_power_tools/environment.rb
|
47
52
|
- lib/subelsky_power_tools/ext/exception.rb
|
48
53
|
- lib/subelsky_power_tools/ext/hash.rb
|
@@ -55,7 +60,6 @@ files:
|
|
55
60
|
- spec/lib/ext/kernel_spec.rb
|
56
61
|
- spec/spec_helper.rb
|
57
62
|
- subelsky_power_tools.gemspec
|
58
|
-
has_rdoc: true
|
59
63
|
homepage: http://github.com/subelsky/subelsky_power_tools
|
60
64
|
licenses:
|
61
65
|
- MIT
|
@@ -78,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
78
82
|
version: '0'
|
79
83
|
requirements: []
|
80
84
|
rubyforge_project:
|
81
|
-
rubygems_version: 1.
|
85
|
+
rubygems_version: 1.8.23
|
82
86
|
signing_key:
|
83
87
|
specification_version: 3
|
84
88
|
summary: This is a collection of Ruby extensions and utilities I've been carting around
|