neo4j_ancestry 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +23 -0
  3. data/.travis.yml +11 -0
  4. data/CHANGELOG.md +5 -0
  5. data/Gemfile +7 -0
  6. data/Guardfile +24 -0
  7. data/MIT-LICENSE +22 -0
  8. data/README.md +73 -0
  9. data/Rakefile +15 -0
  10. data/config/initializers/001_neo4j.rb +39 -0
  11. data/db/migrate/20131102235736_create_links.rb +10 -0
  12. data/lib/models/neo4j_ancestry/active_record_additions.rb +111 -0
  13. data/lib/models/neo4j_ancestry/link.rb +28 -0
  14. data/lib/models/neo4j_ancestry/node_instance_methods.rb +93 -0
  15. data/lib/neo4j_ancestry.rb +11 -0
  16. data/lib/neo4j_ancestry/engine.rb +13 -0
  17. data/lib/neo4j_ancestry/railtie.rb +22 -0
  18. data/lib/neo4j_ancestry/version.rb +3 -0
  19. data/lib/tasks/db_test_prepare.rake +26 -0
  20. data/lib/tasks/setup.rake +24 -0
  21. data/lib/tasks/start.rake +12 -0
  22. data/lib/tasks/stop.rake +12 -0
  23. data/neo4j_ancestry.gemspec +33 -0
  24. data/rails3.2.Gemfile +7 -0
  25. data/rails4.Gemfile +7 -0
  26. data/script/rails +8 -0
  27. data/spec/dummy-rails3/.gitignore +15 -0
  28. data/spec/dummy-rails3/Gemfile +40 -0
  29. data/spec/dummy-rails3/README.rdoc +261 -0
  30. data/spec/dummy-rails3/Rakefile +7 -0
  31. data/spec/dummy-rails3/app/assets/images/rails.png +0 -0
  32. data/spec/dummy-rails3/app/assets/javascripts/application.js +15 -0
  33. data/spec/dummy-rails3/app/assets/stylesheets/application.css +13 -0
  34. data/spec/dummy-rails3/app/controllers/application_controller.rb +3 -0
  35. data/spec/dummy-rails3/app/helpers/application_helper.rb +2 -0
  36. data/spec/dummy-rails3/app/mailers/.gitkeep +0 -0
  37. data/spec/dummy-rails3/app/views/layouts/application.html.erb +14 -0
  38. data/spec/dummy-rails3/config.ru +4 -0
  39. data/spec/dummy-rails3/config/application.rb +62 -0
  40. data/spec/dummy-rails3/config/boot.rb +6 -0
  41. data/spec/dummy-rails3/config/database.yml +25 -0
  42. data/spec/dummy-rails3/config/environment.rb +5 -0
  43. data/spec/dummy-rails3/config/environments/development.rb +37 -0
  44. data/spec/dummy-rails3/config/environments/production.rb +67 -0
  45. data/spec/dummy-rails3/config/environments/test.rb +37 -0
  46. data/spec/dummy-rails3/config/initializers/backtrace_silencers.rb +7 -0
  47. data/spec/dummy-rails3/config/initializers/inflections.rb +15 -0
  48. data/spec/dummy-rails3/config/initializers/mime_types.rb +5 -0
  49. data/spec/dummy-rails3/config/initializers/secret_token.rb +7 -0
  50. data/spec/dummy-rails3/config/initializers/session_store.rb +8 -0
  51. data/spec/dummy-rails3/config/initializers/wrap_parameters.rb +14 -0
  52. data/spec/dummy-rails3/config/locales/en.yml +5 -0
  53. data/spec/dummy-rails3/config/routes.rb +58 -0
  54. data/spec/dummy-rails3/db/schema.rb +35 -0
  55. data/spec/dummy-rails3/db/seeds.rb +7 -0
  56. data/spec/dummy-rails3/lib/assets/.gitkeep +0 -0
  57. data/spec/dummy-rails3/lib/tasks/.gitkeep +0 -0
  58. data/spec/dummy-rails3/log/.gitkeep +0 -0
  59. data/spec/dummy-rails3/public/404.html +26 -0
  60. data/spec/dummy-rails3/public/422.html +26 -0
  61. data/spec/dummy-rails3/public/500.html +25 -0
  62. data/spec/dummy-rails3/public/favicon.ico +0 -0
  63. data/spec/dummy-rails3/public/index.html +241 -0
  64. data/spec/dummy-rails3/public/robots.txt +5 -0
  65. data/spec/dummy-rails3/rails3.2.Gemfile.lock +131 -0
  66. data/spec/dummy-rails3/script/rails +6 -0
  67. data/spec/dummy-rails3/vendor/assets/javascripts/.gitkeep +0 -0
  68. data/spec/dummy-rails3/vendor/assets/stylesheets/.gitkeep +0 -0
  69. data/spec/dummy-rails3/vendor/plugins/.gitkeep +0 -0
  70. data/spec/dummy-rails4/.gitignore +16 -0
  71. data/spec/dummy-rails4/Gemfile +47 -0
  72. data/spec/dummy-rails4/README.rdoc +28 -0
  73. data/spec/dummy-rails4/Rakefile +6 -0
  74. data/spec/dummy-rails4/app/assets/images/.keep +0 -0
  75. data/spec/dummy-rails4/app/assets/javascripts/application.js +16 -0
  76. data/spec/dummy-rails4/app/assets/stylesheets/application.css +13 -0
  77. data/spec/dummy-rails4/app/controllers/application_controller.rb +5 -0
  78. data/spec/dummy-rails4/app/controllers/concerns/.keep +0 -0
  79. data/spec/dummy-rails4/app/helpers/application_helper.rb +2 -0
  80. data/spec/dummy-rails4/app/mailers/.keep +0 -0
  81. data/spec/dummy-rails4/app/models/.keep +0 -0
  82. data/spec/dummy-rails4/app/models/concerns/.keep +0 -0
  83. data/spec/dummy-rails4/app/models/group.rb +10 -0
  84. data/spec/dummy-rails4/app/models/user.rb +3 -0
  85. data/spec/dummy-rails4/app/views/layouts/application.html.erb +14 -0
  86. data/spec/dummy-rails4/bin/bundle +3 -0
  87. data/spec/dummy-rails4/bin/rails +4 -0
  88. data/spec/dummy-rails4/bin/rake +4 -0
  89. data/spec/dummy-rails4/config.ru +4 -0
  90. data/spec/dummy-rails4/config/application.rb +23 -0
  91. data/spec/dummy-rails4/config/boot.rb +4 -0
  92. data/spec/dummy-rails4/config/database.yml +25 -0
  93. data/spec/dummy-rails4/config/environment.rb +5 -0
  94. data/spec/dummy-rails4/config/environments/development.rb +29 -0
  95. data/spec/dummy-rails4/config/environments/production.rb +80 -0
  96. data/spec/dummy-rails4/config/environments/test.rb +36 -0
  97. data/spec/dummy-rails4/config/initializers/backtrace_silencers.rb +7 -0
  98. data/spec/dummy-rails4/config/initializers/filter_parameter_logging.rb +4 -0
  99. data/spec/dummy-rails4/config/initializers/inflections.rb +16 -0
  100. data/spec/dummy-rails4/config/initializers/mime_types.rb +5 -0
  101. data/spec/dummy-rails4/config/initializers/secret_token.rb +12 -0
  102. data/spec/dummy-rails4/config/initializers/session_store.rb +3 -0
  103. data/spec/dummy-rails4/config/initializers/wrap_parameters.rb +14 -0
  104. data/spec/dummy-rails4/config/locales/en.yml +23 -0
  105. data/spec/dummy-rails4/config/routes.rb +57 -0
  106. data/spec/dummy-rails4/db/migrate/20131102131519_create_users.rb +9 -0
  107. data/spec/dummy-rails4/db/migrate/20131102131531_create_groups.rb +9 -0
  108. data/spec/dummy-rails4/db/migrate/20131103162013_create_links.neo4j_ancestry.rb +11 -0
  109. data/spec/dummy-rails4/db/schema.rb +35 -0
  110. data/spec/dummy-rails4/db/seeds.rb +7 -0
  111. data/spec/dummy-rails4/lib/assets/.keep +0 -0
  112. data/spec/dummy-rails4/lib/tasks/.keep +0 -0
  113. data/spec/dummy-rails4/log/.keep +0 -0
  114. data/spec/dummy-rails4/public/404.html +58 -0
  115. data/spec/dummy-rails4/public/422.html +58 -0
  116. data/spec/dummy-rails4/public/500.html +57 -0
  117. data/spec/dummy-rails4/public/favicon.ico +0 -0
  118. data/spec/dummy-rails4/public/robots.txt +5 -0
  119. data/spec/dummy-rails4/vendor/assets/javascripts/.keep +0 -0
  120. data/spec/dummy-rails4/vendor/assets/stylesheets/.keep +0 -0
  121. data/spec/models/neo4j_ancestry/active_record_additions_spec.rb +78 -0
  122. data/spec/models/neo4j_ancestry/link_spec.rb +12 -0
  123. data/spec/spec_helper.rb +26 -0
  124. data/spec/support/schema.rb +42 -0
  125. metadata +409 -0
@@ -0,0 +1,4 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Configure sensitive parameters which will be filtered from the log file.
4
+ Rails.application.config.filter_parameters += [:password]
@@ -0,0 +1,16 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new inflection rules using the following format. Inflections
4
+ # are locale specific, and you may define rules for as many different
5
+ # locales as you wish. All of these examples are active by default:
6
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
7
+ # inflect.plural /^(ox)$/i, '\1en'
8
+ # inflect.singular /^(ox)en/i, '\1'
9
+ # inflect.irregular 'person', 'people'
10
+ # inflect.uncountable %w( fish sheep )
11
+ # end
12
+
13
+ # These inflection rules are supported but not enabled by default:
14
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
15
+ # inflect.acronym 'RESTful'
16
+ # end
@@ -0,0 +1,5 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new mime types for use in respond_to blocks:
4
+ # Mime::Type.register "text/richtext", :rtf
5
+ # Mime::Type.register_alias "text/html", :iphone
@@ -0,0 +1,12 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key is used for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+
6
+ # Make sure the secret is at least 30 characters and all random,
7
+ # no regular words or you'll be exposed to dictionary attacks.
8
+ # You can use `rake secret` to generate a secure secret key.
9
+
10
+ # Make sure your secret_key_base is kept private
11
+ # if you're sharing your code publicly.
12
+ DummyRails4::Application.config.secret_key_base = 'e43aee11ee9374e5d532a908c508de1c4a7cba1a7250b1eba5a198599ebd183219b12ec3fe987198b85a34fe486d2ddfb8aa8556d117bc5804aff6e5c1bac672'
@@ -0,0 +1,3 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ DummyRails4::Application.config.session_store :cookie_store, key: '_dummy-rails4_session'
@@ -0,0 +1,14 @@
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
+ ActiveSupport.on_load(:action_controller) do
8
+ wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
9
+ end
10
+
11
+ # To enable root element in JSON for ActiveRecord objects.
12
+ # ActiveSupport.on_load(:active_record) do
13
+ # self.include_root_in_json = true
14
+ # end
@@ -0,0 +1,23 @@
1
+ # Files in the config/locales directory are used for internationalization
2
+ # and are automatically loaded by Rails. If you want to use locales other
3
+ # than English, add the necessary files in this directory.
4
+ #
5
+ # To use the locales, use `I18n.t`:
6
+ #
7
+ # I18n.t 'hello'
8
+ #
9
+ # In views, this is aliased to just `t`:
10
+ #
11
+ # <%= t('hello') %>
12
+ #
13
+ # To use a different locale, set it with `I18n.locale`:
14
+ #
15
+ # I18n.locale = :es
16
+ #
17
+ # This would use the information in config/locales/es.yml.
18
+ #
19
+ # To learn more, please read the Rails Internationalization guide
20
+ # available at http://guides.rubyonrails.org/i18n.html.
21
+
22
+ en:
23
+ hello: "Hello world"
@@ -0,0 +1,57 @@
1
+ DummyRails4::Application.routes.draw do
2
+
3
+ # The priority is based upon order of creation: first created -> highest priority.
4
+ # See how all your routes lay out with "rake routes".
5
+
6
+ # You can have the root of your site routed with "root"
7
+ # root 'welcome#index'
8
+
9
+ # Example of regular route:
10
+ # get 'products/:id' => 'catalog#view'
11
+
12
+ # Example of named route that can be invoked with purchase_url(id: product.id)
13
+ # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
14
+
15
+ # Example resource route (maps HTTP verbs to controller actions automatically):
16
+ # resources :products
17
+
18
+ # Example resource route with options:
19
+ # resources :products do
20
+ # member do
21
+ # get 'short'
22
+ # post 'toggle'
23
+ # end
24
+ #
25
+ # collection do
26
+ # get 'sold'
27
+ # end
28
+ # end
29
+
30
+ # Example resource route with sub-resources:
31
+ # resources :products do
32
+ # resources :comments, :sales
33
+ # resource :seller
34
+ # end
35
+
36
+ # Example resource route with more complex sub-resources:
37
+ # resources :products do
38
+ # resources :comments
39
+ # resources :sales do
40
+ # get 'recent', on: :collection
41
+ # end
42
+ # end
43
+
44
+ # Example resource route with concerns:
45
+ # concern :toggleable do
46
+ # post 'toggle'
47
+ # end
48
+ # resources :posts, concerns: :toggleable
49
+ # resources :photos, concerns: :toggleable
50
+
51
+ # Example resource route within a namespace:
52
+ # namespace :admin do
53
+ # # Directs /admin/products/* to Admin::ProductsController
54
+ # # (app/controllers/admin/products_controller.rb)
55
+ # resources :products
56
+ # end
57
+ end
@@ -0,0 +1,9 @@
1
+ class CreateUsers < ActiveRecord::Migration
2
+ def change
3
+ create_table :users do |t|
4
+ t.string :name
5
+
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class CreateGroups < ActiveRecord::Migration
2
+ def change
3
+ create_table :groups do |t|
4
+ t.string :name
5
+
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ # This migration comes from neo4j_ancestry (originally 20131102235736)
2
+ class CreateLinks < ActiveRecord::Migration
3
+ def change
4
+ create_table :neo4j_ancestry_links do |t|
5
+ t.integer :parent_id
6
+ t.string :parent_type
7
+ t.integer :child_id
8
+ t.string :child_type
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,35 @@
1
+ # encoding: UTF-8
2
+ # This file is auto-generated from the current state of the database. Instead
3
+ # of editing this file, please use the migrations feature of Active Record to
4
+ # incrementally modify your database, and then regenerate this schema definition.
5
+ #
6
+ # Note that this schema.rb definition is the authoritative source for your
7
+ # database schema. If you need to create the application database on another
8
+ # system, you should be using db:schema:load, not running all the migrations
9
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
11
+ #
12
+ # It's strongly recommended that you check this file into your version control system.
13
+
14
+ ActiveRecord::Schema.define(version: 20131103162013) do
15
+
16
+ create_table "groups", force: true do |t|
17
+ t.string "name"
18
+ t.datetime "created_at"
19
+ t.datetime "updated_at"
20
+ end
21
+
22
+ create_table "neo4j_ancestry_links", force: true do |t|
23
+ t.integer "parent_id"
24
+ t.string "parent_type"
25
+ t.integer "child_id"
26
+ t.string "child_type"
27
+ end
28
+
29
+ create_table "users", force: true do |t|
30
+ t.string "name"
31
+ t.datetime "created_at"
32
+ t.datetime "updated_at"
33
+ end
34
+
35
+ end
@@ -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)
File without changes
File without changes
File without changes
@@ -0,0 +1,58 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/404.html -->
52
+ <div class="dialog">
53
+ <h1>The page you were looking for doesn't exist.</h1>
54
+ <p>You may have mistyped the address or the page may have moved.</p>
55
+ </div>
56
+ <p>If you are the application owner check the logs for more information.</p>
57
+ </body>
58
+ </html>
@@ -0,0 +1,58 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/422.html -->
52
+ <div class="dialog">
53
+ <h1>The change you wanted was rejected.</h1>
54
+ <p>Maybe you tried to change something you didn't have access to.</p>
55
+ </div>
56
+ <p>If you are the application owner check the logs for more information.</p>
57
+ </body>
58
+ </html>
@@ -0,0 +1,57 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/500.html -->
52
+ <div class="dialog">
53
+ <h1>We're sorry, but something went wrong.</h1>
54
+ </div>
55
+ <p>If you are the application owner check the logs for more information.</p>
56
+ </body>
57
+ </html>
File without changes
@@ -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: /
@@ -0,0 +1,78 @@
1
+ require 'spec_helper'
2
+
3
+ describe Neo4jAncestry::ActiveRecordAdditions do
4
+
5
+ specify "additions should be available in ActiveRecord::Base" do
6
+ ActiveRecord::Base.should respond_to :has_neo4j_ancestry
7
+ ActiveRecord::Base.should respond_to :attributes_to_copy_to_neo4j
8
+ end
9
+
10
+ describe "model that has_neo4j_ancestry (here: Group)" do
11
+ before do
12
+ # Here the Group model is used as an example.
13
+ #
14
+ # This model
15
+ # has_neo4j_ancestry parent_class_names: %w(Group), child_class_names: %w(Group User)
16
+ #
17
+ # as can be seen in
18
+ # spec/dummy-rails4/app/models/group.rb
19
+ #
20
+ @group ||= Group.new
21
+ end
22
+ subject { @group }
23
+
24
+ # direct links stored as ActiveRecord associations
25
+ it { should respond_to :links_as_parent }
26
+ it { should respond_to :links_as_child }
27
+
28
+ # parent class names: ["Group"]
29
+ it { should respond_to :parent_groups }
30
+ it { should respond_to :links_as_child_for_groups }
31
+
32
+ # child class names: ["Group", "User"]
33
+ it { should respond_to :child_groups }
34
+ it { should respond_to :child_users }
35
+ it { should respond_to :links_as_parent_for_groups }
36
+ it { should respond_to :links_as_parent_for_users }
37
+ end
38
+
39
+ describe "(simple traversal methods)" do
40
+ before do
41
+ @group = Group.create(name: "Group")
42
+ @parent1 = @group.parent_groups.create(name: "Parent Group 1")
43
+ @parent2 = @group.parent_groups.create(name: "Parent Group 2")
44
+ @parents = [@parent1, @parent2]
45
+ @ancestor1 = @parent1.parent_groups.create(name: "Ancestor Group 1")
46
+ @ancestors = [@parent1, @ancestor1, @parent2]
47
+ @child1 = @group.child_groups.create(name: "Child Group")
48
+ @child2 = @group.child_users.create(name: "Child User")
49
+ @children = [@child1, @child2]
50
+ @descendant1 = @child1.child_users.create(name: "Descendant User 1")
51
+ @descendants = [@child1, @descendant1, @child2]
52
+ @sibling1 = @parent1.child_groups.create(name: "Sibling Group")
53
+ @sibling2 = @parent2.child_users.create(name: "Child User 1")
54
+ @siblings = [@sibling1, @sibling2]
55
+ end
56
+ describe "#parents" do
57
+ subject { @group.parents }
58
+ it { should == @parents }
59
+ end
60
+ describe "#children" do
61
+ subject { @group.children }
62
+ it { should == @children }
63
+ end
64
+ describe "#ancestors" do
65
+ subject { @group.ancestors }
66
+ it { should == @ancestors }
67
+ end
68
+ describe "#descendants" do
69
+ subject { @group.descendants }
70
+ it { should == @descendants }
71
+ end
72
+ describe "#siblings" do
73
+ subject { @group.siblings }
74
+ it { should == @siblings }
75
+ end
76
+ end
77
+
78
+ end