merit 2.1.0 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 62f239d505d3f998184052a8cc62602609fcc06d
4
- data.tar.gz: c1d5bdba54829b26022f9b68322025574e0078df
3
+ metadata.gz: fffa4a71100476ce7342d95ec21d9841dcdba506
4
+ data.tar.gz: 366af39f2fe07ec2eb644a5e7e2710a6fb95abcf
5
5
  SHA512:
6
- metadata.gz: e58ae9a432d4d9a74cf5fed778acee101d39d17cef09a3d8e8fcdd994589d5ce1d091fda10f103d45e3e2a0bfe22b83ae42e536040717badf6586baea0c2cefe
7
- data.tar.gz: b1d067b943eb541adf433b6e775d8bd9ba01d606897ccec084f57aff26c055ffa9c248f3c444356fc1f3b576fd9e17e0e9372b1d046a16f74e794a3eeb77270a
6
+ metadata.gz: 766d06b7c33496656d497f3b06a522e9e29f3d4322e500168cfbfcb0deae4ec0502e1ac754108e6545e61c2e16d7f4538cae24d29e65b8bc1fd4789ffae6e646
7
+ data.tar.gz: 09a1a3dbdc6d61b0acdebb4458fbc043eebcb487f95455bdc913120b97420bee7a4301ae8d34632045b9eb754377ee514fb720cd8a1022b9e6c829bcf7c1fb1d
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.1.1
4
+
5
+ - [#158] Migrations bug fix.
6
+
3
7
  ## 2.1.0
4
8
 
5
9
  - [#148] Mongoid support
@@ -14,7 +14,7 @@ module ActiveRecord
14
14
 
15
15
  def copy_migrations_and_model
16
16
  migration_template 'add_fields_to_model.rb',
17
- "db/migrate/add_fields_to_#{table_name}"
17
+ "db/migrate/add_fields_to_#{table_name}.rb"
18
18
  end
19
19
  end
20
20
  end
@@ -17,7 +17,7 @@ module ActiveRecord
17
17
  'db/migrate/remove_merit_tables.rb'
18
18
 
19
19
  migration_template 'remove_fields_from_model.rb',
20
- "db/migrate/remove_fields_from_#{table_name}"
20
+ "db/migrate/remove_fields_from_#{table_name}.rb"
21
21
  end
22
22
  end
23
23
  end
@@ -13,7 +13,7 @@ module Merit
13
13
  private
14
14
 
15
15
  def model_exists?
16
- File.exists?(File.join(destination_root, model_path))
16
+ File.exist? File.join(destination_root, model_path)
17
17
  end
18
18
 
19
19
  def model_path
@@ -7,7 +7,7 @@ module Merit
7
7
  private
8
8
 
9
9
  def model_exists?
10
- File.exists?(File.join(destination_root, model_path))
10
+ File.exist? File.join(destination_root, model_path)
11
11
  end
12
12
 
13
13
  def model_path
@@ -36,7 +36,8 @@ module Merit
36
36
 
37
37
  # Define current_user_method
38
38
  def self.current_user_method
39
- @config.current_user_method || "current_#{@config.user_model_name.downcase}".to_sym
39
+ @config.current_user_method ||
40
+ "current_#{@config.user_model_name.downcase}".to_sym
40
41
  end
41
42
 
42
43
  def self.observers
@@ -36,9 +36,10 @@ module Merit
36
36
  def target_object
37
37
  target_obj = instance_variable_get(:"@#{controller_name.singularize}")
38
38
  if target_obj.nil?
39
- str = '[merit] No object found, maybe you need a ' +
40
- "'@#{controller_name.singularize}' variable in " +
41
- "'#{controller_path}_controller'?"
39
+ str = '[merit] No object found, you might need a ' \
40
+ "'@#{controller_name.singularize}' variable in " \
41
+ "'#{controller_path}_controller' if no reputation is applied. " \
42
+ 'If you are using `model_name` option in the rule this is ok.'
42
43
  Rails.logger.warn str
43
44
  end
44
45
  target_obj
@@ -1,13 +1,19 @@
1
1
  module Merit
2
2
  class ReputationChangeObserver
3
3
  def update(changed_data)
4
- # TODO: sometimes we recieved true in changed_data[:merit_object]
5
- # it should be nil or merit object with activity_logs relation
6
4
  ActivityLog.create(
7
5
  description: changed_data[:description],
8
- related_change: (changed_data[:merit_object] if changed_data[:merit_object].respond_to?(:activity_logs)),
6
+ related_change: related_change(changed_data),
9
7
  action_id: changed_data[:merit_action_id]
10
8
  )
11
9
  end
10
+
11
+ private
12
+
13
+ def related_change(data)
14
+ if data[:merit_object].respond_to?(:activity_logs)
15
+ data[:merit_object]
16
+ end
17
+ end
12
18
  end
13
19
  end
@@ -5,7 +5,7 @@ Gem::Specification.new do |s|
5
5
  s.homepage = "http://github.com/tute/merit"
6
6
  s.files = `git ls-files`.split("\n").reject{|f| f =~ /^\./ }
7
7
  s.license = 'MIT'
8
- s.version = '2.1.0'
8
+ s.version = '2.1.1'
9
9
  s.authors = ["Tute Costa"]
10
10
  s.email = 'tutecosta@gmail.com'
11
11
 
@@ -7,7 +7,9 @@ module Merit
7
7
  include Merit::PointRulesMethods
8
8
 
9
9
  def initialize
10
- # Thanks for voting point
10
+ # Thanks for voting point. Tests that both rules are called when both
11
+ # apply.
12
+ score 1, on: 'comments#vote'
11
13
  score 1, on: 'comments#vote'
12
14
 
13
15
  # All user's comments earn points
@@ -195,8 +195,10 @@ class NavigationTest < ActiveSupport::IntegrationCase
195
195
 
196
196
  visit "/comments/#{Comment.last.id}/vote/4"
197
197
  user = User.first
198
- assert_equal 46, user.points, 'Voting comments should grant 5 points for voted, and 1 point for voting'
199
- assert_equal 5, user.points(category: 'vote'), 'Voting comments should grant 5 points for voted in vote category'
198
+ assert_equal 47, user.points, 'Voting comments should grant 5 points for
199
+ voted, and 1 point for voting twice (repeated rule)'
200
+ assert_equal 5, user.points(category: 'vote'), 'Voting comments should
201
+ grant 5 points for voted in vote category'
200
202
 
201
203
  visit '/comments/new'
202
204
  fill_in 'Name', with: 'Hi'
@@ -205,7 +207,8 @@ class NavigationTest < ActiveSupport::IntegrationCase
205
207
  click_button('Create Comment')
206
208
 
207
209
  user = User.where(name: 'a').first
208
- assert_equal 50, user.points, 'Commenting should grant the integer in comment points if comment is an integer'
210
+ assert_equal 51, user.points, 'Commenting should grant the integer in
211
+ comment points if comment is an integer'
209
212
  end
210
213
 
211
214
  test 'user workflow should grant levels at some times' do
@@ -246,14 +249,15 @@ class NavigationTest < ActiveSupport::IntegrationCase
246
249
  end
247
250
 
248
251
  test 'assigning points to a group of records' do
249
- DummyObserver.any_instance.expects(:update).times 4
252
+ DummyObserver.any_instance.expects(:update).times 5
250
253
  commenter = User.create(name: 'commenter')
251
254
  comment_1 = commenter.comments.create(name: 'comment_1', comment: 'a')
252
255
  comment_2 = commenter.comments.create(name: 'comment_2', comment: 'b')
253
256
 
254
257
  visit comments_path
255
258
  # Thanks for voting point, to voted user and it's comments
256
- assert_difference('Merit::ActivityLog.count', 4) do
259
+ # (repeated rule, called twice)
260
+ assert_difference('Merit::ActivityLog.count', 5) do
257
261
  within "tr#c_#{comment_2.id}" do
258
262
  click_link '1'
259
263
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: merit
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tute Costa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-28 00:00:00.000000000 Z
11
+ date: 2014-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ambry
@@ -288,7 +288,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
288
288
  version: '0'
289
289
  requirements: []
290
290
  rubyforge_project:
291
- rubygems_version: 2.2.0
291
+ rubygems_version: 2.2.2
292
292
  signing_key:
293
293
  specification_version: 4
294
294
  summary: General reputation Rails engine.