Commit c40cfd39bbef682930a2d5627e36f7493e81aa74
Committed by
Daniela Feitosa
1 parent
0d4ff218
Exists in
master
and in
28 other branches
Fixing ActionTracker::Record.user validation
* Also creating a migration to remove the broken records. (ActionItem1785)
Showing
3 changed files
with
15 additions
and
2 deletions
Show diff stats
db/migrate/20110127174236_remove_action_tracker_record_with_nil_users.rb
0 → 100644
vendor/plugins/action_tracker/lib/action_tracker_model.rb
@@ -11,8 +11,7 @@ module ActionTracker | @@ -11,8 +11,7 @@ module ActionTracker | ||
11 | before_validation :stringify_verb | 11 | before_validation :stringify_verb |
12 | 12 | ||
13 | validates_presence_of :verb | 13 | validates_presence_of :verb |
14 | - validates_presence_of :user_id | ||
15 | - validates_presence_of :user_type | 14 | + validates_presence_of :user |
16 | 15 | ||
17 | alias_method :subject, :user | 16 | alias_method :subject, :user |
18 | 17 |
vendor/plugins/action_tracker/test/action_tracker_model_test.rb
@@ -67,6 +67,11 @@ class ActionTrackerModelTest < ActiveSupport::TestCase | @@ -67,6 +67,11 @@ class ActionTrackerModelTest < ActiveSupport::TestCase | ||
67 | end | 67 | end |
68 | end | 68 | end |
69 | 69 | ||
70 | + def test_user_exists_indeed | ||
71 | + ta = ActionTracker::Record.new(:user_id => -1, :user_type => "SomeModel", :verb => :some_verb) | ||
72 | + assert !ta.valid? | ||
73 | + end | ||
74 | + | ||
70 | def test_verb_must_be_declared_previously | 75 | def test_verb_must_be_declared_previously |
71 | ActionTrackerConfig.verbs = { :some_verb => { :description => "Did something" } } | 76 | ActionTrackerConfig.verbs = { :some_verb => { :description => "Did something" } } |
72 | assert_raise ActiveRecord::RecordInvalid do | 77 | assert_raise ActiveRecord::RecordInvalid do |