zertico 0.5.2 → 0.5.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.
data/lib/zertico/service.rb
CHANGED
@@ -31,11 +31,15 @@ module Zertico
|
|
31
31
|
protected
|
32
32
|
|
33
33
|
def interface_name
|
34
|
-
self.
|
34
|
+
self.interface_class.name.singularize.underscore
|
35
35
|
end
|
36
36
|
|
37
37
|
def interface_class
|
38
|
-
|
38
|
+
begin
|
39
|
+
self.class.name.chomp('Controller').constantize
|
40
|
+
rescue NameError
|
41
|
+
self.class.name.chomp('Controller').split('::').last.constantize
|
42
|
+
end
|
39
43
|
end
|
40
44
|
end
|
41
45
|
end
|
data/lib/zertico/version.rb
CHANGED
@@ -3,18 +3,27 @@ require 'spec_helper'
|
|
3
3
|
describe Zertico::Service do
|
4
4
|
let(:controller) { UserController.new }
|
5
5
|
let(:admin_controller) { Admin::UserController.new }
|
6
|
+
let(:profile_controller) { Person::ProfileController.new }
|
6
7
|
let(:object) { Object.new }
|
7
8
|
|
8
|
-
context '
|
9
|
-
it '
|
10
|
-
|
9
|
+
context 'on a namespaced controller and interface model' do
|
10
|
+
it 'should find the interface model' do
|
11
|
+
profile_controller.send(:interface_class).should == Person::Profile
|
11
12
|
end
|
13
|
+
end
|
12
14
|
|
13
|
-
|
15
|
+
context 'on a namespaced controller and non namespaced interface model' do
|
16
|
+
it 'should find the interface model' do
|
14
17
|
admin_controller.send(:interface_class).should == User
|
15
18
|
end
|
16
19
|
end
|
17
20
|
|
21
|
+
context 'on a non namespaced controller and non namespaced interface model' do
|
22
|
+
it 'should find the interface model' do
|
23
|
+
controller.send(:interface_class).should == User
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
18
27
|
context '#all' do
|
19
28
|
before :each do
|
20
29
|
controller.stub_chain(:interface_name, :pluralize, :to_sym).and_return(:users)
|
@@ -28,58 +37,58 @@ describe Zertico::Service do
|
|
28
37
|
|
29
38
|
context '#build' do
|
30
39
|
before :each do
|
31
|
-
controller.stub_chain(:interface_name, :to_sym).and_return(:
|
40
|
+
controller.stub_chain(:interface_name, :to_sym).and_return(:person)
|
32
41
|
controller.stub_chain(:interface_class, :new).and_return(object)
|
33
42
|
end
|
34
43
|
|
35
44
|
it 'should return a new object' do
|
36
|
-
controller.build.should == { :
|
45
|
+
controller.build.should == { :person => object }
|
37
46
|
end
|
38
47
|
end
|
39
48
|
|
40
49
|
context '#find' do
|
41
50
|
before :each do
|
42
|
-
controller.stub_chain(:interface_name, :to_sym).and_return(:
|
51
|
+
controller.stub_chain(:interface_name, :to_sym).and_return(:person)
|
43
52
|
controller.stub_chain(:interface_class, :find).with(1).and_return(object)
|
44
53
|
end
|
45
54
|
|
46
55
|
it 'should return the specified object' do
|
47
|
-
controller.find(1).should == { :
|
56
|
+
controller.find(1).should == { :person => object }
|
48
57
|
end
|
49
58
|
end
|
50
59
|
|
51
60
|
context '#generate' do
|
52
61
|
before :each do
|
53
|
-
controller.stub_chain(:interface_name, :to_sym).and_return(:
|
62
|
+
controller.stub_chain(:interface_name, :to_sym).and_return(:person)
|
54
63
|
controller.stub_chain(:interface_class, :create).with({}).and_return(object)
|
55
64
|
end
|
56
65
|
|
57
66
|
it 'should return the created object' do
|
58
|
-
controller.generate({}).should == { :
|
67
|
+
controller.generate({}).should == { :person => object }
|
59
68
|
end
|
60
69
|
end
|
61
70
|
|
62
71
|
context '#modify' do
|
63
72
|
before :each do
|
64
|
-
controller.stub(:find).with(1).and_return({ :
|
73
|
+
controller.stub(:find).with(1).and_return({ :person => object })
|
65
74
|
object.stub(:update_attributes).with({}).and_return(true)
|
66
|
-
controller.stub_chain(:interface_name, :to_sym).and_return(:
|
75
|
+
controller.stub_chain(:interface_name, :to_sym).and_return(:person)
|
67
76
|
end
|
68
77
|
|
69
78
|
it 'should return the updated object' do
|
70
|
-
controller.modify(1, {}).should == { :
|
79
|
+
controller.modify(1, {}).should == { :person => object }
|
71
80
|
end
|
72
81
|
end
|
73
82
|
|
74
83
|
context '#delete' do
|
75
84
|
before :each do
|
76
|
-
controller.stub(:find).with(1).and_return({ :
|
85
|
+
controller.stub(:find).with(1).and_return({ :person => object })
|
77
86
|
object.stub(:destroy).and_return(true)
|
78
|
-
controller.stub_chain(:interface_name, :to_sym).and_return(:
|
87
|
+
controller.stub_chain(:interface_name, :to_sym).and_return(:person)
|
79
88
|
end
|
80
89
|
|
81
90
|
it 'should return the destroyed object' do
|
82
|
-
controller.delete(1).should == { :
|
91
|
+
controller.delete(1).should == { :person => object }
|
83
92
|
end
|
84
93
|
end
|
85
94
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zertico
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-07-
|
12
|
+
date: 2013-07-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -84,6 +84,9 @@ files:
|
|
84
84
|
- lib/zertico/version.rb
|
85
85
|
- spec/fake_app/admin/user_controller.rb
|
86
86
|
- spec/fake_app/admin/user_service.rb
|
87
|
+
- spec/fake_app/person/profile.rb
|
88
|
+
- spec/fake_app/person/profile_controller.rb
|
89
|
+
- spec/fake_app/person/profile_service.rb
|
87
90
|
- spec/fake_app/user.rb
|
88
91
|
- spec/fake_app/user_accessor.rb
|
89
92
|
- spec/fake_app/user_controller.rb
|
@@ -107,7 +110,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
107
110
|
version: '0'
|
108
111
|
segments:
|
109
112
|
- 0
|
110
|
-
hash: -
|
113
|
+
hash: -2336383762942507570
|
111
114
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
115
|
none: false
|
113
116
|
requirements:
|
@@ -116,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
119
|
version: '0'
|
117
120
|
segments:
|
118
121
|
- 0
|
119
|
-
hash: -
|
122
|
+
hash: -2336383762942507570
|
120
123
|
requirements: []
|
121
124
|
rubyforge_project:
|
122
125
|
rubygems_version: 1.8.25
|
@@ -128,6 +131,9 @@ test_files:
|
|
128
131
|
- gemfiles/Gemfile.rails3.2
|
129
132
|
- spec/fake_app/admin/user_controller.rb
|
130
133
|
- spec/fake_app/admin/user_service.rb
|
134
|
+
- spec/fake_app/person/profile.rb
|
135
|
+
- spec/fake_app/person/profile_controller.rb
|
136
|
+
- spec/fake_app/person/profile_service.rb
|
131
137
|
- spec/fake_app/user.rb
|
132
138
|
- spec/fake_app/user_accessor.rb
|
133
139
|
- spec/fake_app/user_controller.rb
|