forked from bofh/fetsite
Merge branch 'teststuff'
This commit is contained in:
@@ -6,5 +6,10 @@ FactoryGirl.define do
|
|||||||
phase 1
|
phase 1
|
||||||
name "Pflichtmodule 1"
|
name "Pflichtmodule 1"
|
||||||
desc "ASDFASDF"
|
desc "ASDFASDF"
|
||||||
|
factory :other_modulgruppe do
|
||||||
|
name "PFlichtmodule 2"
|
||||||
|
desc "sdafaswdfsfr"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,10 +3,17 @@
|
|||||||
|
|
||||||
FactoryGirl.define do
|
FactoryGirl.define do
|
||||||
factory :studium do
|
factory :studium do
|
||||||
zahl "066.506"
|
zahl "066506"
|
||||||
name "Automatisierung"
|
name "Automatisierung"
|
||||||
desc "TEST DESC"
|
desc "TEST DESC"
|
||||||
typ "Master"
|
typ "Master"
|
||||||
|
|
||||||
|
factory :other_studium do
|
||||||
|
name "Telecommunication"
|
||||||
|
desc "frueher Telekommungikation"
|
||||||
|
zahl "066507"
|
||||||
|
typ "Master"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,16 +1,46 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe Modulgruppe do
|
describe Modulgruppe do
|
||||||
it "modulgruppe should not be valid without studium" do
|
it "should not be valid without studium" do
|
||||||
mg=FactoryGirl.build(:modulgruppe)
|
mg=FactoryGirl.build(:modulgruppe)
|
||||||
mg.should_not be_valid
|
mg.should_not be_valid
|
||||||
mg.should have(1).errors_on(:studium_id)
|
mg.should have(1).errors_on(:studium_id)
|
||||||
end
|
end
|
||||||
it "modulgruppe should be valid with studium" do
|
it "should be valid with studium" do
|
||||||
s=FactoryGirl.create(:studium)
|
s=FactoryGirl.create(:studium)
|
||||||
mg=FactoryGirl.build(:modulgruppe)
|
mg=FactoryGirl.build(:modulgruppe)
|
||||||
mg.studium=s
|
mg.studium=s
|
||||||
mg.should be_valid
|
mg.should be_valid
|
||||||
end
|
end
|
||||||
|
it "should not be valid without name" do
|
||||||
|
s=FactoryGirl.create(:studium)
|
||||||
|
mg=FactoryGirl.build(:modulgruppe)
|
||||||
|
mg.studium=s
|
||||||
|
mg.name=nil
|
||||||
|
mg.should_not be_valid
|
||||||
|
mg.should have_at_least(1).errors_on(:name)
|
||||||
|
end
|
||||||
|
xit "should not be valid with dubble name" do
|
||||||
|
s=FactoryGirl.create(:studium)
|
||||||
|
mg=FactoryGirl.build(:modulgruppe, name: "Gruppe 1", desc: "132")
|
||||||
|
mg.studium=s
|
||||||
|
mg.save
|
||||||
|
mg=FactoryGirl.build(:modulgruppe, name: "Gruppe 2", desc: "133")
|
||||||
|
mg.studium=s
|
||||||
|
mg.should_not be_valid
|
||||||
|
mg.should have_at_least(1).errors_on(:name)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should be valid with same name on different studien" do
|
||||||
|
s=FactoryGirl.create(:studium)
|
||||||
|
s2=FactoryGirl.create(:other_studium)
|
||||||
|
mg=FactoryGirl.build(:modulgruppe, name: "Gruppe")
|
||||||
|
mg.studium=s
|
||||||
|
mg.save
|
||||||
|
mg=FactoryGirl.build(:other_modulgruppe, name: "Gruppe")
|
||||||
|
mg.studium=s2
|
||||||
|
mg.should be_valid
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user