acts_as_archival 1.1.1 → 1.2.0

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 (57) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +81 -0
  3. data/.rubocop_todo.yml +7 -0
  4. data/.travis.yml +34 -0
  5. data/Appraisals +5 -2
  6. data/CHANGELOG.md +8 -0
  7. data/README.md +14 -7
  8. data/Rakefile +6 -3
  9. data/acts_as_archival.gemspec +3 -4
  10. data/gemfiles/rails_4.1.gemfile +0 -1
  11. data/gemfiles/rails_5.0.gemfile +1 -1
  12. data/gemfiles/rails_5.1.beta.gemfile +7 -0
  13. data/lib/acts_as_archival/version.rb +3 -1
  14. data/lib/expected_behavior/acts_as_archival.rb +115 -77
  15. data/lib/expected_behavior/acts_as_archival_active_record_methods.rb +22 -2
  16. data/lib/expected_behavior/association_operation/base.rb +7 -8
  17. data/lib/expected_behavior/association_operation/unarchive.rb +1 -1
  18. data/script/setup +0 -3
  19. data/test/ambiguous_table_test.rb +2 -0
  20. data/test/application_record_test.rb +3 -1
  21. data/test/associations_test.rb +2 -0
  22. data/test/basic_test.rb +6 -4
  23. data/test/callbacks_test.rb +4 -2
  24. data/test/column_test.rb +8 -6
  25. data/test/deep_nesting_test.rb +4 -2
  26. data/test/fixtures/application_record.rb +2 -0
  27. data/test/fixtures/application_record_row.rb +2 -0
  28. data/test/fixtures/archival.rb +9 -7
  29. data/test/fixtures/archival_grandkid.rb +2 -0
  30. data/test/fixtures/archival_kid.rb +3 -1
  31. data/test/fixtures/archival_table_name.rb +2 -0
  32. data/test/fixtures/callback_archival_4.rb +2 -0
  33. data/test/fixtures/callback_archival_5.rb +4 -1
  34. data/test/fixtures/exploder.rb +2 -0
  35. data/test/fixtures/independent_archival.rb +2 -0
  36. data/test/fixtures/missing_archive_number.rb +2 -0
  37. data/test/fixtures/missing_archived_at.rb +2 -0
  38. data/test/fixtures/plain.rb +2 -0
  39. data/test/fixtures/poly.rb +3 -1
  40. data/test/fixtures/readonly_when_archived.rb +3 -1
  41. data/test/polymorphic_test.rb +4 -2
  42. data/test/readonly_when_archived_test.rb +4 -2
  43. data/test/responds_test.rb +22 -4
  44. data/test/schema.rb +59 -79
  45. data/test/scope_test.rb +10 -6
  46. data/test/test_helper.rb +46 -40
  47. data/test/through_association_test.rb +3 -1
  48. data/test/transaction_test.rb +2 -53
  49. metadata +16 -41
  50. data/script/db_setup +0 -51
  51. data/test/database.yml +0 -26
  52. data/test/fixtures/mass_attribute_protected.rb +0 -7
  53. data/test/fixtures/mysql_archival.rb +0 -10
  54. data/test/fixtures/mysql_exploder.rb +0 -9
  55. data/test/fixtures/pg_archival.rb +0 -10
  56. data/test/fixtures/pg_exploder.rb +0 -9
  57. data/test/mass_attribute_test.rb +0 -20
@@ -3,7 +3,7 @@ require "rr"
3
3
 
4
4
  class TransactionTest < ActiveSupport::TestCase
5
5
 
6
- test "sqlite archiving is transactional" do
6
+ test "archiving is transactional" do
7
7
  archival = Archival.create!
8
8
  exploder = archival.exploders.create!
9
9
  any_instance_of(Exploder) do |canary|
@@ -15,7 +15,7 @@ class TransactionTest < ActiveSupport::TestCase
15
15
  assert_not exploder.reload.archived?
16
16
  end
17
17
 
18
- test "sqlite unarchiving is transactional" do
18
+ test "unarchiving is transactional" do
19
19
  archival = Archival.create!
20
20
  exploder = archival.exploders.create!
21
21
  any_instance_of(Exploder) do |canary|
@@ -28,55 +28,4 @@ class TransactionTest < ActiveSupport::TestCase
28
28
  assert exploder.reload.archived?
29
29
  end
30
30
 
31
- test "mysql archiving is transactional" do
32
- archival = MysqlArchival.create!
33
- exploder = archival.exploders.create!
34
- any_instance_of(MysqlExploder) do |canary|
35
- stub(canary).unarchive { raise "Rollback Imminent" }
36
- end
37
- archival.archive
38
- archival.unarchive
39
-
40
- assert archival.reload.archived?
41
- assert exploder.reload.archived?
42
- end
43
-
44
- test "mysql unarchiving is transactional" do
45
- archival = MysqlArchival.create!
46
- exploder = archival.exploders.create!
47
- any_instance_of(MysqlExploder) do |canary|
48
- stub(canary).unarchive { raise "Rollback Imminent" }
49
- end
50
- archival.archive
51
- archival.unarchive
52
-
53
- assert archival.reload.archived?
54
- assert exploder.reload.archived?
55
- end
56
-
57
- test "postgres archiving is transactional" do
58
- archival = MysqlArchival.create!
59
- exploder = archival.exploders.create!
60
- any_instance_of(MysqlExploder) do |canary|
61
- stub(canary).unarchive { raise "Rollback Imminent" }
62
- end
63
- archival.archive
64
- archival.unarchive
65
-
66
- assert archival.reload.archived?
67
- assert exploder.reload.archived?
68
- end
69
-
70
- test "postgres unarchiving is transactional" do
71
- archival = MysqlArchival.create!
72
- exploder = archival.exploders.create!
73
- any_instance_of(MysqlExploder) do |canary|
74
- stub(canary).unarchive { raise "Rollback Imminent" }
75
- end
76
- archival.archive
77
- archival.unarchive
78
-
79
- assert archival.reload.archived?
80
- assert exploder.reload.archived?
81
- end
82
31
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_archival
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Meador
@@ -16,7 +16,7 @@ authors:
16
16
  autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
- date: 2016-04-10 00:00:00.000000000 Z
19
+ date: 2017-03-19 00:00:00.000000000 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: activerecord
@@ -24,14 +24,14 @@ dependencies:
24
24
  requirements:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: '0'
27
+ version: '4.1'
28
28
  type: :runtime
29
29
  prerelease: false
30
30
  version_requirements: !ruby/object:Gem::Requirement
31
31
  requirements:
32
32
  - - ">="
33
33
  - !ruby/object:Gem::Version
34
- version: '0'
34
+ version: '4.1'
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: appraisal
37
37
  requirement: !ruby/object:Gem::Requirement
@@ -75,21 +75,7 @@ dependencies:
75
75
  - !ruby/object:Gem::Version
76
76
  version: '0'
77
77
  - !ruby/object:Gem::Dependency
78
- name: mysql2
79
- requirement: !ruby/object:Gem::Requirement
80
- requirements:
81
- - - ">="
82
- - !ruby/object:Gem::Version
83
- version: '0'
84
- type: :development
85
- prerelease: false
86
- version_requirements: !ruby/object:Gem::Requirement
87
- requirements:
88
- - - ">="
89
- - !ruby/object:Gem::Version
90
- version: '0'
91
- - !ruby/object:Gem::Dependency
92
- name: pg
78
+ name: rake
93
79
  requirement: !ruby/object:Gem::Requirement
94
80
  requirements:
95
81
  - - ">="
@@ -103,7 +89,7 @@ dependencies:
103
89
  - !ruby/object:Gem::Version
104
90
  version: '0'
105
91
  - !ruby/object:Gem::Dependency
106
- name: rake
92
+ name: rr
107
93
  requirement: !ruby/object:Gem::Requirement
108
94
  requirements:
109
95
  - - ">="
@@ -117,7 +103,7 @@ dependencies:
117
103
  - !ruby/object:Gem::Version
118
104
  version: '0'
119
105
  - !ruby/object:Gem::Dependency
120
- name: rr
106
+ name: sqlite3
121
107
  requirement: !ruby/object:Gem::Requirement
122
108
  requirements:
123
109
  - - ">="
@@ -131,19 +117,19 @@ dependencies:
131
117
  - !ruby/object:Gem::Version
132
118
  version: '0'
133
119
  - !ruby/object:Gem::Dependency
134
- name: sqlite3
120
+ name: rubocop
135
121
  requirement: !ruby/object:Gem::Requirement
136
122
  requirements:
137
- - - ">="
123
+ - - "~>"
138
124
  - !ruby/object:Gem::Version
139
- version: '0'
125
+ version: 0.47.1
140
126
  type: :development
141
127
  prerelease: false
142
128
  version_requirements: !ruby/object:Gem::Requirement
143
129
  requirements:
144
- - - ">="
130
+ - - "~>"
145
131
  - !ruby/object:Gem::Version
146
- version: '0'
132
+ version: 0.47.1
147
133
  description: |
148
134
  *Atomic archiving/unarchiving for ActiveRecord-based apps*
149
135
 
@@ -168,6 +154,9 @@ extensions: []
168
154
  extra_rdoc_files: []
169
155
  files:
170
156
  - ".gitignore"
157
+ - ".rubocop.yml"
158
+ - ".rubocop_todo.yml"
159
+ - ".travis.yml"
171
160
  - Appraisals
172
161
  - CHANGELOG.md
173
162
  - Gemfile
@@ -178,6 +167,7 @@ files:
178
167
  - gemfiles/rails_4.1.gemfile
179
168
  - gemfiles/rails_4.2.gemfile
180
169
  - gemfiles/rails_5.0.gemfile
170
+ - gemfiles/rails_5.1.beta.gemfile
181
171
  - init.rb
182
172
  - lib/acts_as_archival.rb
183
173
  - lib/acts_as_archival/version.rb
@@ -186,7 +176,6 @@ files:
186
176
  - lib/expected_behavior/association_operation/archive.rb
187
177
  - lib/expected_behavior/association_operation/base.rb
188
178
  - lib/expected_behavior/association_operation/unarchive.rb
189
- - script/db_setup
190
179
  - script/setup
191
180
  - test/ambiguous_table_test.rb
192
181
  - test/application_record_test.rb
@@ -194,7 +183,6 @@ files:
194
183
  - test/basic_test.rb
195
184
  - test/callbacks_test.rb
196
185
  - test/column_test.rb
197
- - test/database.yml
198
186
  - test/deep_nesting_test.rb
199
187
  - test/fixtures/application_record.rb
200
188
  - test/fixtures/application_record_row.rb
@@ -206,17 +194,11 @@ files:
206
194
  - test/fixtures/callback_archival_5.rb
207
195
  - test/fixtures/exploder.rb
208
196
  - test/fixtures/independent_archival.rb
209
- - test/fixtures/mass_attribute_protected.rb
210
197
  - test/fixtures/missing_archive_number.rb
211
198
  - test/fixtures/missing_archived_at.rb
212
- - test/fixtures/mysql_archival.rb
213
- - test/fixtures/mysql_exploder.rb
214
- - test/fixtures/pg_archival.rb
215
- - test/fixtures/pg_exploder.rb
216
199
  - test/fixtures/plain.rb
217
200
  - test/fixtures/poly.rb
218
201
  - test/fixtures/readonly_when_archived.rb
219
- - test/mass_attribute_test.rb
220
202
  - test/polymorphic_test.rb
221
203
  - test/readonly_when_archived_test.rb
222
204
  - test/responds_test.rb
@@ -255,7 +237,6 @@ test_files:
255
237
  - test/basic_test.rb
256
238
  - test/callbacks_test.rb
257
239
  - test/column_test.rb
258
- - test/database.yml
259
240
  - test/deep_nesting_test.rb
260
241
  - test/fixtures/application_record.rb
261
242
  - test/fixtures/application_record_row.rb
@@ -267,17 +248,11 @@ test_files:
267
248
  - test/fixtures/callback_archival_5.rb
268
249
  - test/fixtures/exploder.rb
269
250
  - test/fixtures/independent_archival.rb
270
- - test/fixtures/mass_attribute_protected.rb
271
251
  - test/fixtures/missing_archive_number.rb
272
252
  - test/fixtures/missing_archived_at.rb
273
- - test/fixtures/mysql_archival.rb
274
- - test/fixtures/mysql_exploder.rb
275
- - test/fixtures/pg_archival.rb
276
- - test/fixtures/pg_exploder.rb
277
253
  - test/fixtures/plain.rb
278
254
  - test/fixtures/poly.rb
279
255
  - test/fixtures/readonly_when_archived.rb
280
- - test/mass_attribute_test.rb
281
256
  - test/polymorphic_test.rb
282
257
  - test/readonly_when_archived_test.rb
283
258
  - test/responds_test.rb
data/script/db_setup DELETED
@@ -1,51 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require "bundler/setup"
3
- require "yaml"
4
-
5
- STDOUT.sync = true
6
-
7
- DB_CONFIG = YAML.load(File.read(File.join(File.dirname(__FILE__), "..", "test", "database.yml")))
8
-
9
- def execute_mysql(statement, password = nil)
10
- password_option = if password.to_s.size > 0
11
- "-p'#{password}'"
12
- end
13
- command = %Q{echo '#{statement}' | mysql -u root #{password_option}}
14
- puts command
15
- system(command)
16
- end
17
-
18
- def execute_postgres(statement)
19
- command = %Q{echo "#{statement}" | psql postgres}
20
- puts command
21
- system(command)
22
- end
23
-
24
- def setup_mysql
25
- mysql_root_password = nil
26
- if !execute_mysql("SHOW DATABASES;", mysql_root_password)
27
- loop do
28
- print "MySQL root password to setup '#{DB_CONFIG["mysql"]["database"]}': "
29
- mysql_root_password = gets.chomp
30
- if execute_mysql("SHOW DATABASES;", mysql_root_password)
31
- break
32
- end
33
- end
34
- end
35
-
36
- config = DB_CONFIG["mysql"]
37
- execute_mysql("DROP DATABASE IF EXISTS #{config["database"]};", mysql_root_password)
38
- execute_mysql("CREATE DATABASE #{config["database"]};", mysql_root_password)
39
- execute_mysql(%Q{GRANT ALL ON `#{config["database"]}`.* TO `#{config["username"]}` IDENTIFIED BY "#{config["password"]}";}, mysql_root_password)
40
- end
41
-
42
- def setup_postgres
43
- config = DB_CONFIG["pg"]
44
- execute_postgres(%Q{DROP DATABASE IF EXISTS #{config["database"]};})
45
- execute_postgres(%Q{DROP ROLE IF EXISTS #{config["username"]};})
46
- execute_postgres(%Q{CREATE ROLE #{config["username"]} WITH PASSWORD '#{config["password"]}' LOGIN;})
47
- execute_postgres(%Q{CREATE DATABASE #{config["database"]} WITH OWNER #{config["username"]};})
48
- end
49
-
50
- setup_mysql
51
- setup_postgres
data/test/database.yml DELETED
@@ -1,26 +0,0 @@
1
- sqlite:
2
- adapter: sqlite3
3
- database: aaa_test.sqlite3
4
- pool: 5
5
- timeout: 5000
6
-
7
- mysql:
8
- adapter: mysql2
9
- pool: 5
10
- timeout: 5000
11
- encoding: utf8
12
- reconnect: false
13
- database: aaa_test
14
- username: archival_tester
15
- password: perspicacious
16
- socket: /tmp/mysql.sock
17
-
18
- pg:
19
- adapter: postgresql
20
- pool: 5
21
- timeout: 5000
22
- encoding: utf8
23
- database: aaa_test
24
- username: archival_tester
25
- password: perspicacious
26
- min_messages: WARNING
@@ -1,7 +0,0 @@
1
- # name - string
2
- # archive_number - string
3
- # archived_at - datetime
4
- class MassAttributeProtected < ActiveRecord::Base
5
- acts_as_archival
6
- attr_accessible :name
7
- end
@@ -1,10 +0,0 @@
1
- # name - string
2
- # archival_id - integer
3
- # archive_number - string
4
- # archived_at - datetime
5
- class MysqlArchival < ActiveRecord::Base
6
- establish_connection $dbconfig["mysql"]
7
- self.table_name = "archivals"
8
- acts_as_archival
9
- has_many :exploders, :dependent => :destroy, :foreign_key => :archival_id, :class_name => "MysqlExploder"
10
- end
@@ -1,9 +0,0 @@
1
- # archival_id - integer
2
- # archive_number - string
3
- # archived_at - datetime
4
- class MysqlExploder < ActiveRecord::Base
5
- establish_connection $dbconfig["mysql"]
6
- self.table_name = "exploders"
7
- acts_as_archival
8
- belongs_to :mysql_archival, :foreign_key => :archival_id
9
- end
@@ -1,10 +0,0 @@
1
- # name - string
2
- # archival_id - integer
3
- # archive_number - string
4
- # archived_at - datetime
5
- class PgArchival < ActiveRecord::Base
6
- establish_connection $dbconfig["pg"]
7
- self.table_name = "archivals"
8
- acts_as_archival
9
- has_many :exploders, :dependent => :destroy, :foreign_key => :archival_id, :class_name => "PgExploder"
10
- end
@@ -1,9 +0,0 @@
1
- # archival_id - integer
2
- # archive_number - string
3
- # archived_at - datetime
4
- class PgExploder < ActiveRecord::Base
5
- establish_connection $dbconfig["pg"]
6
- self.table_name = "exploders"
7
- acts_as_archival
8
- belongs_to :pg_archival, :foreign_key => :archival_id
9
- end
@@ -1,20 +0,0 @@
1
- require_relative "test_helper"
2
-
3
- class MassAttributeTest < ActiveSupport::TestCase
4
- if $require_mass_protection
5
- test "archive works when attr_accessible present" do
6
- archival = MassAttributeProtected.create(:color => "pink")
7
- archival.archive
8
-
9
- assert archival.reload.archived?
10
- end
11
-
12
- test "unarchive works when attr_accessible present" do
13
- archival = MassAttributeProtected.create(:color => "pink")
14
- archival.archive
15
- archival.unarchive
16
-
17
- assert_not archival.reload.archived?
18
- end
19
- end
20
- end