activehistory 0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,36 @@
1
+ FactoryGirl.define do
2
+
3
+ factory :account do
4
+ name { Faker::Name.name }
5
+ end
6
+
7
+ factory :email_address do
8
+ address { Faker::Internet.email }
9
+ end
10
+
11
+ factory :photo do
12
+ format { ['jpg', 'png', 'tiff'].sample }
13
+ end
14
+
15
+ factory :property do
16
+ name { Faker::Lorem.words(Kernel.rand(1..4)).join(' ') }
17
+ description { Faker::Lorem.sentence }
18
+ constructed { Kernel.rand(1800..(Time.now.year - 2)) }
19
+ size { Kernel.rand(1000..10000000).to_f / 100 }
20
+ active { false }#[true, false].sample }
21
+ end
22
+
23
+ factory :region do
24
+ name { Faker::Name.name }
25
+ end
26
+
27
+ factory :comment do
28
+ title { Faker::Lorem.words }
29
+ body { Faker::Lorem.sentence }
30
+ end
31
+
32
+ factory :unobserved_model do
33
+ body { Faker::Lorem.sentence }
34
+ end
35
+
36
+ end
@@ -0,0 +1,60 @@
1
+ class Account < ActiveRecord::Base
2
+
3
+ track
4
+
5
+ has_many :photos
6
+ has_many :comments
7
+ has_one :email_address
8
+
9
+ end
10
+
11
+ class EmailAddress < ActiveRecord::Base
12
+
13
+ track
14
+
15
+ belongs_to :account
16
+
17
+ end
18
+
19
+ class Photo < ActiveRecord::Base
20
+
21
+ track
22
+
23
+ belongs_to :account, counter_cache: true, inverse_of: :photos
24
+ belongs_to :property, inverse_of: :photos
25
+
26
+ end
27
+
28
+ class Property < ActiveRecord::Base
29
+
30
+ track
31
+
32
+ has_many :photos, inverse_of: :property
33
+
34
+ has_and_belongs_to_many :regions, inverse_of: :properties
35
+
36
+ end
37
+
38
+ class Region < ActiveRecord::Base
39
+
40
+ track
41
+
42
+ has_and_belongs_to_many :properties, inverse_of: :regions
43
+ has_and_belongs_to_many :parents, :join_table => 'regions_regions', :class_name => 'Region', :foreign_key => 'child_id', :association_foreign_key => 'parent_id'
44
+ has_and_belongs_to_many :children, :join_table => 'regions_regions', :class_name => 'Region', :foreign_key => 'parent_id', :association_foreign_key => 'child_id'
45
+
46
+ end
47
+
48
+ class Comment < ActiveRecord::Base
49
+
50
+ track exclude: :title
51
+
52
+ belongs_to :account
53
+
54
+ end
55
+
56
+ class UnobservedModel < ActiveRecord::Base
57
+
58
+ end
59
+
60
+ # ActiveRecord::Base.logger = Logger.new(STDOUT)
@@ -0,0 +1,59 @@
1
+ ActiveRecord::Schema.define do
2
+
3
+ create_table "accounts", force: :cascade do |t|
4
+ t.string "name", limit: 255
5
+ t.integer 'photos_count', null: false, default: 0
6
+ end
7
+
8
+ create_table "email_addresses", force: :cascade do |t|
9
+ t.string "address", limit: 255
10
+ t.integer 'account_id'
11
+ end
12
+
13
+ create_table "photos", force: :cascade do |t|
14
+ t.integer "account_id"
15
+ t.integer "property_id"
16
+ t.string "format", limit: 255
17
+ end
18
+
19
+ create_table "photos_properties", id: false, force: :cascade do |t|
20
+ t.integer "property_id", null: false
21
+ t.integer "photo_id", null: false
22
+ end
23
+
24
+ create_table "properties", force: :cascade do |t|
25
+ t.string "name", limit: 255
26
+ t.string "aliases", default: [], array: true
27
+ t.text "description"
28
+ t.integer "constructed"
29
+ t.decimal "size"
30
+ # t.json "amenities", default: {}, null: false
31
+ t.datetime "created_at", null: false
32
+ # t.geometry "location", limit: {:type=>"Point", :srid=>"4326"}
33
+ t.boolean "active", default: false
34
+ end
35
+
36
+ create_table "regions", force: :cascade do |t|
37
+ t.string "name", limit: 255
38
+ end
39
+
40
+ create_table "properties_regions", id: false, force: :cascade do |t|
41
+ t.integer "property_id", null: false
42
+ t.integer "region_id", null: false
43
+ end
44
+
45
+ create_table "regions_regions", id: false, force: :cascade do |t|
46
+ t.integer "parent_id", null: false
47
+ t.integer "child_id", null: false
48
+ end
49
+
50
+ create_table "comments", force: :cascade do |t|
51
+ t.string 'title', limit: 255
52
+ t.text 'body', null: false
53
+ end
54
+
55
+ create_table "unobserved_models", force: :cascade do |t|
56
+ t.text "body"
57
+ end
58
+
59
+ end
@@ -0,0 +1,55 @@
1
+ # Test within this source tree versus an installed gem
2
+ $LOAD_PATH << File.expand_path('../lib', __FILE__)
3
+
4
+ require 'active_support'
5
+ require 'minitest/autorun'
6
+ require 'minitest/unit'
7
+ require 'minitest/reporters'
8
+ require 'webmock/minitest'
9
+ require 'factory_girl'
10
+ require 'faker'
11
+
12
+
13
+ WebMock.disable_net_connect!
14
+ Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
15
+
16
+ require 'active_record'
17
+ require 'activehistory'
18
+
19
+ ActiveHistory.configure({
20
+ url: 'http://activehistory.com'
21
+ })
22
+ ActiveRecord::Base.establish_connection({
23
+ adapter: 'postgresql',
24
+ database: 'activehistory-client-test'
25
+ })
26
+ ActiveRecord::Migration.suppress_messages do
27
+ require File.expand_path('../schema', __FILE__)
28
+ ActiveRecord::Migration.execute("SELECT c.relname FROM pg_class c WHERE c.relkind = 'S'").each_row do |row|
29
+ ActiveRecord::Migration.execute("ALTER SEQUENCE #{row[0]} RESTART WITH #{rand(50_000)}")
30
+ end
31
+ end
32
+
33
+ require File.expand_path('../models', __FILE__)
34
+
35
+ FactoryGirl.find_definitions
36
+
37
+ class ActiveSupport::TestCase
38
+
39
+ def setup
40
+ WebMock.stub_request(:any, /^http:\/\/activehistory.com\/.*/)
41
+ end
42
+
43
+ def assert_posted(path, &block)
44
+ assert_requested(:post, "#{ActiveHistory.url}#{path}", times: 1, &block)
45
+ end
46
+
47
+ def assert_not_posted(path)
48
+ assert_not_requested(:post, "#{ActiveHistory.url}#{path}")
49
+ end
50
+
51
+ include ActiveRecord::TestFixtures
52
+ include FactoryGirl::Syntax::Methods
53
+ end
54
+
55
+ # ActiveRecord::Base.logger = Logger.new(STDOUT)
metadata ADDED
@@ -0,0 +1,282 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: activehistory
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ platform: ruby
6
+ authors:
7
+ - Jon Bracy
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-10-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rdoc
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: sdoc
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitest
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: minitest-reporters
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: mocha
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: faker
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: factory_girl
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: webmock
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: sdoc-templates-42floors
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: simplecov
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: pg
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
195
+ - !ruby/object:Gem::Dependency
196
+ name: arel
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - "~>"
200
+ - !ruby/object:Gem::Version
201
+ version: '7.0'
202
+ type: :runtime
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - "~>"
207
+ - !ruby/object:Gem::Version
208
+ version: '7.0'
209
+ - !ruby/object:Gem::Dependency
210
+ name: activerecord
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - '='
214
+ - !ruby/object:Gem::Version
215
+ version: 5.0.0.1
216
+ type: :runtime
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - '='
221
+ - !ruby/object:Gem::Version
222
+ version: 5.0.0.1
223
+ description: |
224
+ ActiveHistory tracks and logs changes to your ActiveRecord models and
225
+ relationships for auditing in the future.
226
+ email:
227
+ - jonbracy@gmail.com
228
+ executables: []
229
+ extensions: []
230
+ extra_rdoc_files: []
231
+ files:
232
+ - ".gitignore"
233
+ - Gemfile
234
+ - Gemfile.lock
235
+ - LICENSE
236
+ - README.md
237
+ - Rakefile
238
+ - activehistory.gemspec
239
+ - lib/activehistory.rb
240
+ - lib/activehistory/action.rb
241
+ - lib/activehistory/adapters/active_record.rb
242
+ - lib/activehistory/connection.rb
243
+ - lib/activehistory/event.rb
244
+ - lib/activehistory/exceptions.rb
245
+ - lib/activehistory/regard.rb
246
+ - lib/activehistory/version.rb
247
+ - test/active_record_adapter/association_test/belongs_to_association_test.rb
248
+ - test/active_record_adapter/association_test/has_and_belongs_to_many_test.rb
249
+ - test/active_record_adapter/association_test/has_many_association_test.rb
250
+ - test/active_record_adapter/association_test/has_one_association_test.rb
251
+ - test/active_record_adapter/create_test.rb
252
+ - test/active_record_adapter/destroy_test.rb
253
+ - test/active_record_adapter/event_test.rb
254
+ - test/active_record_adapter/save_test.rb
255
+ - test/factories.rb
256
+ - test/models.rb
257
+ - test/schema.rb
258
+ - test/test_helper.rb
259
+ homepage: https://activehistory.com
260
+ licenses: []
261
+ metadata: {}
262
+ post_install_message:
263
+ rdoc_options: []
264
+ require_paths:
265
+ - lib
266
+ required_ruby_version: !ruby/object:Gem::Requirement
267
+ requirements:
268
+ - - ">="
269
+ - !ruby/object:Gem::Version
270
+ version: '0'
271
+ required_rubygems_version: !ruby/object:Gem::Requirement
272
+ requirements:
273
+ - - ">="
274
+ - !ruby/object:Gem::Version
275
+ version: '0'
276
+ requirements: []
277
+ rubyforge_project:
278
+ rubygems_version: 2.6.4
279
+ signing_key:
280
+ specification_version: 4
281
+ summary: Track changes to ActiveRecord models
282
+ test_files: []