activerecord_sortable 0.0.1 → 0.0.3

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.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/lib/activerecord_sortable/association_reflection.rb +1 -1
  3. data/lib/activerecord_sortable/collection_proxy.rb +19 -0
  4. data/lib/activerecord_sortable/has_many_association.rb +0 -1
  5. data/lib/activerecord_sortable/through_reflection.rb +16 -0
  6. data/lib/activerecord_sortable/version.rb +1 -1
  7. data/lib/activerecord_sortable.rb +2 -1
  8. data/spec/dummy/README.rdoc +28 -0
  9. data/spec/dummy/Rakefile +6 -0
  10. data/spec/dummy/app/assets/javascripts/application.js +16 -0
  11. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  12. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  13. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  14. data/spec/dummy/app/models/post.rb +7 -0
  15. data/spec/dummy/app/models/post_tag.rb +6 -0
  16. data/spec/dummy/app/models/tag.rb +6 -0
  17. data/spec/dummy/app/models/user.rb +7 -0
  18. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  19. data/spec/dummy/bin/bundle +3 -0
  20. data/spec/dummy/bin/rails +4 -0
  21. data/spec/dummy/bin/rake +4 -0
  22. data/spec/dummy/config/application.rb +23 -0
  23. data/spec/dummy/config/boot.rb +4 -0
  24. data/spec/dummy/config/database.yml +25 -0
  25. data/spec/dummy/config/environment.rb +5 -0
  26. data/spec/dummy/config/environments/development.rb +37 -0
  27. data/spec/dummy/config/environments/production.rb +78 -0
  28. data/spec/dummy/config/environments/test.rb +39 -0
  29. data/spec/dummy/config/initializers/assets.rb +8 -0
  30. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  31. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  32. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  33. data/spec/dummy/config/initializers/inflections.rb +16 -0
  34. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  35. data/spec/dummy/config/initializers/session_store.rb +3 -0
  36. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  37. data/spec/dummy/config/locales/en.yml +23 -0
  38. data/spec/dummy/config/routes.rb +56 -0
  39. data/spec/dummy/config/secrets.yml +22 -0
  40. data/spec/dummy/config.ru +4 -0
  41. data/spec/dummy/db/development.sqlite3 +0 -0
  42. data/spec/dummy/db/migrate/20141007145452_create_users.rb +10 -0
  43. data/spec/dummy/db/migrate/20141007150446_create_posts.rb +10 -0
  44. data/spec/dummy/db/migrate/20141007184100_add_position_to_posts.rb +13 -0
  45. data/spec/dummy/db/migrate/20141007184101_create_tags.rb +9 -0
  46. data/spec/dummy/db/migrate/20141007184102_create_post_tags.rb +10 -0
  47. data/spec/dummy/db/migrate/20141008135500_add_position_to_post_tags.rb +11 -0
  48. data/spec/dummy/db/schema.rb +51 -0
  49. data/spec/dummy/db/seeds.rb +7 -0
  50. data/spec/dummy/log/development.log +3386 -0
  51. data/spec/dummy/public/404.html +67 -0
  52. data/spec/dummy/public/422.html +67 -0
  53. data/spec/dummy/public/500.html +66 -0
  54. data/spec/dummy/public/favicon.ico +0 -0
  55. data/spec/dummy/public/robots.txt +5 -0
  56. data/spec/models/association_reflection_spec.rb +57 -0
  57. data/spec/models/association_relation_spec.rb +89 -0
  58. data/spec/models/has_many_association_spec.rb +53 -0
  59. data/spec/spec_helper.rb +25 -0
  60. metadata +109 -4
  61. data/lib/activerecord_sortable/association_relation.rb +0 -17
@@ -0,0 +1,10 @@
1
+ class CreatePosts < ActiveRecord::Migration
2
+ def change
3
+ create_table :posts do |t|
4
+ t.references :user, index: true
5
+ t.string :title
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,13 @@
1
+ class AddPositionToPosts < ActiveRecord::Migration
2
+
3
+ def self.up
4
+ add_column :posts, :position, :integer
5
+ add_column :posts, :user_position, :integer
6
+ end
7
+
8
+ def self.down
9
+ remove_column :posts, :position
10
+ remove_column :posts, :user_position
11
+ end
12
+
13
+ end
@@ -0,0 +1,9 @@
1
+ class CreateTags < ActiveRecord::Migration
2
+ def change
3
+ create_table :tags do |t|
4
+ t.string :name
5
+
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,10 @@
1
+ class CreatePostTags < ActiveRecord::Migration
2
+ def change
3
+ create_table :post_tags do |t|
4
+ t.references :post, index: true
5
+ t.references :tag, index: true
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,11 @@
1
+ class AddPositionToPostTags < ActiveRecord::Migration
2
+
3
+ def self.up
4
+ add_column :post_tags, :position, :integer
5
+ end
6
+
7
+ def self.down
8
+ remove_column :post_tags, :position
9
+ end
10
+
11
+ end
@@ -0,0 +1,51 @@
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: 20141008135500) do
15
+
16
+ create_table "post_tags", force: true do |t|
17
+ t.integer "post_id"
18
+ t.integer "tag_id"
19
+ t.datetime "created_at"
20
+ t.datetime "updated_at"
21
+ t.integer "position"
22
+ end
23
+
24
+ add_index "post_tags", ["post_id"], name: "index_post_tags_on_post_id"
25
+ add_index "post_tags", ["tag_id"], name: "index_post_tags_on_tag_id"
26
+
27
+ create_table "posts", force: true do |t|
28
+ t.integer "user_id"
29
+ t.string "title"
30
+ t.datetime "created_at"
31
+ t.datetime "updated_at"
32
+ t.integer "position"
33
+ t.integer "user_position"
34
+ end
35
+
36
+ add_index "posts", ["user_id"], name: "index_posts_on_user_id"
37
+
38
+ create_table "tags", force: true do |t|
39
+ t.string "name"
40
+ t.datetime "created_at"
41
+ t.datetime "updated_at"
42
+ end
43
+
44
+ create_table "users", force: true do |t|
45
+ t.string "name"
46
+ t.integer "age"
47
+ t.datetime "created_at"
48
+ t.datetime "updated_at"
49
+ end
50
+
51
+ 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)