pickle-dupe 0.2.2 → 0.3.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.
- data/VERSION +1 -1
- data/features/app/action_controllers.rb +18 -0
- data/features/app/active_resources.rb +3 -0
- data/features/app/routes.rb +10 -0
- data/features/path/models_page.feature +44 -0
- data/features/path/named_route_page.feature +11 -0
- data/features/step_definitions/path_steps.rb +2 -1
- data/lib/pickle_dupe/adapter.rb +11 -8
- data/lib/pickle_dupe.rb +0 -1
- metadata +8 -5
- data/lib/pickle_dupe/session.rb +0 -17
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# controllers
|
2
|
+
class DefaultController < ActionController::Base
|
3
|
+
def index
|
4
|
+
render :text => "index: I was invoked with #{request.path}"
|
5
|
+
end
|
6
|
+
|
7
|
+
def show
|
8
|
+
render :text => "show: I was invoked with #{request.path}"
|
9
|
+
end
|
10
|
+
|
11
|
+
def new
|
12
|
+
render :text => "new: I was invoked with #{request.path}"
|
13
|
+
end
|
14
|
+
|
15
|
+
def edit
|
16
|
+
render :text => "edit: I was invoked with #{request.path}"
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# Routes
|
2
|
+
ActionController::Routing::Routes.draw do |map|
|
3
|
+
# Since I started using recipe -> ingredient before working on path stuff, there is no turning back
|
4
|
+
# so even if the nestedness does not make sense, I have to use it
|
5
|
+
map.resources :recipes, :controller => 'default' do |recipe|
|
6
|
+
recipe.resources :ingredients, :controller => 'default' do |ingredient|
|
7
|
+
ingredient.resources :comments, :controller => 'default'
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
Feature: I can visit a page for a model
|
2
|
+
In order to easily go to pages for models I've created
|
3
|
+
As a feature writer
|
4
|
+
I want to be able visit pages their model
|
5
|
+
|
6
|
+
Scenario: create a recipe, go its page
|
7
|
+
Given a recipe exists
|
8
|
+
When I go to the recipe's page
|
9
|
+
Then I should be at the recipe's page
|
10
|
+
And the recipe's page should match route /recipes/:id
|
11
|
+
|
12
|
+
Scenario: create a recipe, go to its edit page, check lots of different refs to it
|
13
|
+
Given a recipe: "chicken fingers" exists
|
14
|
+
When I go to recipe: "chicken fingers"'s edit page
|
15
|
+
Then I should be at the 1st recipe's edit page
|
16
|
+
And the 1st recipe's edit page should match route /recipes/:id/edit
|
17
|
+
And the recipe's edit page should match route /recipes/:id/edit
|
18
|
+
And the recipe: "chicken fingers"'s edit page should match route /recipes/:id/edit
|
19
|
+
|
20
|
+
Scenario: go to a recipe's nested ingredients page
|
21
|
+
Given a recipe exists
|
22
|
+
When I go to the recipe's ingredients page
|
23
|
+
Then I should be at the recipe's ingredients page
|
24
|
+
And the recipe's ingredients page should match route /recipes/:recipe_id/ingredients
|
25
|
+
|
26
|
+
Scenario: go to a recipe's new ingredient page
|
27
|
+
Given a recipe exists
|
28
|
+
When I go to the recipe's new ingredient page
|
29
|
+
Then I should be at the recipe's new ingredient page
|
30
|
+
And the recipe's new ingredient page should match route /recipes/:recipe_id/ingredients/new
|
31
|
+
|
32
|
+
Scenario: go to a ingredient in recipe context page
|
33
|
+
Given a recipe exists
|
34
|
+
And an ingredient exists with recipe: the recipe
|
35
|
+
When I go to the recipe's ingredient's page
|
36
|
+
Then I should be at the recipe's ingredient's page
|
37
|
+
And the recipe's ingredient's page should match route /recipes/:recipe_id/ingredients/:id
|
38
|
+
|
39
|
+
Scenario: go to a ingredient's comments in recipe context
|
40
|
+
Given a recipe exists
|
41
|
+
And an ingredient exists with recipe: the recipe
|
42
|
+
When I go to the recipe's ingredient's comments page
|
43
|
+
Then I should be at the recipe's ingredient's comments page
|
44
|
+
And the recipe's ingredient's comments page should match route /recipes/:recipe_id/ingredients/:ingredient_id/comments
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Feature: I can visit a page by named route
|
2
|
+
In order to nav in my features
|
3
|
+
As a feature writer
|
4
|
+
I want to be able visit named routes
|
5
|
+
|
6
|
+
@wip
|
7
|
+
Scenario: visit the new spoons page
|
8
|
+
When I go to the new recipe page
|
9
|
+
Then I should be at the new recipe page
|
10
|
+
And the new recipe page should match route /recipes/new
|
11
|
+
|
@@ -1,7 +1,8 @@
|
|
1
1
|
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
|
2
2
|
|
3
|
+
#FIXME GC 04/09/2010 - Should match either a digit or a valid label
|
3
4
|
Then(/^(.+?) should match route \/(.+?)$/) do |page, route|
|
4
|
-
regexp = route.gsub(/:(\w*?)id/,'
|
5
|
+
regexp = route.gsub(/:(\w*?)id/,'(?:\d+|[A-Za-z0-9_-]+)')
|
5
6
|
path_to(page).should =~ /#{regexp}/
|
6
7
|
end
|
7
8
|
|
data/lib/pickle_dupe/adapter.rb
CHANGED
@@ -26,12 +26,12 @@ module Pickle
|
|
26
26
|
end
|
27
27
|
@name = model.name.to_s
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
def create(attrs = {})
|
31
31
|
duped_object = ::Dupe.create(@name, attrs)
|
32
32
|
assign_missing_associations(duped_object, attrs) unless attrs.blank?
|
33
|
-
|
34
|
-
return duped_object
|
33
|
+
|
34
|
+
return @klass.send(:find, duped_object.id)
|
35
35
|
end
|
36
36
|
|
37
37
|
private
|
@@ -96,11 +96,14 @@ module Pickle
|
|
96
96
|
has_many_association = has_one_association.to_s.pluralize.to_sym #=> :direction_steps
|
97
97
|
|
98
98
|
# The following would check for the existence of the key :direction_steps
|
99
|
-
# in the duped recipe's definition
|
100
|
-
|
101
|
-
|
99
|
+
# in the duped recipe's definition
|
100
|
+
association_duped_object = ::Dupe.find(association_object.class.name.underscore){|d|
|
101
|
+
d.id == association_object.id
|
102
|
+
}
|
103
|
+
if association_duped_object.__model__.schema.attribute_templates.keys.include?(has_many_association)
|
104
|
+
association_duped_object[has_many_association] << duped_object
|
102
105
|
else #assume it's a has_one association
|
103
|
-
|
106
|
+
association_duped_object[has_one_association] = duped_object
|
104
107
|
end
|
105
108
|
end
|
106
109
|
|
@@ -110,7 +113,7 @@ module Pickle
|
|
110
113
|
# :association => [<#Duped...>] will return [[<#Duped...>,<#Duped...>],<#Duped...>]
|
111
114
|
def collect_association_objects(attrs)
|
112
115
|
attrs.select {|k,v|
|
113
|
-
v.kind_of?(Array) || v.kind_of?(::
|
116
|
+
v.kind_of?(Array) || v.kind_of?(ActiveResource::Base)
|
114
117
|
}.collect {|i| i[1]}.flatten
|
115
118
|
end
|
116
119
|
|
data/lib/pickle_dupe.rb
CHANGED
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 3
|
8
|
+
- 0
|
9
|
+
version: 0.3.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- iawgens
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-04-
|
17
|
+
date: 2010-04-09 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -61,8 +61,12 @@ files:
|
|
61
61
|
- README.rdoc
|
62
62
|
- Rakefile
|
63
63
|
- VERSION
|
64
|
+
- features/app/action_controllers.rb
|
64
65
|
- features/app/active_resources.rb
|
65
66
|
- features/app/dupe_definitions.rb
|
67
|
+
- features/app/routes.rb
|
68
|
+
- features/path/models_page.feature
|
69
|
+
- features/path/named_route_page.feature
|
66
70
|
- features/pickle/create_from_dupe.feature
|
67
71
|
- features/step_definitions/path_steps.rb
|
68
72
|
- features/step_definitions/pickle_steps.rb
|
@@ -75,7 +79,6 @@ files:
|
|
75
79
|
- lib/pickle_dupe.rb
|
76
80
|
- lib/pickle_dupe/adapter.rb
|
77
81
|
- lib/pickle_dupe/parser.rb
|
78
|
-
- lib/pickle_dupe/session.rb
|
79
82
|
has_rdoc: true
|
80
83
|
homepage: http://github.com/iawgens/pickle-dupe
|
81
84
|
licenses: []
|
data/lib/pickle_dupe/session.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
module Pickle
|
2
|
-
module Session
|
3
|
-
# return a newly selected model when dupe is used
|
4
|
-
def model_with_dupe(name)
|
5
|
-
model = created_model(name)
|
6
|
-
|
7
|
-
if model.kind_of?(Dupe::Database::Record)
|
8
|
-
Dupe.find(model.__model__.name) {|dupe_model| dupe_model.id == model.id}
|
9
|
-
else
|
10
|
-
model_without_dupe(name)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
alias_method :model_without_dupe, :model
|
15
|
-
alias_method :model, :model_with_dupe
|
16
|
-
end
|
17
|
-
end
|