secretary-rails 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -12,6 +12,11 @@ describe Secretary::InstallGenerator do
12
12
  end
13
13
 
14
14
  it 'copies the migration file' do
15
- assert_migration "db/migrate/create_versions"
15
+ assert_migration "db/migrate/secretary_create_versions"
16
16
  end
17
+
18
+ it 'copies the config' do
19
+ assert_file "config/initializers/secretary.rb"
20
+ end
21
+
17
22
  end
@@ -33,8 +33,9 @@ describe "Dirty Singular Association" do
33
33
  version.object_changes["image"][0].should eq Hash[]
34
34
 
35
35
  version.object_changes["image"][1].should eq Hash[{
36
- "title" => "Superman",
37
- "url" => "superman.jpg"
36
+ "title" => "Superman",
37
+ "url" => "superman.jpg",
38
+ "story_id" => story.id
38
39
  }]
39
40
  end
40
41
 
@@ -49,8 +50,9 @@ describe "Dirty Singular Association" do
49
50
 
50
51
  versions = story.versions.order('version_number').to_a
51
52
  versions.last.object_changes["image"][0].should eq Hash[{
52
- "title" => "Superman",
53
- "url" => "superman.jpg"
53
+ "title" => "Superman",
54
+ "url" => "superman.jpg",
55
+ "story_id" => story.id
54
56
  }]
55
57
  versions.last.object_changes["image"][1].should eq Hash[]
56
58
  end
@@ -70,8 +72,9 @@ describe "Dirty Singular Association" do
70
72
  version = story.versions.order('version_number').last
71
73
  version.object_changes["image"][0].should eq Hash[]
72
74
  version.object_changes["image"][1].should eq Hash[{
73
- "title" => "Superman",
74
- "url" => "super.jpg"
75
+ "title" => "Superman",
76
+ "url" => "super.jpg",
77
+ "story_id" => story.id
75
78
  }]
76
79
  end
77
80
 
@@ -91,12 +94,14 @@ describe "Dirty Singular Association" do
91
94
 
92
95
  version = story.versions.order('version_number').last
93
96
  version.object_changes["image"][0].should eq Hash[{
94
- "title" => "Superman",
95
- "url" => "superman.jpg"
97
+ "title" => "Superman",
98
+ "url" => "superman.jpg",
99
+ "story_id" => story.id
96
100
  }]
97
101
  version.object_changes["image"][1].should eq Hash[{
98
102
  "title" => "Lemon",
99
- "url" => "superman.jpg"
103
+ "url" => "superman.jpg",
104
+ "story_id" => story.id
100
105
  }]
101
106
  end
102
107
 
@@ -116,8 +121,9 @@ describe "Dirty Singular Association" do
116
121
 
117
122
  version = story.versions.order('version_number').last
118
123
  version.object_changes["image"][0].should eq Hash[{
119
- "title" => "Superman",
120
- "url" => "superman.jpg"
124
+ "title" => "Superman",
125
+ "url" => "superman.jpg",
126
+ "story_id" => story.id
121
127
  }]
122
128
  version.object_changes["image"][1].should eq Hash[]
123
129
  end
@@ -205,6 +211,17 @@ describe "Dirty Singular Association" do
205
211
  }]
206
212
  end
207
213
 
214
+ it "tracks the foreign key as the normally" do
215
+ image.story_id = story.id
216
+ image.save!
217
+ image.versions.count.should eq 2
218
+
219
+ version = image.versions.order('version_number').last
220
+ version.object_changes["story_id"][0].should eq nil
221
+ version.object_changes["story_id"][1].should eq story.id
222
+ version.description.should eq "Changed Story"
223
+ end
224
+
208
225
  it 'makes a version when removing' do
209
226
  image.story = story
210
227
  image.save!
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+
3
+ describe Secretary::UserActivityAssociation do
4
+ it "adds an activities association to the user class" do
5
+ user = build :user
6
+ user.activities.to_a.should eq []
7
+ end
8
+ end
@@ -9,6 +9,14 @@ describe Secretary::Version do
9
9
  Secretary::Version.count.should eq 2
10
10
  story.versions.last.should eq version
11
11
  end
12
+
13
+ it "sets the user association" do
14
+ user = create :user
15
+ story = create :story, logged_user_id: user.id
16
+ version = Secretary::Version.generate(story)
17
+
18
+ story.versions.last.user.should eq user
19
+ end
12
20
  end
13
21
 
14
22
 
@@ -24,8 +32,14 @@ describe Secretary::Version do
24
32
 
25
33
  it "generates a description with the changed attributes on update" do
26
34
  story.save!
27
- story.update_attributes(:headline => "Another Headline", :body => "New Body")
28
- story.versions.last.description.should eq "Changed headline and body"
35
+ image = create :image
36
+
37
+ image.update_attributes({
38
+ :story_id => story.id,
39
+ :url => "http://kitty.com/kitty.jpg"
40
+ })
41
+
42
+ image.versions.last.description.should eq("Changed Story and Url")
29
43
  end
30
44
  end
31
45
 
@@ -0,0 +1,4 @@
1
+ Secretary.configure do |config|
2
+ # config.user_class = "::User"
3
+ # config.ignored_attributes = ["id", "created_at", "updated_at"]
4
+ end
@@ -4,7 +4,7 @@ class SecretaryCreateVersions < ActiveRecord::Migration
4
4
  t.integer "version_number"
5
5
  t.string "versioned_type"
6
6
  t.integer "versioned_id"
7
- t.string "user_id"
7
+ t.integer "user_id"
8
8
  t.text "description"
9
9
  t.text "object_changes"
10
10
  t.datetime "created_at"
metadata CHANGED
@@ -1,155 +1,126 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: secretary-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Bryan Ricker
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-11-19 00:00:00.000000000 Z
12
+ date: 2014-03-20 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: railties
15
- requirement: !ruby/object:Gem::Requirement
16
+ requirement: &70179114724880 !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
- - - '>='
19
+ - - ! '>='
18
20
  - !ruby/object:Gem::Version
19
21
  version: 3.2.0
20
22
  type: :runtime
21
23
  prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - '>='
25
- - !ruby/object:Gem::Version
26
- version: 3.2.0
24
+ version_requirements: *70179114724880
27
25
  - !ruby/object:Gem::Dependency
28
26
  name: activerecord
29
- requirement: !ruby/object:Gem::Requirement
27
+ requirement: &70179114724380 !ruby/object:Gem::Requirement
28
+ none: false
30
29
  requirements:
31
- - - '>='
30
+ - - ! '>='
32
31
  - !ruby/object:Gem::Version
33
32
  version: 3.2.0
34
33
  type: :runtime
35
34
  prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - '>='
39
- - !ruby/object:Gem::Version
40
- version: 3.2.0
35
+ version_requirements: *70179114724380
41
36
  - !ruby/object:Gem::Dependency
42
37
  name: diffy
43
- requirement: !ruby/object:Gem::Requirement
38
+ requirement: &70179114723920 !ruby/object:Gem::Requirement
39
+ none: false
44
40
  requirements:
45
41
  - - ~>
46
42
  - !ruby/object:Gem::Version
47
43
  version: 3.0.1
48
44
  type: :runtime
49
45
  prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ~>
53
- - !ruby/object:Gem::Version
54
- version: 3.0.1
46
+ version_requirements: *70179114723920
55
47
  - !ruby/object:Gem::Dependency
56
48
  name: sqlite3
57
- requirement: !ruby/object:Gem::Requirement
49
+ requirement: &70179114723300 !ruby/object:Gem::Requirement
50
+ none: false
58
51
  requirements:
59
- - - '>='
52
+ - - ! '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  type: :development
63
56
  prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - '>='
67
- - !ruby/object:Gem::Version
68
- version: '0'
57
+ version_requirements: *70179114723300
69
58
  - !ruby/object:Gem::Dependency
70
59
  name: mysql2
71
- requirement: !ruby/object:Gem::Requirement
60
+ requirement: &70179114722340 !ruby/object:Gem::Requirement
61
+ none: false
72
62
  requirements:
73
- - - '>='
63
+ - - ! '>='
74
64
  - !ruby/object:Gem::Version
75
65
  version: '0'
76
66
  type: :development
77
67
  prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - '>='
81
- - !ruby/object:Gem::Version
82
- version: '0'
68
+ version_requirements: *70179114722340
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: pg
85
- requirement: !ruby/object:Gem::Requirement
71
+ requirement: &70179114721580 !ruby/object:Gem::Requirement
72
+ none: false
86
73
  requirements:
87
- - - '>='
74
+ - - ! '>='
88
75
  - !ruby/object:Gem::Version
89
76
  version: '0'
90
77
  type: :development
91
78
  prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - '>='
95
- - !ruby/object:Gem::Version
96
- version: '0'
79
+ version_requirements: *70179114721580
97
80
  - !ruby/object:Gem::Dependency
98
81
  name: rspec-rails
99
- requirement: !ruby/object:Gem::Requirement
82
+ requirement: &70179117649920 !ruby/object:Gem::Requirement
83
+ none: false
100
84
  requirements:
101
- - - '>='
85
+ - - ! '>='
102
86
  - !ruby/object:Gem::Version
103
87
  version: '0'
104
88
  type: :development
105
89
  prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - '>='
109
- - !ruby/object:Gem::Version
110
- version: '0'
90
+ version_requirements: *70179117649920
111
91
  - !ruby/object:Gem::Dependency
112
92
  name: factory_girl
113
- requirement: !ruby/object:Gem::Requirement
93
+ requirement: &70179117649500 !ruby/object:Gem::Requirement
94
+ none: false
114
95
  requirements:
115
- - - '>='
96
+ - - ! '>='
116
97
  - !ruby/object:Gem::Version
117
98
  version: '0'
118
99
  type: :development
119
100
  prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - '>='
123
- - !ruby/object:Gem::Version
124
- version: '0'
101
+ version_requirements: *70179117649500
125
102
  - !ruby/object:Gem::Dependency
126
103
  name: generator_spec
127
- requirement: !ruby/object:Gem::Requirement
104
+ requirement: &70179117649000 !ruby/object:Gem::Requirement
105
+ none: false
128
106
  requirements:
129
107
  - - ~>
130
108
  - !ruby/object:Gem::Version
131
109
  version: 0.9.1
132
110
  type: :development
133
111
  prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - ~>
137
- - !ruby/object:Gem::Version
138
- version: 0.9.1
112
+ version_requirements: *70179117649000
139
113
  - !ruby/object:Gem::Dependency
140
114
  name: appraisal
141
- requirement: !ruby/object:Gem::Requirement
115
+ requirement: &70179117648500 !ruby/object:Gem::Requirement
116
+ none: false
142
117
  requirements:
143
- - - '>='
118
+ - - ! '>='
144
119
  - !ruby/object:Gem::Version
145
120
  version: 1.0.0.beta2
146
121
  type: :development
147
122
  prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - '>='
151
- - !ruby/object:Gem::Version
152
- version: 1.0.0.beta2
123
+ version_requirements: *70179117648500
153
124
  description: A Rails engine that provides simple versioning for your records.
154
125
  email:
155
126
  - bricker@scpr.org
@@ -157,8 +128,10 @@ executables: []
157
128
  extensions: []
158
129
  extra_rdoc_files: []
159
130
  files:
131
+ - app/models/concerns/secretary/user_activity_association.rb
160
132
  - app/models/secretary/version.rb
161
133
  - lib/generators/secretary/install_generator.rb
134
+ - lib/generators/secretary/templates/secretary_config.rb
162
135
  - lib/generators/secretary/templates/versions_migration.rb
163
136
  - lib/secretary/config.rb
164
137
  - lib/secretary/dirty_associations/collection.rb
@@ -185,6 +158,7 @@ files:
185
158
  - spec/internal/app/models/story.rb
186
159
  - spec/internal/app/models/story_user.rb
187
160
  - spec/internal/app/models/user.rb
161
+ - spec/internal/config/database.yml
188
162
  - spec/internal/config/database_configs/mysql.yml
189
163
  - spec/internal/config/database_configs/postgresql.yml
190
164
  - spec/internal/config/database_configs/sqlite.yml
@@ -198,35 +172,38 @@ files:
198
172
  - spec/lib/secretary/dirty_singular_association_spec.rb
199
173
  - spec/lib/secretary/has_secretary_spec.rb
200
174
  - spec/lib/secretary/tracks_association_spec.rb
175
+ - spec/lib/secretary/user_activity_association.rb
201
176
  - spec/lib/secretary/versioned_attributes_spec.rb
202
177
  - spec/lib/secretary_spec.rb
203
178
  - spec/models/secretary/version_spec.rb
204
179
  - spec/spec_helper.rb
205
180
  - spec/support/test_setup.rb
206
- - spec/tmp/db/migrate/20131119071129_create_versions.rb
181
+ - spec/tmp/config/initializers/secretary.rb
182
+ - spec/tmp/db/migrate/20140320004842_secretary_create_versions.rb
207
183
  homepage: https://github.com/scpr/secretary-rails
208
184
  licenses:
209
185
  - MIT
210
- metadata: {}
211
186
  post_install_message:
212
187
  rdoc_options: []
213
188
  require_paths:
214
189
  - lib
215
190
  required_ruby_version: !ruby/object:Gem::Requirement
191
+ none: false
216
192
  requirements:
217
- - - '>='
193
+ - - ! '>='
218
194
  - !ruby/object:Gem::Version
219
195
  version: '0'
220
196
  required_rubygems_version: !ruby/object:Gem::Requirement
197
+ none: false
221
198
  requirements:
222
- - - '>='
199
+ - - ! '>='
223
200
  - !ruby/object:Gem::Version
224
201
  version: '0'
225
202
  requirements: []
226
203
  rubyforge_project:
227
- rubygems_version: 2.0.3
204
+ rubygems_version: 1.8.11
228
205
  signing_key:
229
- specification_version: 4
206
+ specification_version: 3
230
207
  summary: Light-weight model versioning for ActiveRecord.
231
208
  test_files:
232
209
  - spec/factories.rb
@@ -239,6 +216,7 @@ test_files:
239
216
  - spec/internal/app/models/story.rb
240
217
  - spec/internal/app/models/story_user.rb
241
218
  - spec/internal/app/models/user.rb
219
+ - spec/internal/config/database.yml
242
220
  - spec/internal/config/database_configs/mysql.yml
243
221
  - spec/internal/config/database_configs/postgresql.yml
244
222
  - spec/internal/config/database_configs/sqlite.yml
@@ -252,10 +230,11 @@ test_files:
252
230
  - spec/lib/secretary/dirty_singular_association_spec.rb
253
231
  - spec/lib/secretary/has_secretary_spec.rb
254
232
  - spec/lib/secretary/tracks_association_spec.rb
233
+ - spec/lib/secretary/user_activity_association.rb
255
234
  - spec/lib/secretary/versioned_attributes_spec.rb
256
235
  - spec/lib/secretary_spec.rb
257
236
  - spec/models/secretary/version_spec.rb
258
237
  - spec/spec_helper.rb
259
238
  - spec/support/test_setup.rb
260
- - spec/tmp/db/migrate/20131119071129_create_versions.rb
261
- has_rdoc:
239
+ - spec/tmp/config/initializers/secretary.rb
240
+ - spec/tmp/db/migrate/20140320004842_secretary_create_versions.rb
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 2d57032707a48935f4cd868ce3230c1e30628931
4
- data.tar.gz: b84674f6e9d5ff487974a94657b9765ddfe37650
5
- SHA512:
6
- metadata.gz: 1cf913c07526528e2b4c8f016a8d7f2ad72d1393b471f8590e261dc69338be83df8acb6a1262345f85693904576b0dd9acba6807a3fd9cfd84375224f8ff8e5d
7
- data.tar.gz: d385d6f11fcc7db4b81a6f5791158576bd5e341fe233899e6581f25f6f514d9492e6c0f1572016b0753168ac32e19382d697c83a817d96b71179f59f63cebee6