controlled_versioning 0.6.3 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +8 -8
  2. data/MIT-LICENSE +1 -1
  3. data/Rakefile +0 -6
  4. data/app/assets/javascripts/controlled_versioning/application.js +13 -0
  5. data/app/assets/stylesheets/controlled_versioning/application.css +13 -0
  6. data/app/controllers/controlled_versioning/application_controller.rb +4 -0
  7. data/app/helpers/controlled_versioning/application_helper.rb +4 -0
  8. data/app/models/controlled_versioning/version.rb +23 -0
  9. data/app/models/controlled_versioning/version_attribute.rb +8 -0
  10. data/app/models/controlled_versioning/version_child.rb +9 -0
  11. data/app/views/layouts/controlled_versioning/application.html.erb +14 -0
  12. data/lib/controlled_versioning/engine.rb +16 -0
  13. data/lib/controlled_versioning/version_number.rb +1 -1
  14. data/lib/controlled_versioning.rb +2 -0
  15. data/spec/controlled_versioning_spec.rb +316 -0
  16. data/spec/dummy/README.rdoc +28 -0
  17. data/spec/dummy/Rakefile +6 -0
  18. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  19. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  20. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  21. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  22. data/spec/dummy/app/models/child_resource.rb +10 -0
  23. data/spec/dummy/app/models/grand_child_resource.rb +7 -0
  24. data/spec/dummy/app/models/nonversionable_resource.rb +2 -0
  25. data/spec/dummy/app/models/parent_resource.rb +9 -0
  26. data/spec/dummy/app/models/partially_exclusive_versionable_resource.rb +3 -0
  27. data/spec/dummy/app/models/partially_inclusive_versionable_resource.rb +3 -0
  28. data/spec/dummy/app/models/user.rb +3 -0
  29. data/spec/dummy/app/models/versionable_resource.rb +5 -0
  30. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  31. data/spec/dummy/bin/bundle +3 -0
  32. data/spec/dummy/bin/rails +4 -0
  33. data/spec/dummy/bin/rake +4 -0
  34. data/spec/dummy/config/application.rb +30 -0
  35. data/spec/dummy/config/boot.rb +5 -0
  36. data/spec/dummy/config/database.yml +60 -0
  37. data/spec/dummy/config/environment.rb +5 -0
  38. data/spec/dummy/config/environments/development.rb +29 -0
  39. data/spec/dummy/config/environments/production.rb +80 -0
  40. data/spec/dummy/config/environments/test.rb +36 -0
  41. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  42. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  43. data/spec/dummy/config/initializers/inflections.rb +16 -0
  44. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  45. data/spec/dummy/config/initializers/secret_token.rb +12 -0
  46. data/spec/dummy/config/initializers/session_store.rb +3 -0
  47. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  48. data/spec/dummy/config/locales/en.yml +23 -0
  49. data/spec/dummy/config/routes.rb +3 -0
  50. data/spec/dummy/config.ru +4 -0
  51. data/spec/dummy/db/migrate/20140117222800_create_users.rb +11 -0
  52. data/spec/dummy/db/migrate/20140117222808_create_versionable_resources.rb +17 -0
  53. data/spec/dummy/db/migrate/20140117222814_create_partially_inclusive_versionable_resources.rb +17 -0
  54. data/spec/dummy/db/migrate/20140117222815_create_partially_exclusive_versionable_resources.rb +17 -0
  55. data/spec/dummy/db/migrate/20140117222828_create_nonversionable_resources.rb +17 -0
  56. data/spec/dummy/db/migrate/20140117222840_create_parent_resources.rb +17 -0
  57. data/spec/dummy/db/migrate/20140117222841_create_child_resources.rb +19 -0
  58. data/spec/dummy/db/migrate/20140117222842_create_grand_child_resources.rb +19 -0
  59. data/spec/dummy/db/migrate/20140206173607_create_controlled_versioning_versions.controlled_versioning.rb +30 -0
  60. data/spec/dummy/db/migrate/20140206173608_create_controlled_versioning_version_attributes.controlled_versioning.rb +15 -0
  61. data/spec/dummy/db/migrate/20140206173609_create_controlled_versioning_version_children.controlled_versioning.rb +19 -0
  62. data/spec/dummy/db/schema.rb +163 -0
  63. data/spec/dummy/public/404.html +58 -0
  64. data/spec/dummy/public/422.html +58 -0
  65. data/spec/dummy/public/500.html +57 -0
  66. data/spec/dummy/public/favicon.ico +0 -0
  67. data/spec/factories/child_resources.rb +28 -0
  68. data/spec/factories/controlled_versioning_versions.rb +7 -0
  69. data/spec/factories/grand_child_resources.rb +17 -0
  70. data/spec/factories/parent_resources.rb +35 -0
  71. data/spec/factories/partially_exclusive_versionable_resources.rb +14 -0
  72. data/spec/factories/partially_inclusive_versionable_resources.rb +14 -0
  73. data/spec/factories/unversionable_resources.rb +14 -0
  74. data/spec/factories/users.rb +6 -0
  75. data/spec/factories/versionable_resources.rb +14 -0
  76. data/spec/spec_helper.rb +86 -0
  77. metadata +136 -11
  78. data/config/locales/en.yml +0 -4
  79. data/lib/generators/controlled_versioning/install_generator.rb +0 -30
  80. data/lib/generators/templates/create_version_attributes.rb +0 -17
  81. data/lib/generators/templates/create_version_children.rb +0 -20
  82. data/lib/generators/templates/create_versions.rb +0 -36
  83. data/lib/generators/templates/version.rb +0 -19
  84. data/lib/generators/templates/version_attribute.rb +0 -7
  85. data/lib/generators/templates/version_child.rb +0 -8
@@ -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
+ Dummy::Application.config.secret_key_base = '241e57978578cf14f0540d8bac966effbe5284c8bd00298995f5e077fc5a04526066220ec82e3dfe64979277c4324cb498c65d5860cb4d7ba9883017b3fb7966'
@@ -0,0 +1,3 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ Dummy::Application.config.session_store :cookie_store, key: '_dummy_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,3 @@
1
+ Rails.application.routes.draw do
2
+
3
+ end
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run Rails.application
@@ -0,0 +1,11 @@
1
+ class CreateUsers < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :users do |t|
4
+ t.string :name, null: false
5
+ end
6
+ end
7
+
8
+ def self.down
9
+ drop_table :users
10
+ end
11
+ end
@@ -0,0 +1,17 @@
1
+ class CreateVersionableResources < ActiveRecord::Migration
2
+ def change
3
+ create_table :versionable_resources do |t|
4
+ t.boolean :r_boolean
5
+ t.date :r_date
6
+ t.datetime :r_datetime
7
+ t.decimal :r_decimal
8
+ t.float :r_float
9
+ t.integer :r_integer
10
+ t.string :r_string
11
+ t.text :r_text
12
+ t.time :r_time
13
+
14
+ t.timestamps
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ class CreatePartiallyInclusiveVersionableResources < ActiveRecord::Migration
2
+ def change
3
+ create_table :partially_inclusive_versionable_resources do |t|
4
+ t.boolean :r_boolean
5
+ t.date :r_date
6
+ t.datetime :r_datetime
7
+ t.decimal :r_decimal
8
+ t.float :r_float
9
+ t.integer :r_integer
10
+ t.string :r_string
11
+ t.text :r_text
12
+ t.time :r_time
13
+
14
+ t.timestamps
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ class CreatePartiallyExclusiveVersionableResources < ActiveRecord::Migration
2
+ def change
3
+ create_table :partially_exclusive_versionable_resources do |t|
4
+ t.boolean :r_boolean
5
+ t.date :r_date
6
+ t.datetime :r_datetime
7
+ t.decimal :r_decimal
8
+ t.float :r_float
9
+ t.integer :r_integer
10
+ t.string :r_string
11
+ t.text :r_text
12
+ t.time :r_time
13
+
14
+ t.timestamps
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ class CreateNonversionableResources < ActiveRecord::Migration
2
+ def change
3
+ create_table :nonversionable_resources do |t|
4
+ t.boolean :r_boolean
5
+ t.date :r_date
6
+ t.datetime :r_datetime
7
+ t.decimal :r_decimal
8
+ t.float :r_float
9
+ t.integer :r_integer
10
+ t.string :r_string
11
+ t.text :r_text
12
+ t.time :r_time
13
+
14
+ t.timestamps
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ class CreateParentResources < ActiveRecord::Migration
2
+ def change
3
+ create_table :parent_resources do |t|
4
+ t.boolean :r_boolean
5
+ t.date :r_date
6
+ t.datetime :r_datetime
7
+ t.decimal :r_decimal
8
+ t.float :r_float
9
+ t.integer :r_integer
10
+ t.string :r_string
11
+ t.text :r_text
12
+ t.time :r_time
13
+
14
+ t.timestamps
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,19 @@
1
+ class CreateChildResources < ActiveRecord::Migration
2
+ def change
3
+ create_table :child_resources do |t|
4
+ t.integer :parent_resource_id
5
+
6
+ t.boolean :r_boolean
7
+ t.date :r_date
8
+ t.datetime :r_datetime
9
+ t.decimal :r_decimal
10
+ t.float :r_float
11
+ t.integer :r_integer
12
+ t.string :r_string
13
+ t.text :r_text
14
+ t.time :r_time
15
+
16
+ t.timestamps
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ class CreateGrandChildResources < ActiveRecord::Migration
2
+ def change
3
+ create_table :grand_child_resources do |t|
4
+ t.integer :child_resource_id
5
+
6
+ t.boolean :r_boolean
7
+ t.date :r_date
8
+ t.datetime :r_datetime
9
+ t.decimal :r_decimal
10
+ t.float :r_float
11
+ t.integer :r_integer
12
+ t.string :r_string
13
+ t.text :r_text
14
+ t.time :r_time
15
+
16
+ t.timestamps
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,30 @@
1
+ # This migration comes from controlled_versioning (originally 20140206165158)
2
+ class CreateControlledVersioningVersions < ActiveRecord::Migration
3
+ def change
4
+ create_table :controlled_versioning_versions do |t|
5
+ t.string :versionable_type, null: false
6
+ t.integer :versionable_id, null: false
7
+
8
+ t.integer :user_id
9
+
10
+ t.text :notes
11
+
12
+ t.boolean :initial, null: false, default: false
13
+
14
+ t.boolean :marked_for_removal, null: false, default: false
15
+
16
+ t.boolean :accepted, null: false, default: false
17
+ t.boolean :declined, null: false, default: false
18
+ t.boolean :pending, null: false, default: true
19
+
20
+ t.datetime :created_at
21
+ end
22
+ add_index :controlled_versioning_versions, :initial
23
+ add_index :controlled_versioning_versions, :accepted
24
+ add_index :controlled_versioning_versions, :declined
25
+ add_index :controlled_versioning_versions, :pending
26
+ add_index :controlled_versioning_versions,
27
+ [:versionable_type, :versionable_id],
28
+ name: "controlled_versioning_versions_on_versionable"
29
+ end
30
+ end
@@ -0,0 +1,15 @@
1
+ # This migration comes from controlled_versioning (originally 20140206165205)
2
+ class CreateControlledVersioningVersionAttributes < ActiveRecord::Migration
3
+ def change
4
+ create_table :controlled_versioning_version_attributes do |t|
5
+ t.string :version_type, null: false
6
+ t.integer :version_id, null: false
7
+ t.string :name, null: false
8
+ t.text :old_value
9
+ t.text :new_value
10
+ end
11
+ add_index :controlled_versioning_version_attributes,
12
+ [:version_type, :version_id],
13
+ name: "controlled_versioning_version_attriubtes_on_version"
14
+ end
15
+ end
@@ -0,0 +1,19 @@
1
+ # This migration comes from controlled_versioning (originally 20140206165210)
2
+ class CreateControlledVersioningVersionChildren < ActiveRecord::Migration
3
+ def change
4
+ create_table :controlled_versioning_version_children do |t|
5
+ t.string :version_type, null: false
6
+ t.integer :version_id, null: false
7
+ t.string :versionable_type
8
+ t.integer :versionable_id
9
+
10
+ t.boolean :marked_for_removal, null: false, default: false
11
+ end
12
+ add_index :controlled_versioning_version_children,
13
+ [:version_type, :version_id],
14
+ name: "controlled_versioning_version_children_on_version"
15
+ add_index :controlled_versioning_version_children,
16
+ [:versionable_type, :versionable_id],
17
+ name: "controlled_versioning_version_children_on_versionable"
18
+ end
19
+ end
@@ -0,0 +1,163 @@
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: 20140206173609) do
15
+
16
+ # These are extensions that must be enabled in order to support this database
17
+ enable_extension "plpgsql"
18
+
19
+ create_table "child_resources", force: true do |t|
20
+ t.integer "parent_resource_id"
21
+ t.boolean "r_boolean"
22
+ t.date "r_date"
23
+ t.datetime "r_datetime"
24
+ t.decimal "r_decimal"
25
+ t.float "r_float"
26
+ t.integer "r_integer"
27
+ t.string "r_string"
28
+ t.text "r_text"
29
+ t.time "r_time"
30
+ t.datetime "created_at"
31
+ t.datetime "updated_at"
32
+ end
33
+
34
+ create_table "controlled_versioning_version_attributes", force: true do |t|
35
+ t.string "version_type", null: false
36
+ t.integer "version_id", null: false
37
+ t.string "name", null: false
38
+ t.text "old_value"
39
+ t.text "new_value"
40
+ end
41
+
42
+ add_index "controlled_versioning_version_attributes", ["version_type", "version_id"], name: "controlled_versioning_version_attriubtes_on_version", using: :btree
43
+
44
+ create_table "controlled_versioning_version_children", force: true do |t|
45
+ t.string "version_type", null: false
46
+ t.integer "version_id", null: false
47
+ t.string "versionable_type"
48
+ t.integer "versionable_id"
49
+ t.boolean "marked_for_removal", default: false, null: false
50
+ end
51
+
52
+ add_index "controlled_versioning_version_children", ["version_type", "version_id"], name: "controlled_versioning_version_children_on_version", using: :btree
53
+ add_index "controlled_versioning_version_children", ["versionable_type", "versionable_id"], name: "controlled_versioning_version_children_on_versionable", using: :btree
54
+
55
+ create_table "controlled_versioning_versions", force: true do |t|
56
+ t.string "versionable_type", null: false
57
+ t.integer "versionable_id", null: false
58
+ t.integer "user_id"
59
+ t.text "notes"
60
+ t.boolean "initial", default: false, null: false
61
+ t.boolean "marked_for_removal", default: false, null: false
62
+ t.boolean "accepted", default: false, null: false
63
+ t.boolean "declined", default: false, null: false
64
+ t.boolean "pending", default: true, null: false
65
+ t.datetime "created_at"
66
+ end
67
+
68
+ add_index "controlled_versioning_versions", ["accepted"], name: "index_controlled_versioning_versions_on_accepted", using: :btree
69
+ add_index "controlled_versioning_versions", ["declined"], name: "index_controlled_versioning_versions_on_declined", using: :btree
70
+ add_index "controlled_versioning_versions", ["initial"], name: "index_controlled_versioning_versions_on_initial", using: :btree
71
+ add_index "controlled_versioning_versions", ["pending"], name: "index_controlled_versioning_versions_on_pending", using: :btree
72
+ add_index "controlled_versioning_versions", ["versionable_type", "versionable_id"], name: "controlled_versioning_versions_on_versionable", using: :btree
73
+
74
+ create_table "grand_child_resources", force: true do |t|
75
+ t.integer "child_resource_id"
76
+ t.boolean "r_boolean"
77
+ t.date "r_date"
78
+ t.datetime "r_datetime"
79
+ t.decimal "r_decimal"
80
+ t.float "r_float"
81
+ t.integer "r_integer"
82
+ t.string "r_string"
83
+ t.text "r_text"
84
+ t.time "r_time"
85
+ t.datetime "created_at"
86
+ t.datetime "updated_at"
87
+ end
88
+
89
+ create_table "nonversionable_resources", force: true do |t|
90
+ t.boolean "r_boolean"
91
+ t.date "r_date"
92
+ t.datetime "r_datetime"
93
+ t.decimal "r_decimal"
94
+ t.float "r_float"
95
+ t.integer "r_integer"
96
+ t.string "r_string"
97
+ t.text "r_text"
98
+ t.time "r_time"
99
+ t.datetime "created_at"
100
+ t.datetime "updated_at"
101
+ end
102
+
103
+ create_table "parent_resources", force: true do |t|
104
+ t.boolean "r_boolean"
105
+ t.date "r_date"
106
+ t.datetime "r_datetime"
107
+ t.decimal "r_decimal"
108
+ t.float "r_float"
109
+ t.integer "r_integer"
110
+ t.string "r_string"
111
+ t.text "r_text"
112
+ t.time "r_time"
113
+ t.datetime "created_at"
114
+ t.datetime "updated_at"
115
+ end
116
+
117
+ create_table "partially_exclusive_versionable_resources", force: true do |t|
118
+ t.boolean "r_boolean"
119
+ t.date "r_date"
120
+ t.datetime "r_datetime"
121
+ t.decimal "r_decimal"
122
+ t.float "r_float"
123
+ t.integer "r_integer"
124
+ t.string "r_string"
125
+ t.text "r_text"
126
+ t.time "r_time"
127
+ t.datetime "created_at"
128
+ t.datetime "updated_at"
129
+ end
130
+
131
+ create_table "partially_inclusive_versionable_resources", force: true do |t|
132
+ t.boolean "r_boolean"
133
+ t.date "r_date"
134
+ t.datetime "r_datetime"
135
+ t.decimal "r_decimal"
136
+ t.float "r_float"
137
+ t.integer "r_integer"
138
+ t.string "r_string"
139
+ t.text "r_text"
140
+ t.time "r_time"
141
+ t.datetime "created_at"
142
+ t.datetime "updated_at"
143
+ end
144
+
145
+ create_table "users", force: true do |t|
146
+ t.string "name", null: false
147
+ end
148
+
149
+ create_table "versionable_resources", force: true do |t|
150
+ t.boolean "r_boolean"
151
+ t.date "r_date"
152
+ t.datetime "r_datetime"
153
+ t.decimal "r_decimal"
154
+ t.float "r_float"
155
+ t.integer "r_integer"
156
+ t.string "r_string"
157
+ t.text "r_text"
158
+ t.time "r_time"
159
+ t.datetime "created_at"
160
+ t.datetime "updated_at"
161
+ end
162
+
163
+ end