rezource 0.0.4 → 0.0.5

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.
@@ -82,49 +82,62 @@ module Rezource
82
82
  # -----------
83
83
 
84
84
  def new_resource_path(*args)
85
- send raw_path("new").to_sym, *args
85
+ parts = ["new"] + namespace + (parent? ? [parent_ivar] : []) + [resource_ivar] + ["path"]
86
+ send parts.join("_").to_sym, *args
87
+
88
+ # send raw_path("new").to_sym, *args
86
89
  end
87
90
 
88
91
  def edit_resource_path(*args)
89
- send raw_path("edit").to_sym, *args
92
+ action_resource_path "edit", *args
93
+ # parts = ["edit"] + namespace + [resource_ivar] + ["path"]
94
+ # send parts.join("_").to_sym, *args
95
+ # send raw_path("edit").to_sym, *args
90
96
  end
91
97
 
92
98
  def action_resource_path(action, *args)
93
- send raw_path(action).to_sym, *args
99
+ parts = [action] + namespace + [resource_ivar] + ["path"]
100
+ send parts.join("_").to_sym, *args
101
+ # send raw_path(action).to_sym, *args
94
102
  end
95
103
 
96
104
  def resources_path(*args)
97
- send raw_path.to_sym, *args
105
+ parts = namespace + (parent? ? [parent_ivar] : []) + [resource_options[:singleton] ? resource_ivar : resources_ivar] + ["path"]
106
+ send parts.join("_").to_sym, *args
107
+ # send raw_path.to_sym, *args
98
108
  end
99
109
 
100
110
  def resource_path(*args)
101
- send raw_path(nil, true).to_sym, *args
111
+ parts = namespace + [resource_ivar] + ["path"]
112
+ send parts.join("_").to_sym, *args
113
+ # send raw_path(nil, true).to_sym, *args
102
114
  end
103
115
 
104
- def raw_path(action=nil, singleton=false)
105
- parts = []
106
- parts += [action] if action
107
- parts += namespace
116
+ # def raw_path(action=nil, singleton=false)
117
+ # parts = []
118
+ # parts += [action] if action
108
119
 
109
- if parent?
110
- if !action || action != "edit"
111
- parts += [parent_ivar]
112
- end
113
- end
114
-
115
- parts += if action
116
- [resource_ivar]
117
- elsif singleton
118
- [resource_ivar]
119
- elsif resource_options[:singleton]
120
- [resource_ivar]
121
- else
122
- [resources_ivar]
123
- end
120
+ # parts += namespace
124
121
 
125
- parts += ["path"]
126
- parts.join("_")
127
- end
122
+ # if parent?
123
+ # if !action || action != "edit"
124
+ # parts += [parent_ivar]
125
+ # end
126
+ # end
127
+
128
+ # parts += if action
129
+ # [resource_ivar]
130
+ # elsif singleton
131
+ # [resource_ivar]
132
+ # elsif resource_options[:singleton]
133
+ # [resource_ivar]
134
+ # else
135
+ # [resources_ivar]
136
+ # end
137
+
138
+ # parts += ["path"]
139
+ # parts.join("_")
140
+ # end
128
141
 
129
142
  # -----------
130
143
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "rezource"
3
- s.version = "0.0.4"
3
+ s.version = "0.0.5"
4
4
 
5
5
  s.authors = ["Jan Zimmek"]
6
6
  s.email = %q{jan.zimmek@web.de}
@@ -130,76 +130,124 @@ class RezourceTest < Test::Unit::TestCase
130
130
  # ----- url resources
131
131
 
132
132
 
133
- def test_raw_path
133
+ # def test_raw_path
134
+ # c = SamplesController.new
135
+ # assert_equal "samples_path", c.raw_path
136
+ # end
137
+
138
+ # def test_raw_path__with_singleton
139
+ # c = SamplesController.new
140
+ # assert_equal "sample_path", c.raw_path(nil, true)
141
+ # end
142
+
143
+ # def test_raw_path__with_new_action
144
+ # c = SamplesController.new
145
+ # assert_equal "new_sample_path", c.raw_path("new")
146
+ # end
147
+
148
+ # def test_raw_path__with_edit_action
149
+ # c = SamplesController.new
150
+ # assert_equal "edit_sample_path", c.raw_path("edit")
151
+ # end
152
+
153
+ # def test_raw_path__with_namespace
154
+ # c = Namespaced::SamplesController.new
155
+ # assert_equal "namespaced_samples_path", c.raw_path
156
+ # end
157
+
158
+ # def test_raw_path__with_parent
159
+ # c = SamplesController.resource(belongs_to: SampleParent).new
160
+ # assert_equal "sample_parent_samples_path", c.raw_path
161
+ # end
162
+
163
+ # def test_raw_path__with_parent_and_namespace
164
+ # c = Namespaced::SamplesController.resource(belongs_to: SampleParent).new
165
+ # assert_equal "namespaced_sample_parent_samples_path", c.raw_path
166
+ # end
167
+
168
+ # def test_raw_path__with_parent_and_namespace_and_action
169
+ # c = Namespaced::SamplesController.resource(belongs_to: SampleParent).new
170
+ # assert_equal "edit_namespaced_sample_path", c.raw_path("edit")
171
+ # end
172
+
173
+ def test_resources_path
134
174
  c = SamplesController.new
135
- assert_equal "samples_path", c.raw_path
175
+ c.stubs(:samples_path).returns "xyz"
176
+ assert_equal "xyz", c.resources_path
136
177
  end
137
178
 
138
- def test_raw_path__with_singleton
139
- c = SamplesController.new
140
- assert_equal "sample_path", c.raw_path(nil, true)
179
+ def test_resources_path__with_singleton
180
+ c = SamplesController.resource(singleton: true).new
181
+ c.stubs(:sample_path).returns "xyz"
182
+ assert_equal "xyz", c.resources_path
141
183
  end
142
184
 
143
- def test_raw_path__with_new_action
144
- c = SamplesController.new
145
- assert_equal "new_sample_path", c.raw_path("new")
185
+ def test_resources_path__with_namespace
186
+ c = Namespaced::SamplesController.new
187
+ c.stubs(:namespaced_samples_path).returns "xyz"
188
+ assert_equal "xyz", c.resources_path
146
189
  end
147
190
 
148
- def test_raw_path__with_edit_action
191
+
192
+
193
+
194
+ def test_resource_path
149
195
  c = SamplesController.new
150
- assert_equal "edit_sample_path", c.raw_path("edit")
196
+ c.stubs(:sample_path).returns "xyz"
197
+ assert_equal "xyz", c.resource_path
151
198
  end
152
199
 
153
- def test_raw_path__with_namespace
154
- c = Namespaced::SamplesController.new
155
- assert_equal "namespaced_samples_path", c.raw_path
200
+ def test_resource_path__with_singleton
201
+ c = SamplesController.resource(singleton: true).new
202
+ c.stubs(:sample_path).returns "xyz"
203
+ assert_equal "xyz", c.resource_path
156
204
  end
157
205
 
158
- def test_raw_path__with_parent
159
- c = SamplesController.resource(belongs_to: SampleParent).new
160
- assert_equal "sample_parent_samples_path", c.raw_path
206
+ def test_resource_path__with_namespace
207
+ c = Namespaced::SamplesController.new
208
+ c.stubs(:namespaced_sample_path).returns "xyz"
209
+ assert_equal "xyz", c.resource_path
161
210
  end
162
211
 
163
- def test_raw_path__with_parent_and_namespace
164
- c = Namespaced::SamplesController.resource(belongs_to: SampleParent).new
165
- assert_equal "namespaced_sample_parent_samples_path", c.raw_path
166
- end
167
212
 
168
- def test_raw_path__with_parent_and_namespace_and_action
169
- c = Namespaced::SamplesController.resource(belongs_to: SampleParent).new
170
- assert_equal "edit_namespaced_sample_path", c.raw_path("edit")
171
- end
172
213
 
173
- def test_resources_path
214
+ def test_new_resources_path
174
215
  c = SamplesController.new
175
- c.stubs(:samples_path).returns "/samples"
176
- assert_equal "/samples", c.resources_path
216
+ c.stubs(:new_sample_path).returns "xyz"
217
+ assert_equal "xyz", c.new_resource_path
177
218
  end
178
219
 
179
- def test_resource_path
180
- c = SamplesController.new
181
- c.stubs(:sample_path).returns "/sample/XYZ"
182
- assert_equal "/sample/XYZ", c.resource_path
220
+ def test_new_resources_path__with_namespace
221
+ c = Namespaced::SamplesController.new
222
+ c.stubs(:new_namespaced_sample_path).returns "xyz"
223
+ assert_equal "xyz", c.new_resource_path
183
224
  end
184
225
 
185
- def test_new_resources_path
226
+ def test_edit_resources_path
186
227
  c = SamplesController.new
187
- c.stubs(:new_sample_path).returns "/samples/new"
188
- assert_equal "/samples/new", c.new_resource_path
228
+ c.stubs(:edit_sample_path).returns "xyz"
229
+ assert_equal "xyz", c.edit_resource_path
189
230
  end
190
231
 
191
- def test_edit_resources_path
192
- c = SamplesController.new
193
- c.stubs(:edit_sample_path).returns "/samples/XYZ/edit"
194
- assert_equal "/samples/XYZ/edit", c.edit_resource_path
232
+ def test_edit_resources_path__with_namespace
233
+ c = Namespaced::SamplesController.new
234
+ c.stubs(:edit_namespaced_sample_path).returns "xyz"
235
+ assert_equal "xyz", c.edit_resource_path
195
236
  end
196
237
 
197
238
  def test_action_resources_path
198
239
  c = SamplesController.new
199
- c.stubs(:custom_sample_path).returns "/samples/XYZ/custom"
200
- assert_equal "/samples/XYZ/custom", c.action_resource_path("custom")
240
+ c.stubs(:custom_sample_path).returns "xyz"
241
+ assert_equal "xyz", c.action_resource_path("custom")
242
+ end
243
+
244
+ def test_action_resources_path__with_namespace
245
+ c = Namespaced::SamplesController.new
246
+ c.stubs(:custom_namespaced_sample_path).returns "xyz"
247
+ assert_equal "xyz", c.action_resource_path("custom")
201
248
  end
202
249
 
250
+ # ------
203
251
 
204
252
  def test_default_respond_with
205
253
  c = SamplesController.new
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rezource
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: