Commit 9ea639652a16d336eb029bbf2ca5f8c1031b8420
1 parent
a6423fab
Exists in
master
and in
27 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 | 14 | validates_presence_of :slug, :if => lambda {|license| license.name.present?} |
| 15 | 15 | validates_uniqueness_of :slug, :scope => :environment_id |
| 16 | 16 | |
| 17 | + attr_accessible :environment, :slug | |
| 18 | + | |
| 17 | 19 | before_validation do |license| |
| 18 | 20 | license.slug ||= license.name.to_slug if license.name.present? |
| 19 | 21 | end | ... | ... |
test/unit/license_test.rb
| ... | ... | @@ -4,14 +4,14 @@ class LicenseTest < ActiveSupport::TestCase |
| 4 | 4 | should 'validate presence of name and environment' do |
| 5 | 5 | license = License.new |
| 6 | 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 | 10 | license.name = 'GPLv3' |
| 11 | 11 | license.environment = Environment.default |
| 12 | 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 | 15 | end |
| 16 | 16 | |
| 17 | 17 | should 'fill in slug before creation' do | ... | ... |