zertico 0.4.0 → 0.5.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.
@@ -4,7 +4,7 @@ module Zertico
4
4
  class Controller < ActionController::Base
5
5
  def initialize
6
6
  begin
7
- extend "::#{self.class.name.chomp("Controller").concat("Service")}".constantize
7
+ extend "::#{self.class.name.chomp('Controller').concat('Service')}".constantize
8
8
  rescue NameError
9
9
  extend Zertico::Service
10
10
  end
@@ -13,37 +13,49 @@ module Zertico
13
13
 
14
14
  def index
15
15
  initialize_object all
16
- respond_with(instance_variable_get("@responder"))
16
+ respond_with(instance_variable_get('@responder'))
17
17
  end
18
18
 
19
19
  def new
20
20
  initialize_object build
21
- respond_with(instance_variable_get("@responder"))
21
+ respond_with(instance_variable_get('@responder'))
22
22
  end
23
23
 
24
24
  def show
25
25
  initialize_object find(params[:id])
26
- respond_with(instance_variable_get("@responder"))
26
+ respond_with(instance_variable_get('@responder'))
27
27
  end
28
28
 
29
29
  def edit
30
30
  initialize_object find(params[:id])
31
- respond_with(instance_variable_get("@responder"))
31
+ respond_with(instance_variable_get('@responder'))
32
32
  end
33
33
 
34
34
  def create
35
35
  initialize_object generate(params[interface_name.to_sym])
36
- respond_with(instance_variable_get("@responder"))
36
+ if instance_variable_defined?('@path')
37
+ respond_with(instance_variable_get('@responder'), :path => instance_variable_get('@path'))
38
+ else
39
+ respond_with(instance_variable_get('@responder'))
40
+ end
37
41
  end
38
42
 
39
43
  def update
40
44
  initialize_object modify(params[:id], params[interface_name.to_sym])
41
- respond_with(instance_variable_get("@responder"))
45
+ if instance_variable_defined?('@path')
46
+ respond_with(instance_variable_get('@responder'), :path => instance_variable_get('@path'))
47
+ else
48
+ respond_with(instance_variable_get('@responder'))
49
+ end
42
50
  end
43
51
 
44
52
  def destroy
45
53
  initialize_object delete(params[:id])
46
- respond_with(instance_variable_get("@responder"))
54
+ if instance_variable_defined?('@path')
55
+ respond_with(instance_variable_get('@responder'), :path => instance_variable_get('@path'))
56
+ else
57
+ respond_with(instance_variable_get('@responder'))
58
+ end
47
59
  end
48
60
 
49
61
  protected
@@ -51,7 +63,7 @@ module Zertico
51
63
  def initialize_object(objects = {})
52
64
  objects.each do |key, value|
53
65
  instance_variable_set("@#{key}", value)
54
- instance_variable_set("@responder", value) unless @responder
66
+ instance_variable_set('@responder', value) unless @responder
55
67
  end
56
68
  end
57
69
  end
@@ -1,3 +1,3 @@
1
1
  module Zertico
2
- VERSION = '0.4.0'
2
+ VERSION = '0.5.0'
3
3
  end
@@ -32,6 +32,20 @@ describe Zertico::Controller do
32
32
  end
33
33
  end
34
34
 
35
+ context 'with a custom path to redirect' do
36
+ before :each do
37
+ controller.stub_chain(:interface_name, :to_sym).and_return(:user)
38
+ controller.stub(:params).and_return({ :user => 'user' })
39
+ controller.stub(:generate => { :user => 'user', :path => 'admin_path' } )
40
+ controller.stub(:respond_with)
41
+ controller.create
42
+ end
43
+
44
+ it 'should intialize an object with it' do
45
+ controller.instance_variable_get('@path').should == 'admin_path'
46
+ end
47
+ end
48
+
35
49
  context '#index' do
36
50
  before :each do
37
51
  controller.stub(:all).and_return({ :user => 'user' })
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.4.0
4
+ version: 0.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -107,7 +107,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
107
107
  version: '0'
108
108
  segments:
109
109
  - 0
110
- hash: -1517778425785026116
110
+ hash: 3691606098215597060
111
111
  required_rubygems_version: !ruby/object:Gem::Requirement
112
112
  none: false
113
113
  requirements:
@@ -116,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
116
  version: '0'
117
117
  segments:
118
118
  - 0
119
- hash: -1517778425785026116
119
+ hash: 3691606098215597060
120
120
  requirements: []
121
121
  rubyforge_project:
122
122
  rubygems_version: 1.8.25