forked from bofh/fetsite
Upgraded to Rails 4
This commit is contained in:
@@ -2,7 +2,7 @@ require 'spec_helper'
|
||||
|
||||
describe Attachment do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
let(:attachment) {FactoryGirl.build_stubbed(:attachment)}
|
||||
let(:attachment) {FactoryBot.build_stubbed(:attachment)}
|
||||
it "responds to image" do
|
||||
expect(attachment.respond_to?(:image?)).to be true
|
||||
end
|
||||
|
||||
@@ -3,25 +3,25 @@ require 'spec_helper'
|
||||
describe Beispiel, :type=>:model do
|
||||
let_studium_lva
|
||||
# before(:each) do
|
||||
# s=FactoryGirl.create(:studium)
|
||||
# mg=FactoryGirl.create(:modulgruppe, studium_id: s.id)#
|
||||
# s=FactoryBot.create(:studium)
|
||||
# mg=FactoryBot.create(:modulgruppe, studium_id: s.id)#
|
||||
|
||||
# m=FactoryGirl.build(:other_modul)
|
||||
# m=FactoryBot.build(:other_modul)
|
||||
# m.modulgruppen << mg
|
||||
# m.save!
|
||||
|
||||
# @l=FactoryGirl.build(:lva)
|
||||
# @l=FactoryBot.build(:lva)
|
||||
# @l.modul << m
|
||||
# @l.save!
|
||||
# end
|
||||
let(:lva){FactoryGirl.build_stubbed(:lva)}
|
||||
let(:beispiel){FactoryGirl.build(:beispiel, lva: lva)}
|
||||
let(:lva){FactoryBot.build_stubbed(:lva)}
|
||||
let(:beispiel){FactoryBot.build(:beispiel, lva: lva)}
|
||||
|
||||
it "should be created" do
|
||||
expect{beispiel.save!; Sunspot.commit}.to change{Beispiel.count}.by(1)
|
||||
end
|
||||
it "is not valid without lva" do
|
||||
b=FactoryGirl.build(:beispiel)
|
||||
b=FactoryBot.build(:beispiel)
|
||||
expect(b.valid?).to be false
|
||||
end
|
||||
it "responds to comments" do
|
||||
|
||||
@@ -2,8 +2,8 @@ require 'spec_helper'
|
||||
|
||||
describe Calendar do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
let(:rubrik) {FactoryGirl.create(:rubrik)}
|
||||
let(:calendar) {FactoryGirl.build(:calendar, rubrik_id: rubrik.id)}
|
||||
let(:rubrik) {FactoryBot.create(:rubrik)}
|
||||
let(:calendar) {FactoryBot.build(:calendar, rubrik_id: rubrik.id)}
|
||||
it "should be valid" do
|
||||
expect(calendar).to be_valid
|
||||
end
|
||||
|
||||
@@ -2,11 +2,11 @@ require 'spec_helper'
|
||||
|
||||
describe Calentry do
|
||||
|
||||
let(:rubrik) {FactoryGirl.create(:rubrik)}
|
||||
let(:user) {FactoryGirl.create(:user)}
|
||||
let(:calendar) {FactoryGirl.create(:calendar,updated_at: 1.hour.ago)}
|
||||
let(:neuigkeit) {FactoryGirl.create(:neuigkeit, rubrik_id: rubrik.id, author_id: user.id, updated_at: 1.hour.ago)}
|
||||
subject(:calentry) {FactoryGirl.build(:calentry, calendar_id: calendar.id, object_type: "Neuigkeit",object_id: neuigkeit.id)}
|
||||
let(:rubrik) {FactoryBot.create(:rubrik)}
|
||||
let(:user) {FactoryBot.create(:user)}
|
||||
let(:calendar) {FactoryBot.create(:calendar,updated_at: 1.hour.ago)}
|
||||
let(:neuigkeit) {FactoryBot.create(:neuigkeit, rubrik_id: rubrik.id, author_id: user.id, updated_at: 1.hour.ago)}
|
||||
subject(:calentry) {FactoryBot.build(:calentry, calendar_id: calendar.id, object_type: "Neuigkeit",object_id: neuigkeit.id)}
|
||||
|
||||
it "is valid with full data" do
|
||||
expect(calentry).to be_valid
|
||||
@@ -14,7 +14,7 @@ describe Calentry do
|
||||
|
||||
[:ende,:start,:typ].each do |attr|
|
||||
it "is not valid without #{attr}" do
|
||||
e= FactoryGirl.build(:calentry, calendar_id: calendar.id, object_type: "Neuigkeit",object_id: neuigkeit.id, attr => nil)
|
||||
e= FactoryBot.build(:calentry, calendar_id: calendar.id, object_type: "Neuigkeit",object_id: neuigkeit.id, attr => nil)
|
||||
expect(e).not_to be_valid
|
||||
expect(e).to have_at_least(1).errors_on(attr)
|
||||
end
|
||||
|
||||
@@ -3,22 +3,22 @@ require 'spec_helper'
|
||||
describe Fetprofile do
|
||||
[:vorname,:nachname].each do |attr|
|
||||
it "should not be valid without #{attr}" do
|
||||
fp = FactoryGirl.build(:fetprofile)
|
||||
fp = FactoryBot.build(:fetprofile)
|
||||
fp.send("#{attr}=".to_sym,nil)
|
||||
fp.should_not be_valid
|
||||
end
|
||||
end
|
||||
it "should be created" do
|
||||
fp=Fetprofile.new(FactoryGirl.attributes_for(:fetprofile))
|
||||
fp=Fetprofile.new(FactoryBot.attributes_for(:fetprofile))
|
||||
expect(fp.save).to be true
|
||||
end
|
||||
|
||||
it "should be valid" do
|
||||
fp = FactoryGirl.build(:fetprofile)
|
||||
fp = FactoryBot.build(:fetprofile)
|
||||
fp.should be_valid
|
||||
end
|
||||
it "should not be valid with short name" do
|
||||
fp = FactoryGirl.build(:fetprofile)
|
||||
fp = FactoryBot.build(:fetprofile)
|
||||
fp.nachname ="S"
|
||||
fp.should_not be_valid
|
||||
fp.vorname ="d"
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe Gremium do
|
||||
let(:gremium) {FactoryGirl.build(:gremium)}
|
||||
let(:gremium) {FactoryBot.build(:gremium)}
|
||||
let(:object_variable){gremium}
|
||||
it_behaves_like "a valid object"
|
||||
|
||||
[:name,:typ].each do |attr|
|
||||
it "is not valid without #{attr}" do
|
||||
g = FactoryGirl.build(:gremium,attr.to_sym => nil)
|
||||
g = FactoryBot.build(:gremium,attr.to_sym => nil)
|
||||
expect(g).not_to be_valid
|
||||
expect(g.errors[attr]).to have_at_least(1).items
|
||||
end
|
||||
@@ -18,33 +18,33 @@ describe Gremium do
|
||||
|
||||
it "is not valid with wrong typ" do
|
||||
((-5..30).to_a-Gremium::TYPEN.keys()).each do |i|
|
||||
g = FactoryGirl.build(:gremium, typ: i)
|
||||
g = FactoryBot.build(:gremium, typ: i)
|
||||
expect(g).not_to be_valid
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
it "is in tabs if typ is 1" do
|
||||
g = FactoryGirl.create(:gremium, typ: 1)
|
||||
g = FactoryBot.create(:gremium, typ: 1)
|
||||
expect(Gremium.tabs).to eq([g])
|
||||
end
|
||||
|
||||
|
||||
it "is not in tabs if typ is not 1 or 3" do
|
||||
g = FactoryGirl.create(:gremium, typ: 2)
|
||||
g = FactoryBot.create(:gremium, typ: 2)
|
||||
expect(Gremium.tabs).to eq([])
|
||||
end
|
||||
it "destroys memberships if its destroyed" do
|
||||
g=FactoryGirl.create(:gremium)
|
||||
fp=FactoryGirl.create(:fetprofile)
|
||||
m=FactoryGirl.create(:membership, gremium_id: g.id, fetprofile_id: fp.id)
|
||||
g=FactoryBot.create(:gremium)
|
||||
fp=FactoryBot.create(:fetprofile)
|
||||
m=FactoryBot.create(:membership, gremium_id: g.id, fetprofile_id: fp.id)
|
||||
expect{g.destroy}.to change {Membership.count}.by(-1)
|
||||
|
||||
|
||||
end
|
||||
|
||||
it "responds to title" do
|
||||
g=FactoryGirl.build(:gremium)
|
||||
g=FactoryBot.build(:gremium)
|
||||
expect(g.respond_to?(:title)).to be true
|
||||
end
|
||||
end
|
||||
|
||||
@@ -51,7 +51,7 @@ describe Lva, :type=>:model do
|
||||
end
|
||||
|
||||
describe "if bare" do
|
||||
let(:lva) {FactoryGirl.build(:lva)}
|
||||
let(:lva) {FactoryBot.build(:lva)}
|
||||
it "should be created" do
|
||||
l=lva
|
||||
l.modul << modul
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
require 'spec_helper'
|
||||
|
||||
RSpec.describe Meeting, :type => :model do
|
||||
let(:user){FactoryGirl.create(:user)}
|
||||
let(:rubrik) {FactoryGirl.create(:rubrik)}
|
||||
let(:calendar){FactoryGirl.create(:calendar, rubrik_id: rubrik.id)}
|
||||
let(:calentry){FactoryGirl.build(:calentry, calendar_id: calendar.id, typ: 2)}
|
||||
let(:meetingtyp){FactoryGirl.create(:meetingtyp, rubrik_id: rubrik.id)}
|
||||
let(:meeting){FactoryGirl.build(:meeting, meetingtyp_id: meetingtyp.id)}
|
||||
let(:user){FactoryBot.create(:user)}
|
||||
let(:rubrik) {FactoryBot.create(:rubrik)}
|
||||
let(:calendar){FactoryBot.create(:calendar, rubrik_id: rubrik.id)}
|
||||
let(:calentry){FactoryBot.build(:calentry, calendar_id: calendar.id, typ: 2)}
|
||||
let(:meetingtyp){FactoryBot.create(:meetingtyp, rubrik_id: rubrik.id)}
|
||||
let(:meeting){FactoryBot.build(:meeting, meetingtyp_id: meetingtyp.id)}
|
||||
let(:object_variable) {meeting}
|
||||
|
||||
it_behaves_like "a valid object"
|
||||
@@ -27,7 +27,7 @@ RSpec.describe Meeting, :type => :model do
|
||||
expect(meeting).to be_valid
|
||||
end
|
||||
context "without calentry" do
|
||||
# let(:meeting){FactoryGirl.build(:meeting, :without_calentry, meetingtyp_id: meetingtyp.id)}
|
||||
# let(:meeting){FactoryBot.build(:meeting, :without_calentry, meetingtyp_id: meetingtyp.id)}
|
||||
|
||||
it "should be creating a calentry typ 2" do
|
||||
meeting.create_calentry
|
||||
|
||||
@@ -2,8 +2,8 @@ require 'spec_helper'
|
||||
|
||||
RSpec.describe Meetingtyp, :type => :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
let(:rubrik) {FactoryGirl.create(:rubrik)}
|
||||
let(:meetingtyp){FactoryGirl.build(:meetingtyp, rubrik_id: rubrik.id)}
|
||||
let(:rubrik) {FactoryBot.create(:rubrik)}
|
||||
let(:meetingtyp){FactoryBot.build(:meetingtyp, rubrik_id: rubrik.id)}
|
||||
it "should be created" do
|
||||
expect(meetingtyp).to be_valid
|
||||
expect(meetingtyp.save).to be true
|
||||
|
||||
@@ -3,14 +3,14 @@ require 'spec_helper'
|
||||
describe Modul do
|
||||
[:name].each do |attr|
|
||||
it "should not be valid without #{attr}" do
|
||||
modul = FactoryGirl.build(:modul)
|
||||
modul = FactoryBot.build(:modul)
|
||||
modul.send("#{attr}=".to_sym,nil)
|
||||
expect(modul).not_to be_valid
|
||||
expect(modul).to have_at_least(1).errors_on(attr)
|
||||
end
|
||||
end
|
||||
it "is valid with everything" do
|
||||
m = FactoryGirl.build(:modul)
|
||||
m = FactoryBot.build(:modul)
|
||||
expect(m).to be_valid
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,42 +2,42 @@ require 'spec_helper'
|
||||
|
||||
describe Modulgruppe, :type =>:model do
|
||||
it "should not be valid without studium" do
|
||||
mg=FactoryGirl.build(:modulgruppe)
|
||||
mg=FactoryBot.build(:modulgruppe)
|
||||
mg.should_not be_valid
|
||||
mg.should have(1).errors_on(:studium_id)
|
||||
end
|
||||
it "should be valid with studium" do
|
||||
s=FactoryGirl.create(:studium)
|
||||
mg=FactoryGirl.build(:modulgruppe)
|
||||
s=FactoryBot.create(:studium)
|
||||
mg=FactoryBot.build(:modulgruppe)
|
||||
mg.studium=s
|
||||
mg.should be_valid
|
||||
end
|
||||
it "should not be valid without name" do
|
||||
s=FactoryGirl.create(:studium)
|
||||
mg=FactoryGirl.build(:modulgruppe)
|
||||
s=FactoryBot.create(:studium)
|
||||
mg=FactoryBot.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")
|
||||
s=FactoryBot.create(:studium)
|
||||
mg=FactoryBot.build(:modulgruppe, name: "Gruppe 1", desc: "132")
|
||||
mg.studium=s
|
||||
mg.save
|
||||
mg=FactoryGirl.build(:modulgruppe, name: "Gruppe 2", desc: "133")
|
||||
mg=FactoryBot.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")
|
||||
s=FactoryBot.create(:studium)
|
||||
s2=FactoryBot.create(:other_studium)
|
||||
mg=FactoryBot.build(:modulgruppe, name: "Gruppe")
|
||||
mg.studium=s
|
||||
mg.save
|
||||
mg=FactoryGirl.build(:other_modulgruppe, name: "Gruppe")
|
||||
mg=FactoryBot.build(:other_modulgruppe, name: "Gruppe")
|
||||
mg.studium=s2
|
||||
mg.should be_valid
|
||||
|
||||
|
||||
@@ -2,13 +2,13 @@ require 'spec_helper'
|
||||
|
||||
describe Neuigkeit do
|
||||
|
||||
let(:neuigkeit) {(FactoryGirl.build(:neuigkeit, :with_rubrik))}
|
||||
let(:intern_neuigkeit) {FactoryGirl.build(:neuigkeit, :with_intern_rubrik)}
|
||||
let(:unpublished_neuigkeit){FactoryGirl.build(:neuigkeit, :unpublished,:with_rubrik)}
|
||||
let(:attachment) {FactoryGirl.build_stubbed(:attachment)}
|
||||
let(:neuigkeit) {(FactoryBot.build(:neuigkeit, :with_rubrik))}
|
||||
let(:intern_neuigkeit) {FactoryBot.build(:neuigkeit, :with_intern_rubrik)}
|
||||
let(:unpublished_neuigkeit){FactoryBot.build(:neuigkeit, :unpublished,:with_rubrik)}
|
||||
let(:attachment) {FactoryBot.build_stubbed(:attachment)}
|
||||
|
||||
let(:calentry) {
|
||||
FactoryGirl.build(:calentry, start: 1.hour.ago, ende: 5.minutes.ago)
|
||||
FactoryBot.build(:calentry, start: 1.hour.ago, ende: 5.minutes.ago)
|
||||
}
|
||||
|
||||
let(:object_variable) {neuigkeit}
|
||||
@@ -40,7 +40,7 @@ describe Neuigkeit do
|
||||
end
|
||||
|
||||
context "with meeting" do
|
||||
let(:neuigkeit) {(FactoryGirl.build(:neuigkeit, :with_rubrik, :with_meeting))}
|
||||
let(:neuigkeit) {(FactoryBot.build(:neuigkeit, :with_rubrik, :with_meeting))}
|
||||
let(:object_variable) {neuigkeit}
|
||||
it_behaves_like "a valid object"
|
||||
it "has meeting" do expect(neuigkeit.meeting).to be_truthy end
|
||||
|
||||
@@ -2,7 +2,7 @@ require 'spec_helper'
|
||||
|
||||
describe Rubrik do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
let(:rubrik){FactoryGirl.create(:rubrik)}
|
||||
let(:rubrik){FactoryBot.create(:rubrik)}
|
||||
it "should be valid" do
|
||||
expect(rubrik).to be_valid
|
||||
end
|
||||
|
||||
@@ -2,12 +2,12 @@ require 'spec_helper'
|
||||
|
||||
describe Studium do
|
||||
# test if it is invalid if certain attributes are missing
|
||||
let(:studium) { FactoryGirl.build(:studium)}
|
||||
let(:studium) { FactoryBot.build(:studium)}
|
||||
let(:object_variable) {studium}
|
||||
|
||||
[:name, :zahl].each do |attr|
|
||||
it "should not be valid without #{attr}" do
|
||||
s = FactoryGirl.build(:studium, attr=>nil)
|
||||
s = FactoryBot.build(:studium, attr=>nil)
|
||||
expect(s).not_to be_valid
|
||||
end
|
||||
end
|
||||
@@ -15,12 +15,12 @@ describe Studium do
|
||||
it_behaves_like "a valid object"
|
||||
|
||||
it "should create studium with valid data" do
|
||||
s=FactoryGirl.build(:studium)
|
||||
s=FactoryBot.build(:studium)
|
||||
lambda {
|
||||
s.save!; Sunspot.commit}.should change {Studium.count()}.by(1)
|
||||
end
|
||||
it "should not accept double entrys" do
|
||||
FactoryGirl.create(:studium)
|
||||
FactoryBot.create(:studium)
|
||||
expect(studium).not_to be_valid
|
||||
|
||||
|
||||
@@ -28,14 +28,14 @@ describe Studium do
|
||||
expect(studium).to have_at_least(1).error_on(:zahl)
|
||||
end
|
||||
it "expect zahl to be 000.000" do
|
||||
s=FactoryGirl.build(:studium, :zahl=>"000.000")
|
||||
s=FactoryBot.build(:studium, :zahl=>"000.000")
|
||||
#Sunspot.commit
|
||||
s.should_not be_valid
|
||||
expect(s.errors.size).to be > 0
|
||||
end
|
||||
|
||||
it "is not valid with a short zahl" do
|
||||
s=FactoryGirl.build(:studium, :zahl=>"123")
|
||||
s=FactoryBot.build(:studium, :zahl=>"123")
|
||||
expect(s).not_to be_valid
|
||||
end
|
||||
|
||||
|
||||
@@ -4,15 +4,15 @@ describe Thema do
|
||||
|
||||
[:text, :title].each do |attr|
|
||||
it "should not be valid without #{attr}" do
|
||||
tg=FactoryGirl.build(:themengruppe)
|
||||
t = FactoryGirl.build(:thema, attr=>nil)
|
||||
tg=FactoryBot.build(:themengruppe)
|
||||
t = FactoryBot.build(:thema, attr=>nil)
|
||||
t.themengruppe=tg
|
||||
t.should_not be_valid
|
||||
end
|
||||
end
|
||||
it "should not be valid without Themengruppe" do
|
||||
tg=FactoryGirl.build(:themengruppe)
|
||||
t = FactoryGirl.build(:thema)
|
||||
tg=FactoryBot.build(:themengruppe)
|
||||
t = FactoryBot.build(:thema)
|
||||
t.should_not be_valid
|
||||
end
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ require 'spec_helper'
|
||||
describe Themengruppe do
|
||||
[:text, :title].each do |attr|
|
||||
it "should not be valid without #{attr}" do
|
||||
tg=FactoryGirl.build(:themengruppe, attr=>nil)
|
||||
tg=FactoryBot.build(:themengruppe, attr=>nil)
|
||||
tg.should_not be_valid
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user