puffer 0.0.19 → 0.0.20

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. data/.rvmrc +1 -0
  2. data/Gemfile +11 -8
  3. data/Gemfile.lock +117 -103
  4. data/Guardfile +20 -0
  5. data/VERSION +1 -1
  6. data/app/assets/javascripts/puffer/application.js +5 -0
  7. data/{lib/generators/puffer/install/templates/puffer/javascripts → app/assets/javascripts/puffer}/puffer.js +0 -0
  8. data/{lib/generators/puffer/install/templates/puffer/javascripts → app/assets/javascripts/puffer}/rails.js +0 -0
  9. data/{lib/generators/puffer/install/templates/puffer/javascripts → app/assets/javascripts/puffer}/right-autocompleter.js +0 -0
  10. data/{lib/generators/puffer/install/templates/puffer/javascripts → app/assets/javascripts/puffer}/right-calendar.js +0 -0
  11. data/{lib/generators/puffer/install/templates/puffer/javascripts → app/assets/javascripts/puffer}/right.js +0 -0
  12. data/app/assets/stylesheets/puffer/application.css +4 -0
  13. data/{lib/generators/puffer/install/templates/puffer/stylesheets → app/assets/stylesheets/puffer}/puffer.css +2 -1
  14. data/{lib/generators/puffer/install/templates/puffer/stylesheets → app/assets/stylesheets/puffer}/reset.css +0 -0
  15. data/app/controllers/puffer/dashboard.rb +12 -0
  16. data/app/controllers/puffer/{sessions_base.rb → sessions.rb} +1 -2
  17. data/app/helpers/puffer_helper.rb +2 -10
  18. data/app/views/layouts/puffer.html.erb +24 -5
  19. data/app/views/layouts/puffer_dashboard.html.erb +3 -3
  20. data/app/views/layouts/puffer_sessions.html.erb +3 -3
  21. data/app/views/puffer/{_form.html.erb → base/_form.html.erb} +2 -2
  22. data/app/views/puffer/{associated → base/associated}/_many.html.erb +1 -1
  23. data/app/views/puffer/{associated → base/associated}/many.rjs +0 -0
  24. data/app/views/puffer/{associated → base/associated}/one.js.erb +1 -1
  25. data/app/views/puffer/{association → base/association}/_many.html.erb +0 -0
  26. data/app/views/puffer/{edit.html.erb → base/edit.html.erb} +1 -1
  27. data/app/views/puffer/{index.html.erb → base/index.html.erb} +2 -2
  28. data/app/views/puffer/{new.html.erb → base/new.html.erb} +1 -1
  29. data/app/views/puffer/{show.html.erb → base/show.html.erb} +1 -1
  30. data/app/views/{puffer_dashboard → puffer/dashboard}/index.html.erb +0 -0
  31. data/app/views/{puffer_sessions → puffer/sessions}/new.html.erb +0 -0
  32. data/config/locales/puffer.yml +5 -0
  33. data/lib/generators/puffer/install/install_generator.rb +0 -8
  34. data/lib/generators/puffer/install/templates/dashboard_controller.rb +1 -1
  35. data/lib/generators/puffer/install/templates/sessions_controller.rb +1 -1
  36. data/lib/puffer.rb +0 -16
  37. data/lib/puffer/base.rb +8 -3
  38. data/lib/puffer/controller/config.rb +2 -0
  39. data/lib/puffer/controller/dsl.rb +2 -2
  40. data/lib/puffer/controller/generated.rb +4 -4
  41. data/lib/puffer/controller/helpers.rb +1 -1
  42. data/lib/puffer/controller/mutate.rb +0 -14
  43. data/lib/puffer/customs.rb +1 -0
  44. data/lib/puffer/engine.rb +0 -4
  45. data/lib/puffer/extensions/mapper.rb +5 -1
  46. data/lib/puffer/fields.rb +2 -2
  47. data/lib/puffer/fields/field.rb +16 -17
  48. data/lib/puffer/inputs/association.rb +3 -2
  49. data/lib/puffer/resource.rb +13 -12
  50. data/lib/puffer/resource/routing.rb +1 -1
  51. data/lib/puffer/resource/scoping.rb +2 -2
  52. data/puffer.gemspec +63 -126
  53. data/spec/dummy/.rvmrc +1 -0
  54. data/spec/dummy/Rakefile +1 -1
  55. data/spec/dummy/app/assets/images/rails.png +0 -0
  56. data/spec/dummy/app/assets/javascripts/application.js +9 -0
  57. data/spec/dummy/app/assets/stylesheets/application.css +7 -0
  58. data/spec/dummy/app/controllers/admin/posts_controller.rb +3 -1
  59. data/spec/dummy/app/controllers/admin/profiles_controller.rb +4 -1
  60. data/spec/dummy/app/controllers/puffer/dashboard_controller.rb +1 -1
  61. data/spec/dummy/app/controllers/puffer/sessions_controller.rb +1 -1
  62. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  63. data/spec/dummy/config/application.rb +5 -9
  64. data/spec/dummy/config/boot.rb +5 -7
  65. data/spec/dummy/config/database.yml +4 -1
  66. data/spec/dummy/config/environments/development.rb +4 -3
  67. data/spec/dummy/config/environments/production.rb +17 -12
  68. data/spec/dummy/config/environments/test.rb +5 -1
  69. data/spec/dummy/config/initializers/secret_token.rb +1 -1
  70. data/spec/dummy/config/initializers/session_store.rb +1 -1
  71. data/spec/dummy/config/initializers/wrap_parameters.rb +12 -0
  72. data/spec/dummy/config/locales/en.yml +1 -1
  73. data/spec/dummy/db/seeds.rb +7 -0
  74. data/spec/dummy/public/robots.txt +5 -0
  75. data/spec/fabricators/posts_fabricator.rb +1 -1
  76. data/spec/fabricators/profiles_fabricator.rb +1 -1
  77. data/spec/fabricators/users_fabricator.rb +1 -1
  78. data/spec/lib/resource/routing_spec.rb +5 -5
  79. data/spec/lib/resource_spec.rb +37 -88
  80. data/spec/spec_helper.rb +15 -0
  81. metadata +171 -272
  82. data/app/cells/puffer/base/additional.html.erb +0 -25
  83. data/app/cells/puffer/base_cell.rb +0 -25
  84. data/app/controllers/puffer/dashboard_base.rb +0 -13
  85. data/autotest/discover.rb +0 -2
  86. data/lib/generators/puffer/install/templates/puffer.rb +0 -12
  87. data/lib/puffer/path_set.rb +0 -24
  88. data/spec/dummy/app/views/admin/users/index.html.erb +0 -3
  89. data/spec/dummy/config/initializers/puffer.rb +0 -12
  90. data/spec/dummy/db/schema.rb +0 -83
  91. data/spec/dummy/public/javascripts/application.js +0 -2
  92. data/spec/dummy/public/javascripts/controls.js +0 -965
  93. data/spec/dummy/public/javascripts/dragdrop.js +0 -974
  94. data/spec/dummy/public/javascripts/effects.js +0 -1123
  95. data/spec/dummy/public/javascripts/prototype.js +0 -6001
  96. data/spec/dummy/public/javascripts/rails.js +0 -175
  97. data/spec/dummy/public/puffer/javascripts/puffer.js +0 -10
  98. data/spec/dummy/public/puffer/javascripts/rails.js +0 -57
  99. data/spec/dummy/public/puffer/javascripts/right-autocompleter.js +0 -621
  100. data/spec/dummy/public/puffer/javascripts/right-calendar.js +0 -1461
  101. data/spec/dummy/public/puffer/javascripts/right.js +0 -5892
  102. data/spec/dummy/public/puffer/stylesheets/puffer.css +0 -469
  103. data/spec/dummy/public/puffer/stylesheets/reset.css +0 -60
  104. data/spec/dummy/public/stylesheets/.gitkeep +0 -0
  105. data/spec/lib/render_fallback_spec.rb +0 -17
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= stylesheet_link_tag "application" %>
6
+ <%= javascript_include_tag "application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -1,13 +1,9 @@
1
1
  require File.expand_path('../boot', __FILE__)
2
2
 
3
- require "active_model/railtie"
4
- require "active_record/railtie"
5
- require "action_controller/railtie"
6
- require "action_view/railtie"
7
- require "action_mailer/railtie"
3
+ require 'rails/all'
8
4
 
9
5
  Bundler.require
10
- require "puffer"
6
+ require 'puffer'
11
7
 
12
8
  module Dummy
13
9
  class Application < Rails::Application
@@ -33,13 +29,13 @@ module Dummy
33
29
  # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
34
30
  # config.i18n.default_locale = :de
35
31
 
36
- # JavaScript files you want as :defaults (application.js is always included).
37
- # config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
38
-
39
32
  # Configure the default encoding used in templates for Ruby 1.9.
40
33
  config.encoding = "utf-8"
41
34
 
42
35
  # Configure sensitive parameters which will be filtered from the log file.
43
36
  config.filter_parameters += [:password]
37
+
38
+ # Enable the asset pipeline
39
+ config.assets.enabled = true
44
40
  end
45
41
  end
@@ -1,10 +1,8 @@
1
1
  require 'rubygems'
2
- gemfile = File.expand_path('../../../../Gemfile', __FILE__)
3
2
 
4
- if File.exist?(gemfile)
5
- ENV['BUNDLE_GEMFILE'] = gemfile
6
- require 'bundler'
7
- Bundler.setup
8
- end
3
+ # Set up gems listed in the Gemfile.
4
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
9
5
 
10
- $:.unshift File.expand_path('../../../../lib', __FILE__)
6
+ require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
7
+
8
+ $:.unshift File.expand_path('../../../../lib', __FILE__)
@@ -1,5 +1,8 @@
1
1
  # SQLite version 3.x
2
- # gem install sqlite3-ruby (not necessary on OS X Leopard)
2
+ # gem install sqlite3
3
+ #
4
+ # Ensure the SQLite 3 gem is defined in your Gemfile
5
+ # gem 'sqlite3'
3
6
  development:
4
7
  adapter: sqlite3
5
8
  database: db/development.sqlite3
@@ -3,7 +3,7 @@ Dummy::Application.configure do
3
3
 
4
4
  # In the development environment your application's code is reloaded on
5
5
  # every request. This slows down response time but is perfect for development
6
- # since you don't have to restart the webserver when you make code changes.
6
+ # since you don't have to restart the web server when you make code changes.
7
7
  config.cache_classes = false
8
8
 
9
9
  # Log error messages when you accidentally call methods on nil.
@@ -11,7 +11,6 @@ Dummy::Application.configure do
11
11
 
12
12
  # Show full error reports and disable caching
13
13
  config.consider_all_requests_local = true
14
- config.action_view.debug_rjs = true
15
14
  config.action_controller.perform_caching = false
16
15
 
17
16
  # Don't care if the mailer can't send
@@ -22,5 +21,7 @@ Dummy::Application.configure do
22
21
 
23
22
  # Only use best-standards-support built into browsers
24
23
  config.action_dispatch.best_standards_support = :builtin
25
- end
26
24
 
25
+ # Do not compress assets
26
+ config.assets.compress = false
27
+ end
@@ -1,7 +1,6 @@
1
1
  Dummy::Application.configure do
2
2
  # Settings specified here will take precedence over those in config/application.rb
3
3
 
4
- # The production environment is meant for finished, "live" apps.
5
4
  # Code is not reloaded between requests
6
5
  config.cache_classes = true
7
6
 
@@ -9,14 +8,21 @@ Dummy::Application.configure do
9
8
  config.consider_all_requests_local = false
10
9
  config.action_controller.perform_caching = true
11
10
 
12
- # Specifies the header that your server uses for sending files
13
- config.action_dispatch.x_sendfile_header = "X-Sendfile"
11
+ # Disable Rails's static asset server (Apache or nginx will already do this)
12
+ config.serve_static_assets = false
13
+
14
+ # Compress JavaScripts and CSS
15
+ config.assets.compress = true
16
+
17
+ # Specify the default JavaScript compressor
18
+ config.assets.js_compressor = :uglifier
14
19
 
15
- # For nginx:
16
- # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
20
+ # Specifies the header that your server uses for sending files
21
+ # (comment out if your front-end server doesn't support this)
22
+ config.action_dispatch.x_sendfile_header = "X-Sendfile" # Use 'X-Accel-Redirect' for nginx
17
23
 
18
- # If you have no front-end server that supports something like X-Sendfile,
19
- # just comment this out and Rails will serve the files
24
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
25
+ # config.force_ssl = true
20
26
 
21
27
  # See everything in the log (default is :info)
22
28
  # config.log_level = :debug
@@ -27,13 +33,12 @@ Dummy::Application.configure do
27
33
  # Use a different cache store in production
28
34
  # config.cache_store = :mem_cache_store
29
35
 
30
- # Disable Rails's static asset server
31
- # In production, Apache or nginx will already do this
32
- config.serve_static_assets = false
33
-
34
- # Enable serving of images, stylesheets, and javascripts from an asset server
36
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server
35
37
  # config.action_controller.asset_host = "http://assets.example.com"
36
38
 
39
+ # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
40
+ # config.assets.precompile += %w( search.js )
41
+
37
42
  # Disable delivery errors, bad email addresses will be ignored
38
43
  # config.action_mailer.raise_delivery_errors = false
39
44
 
@@ -7,7 +7,11 @@ Dummy::Application.configure do
7
7
  # and recreated between test runs. Don't rely on the data there!
8
8
  config.cache_classes = true
9
9
 
10
- # Log error messages when you accidentally call methods on nil.
10
+ # Configure static asset server for tests with Cache-Control for performance
11
+ config.serve_static_assets = true
12
+ config.static_cache_control = "public, max-age=3600"
13
+
14
+ # Log error messages when you accidentally call methods on nil
11
15
  config.whiny_nils = true
12
16
 
13
17
  # Show full error reports and disable caching
@@ -4,4 +4,4 @@
4
4
  # If you change this key, all old signed cookies will become invalid!
5
5
  # Make sure the secret is at least 30 characters and all random,
6
6
  # no regular words or you'll be exposed to dictionary attacks.
7
- Dummy::Application.config.secret_token = '14a4432ff8033f97f9e6dccdc2d8f29640bb61581f7befae59ad61d67e4707fc58ba747244f150ac8bf086348a23b6b155987127c63d0688b22d113f6cc83e0d'
7
+ Dummy::Application.config.secret_token = '3b4aedd9d9f6f4923f180118e97ca019364669e065127e0d5d3f08f2a97f7353ef5cedc847d24afd9c6d3e34160a1232bba864bfcd43d2b473a411a207f2e30a'
@@ -1,6 +1,6 @@
1
1
  # Be sure to restart your server when you modify this file.
2
2
 
3
- Dummy::Application.config.session_store :cookie_store, :key => '_dummy_session'
3
+ Dummy::Application.config.session_store :cookie_store, key: '_dummy_session'
4
4
 
5
5
  # Use the database for sessions instead of the cookie-based default,
6
6
  # which shouldn't be used to store highly confidential information
@@ -0,0 +1,12 @@
1
+ # Be sure to restart your server when you modify this file.
2
+ #
3
+ # This file contains settings for ActionController::ParamsWrapper which
4
+ # is enabled by default.
5
+
6
+ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
+ ActionController::Base.wrap_parameters format: [:json]
8
+
9
+ # Disable root element in JSON by default.
10
+ if defined?(ActiveRecord)
11
+ ActiveRecord::Base.include_root_in_json = false
12
+ end
@@ -1,5 +1,5 @@
1
1
  # Sample localization file for English. Add more files in this directory for other locales.
2
- # See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
2
+ # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
3
 
4
4
  en:
5
5
  hello: "Hello world"
@@ -0,0 +1,7 @@
1
+ # This file should contain all the record creation needed to seed the database with its default values.
2
+ # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
3
+ #
4
+ # Examples:
5
+ #
6
+ # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
7
+ # Mayor.create(name: 'Emanuel', city: cities.first)
@@ -0,0 +1,5 @@
1
+ # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
2
+ #
3
+ # To ban all spiders from the entire site uncomment the next two lines:
4
+ # User-Agent: *
5
+ # Disallow: /
@@ -4,5 +4,5 @@ Fabricator :post do
4
4
  end
5
5
 
6
6
  Fabricator :post_with_categories, :from => :post do
7
- categories!(:count => 2) { |post, i| Fabricate(:category, :posts => [post]) }
7
+ categories!(:count => 2) { |post, i| Fabricate(:category) }
8
8
  end
@@ -5,5 +5,5 @@ Fabricator :profile do
5
5
  end
6
6
 
7
7
  Fabricator :profile_with_tags, :from => :profile do
8
- tags!(:count => 3) { |profile, i| Fabricate :tag }
8
+ tags!(:count => 3) { |profile, i| Fabricate(:tag) }
9
9
  end
@@ -4,7 +4,7 @@ Fabricator :user do
4
4
  end
5
5
 
6
6
  Fabricator :user_with_profile, :from => :user do
7
- profile! { Fabricate :profile }
7
+ profile!
8
8
  end
9
9
 
10
10
  Fabricator :user_with_profile_and_tags, :from => :user do
@@ -9,7 +9,7 @@ describe Puffer::Resource do
9
9
  @mock_category = mock_model Category, :id => 42
10
10
 
11
11
  get admin_category_path(@category)
12
- resource = Puffer::Resource.new request.params.merge(:controller => 'admin/categories', :action => 'show'), request
12
+ resource = Puffer::Resource.new request.params.merge(:controller => 'admin/categories', :action => 'show'), controller
13
13
 
14
14
  resource.collection_path.should == admin_categories_path
15
15
  resource.member_path.should == admin_category_path(@category)
@@ -24,7 +24,7 @@ describe Puffer::Resource do
24
24
  @mock_news = mock_model News, :id => 42
25
25
 
26
26
  get admin_news_path(@news)
27
- resource = Puffer::Resource.new request.params.merge(:controller => 'admin/news', :action => 'show'), request
27
+ resource = Puffer::Resource.new request.params.merge(:controller => 'admin/news', :action => 'show'), controller
28
28
 
29
29
  resource.collection_path.should == admin_news_index_path
30
30
  resource.member_path.should == admin_news_path(@news)
@@ -40,7 +40,7 @@ describe Puffer::Resource do
40
40
  @mock_category = mock_model Category, :id => 42
41
41
 
42
42
  get admin_post_category_path(@post, @category)
43
- resource = Puffer::Resource.new request.params.merge(:controller => 'admin/categories', :action => 'show'), request
43
+ resource = Puffer::Resource.new request.params.merge(:controller => 'admin/categories', :action => 'show'), controller
44
44
 
45
45
  resource.collection_path.should == admin_post_categories_path(@post)
46
46
  resource.member_path.should == admin_post_category_path(@post, @category)
@@ -55,7 +55,7 @@ describe Puffer::Resource do
55
55
  @profile = @user.profile
56
56
 
57
57
  get admin_user_profile_path(@user)
58
- resource = Puffer::Resource.new request.params.merge(:controller => 'admin/profiles', :action => 'show'), request
58
+ resource = Puffer::Resource.new request.params.merge(:controller => 'admin/profiles', :action => 'show'), controller
59
59
 
60
60
  resource.collection_path.should == admin_user_profile_path(@user)
61
61
  resource.member_path.should == admin_user_profile_path(@user)
@@ -69,7 +69,7 @@ describe Puffer::Resource do
69
69
  @mock_tag = mock_model Tag, :id => 42
70
70
 
71
71
  get admin_user_profile_tag_path(@user, @tag)
72
- resource = Puffer::Resource.new request.params.merge(:controller => 'admin/tags', :action => 'show'), request
72
+ resource = Puffer::Resource.new request.params.merge(:controller => 'admin/tags', :action => 'show'), controller
73
73
 
74
74
  resource.collection_path.should == admin_user_profile_tags_path(@user)
75
75
  resource.member_path.should == admin_user_profile_tag_path(@user, @tag)
@@ -65,165 +65,114 @@ describe Puffer::Resource do
65
65
 
66
66
  describe "#collection" do
67
67
 
68
- before :all do
68
+ before do
69
69
  @post = Fabricate :post_with_categories
70
- @category = Fabricate :category
71
70
  @user = Fabricate :user_with_profile_and_tags
72
71
  end
73
72
 
74
73
  it "no parent" do
75
74
  resource = Puffer::Resource.new default_params
76
-
77
- resource.collection.should == Category.limit(30).all
75
+ resource.collection.should == Category.limit(25).all
78
76
  end
79
77
 
80
78
  it "plural parent" do
81
- resource = Puffer::Resource.new default_params.merge(:ancestors => [:posts], :post_id => 42)
82
-
83
- Post.stub(:find).with(42) {@post}
84
- resource.collection.should == @post.categories.limit(30).all
79
+ resource = Puffer::Resource.new default_params.merge(:ancestors => [:posts], :post_id => @post.id)
80
+ resource.collection.should == @post.categories.limit(25).all
85
81
  end
86
82
 
87
83
  it "singular parent" do
88
- resource = Puffer::Resource.new default_params.merge(:controller => 'admin/tags', :ancestors => [:users, :profile], :user_id => 42)
89
-
90
- User.stub(:find).with(42) {@user}
91
- resource.collection.should == @user.profile.tags.limit(30).all
84
+ resource = Puffer::Resource.new default_params.merge(:controller => 'admin/tags', :ancestors => [:users, :profile], :user_id => @user.id)
85
+ resource.collection.should == @user.profile.tags.limit(25).all
92
86
  end
93
87
 
94
88
  end
95
89
 
96
90
  describe "#member" do
97
91
 
98
- before :all do
92
+ before do
99
93
  @post = Fabricate :post_with_categories
100
94
  @category = Fabricate :category
101
95
  @user = Fabricate :user_with_profile_and_tags
102
96
  end
103
97
 
104
98
  it "no parent" do
105
- resource = Puffer::Resource.new default_params.merge(:id => 42)
106
-
107
- Category.stub(:find).with(42) {@category}
99
+ resource = Puffer::Resource.new default_params.merge(:id => @category.id)
108
100
  resource.member.should == @category
109
101
  end
110
102
 
111
103
  it "plural parent" do
112
- resource = Puffer::Resource.new default_params.merge(:ancestors => [:posts], :post_id => 42, :id => 37)
113
-
114
- @categories = @post.categories
115
-
116
- Post.stub(:find).with(42) {@post}
117
- @categories.stub(:find).with(37) {@category}
118
- resource.member.should == @category
104
+ resource = Puffer::Resource.new default_params.merge(:ancestors => [:posts], :post_id => @post.id, :id => @post.categories.first.id)
105
+ resource.member.should == @post.categories.first
119
106
  end
120
107
 
121
108
  it "singular" do
122
- resource = Puffer::Resource.new default_params.merge(:controller => 'admin/profiles', :plural => false, :ancestors => [:users], :user_id => 42)
123
-
124
- @profile = @user.profile
125
-
126
- User.stub(:find).with(42) {@user}
127
- @user.stub(:profile) {@profile}
128
-
129
- resource.member.should == @profile
109
+ resource = Puffer::Resource.new default_params.merge(:controller => 'admin/profiles', :plural => false, :ancestors => [:users], :user_id => @user.id)
110
+ resource.member.should == @user.profile
130
111
  end
131
112
 
132
113
  it "singular parent" do
133
- resource = Puffer::Resource.new default_params.merge(:controller => 'admin/tags', :ancestors => [:users, :profile], :user_id => 42, :id => 37)
134
-
135
- @profile = @user.profile
136
- @tag = @profile.tags.first
137
-
138
- User.stub(:find).with(42) {@user}
139
- @user.stub(:profile) {@profile}
140
- @profile.tags.stub(:find).with(37) {@tag}
141
-
142
- resource.member.should == @tag
114
+ resource = Puffer::Resource.new default_params.merge(:controller => 'admin/tags', :ancestors => [:users, :profile], :user_id => @user.id, :id => @user.profile.tags.first.id)
115
+ resource.member.should == @user.profile.tags.first
143
116
  end
144
117
 
145
118
  end
146
119
 
147
120
  describe "#new_member" do
148
121
 
149
- before :all do
122
+ before do
150
123
  @post = Fabricate :post_with_categories
151
- @category = Fabricate :category
152
124
  @user = Fabricate :user_with_profile_and_tags
153
125
  end
154
126
 
155
127
  it "no parent" do
156
128
  resource = Puffer::Resource.new default_params
157
-
158
- Category.stub(:new) {@category}
159
-
160
- resource.new_member.should == @category
129
+ resource.new_member.should be_new_record
130
+ resource.new_member.should be_instance_of(Category)
161
131
  end
162
132
 
163
133
  it "no parent with attributes" do
164
134
  resource = Puffer::Resource.new default_params.merge(:category => {:title => 'my new title'})
165
-
135
+ resource.new_member.should be_new_record
136
+ resource.new_member.should be_instance_of(Category)
166
137
  resource.new_member.title.should == 'my new title'
167
138
  end
168
139
 
169
140
  it "plural parent" do
170
- resource = Puffer::Resource.new default_params.merge(:ancestors => [:posts], :post_id => 42)
171
-
172
- @categories = @post.categories
173
- Post.stub(:find).with(42) {@post}
174
- @categories.stub(:new) {@category}
175
-
176
- resource.new_member.should == @category
141
+ resource = Puffer::Resource.new default_params.merge(:ancestors => [:posts], :post_id => @post.id)
142
+ resource.new_member.should be_new_record
143
+ resource.new_member.should be_instance_of(Category)
177
144
  end
178
145
 
179
146
  it "plural parent with attributes" do
180
- resource = Puffer::Resource.new default_params.merge(:ancestors => [:posts], :post_id => 42, :category => {:title => 'my new title'})
181
-
182
- @categories = @post.categories
183
- Post.stub(:find).with(42) {@post}
184
-
147
+ resource = Puffer::Resource.new default_params.merge(:ancestors => [:posts], :post_id => @post.id, :category => {:title => 'my new title'})
148
+ resource.new_member.should be_new_record
149
+ resource.new_member.should be_instance_of(Category)
185
150
  resource.new_member.title.should == 'my new title'
186
151
  end
187
152
 
188
153
  it "singular" do
189
- resource = Puffer::Resource.new default_params.merge(:controller => 'admin/profiles', :plural => false, :ancestors => [:users], :user_id => 42)
190
-
191
- @profile = @user.profile
192
- User.stub(:find).with(42) {@user}
193
- @user.stub(:build_profile) {@profile}
194
-
195
- resource.new_member.should == @profile
154
+ resource = Puffer::Resource.new default_params.merge(:controller => 'admin/profiles', :plural => false, :ancestors => [:users], :user_id => @user.id)
155
+ resource.new_member.should be_new_record
156
+ resource.new_member.should be_instance_of(Profile)
196
157
  end
197
158
 
198
159
  it "singular with attributes" do
199
- resource = Puffer::Resource.new default_params.merge(:controller => 'admin/profiles', :plural => false, :ancestors => [:users], :user_id => 42, :profile => {:name => 'my new name'})
200
-
201
- @profile = @user.profile
202
- User.stub(:find).with(42) {@user}
203
-
160
+ resource = Puffer::Resource.new default_params.merge(:controller => 'admin/profiles', :plural => false, :ancestors => [:users], :user_id => @user.id, :profile => {:name => 'my new name'})
161
+ resource.new_member.should be_new_record
162
+ resource.new_member.should be_instance_of(Profile)
204
163
  resource.new_member.name.should == 'my new name'
205
164
  end
206
165
 
207
166
  it "singular parent" do
208
- resource = Puffer::Resource.new default_params.merge(:controller => 'admin/tags', :ancestors => [:users, :profile], :user_id => 42)
209
-
210
- @profile = @user.profile
211
- @tag = @profile.tags.first
212
- User.stub(:find).with(42) {@user}
213
- @user.stub(:profile) {@profile}
214
- @profile.tags.stub(:new) {@tag}
215
-
216
- resource.new_member.should == @tag
167
+ resource = Puffer::Resource.new default_params.merge(:controller => 'admin/tags', :ancestors => [:users, :profile], :user_id => @user.id)
168
+ resource.new_member.should be_new_record
169
+ resource.new_member.should be_instance_of(Tag)
217
170
  end
218
171
 
219
172
  it "singular parent with attributes" do
220
- resource = Puffer::Resource.new default_params.merge(:controller => 'admin/tags', :ancestors => [:users, :profile], :user_id => 42, :tag => {:name => 'my new name'})
221
-
222
- @profile = @user.profile
223
- @tag = @profile.tags.first
224
- User.stub(:find).with(42) {@user}
225
- @user.stub(:profile) {@profile}
226
-
173
+ resource = Puffer::Resource.new default_params.merge(:controller => 'admin/tags', :ancestors => [:users, :profile], :user_id => @user.id, :tag => {:name => 'my new name'})
174
+ resource.new_member.should be_new_record
175
+ resource.new_member.should be_instance_of(Tag)
227
176
  resource.new_member.name.should == 'my new name'
228
177
  end
229
178