zertico 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -22,12 +22,12 @@ module Zertico
22
22
  end
23
23
 
24
24
  def show
25
- initialize_object find(params[:id])
25
+ initialize_object find(params[interface_id.to_sym])
26
26
  respond_with(instance_variable_get('@responder'))
27
27
  end
28
28
 
29
29
  def edit
30
- initialize_object find(params[:id])
30
+ initialize_object find(params[interface_id.to_sym])
31
31
  respond_with(instance_variable_get('@responder'))
32
32
  end
33
33
 
@@ -41,7 +41,7 @@ module Zertico
41
41
  end
42
42
 
43
43
  def update
44
- initialize_object modify(params[:id], params[interface_name.to_sym])
44
+ initialize_object modify(params[interface_id.to_sym], params[interface_name.to_sym])
45
45
  if instance_variable_defined?('@location')
46
46
  respond_with(instance_variable_get('@responder'), :location => instance_variable_get('@location'))
47
47
  else
@@ -50,7 +50,7 @@ module Zertico
50
50
  end
51
51
 
52
52
  def destroy
53
- initialize_object delete(params[:id])
53
+ initialize_object delete(params[interface_id.to_sym])
54
54
  if instance_variable_defined?('@location')
55
55
  respond_with(instance_variable_get('@responder'), :location => instance_variable_get('@location'))
56
56
  else
@@ -42,6 +42,11 @@ module Zertico
42
42
 
43
43
  protected
44
44
 
45
+ def interface_id
46
+ return "#{interface_name}_id" if self.class.name.chomp('Controller').split('::').size > 1
47
+ 'id'
48
+ end
49
+
45
50
  def interface_name
46
51
  self.interface_class.name.singularize.underscore
47
52
  end
@@ -1,3 +1,3 @@
1
1
  module Zertico
2
- VERSION = '0.6.0'
2
+ VERSION = '0.6.1'
3
3
  end
@@ -3,6 +3,19 @@ require 'spec_helper'
3
3
  describe Zertico::Controller do
4
4
  let(:controller) { Zertico::Controller.new }
5
5
  let(:user_controller) { UserController.new }
6
+ let(:admin_controller) { Admin::UserController.new }
7
+
8
+ context 'not being nested' do
9
+ it 'should find on the correct id' do
10
+ user_controller.send(:interface_id).should == 'id'
11
+ end
12
+ end
13
+
14
+ context 'being nested' do
15
+ it 'should find on the correct id' do
16
+ admin_controller.send(:interface_id).should == 'user_id'
17
+ end
18
+ end
6
19
 
7
20
  context 'without a custom service' do
8
21
  it 'should extend Zertico::Service' do
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.6.0
4
+ version: 0.6.1
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-08-22 00:00:00.000000000 Z
12
+ date: 2013-09-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -113,7 +113,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
113
113
  version: '0'
114
114
  segments:
115
115
  - 0
116
- hash: -3191919241399243181
116
+ hash: 3377979383132618450
117
117
  required_rubygems_version: !ruby/object:Gem::Requirement
118
118
  none: false
119
119
  requirements:
@@ -122,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
122
122
  version: '0'
123
123
  segments:
124
124
  - 0
125
- hash: -3191919241399243181
125
+ hash: 3377979383132618450
126
126
  requirements: []
127
127
  rubyforge_project:
128
128
  rubygems_version: 1.8.25