Modul sollte keine Abhängigkeit von Modulgruppe haben

This commit is contained in:
Thomas Blazek
2013-08-05 11:12:07 +02:00
parent eb2f14f18b
commit 15a9b4fbe7
3 changed files with 15 additions and 2 deletions

View File

@@ -18,7 +18,7 @@ class Modul < ActiveRecord::Base
has_and_belongs_to_many :modulgruppen has_and_belongs_to_many :modulgruppen
validates :modulgruppen, :presence=>true # Ein Modul muss zu einer Modulgruppe gehören # validates :modulgruppen, :presence=>true # Ein Modul muss zu einer Modulgruppe gehören
validates :name, :presence=>true # Ein Modul muss einen Namen haben validates :name, :presence=>true # Ein Modul muss einen Namen haben
translates :desc,:depend,:name, :versioning =>true, :fallbacks_for_empty_translations => true translates :desc,:depend,:name, :versioning =>true, :fallbacks_for_empty_translations => true

View File

@@ -2,5 +2,9 @@
FactoryGirl.define do FactoryGirl.define do
factory :modul do factory :modul do
name ""
factory :other_modul do
name "Modul 1"
end
end end
end end

View File

@@ -1,5 +1,14 @@
require 'spec_helper' require 'spec_helper'
describe Modul do describe Modul do
pending "add some examples to (or delete) #{__FILE__}" it "should not be valid without name" do
m = FactoryGirl.build(:modul)
m.should_not be_valid
m.should have(1).errors_on(:name)
end
it "should be valid with name" do
m = FactoryGirl.build(:modul)
m.name = "Grundlagen"
m.should be_valid
end
end end