AutoCommit Son Aug 30 14:03:01 CEST 2015
This commit is contained in:
5
Gemfile
5
Gemfile
@@ -86,6 +86,9 @@ gem 'carrierwave', "~>0.9.0"
|
|||||||
group :development, :test do
|
group :development, :test do
|
||||||
gem 'factory_girl_rails'
|
gem 'factory_girl_rails'
|
||||||
gem 'rspec-rails'
|
gem 'rspec-rails'
|
||||||
|
gem 'minitest'
|
||||||
|
gem 'rspec-collection_matchers'
|
||||||
|
gem 'rspec-expectations'
|
||||||
end
|
end
|
||||||
|
|
||||||
gem "simple_calendar", "~> 0.1.9"
|
gem "simple_calendar", "~> 0.1.9"
|
||||||
@@ -125,3 +128,5 @@ gem 'blueimp-gallery'
|
|||||||
gem 'blueimp-gallery-rails'
|
gem 'blueimp-gallery-rails'
|
||||||
|
|
||||||
gem 'shareable'
|
gem 'shareable'
|
||||||
|
|
||||||
|
gem 'sunspot_test'
|
||||||
@@ -34,7 +34,7 @@ class Studium < ActiveRecord::Base
|
|||||||
has_many :lvas, :through=>:moduls
|
has_many :lvas, :through=>:moduls
|
||||||
has_many :semester, :dependent => :destroy
|
has_many :semester, :dependent => :destroy
|
||||||
has_many :attachments, :as=>:parent
|
has_many :attachments, :as=>:parent
|
||||||
validates :abkuerzung, :length=>{:maximum=>5}, :format=>{:with=>/^[a-zA-z]{0,5}$/}
|
validates :abkuerzung, :length=>{:maximum=>5}, :format=>{:with=>/^[a-zA-z]{0,5}$/}
|
||||||
validates :typ, :inclusion => {:in => ["Bachelor","Master"] }
|
validates :typ, :inclusion => {:in => ["Bachelor","Master"] }
|
||||||
validates :name, :uniqueness => true, :presence=>true
|
validates :name, :uniqueness => true, :presence=>true
|
||||||
validates :zahl, :presence=>true, :format=>{:with=>/^[0-9A-Z]{4,10}$/}, :uniqueness => true
|
validates :zahl, :presence=>true, :format=>{:with=>/^[0-9A-Z]{4,10}$/}, :uniqueness => true
|
||||||
|
|||||||
@@ -2,5 +2,8 @@
|
|||||||
|
|
||||||
FactoryGirl.define do
|
FactoryGirl.define do
|
||||||
factory :beispiel do
|
factory :beispiel do
|
||||||
|
name "BSP1"
|
||||||
|
desc "sdf"
|
||||||
|
datum Date.today
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,5 +2,13 @@
|
|||||||
|
|
||||||
FactoryGirl.define do
|
FactoryGirl.define do
|
||||||
factory :lva do
|
factory :lva do
|
||||||
|
name "Vorlesung 1"
|
||||||
|
desc "Das ist eine Vorlesung"
|
||||||
|
lvanr "001.002"
|
||||||
|
ects 3
|
||||||
|
stunden 2
|
||||||
|
pruefungsinformation "sdf"
|
||||||
|
lernaufwand "sdf"
|
||||||
|
typ 'VO'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
# Read about factories at https://github.com/thoughtbot/factory_girl
|
# Read about factories at https://github.com/thoughtbot/factory_girl
|
||||||
|
|
||||||
FactoryGirl.define do
|
FactoryGirl.define do
|
||||||
|
|
||||||
factory :modul do
|
factory :modul do
|
||||||
name ""
|
name ""
|
||||||
factory :other_modul do
|
factory :other_modul do
|
||||||
|
|||||||
@@ -1,5 +1,20 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe Beispiel do
|
describe Beispiel do
|
||||||
pending "add some examples to (or delete) #{__FILE__}"
|
|
||||||
|
it "should be created" do
|
||||||
|
b=FactoryGirl.build(:beispiel)
|
||||||
|
l=FactoryGirl.create(:lva)
|
||||||
|
b.lva=l
|
||||||
|
expect{b.save!; Sunspot.commit}.to change{Beispiel.count}.by(1)
|
||||||
|
end
|
||||||
|
it "should not be valid without lva" do
|
||||||
|
b=FactoryGirl.build(:beispiel)
|
||||||
|
expect(b.valid?).to be false
|
||||||
|
end
|
||||||
|
it "shout respond to comments" do
|
||||||
|
b=FactoryGirl.create(:beispiel)
|
||||||
|
expect(b.responds_to?(:comments)).to be true
|
||||||
|
end
|
||||||
|
pending "should be flagable"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,4 +2,26 @@ require 'spec_helper'
|
|||||||
|
|
||||||
describe Lva do
|
describe Lva do
|
||||||
pending "add some examples to (or delete) #{__FILE__}"
|
pending "add some examples to (or delete) #{__FILE__}"
|
||||||
|
it "should be created" do
|
||||||
|
l=FactoryGirl.build(:lva)
|
||||||
|
mg=FactoryGirl.build(:modulgruppe)
|
||||||
|
s=FactoryGirl.create(:studium)
|
||||||
|
mg.studium= s
|
||||||
|
mg.save!
|
||||||
|
|
||||||
|
m=FactoryGirl.build(:other_modul)
|
||||||
|
m.modulgruppe=mg
|
||||||
|
m.save!
|
||||||
|
|
||||||
|
l.modul= m
|
||||||
|
expect{l.save!; Sunspot.commit}.to change{Lva.count}.by(1)
|
||||||
|
end
|
||||||
|
it "should not be valid without module" do
|
||||||
|
l=FactoryGirl.build(:lva)
|
||||||
|
expect(l.valid?).to be false
|
||||||
|
expect(l.errors[:modul].size).to be(1)
|
||||||
|
end
|
||||||
|
pending "should not be valid without modul"
|
||||||
|
pending "should have beispiele"
|
||||||
|
pending "should be flagable"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe Studium do
|
describe Studium do
|
||||||
|
# test if it is invalid if certain attributes are missing
|
||||||
[:name, :zahl].each do |attr|
|
[:name, :zahl].each do |attr|
|
||||||
it "should not be valid without #{attr}" do
|
it "should not be valid without #{attr}" do
|
||||||
s = FactoryGirl.build(:studium, attr=>nil)
|
s = FactoryGirl.build(:studium, attr=>nil)
|
||||||
@@ -10,18 +11,20 @@ describe Studium do
|
|||||||
it "should create studium with valid data" do
|
it "should create studium with valid data" do
|
||||||
s=FactoryGirl.build(:studium)
|
s=FactoryGirl.build(:studium)
|
||||||
lambda {
|
lambda {
|
||||||
s.save!}.should change {Studium.count()}.by(1)
|
s.save!; Sunspot.commit}.should change {Studium.count()}.by(1)
|
||||||
end
|
end
|
||||||
it "should not accept double entrys" do
|
it "should not accept double entrys" do
|
||||||
FactoryGirl.create(:studium)
|
FactoryGirl.create(:studium)
|
||||||
|
Sunspot.commit
|
||||||
s=FactoryGirl.build(:studium)
|
s=FactoryGirl.build(:studium)
|
||||||
s.should_not be_valid
|
s.should_not be_valid
|
||||||
s.should have_at_least(1).error_on(:name)
|
s.should have_at_least(1).error_on(:name)
|
||||||
s.should have_at_least(1).error_on(:zahl)
|
s.should have_at_least(1).error_on(:zahl)
|
||||||
end
|
end
|
||||||
it "should expect zahl to be 000.000" do
|
it "should expect zahl to be 000.000" do
|
||||||
s=FactoryGirl.build(:studium, :zahl=>"000000")
|
s=FactoryGirl.build(:studium, :zahl=>"000.000")
|
||||||
|
Sunspot.commit
|
||||||
s.should_not be_valid
|
s.should_not be_valid
|
||||||
s.should have_at_least(1).error_on(:zahl)
|
expect(s.errors.size).to be > 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ ENV["RAILS_ENV"] ||= 'test'
|
|||||||
require File.expand_path("../../config/environment", __FILE__)
|
require File.expand_path("../../config/environment", __FILE__)
|
||||||
require 'rspec/rails'
|
require 'rspec/rails'
|
||||||
require 'rspec/autorun'
|
require 'rspec/autorun'
|
||||||
|
require 'sunspot_test/rspec'
|
||||||
|
|
||||||
# Requires supporting ruby files with custom matchers and macros, etc,
|
# Requires supporting ruby files with custom matchers and macros, etc,
|
||||||
# in spec/support/ and its subdirectories.
|
# in spec/support/ and its subdirectories.
|
||||||
|
|||||||
Reference in New Issue
Block a user