acts_as_archive 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. data/.gitignore +9 -0
  2. data/LICENSE +18 -0
  3. data/README.md +112 -0
  4. data/Rakefile +90 -0
  5. data/acts_as_archive.gemspec +32 -0
  6. data/bin/acts_as_archive +2 -0
  7. data/config/externals.yml +12 -0
  8. data/config/gemsets.yml +10 -0
  9. data/config/gemspec.yml +17 -0
  10. data/init.rb +1 -0
  11. data/lib/acts_as_archive.rb +192 -0
  12. data/lib/acts_as_archive/gems.rb +154 -0
  13. data/rails/init.rb +1 -0
  14. data/spec/Rakefile +9 -0
  15. data/spec/acts_as_archive/gems_spec.rb +249 -0
  16. data/spec/acts_as_archive_spec.rb +113 -0
  17. data/spec/fixtures/config/database.yml.example +6 -0
  18. data/spec/fixtures/db/migrate/001_belongs_tos.rb +14 -0
  19. data/spec/fixtures/db/migrate/002_records.rb +15 -0
  20. data/spec/fixtures/db/migrate/003_has_ones.rb +15 -0
  21. data/spec/fixtures/db/migrate/004_has_manies.rb +15 -0
  22. data/spec/fixtures/db/migrate/005_has_many_through_throughs.rb +16 -0
  23. data/spec/fixtures/db/migrate/006_has_many_throughs.rb +14 -0
  24. data/spec/fixtures/db/migrate/007_has_one_through_throughs.rb +15 -0
  25. data/spec/fixtures/db/migrate/008_has_one_throughs.rb +15 -0
  26. data/spec/fixtures/frameworks.yml +36 -0
  27. data/spec/fixtures/frameworks/rails2/application_controller.rb +58 -0
  28. data/spec/fixtures/frameworks/rails2/database.yml +12 -0
  29. data/spec/fixtures/frameworks/rails2/init.rb +1 -0
  30. data/spec/fixtures/frameworks/rails2/routes.rb +46 -0
  31. data/spec/fixtures/frameworks/rails3/Gemfile +34 -0
  32. data/spec/fixtures/frameworks/rails3/application_controller.rb +51 -0
  33. data/spec/fixtures/frameworks/rails3/database.yml +12 -0
  34. data/spec/fixtures/frameworks/rails3/routes.rb +60 -0
  35. data/spec/fixtures/frameworks/sinatra/application.rb +58 -0
  36. data/spec/fixtures/gemsets.yml +9 -0
  37. data/spec/fixtures/gemspec.yml +15 -0
  38. data/spec/fixtures/helpers/spec_helper.rb +210 -0
  39. data/spec/fixtures/models/belongs_to.rb +6 -0
  40. data/spec/fixtures/models/has_many.rb +6 -0
  41. data/spec/fixtures/models/has_many_through.rb +7 -0
  42. data/spec/fixtures/models/has_many_through_through.rb +7 -0
  43. data/spec/fixtures/models/has_one.rb +6 -0
  44. data/spec/fixtures/models/has_one_through.rb +6 -0
  45. data/spec/fixtures/models/has_one_through_through.rb +7 -0
  46. data/spec/fixtures/models/record.rb +16 -0
  47. data/spec/run +27 -0
  48. data/spec/spec.opts +1 -0
  49. data/spec/spec_helper.rb +73 -0
  50. metadata +96 -13
@@ -0,0 +1,6 @@
1
+ test:
2
+ adapter: mysql
3
+ database: acts_as_archive
4
+ username: root
5
+ password:
6
+ host: localhost
@@ -0,0 +1,14 @@
1
+ class BelongsTos < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :belongs_tos do |t|
4
+ t.string :string, :default => 'string'
5
+ t.integer :integer, :default => '1'
6
+ t.datetime :restored_at
7
+ t.timestamps
8
+ end
9
+ end
10
+
11
+ def self.down
12
+ drop_table :belongs_tos
13
+ end
14
+ end
@@ -0,0 +1,15 @@
1
+ class Records < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :records do |t|
4
+ t.string :string, :default => 'string'
5
+ t.integer :integer, :default => '1'
6
+ t.integer :belongs_to_id
7
+ t.datetime :restored_at
8
+ t.timestamps
9
+ end
10
+ end
11
+
12
+ def self.down
13
+ drop_table :records
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ class HasOnes < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :has_ones do |t|
4
+ t.string :string, :default => 'string'
5
+ t.integer :integer, :default => '1'
6
+ t.integer :record_id
7
+ t.datetime :restored_at
8
+ t.timestamps
9
+ end
10
+ end
11
+
12
+ def self.down
13
+ drop_table :has_ones
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ class HasManies < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :has_manies do |t|
4
+ t.string :string, :default => 'string'
5
+ t.integer :integer, :default => '1'
6
+ t.integer :record_id
7
+ t.datetime :restored_at
8
+ t.timestamps
9
+ end
10
+ end
11
+
12
+ def self.down
13
+ drop_table :has_manies
14
+ end
15
+ end
@@ -0,0 +1,16 @@
1
+ class HasManyThroughThroughs < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :has_many_through_throughs do |t|
4
+ t.string :string, :default => 'string'
5
+ t.integer :integer, :default => '1'
6
+ t.integer :has_many_through_id
7
+ t.integer :record_id
8
+ t.datetime :restored_at
9
+ t.timestamps
10
+ end
11
+ end
12
+
13
+ def self.down
14
+ drop_table :has_many_through_throughs
15
+ end
16
+ end
@@ -0,0 +1,14 @@
1
+ class HasManyThroughs < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :has_many_throughs do |t|
4
+ t.string :string, :default => 'string'
5
+ t.integer :integer, :default => '1'
6
+ t.datetime :restored_at
7
+ t.timestamps
8
+ end
9
+ end
10
+
11
+ def self.down
12
+ drop_table :has_many_throughs
13
+ end
14
+ end
@@ -0,0 +1,15 @@
1
+ class HasOneThroughThroughs < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :has_one_through_throughs do |t|
4
+ t.string :string, :default => 'string'
5
+ t.integer :integer, :default => '1'
6
+ t.integer :record_id
7
+ t.datetime :restored_at
8
+ t.timestamps
9
+ end
10
+ end
11
+
12
+ def self.down
13
+ drop_table :has_one_through_throughs
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ class HasOneThroughs < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :has_one_throughs do |t|
4
+ t.string :string, :default => 'string'
5
+ t.integer :integer, :default => '1'
6
+ t.integer :has_one_through_through_id
7
+ t.datetime :restored_at
8
+ t.timestamps
9
+ end
10
+ end
11
+
12
+ def self.down
13
+ drop_table :has_one_throughs
14
+ end
15
+ end
@@ -0,0 +1,36 @@
1
+ rails:
2
+ <3:
3
+ frameworks/rails2:
4
+ - app/controllers/application_controller.rb
5
+ - config/database.yml
6
+ - config/routes.rb
7
+ - vendor/plugins/plugin/rails/init.rb
8
+ helpers: &h
9
+ - app/helpers/spec_helper.rb
10
+ models: &m
11
+ - app/models/belongs_to.rb
12
+ - app/models/has_many.rb
13
+ - app/models/has_many_through.rb
14
+ - app/models/has_many_through_through.rb
15
+ - app/models/has_one.rb
16
+ - app/models/has_one_through.rb
17
+ - app/models/has_one_through_through.rb
18
+ - app/models/record.rb
19
+ <4:
20
+ frameworks/rails3:
21
+ - app/controllers/application_controller.rb
22
+ - config/database.yml
23
+ - config/routes.rb
24
+ - Gemfile
25
+ helpers: *h
26
+ models: *m
27
+ sinatra:
28
+ <1:
29
+ frameworks/sinatra: &s
30
+ - application.rb
31
+ helpers: *h
32
+ models: *m
33
+ <2:
34
+ frameworks/sinatra: *s
35
+ helpers: *h
36
+ models: *m
@@ -0,0 +1,58 @@
1
+ # Filters added to this controller apply to all controllers in the application.
2
+ # Likewise, all the methods added will be available for all controllers.
3
+
4
+ class ApplicationController < ActionController::Base
5
+ helper :all # include all helpers, all the time
6
+ protect_from_forgery # See ActionController::RequestForgeryProtection for details
7
+
8
+ # Scrub sensitive parameters from your log
9
+ # filter_parameter_logging :password
10
+
11
+ include SpecHelper
12
+
13
+ def pulse
14
+ render :text => '1'
15
+ end
16
+
17
+ def should_have_valid_schema_action
18
+ before_each false, true
19
+ should_have_valid_schema
20
+ render :text => '1'
21
+ end
22
+
23
+ def should_create_records_action
24
+ before_each false, true
25
+ should_create_records
26
+ render :text => '1'
27
+ end
28
+
29
+ def should_migrate_record_and_preserve_deleted_at_action
30
+ before_each false, true
31
+ should_migrate_record_and_preserve_deleted_at
32
+ render :text => '1'
33
+ end
34
+
35
+ def should_emulate_delete_all_action
36
+ before_each false, true
37
+ should_emulate_delete_all
38
+ render :text => '1'
39
+ end
40
+
41
+ def should_move_records_back_to_original_tables_action
42
+ before_each false, true
43
+ should_move_records_back_to_original_tables(params[:type])
44
+ render :text => '1'
45
+ end
46
+
47
+ def should_move_records_to_archive_tables_action
48
+ before_each false, true
49
+ should_move_records_to_archive_tables(params[:type])
50
+ render :text => '1'
51
+ end
52
+
53
+ def should_delete_records_without_archiving_action
54
+ before_each false, true
55
+ should_delete_records_without_archiving(params[:type])
56
+ render :text => '1'
57
+ end
58
+ end
@@ -0,0 +1,12 @@
1
+ test:
2
+ adapter: mysql
3
+ database: acts_as_archive
4
+ username: root
5
+ password:
6
+ host: localhost
7
+ development:
8
+ adapter: mysql
9
+ database: acts_as_archive
10
+ username: root
11
+ password:
12
+ host: localhost
@@ -0,0 +1 @@
1
+ require "#{$root}/lib/acts_as_archive"
@@ -0,0 +1,46 @@
1
+ ActionController::Routing::Routes.draw do |map|
2
+ # The priority is based upon order of creation: first created -> highest priority.
3
+
4
+ # Sample of regular route:
5
+ # map.connect 'products/:id', :controller => 'catalog', :action => 'view'
6
+ # Keep in mind you can assign values other than :controller and :action
7
+
8
+ # Sample of named route:
9
+ # map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
10
+ # This route can be invoked with purchase_url(:id => product.id)
11
+
12
+ # Sample resource route (maps HTTP verbs to controller actions automatically):
13
+ # map.resources :products
14
+
15
+ # Sample resource route with options:
16
+ # map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }
17
+
18
+ # Sample resource route with sub-resources:
19
+ # map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
20
+
21
+ # Sample resource route with more complex sub-resources
22
+ # map.resources :products do |products|
23
+ # products.resources :comments
24
+ # products.resources :sales, :collection => { :recent => :get }
25
+ # end
26
+
27
+ # Sample resource route within a namespace:
28
+ # map.namespace :admin do |admin|
29
+ # # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
30
+ # admin.resources :products
31
+ # end
32
+
33
+ # You can have the root of your site routed with map.root -- just remember to delete public/index.html.
34
+ # map.root :controller => "welcome"
35
+
36
+ # See how all your routes lay out with "rake routes"
37
+
38
+ # Install the default routes as the lowest priority.
39
+ # Note: These default routes make all actions in every controller accessible via GET requests. You should
40
+ # consider removing or commenting them out if you're using named routes and resources.
41
+
42
+ # map.connect ':controller/:action/:id'
43
+ # map.connect ':controller/:action/:id.:format'
44
+
45
+ map.connect ':action', :controller => 'application'
46
+ end
@@ -0,0 +1,34 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'mysql2'
4
+ gem 'rails', '3.0.3'
5
+ gem 'rspec'
6
+
7
+ gem 'acts_as_archive', :path => "../../../../"
8
+
9
+ # Bundle edge Rails instead:
10
+ # gem 'rails', :git => 'git://github.com/rails/rails.git'
11
+
12
+
13
+ # Use unicorn as the web server
14
+ # gem 'unicorn'
15
+
16
+ # Deploy with Capistrano
17
+ # gem 'capistrano'
18
+
19
+ # To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)
20
+ # gem 'ruby-debug'
21
+ # gem 'ruby-debug19'
22
+
23
+ # Bundle the extra gems:
24
+ # gem 'bj'
25
+ # gem 'nokogiri'
26
+ # gem 'sqlite3-ruby', :require => 'sqlite3'
27
+ # gem 'aws-s3', :require => 'aws/s3'
28
+
29
+ # Bundle gems for the local environment. Make sure to
30
+ # put test-only gems in this group so their generators
31
+ # and rake tasks are available in development mode:
32
+ # group :development, :test do
33
+ # gem 'webrat'
34
+ # end
@@ -0,0 +1,51 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery
3
+
4
+ include SpecHelper
5
+
6
+ def pulse
7
+ render :text => '1'
8
+ end
9
+
10
+ def should_have_valid_schema_action
11
+ before_each false, true
12
+ should_have_valid_schema
13
+ render :text => '1'
14
+ end
15
+
16
+ def should_create_records_action
17
+ before_each false, true
18
+ should_create_records
19
+ render :text => '1'
20
+ end
21
+
22
+ def should_migrate_record_and_preserve_deleted_at_action
23
+ before_each false, true
24
+ should_migrate_record_and_preserve_deleted_at
25
+ render :text => '1'
26
+ end
27
+
28
+ def should_emulate_delete_all_action
29
+ before_each false, true
30
+ should_emulate_delete_all
31
+ render :text => '1'
32
+ end
33
+
34
+ def should_move_records_back_to_original_tables_action
35
+ before_each false, true
36
+ should_move_records_back_to_original_tables(params[:type])
37
+ render :text => '1'
38
+ end
39
+
40
+ def should_move_records_to_archive_tables_action
41
+ before_each false, true
42
+ should_move_records_to_archive_tables(params[:type])
43
+ render :text => '1'
44
+ end
45
+
46
+ def should_delete_records_without_archiving_action
47
+ before_each false, true
48
+ should_delete_records_without_archiving(params[:type])
49
+ render :text => '1'
50
+ end
51
+ end
@@ -0,0 +1,12 @@
1
+ test:
2
+ adapter: mysql2
3
+ database: acts_as_archive
4
+ username: root
5
+ password:
6
+ host: localhost
7
+ development:
8
+ adapter: mysql2
9
+ database: acts_as_archive
10
+ username: root
11
+ password:
12
+ host: localhost
@@ -0,0 +1,60 @@
1
+ Rails3::Application.routes.draw do
2
+ # The priority is based upon order of creation:
3
+ # first created -> highest priority.
4
+
5
+ # Sample of regular route:
6
+ # match 'products/:id' => 'catalog#view'
7
+ # Keep in mind you can assign values other than :controller and :action
8
+
9
+ # Sample of named route:
10
+ # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
11
+ # This route can be invoked with purchase_url(:id => product.id)
12
+
13
+ # Sample resource route (maps HTTP verbs to controller actions automatically):
14
+ # resources :products
15
+
16
+ # Sample resource route with options:
17
+ # resources :products do
18
+ # member do
19
+ # get 'short'
20
+ # post 'toggle'
21
+ # end
22
+ #
23
+ # collection do
24
+ # get 'sold'
25
+ # end
26
+ # end
27
+
28
+ # Sample resource route with sub-resources:
29
+ # resources :products do
30
+ # resources :comments, :sales
31
+ # resource :seller
32
+ # end
33
+
34
+ # Sample resource route with more complex sub-resources
35
+ # resources :products do
36
+ # resources :comments
37
+ # resources :sales do
38
+ # get 'recent', :on => :collection
39
+ # end
40
+ # end
41
+
42
+ # Sample resource route within a namespace:
43
+ # namespace :admin do
44
+ # # Directs /admin/products/* to Admin::ProductsController
45
+ # # (app/controllers/admin/products_controller.rb)
46
+ # resources :products
47
+ # end
48
+
49
+ # You can have the root of your site routed with "root"
50
+ # just remember to delete public/index.html.
51
+ # root :to => "welcome#index"
52
+
53
+ # See how all your routes lay out with "rake routes"
54
+
55
+ # This is a legacy wild controller route that's not recommended for RESTful applications.
56
+ # Note: This route will make all actions in every controller accessible via GET requests.
57
+ # match ':controller(/:action(/:id(.:format)))'
58
+
59
+ match ':action', :controller => 'application'
60
+ end