Commit 9ea639652a16d336eb029bbf2ca5f8c1031b8420
1 parent
a6423fab
Exists in
master
and in
29 other branches
rails3: fix License unit tests
Showing
2 changed files
with
6 additions
and
4 deletions
Show diff stats
app/models/license.rb
@@ -14,6 +14,8 @@ class License < ActiveRecord::Base | @@ -14,6 +14,8 @@ class License < ActiveRecord::Base | ||
14 | validates_presence_of :slug, :if => lambda {|license| license.name.present?} | 14 | validates_presence_of :slug, :if => lambda {|license| license.name.present?} |
15 | validates_uniqueness_of :slug, :scope => :environment_id | 15 | validates_uniqueness_of :slug, :scope => :environment_id |
16 | 16 | ||
17 | + attr_accessible :environment, :slug | ||
18 | + | ||
17 | before_validation do |license| | 19 | before_validation do |license| |
18 | license.slug ||= license.name.to_slug if license.name.present? | 20 | license.slug ||= license.name.to_slug if license.name.present? |
19 | end | 21 | end |
test/unit/license_test.rb
@@ -4,14 +4,14 @@ class LicenseTest < ActiveSupport::TestCase | @@ -4,14 +4,14 @@ class LicenseTest < ActiveSupport::TestCase | ||
4 | should 'validate presence of name and environment' do | 4 | should 'validate presence of name and environment' do |
5 | license = License.new | 5 | license = License.new |
6 | license.valid? | 6 | license.valid? |
7 | - assert license.errors.invalid?(:name) | ||
8 | - assert license.errors.invalid?(:environment) | 7 | + assert license.errors[:name].any? |
8 | + assert license.errors[:environment].any? | ||
9 | 9 | ||
10 | license.name = 'GPLv3' | 10 | license.name = 'GPLv3' |
11 | license.environment = Environment.default | 11 | license.environment = Environment.default |
12 | license.valid? | 12 | license.valid? |
13 | - assert !license.errors.invalid?(:name) | ||
14 | - assert !license.errors.invalid?(:environment) | 13 | + assert !license.errors[:name].any? |
14 | + assert !license.errors[:environment].any? | ||
15 | end | 15 | end |
16 | 16 | ||
17 | should 'fill in slug before creation' do | 17 | should 'fill in slug before creation' do |