diff --git a/.gitignore b/.gitignore
index 864b11d..9679a17 100755
--- a/.gitignore
+++ b/.gitignore
@@ -15,8 +15,8 @@
/log/*.log
/tmp
/config/initializers/devise.rb
-
-/console
+/app/doc/*
+console
/server
/public/uploads/
-*~
\ No newline at end of file
+
diff --git a/.rspec b/.rspec
new file mode 100644
index 0000000..4e1e0d2
--- /dev/null
+++ b/.rspec
@@ -0,0 +1 @@
+--color
diff --git a/Gemfile b/Gemfile
index 3fb298c..7fce64e 100755
--- a/Gemfile
+++ b/Gemfile
@@ -70,4 +70,8 @@ gem 'haml'
#gem 'gollum'
gem 'awesome_nested_set'
gem 'annotate', ">=2.5.0"
-gem 'carrierwave'
\ No newline at end of file
+gem 'carrierwave'
+group :development, :test do
+gem 'factory_girl_rails'
+gem 'rspec-rails'
+end
diff --git a/Gemfile.lock b/Gemfile.lock
index 9508763..2f98cfb 100755
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -56,9 +56,15 @@ GEM
orm_adapter (~> 0.1)
railties (~> 3.1)
warden (~> 1.2.1)
+ diff-lcs (1.2.4)
erubis (2.7.0)
execjs (1.4.0)
multi_json (~> 1.0)
+ factory_girl (4.2.0)
+ activesupport (>= 3.0.0)
+ factory_girl_rails (4.2.1)
+ factory_girl (~> 4.2.0)
+ railties (>= 3.0.0)
formtastic (2.2.1)
actionpack (>= 3.0)
formtastic-bootstrap (2.0.0)
@@ -123,6 +129,17 @@ GEM
json (~> 1.4)
ref (1.0.2)
rolify (3.2.0)
+ rspec-core (2.14.4)
+ rspec-expectations (2.14.0)
+ diff-lcs (>= 1.1.3, < 2.0)
+ rspec-mocks (2.14.1)
+ rspec-rails (2.14.0)
+ actionpack (>= 3.0)
+ activesupport (>= 3.0)
+ railties (>= 3.0)
+ rspec-core (~> 2.14.0)
+ rspec-expectations (~> 2.14.0)
+ rspec-mocks (~> 2.14.0)
sass (3.2.5)
sass-rails (3.2.6)
railties (~> 3.2.0)
@@ -165,6 +182,7 @@ DEPENDENCIES
coffee-rails (~> 3.2.1)
devise (~> 2.2.3)
execjs (~> 1.4.0)
+ factory_girl_rails
formtastic (~> 2.2.1)
formtastic-bootstrap
git
@@ -175,6 +193,7 @@ DEPENDENCIES
paperclip (~> 3.4.0)
rails (= 3.2.9)
rolify
+ rspec-rails
sass-rails (~> 3.2.3)
sqlite3
therubyracer
diff --git a/app/doc/Lva.html b/app/doc/Lva.html
index 781473d..11c7842 100644
--- a/app/doc/Lva.html
+++ b/app/doc/Lva.html
@@ -168,18 +168,6 @@ updated_at :datetime not null
modul_id :integer
semester_id :integer
-
-- Author
-
-
-
Andreas Stephanides
- - License
-
-
-
GPL
-
-
-Dieses Model repräsentiert eine LVA. Die notwendigen Informationen können
-mit TISS (dem Online System der TU Wien) synchronisiert werden
-
diff --git a/app/doc/ModulgruppenController.html b/app/doc/ModulgruppenController.html
index 643b348..086f4ce 100644
--- a/app/doc/ModulgruppenController.html
+++ b/app/doc/ModulgruppenController.html
@@ -215,9 +215,9 @@
def create
@modulgruppe = Modulgruppe.new(params[:modulgruppe])
if !params[:studium_id].nil?
- @studium=Studium.find(params[:studium_id])
+ @studium=Studium.find_by_id(params[:studium_id])
else
- @studium=Studium.find(params[:modulgruppe][:studium_id])
+ @studium=Studium.find_by_id(params[:modulgruppe][:studium_id])
end
respond_to do |format|
if @modulgruppe.save
diff --git a/app/doc/created.rid b/app/doc/created.rid
index 55e1a29..60c43be 100644
--- a/app/doc/created.rid
+++ b/app/doc/created.rid
@@ -1,4 +1,4 @@
-Tue, 23 Jul 2013 13:44:11 +0200
+Wed, 24 Jul 2013 20:10:11 +0200
./controllers/studien_controller.rb Mon, 22 Jul 2013 16:40:55 +0200
./controllers/rubriken_controller.rb Mon, 22 Jul 2013 16:40:55 +0200
./controllers/users_controller.rb Mon, 22 Jul 2013 16:40:55 +0200
@@ -8,7 +8,7 @@ Tue, 23 Jul 2013 13:44:11 +0200
./controllers/moduls_controller.rb Mon, 22 Jul 2013 16:40:55 +0200
./controllers/semesters_controller.rb Mon, 22 Jul 2013 16:40:55 +0200
./controllers/home_controller.rb Mon, 22 Jul 2013 16:40:55 +0200
-./controllers/modulgruppen_controller.rb Mon, 22 Jul 2013 16:40:55 +0200
+./controllers/modulgruppen_controller.rb Wed, 24 Jul 2013 16:58:23 +0200
./controllers/beispiele_controller.rb Mon, 22 Jul 2013 16:40:55 +0200
./controllers/neuigkeiten_controller.rb Mon, 22 Jul 2013 16:40:55 +0200
./helpers/studien_helper.rb Mon, 22 Jul 2013 16:40:55 +0200
@@ -22,16 +22,16 @@ Tue, 23 Jul 2013 13:44:11 +0200
./helpers/application_helper.rb Mon, 22 Jul 2013 16:40:55 +0200
./helpers/lvas_helper.rb Mon, 22 Jul 2013 16:40:55 +0200
./helpers/neuigkeiten_helper.rb Mon, 22 Jul 2013 16:40:55 +0200
-./models/modulgruppe.rb Tue, 23 Jul 2013 13:25:47 +0200
-./models/role.rb Tue, 23 Jul 2013 13:25:48 +0200
-./models/beispiel.rb Tue, 23 Jul 2013 13:25:48 +0200
-./models/neuigkeit.rb Tue, 23 Jul 2013 13:25:48 +0200
-./models/modul.rb Tue, 23 Jul 2013 13:25:48 +0200
+./models/modulgruppe.rb Wed, 24 Jul 2013 16:58:23 +0200
+./models/role.rb Tue, 23 Jul 2013 13:57:03 +0200
+./models/beispiel.rb Tue, 23 Jul 2013 13:57:03 +0200
+./models/neuigkeit.rb Tue, 23 Jul 2013 13:57:03 +0200
+./models/modul.rb Tue, 23 Jul 2013 13:57:03 +0200
./models/ability.rb Mon, 22 Jul 2013 16:40:55 +0200
-./models/rubrik.rb Tue, 23 Jul 2013 13:25:48 +0200
-./models/lva.rb Tue, 23 Jul 2013 13:44:06 +0200
-./models/semester.rb Tue, 23 Jul 2013 13:25:48 +0200
-./models/studium.rb Tue, 23 Jul 2013 13:25:49 +0200
-./models/user.rb Tue, 23 Jul 2013 13:25:49 +0200
+./models/rubrik.rb Tue, 23 Jul 2013 13:57:03 +0200
+./models/lva.rb Wed, 24 Jul 2013 20:09:39 +0200
+./models/semester.rb Tue, 23 Jul 2013 13:57:03 +0200
+./models/studium.rb Wed, 24 Jul 2013 16:58:23 +0200
+./models/user.rb Tue, 23 Jul 2013 13:57:03 +0200
./mailers/confirmmailer.rb Mon, 22 Jul 2013 16:40:55 +0200
./inputs/tinymce_text_input.rb Mon, 22 Jul 2013 16:40:55 +0200
diff --git a/app/doc/table_of_contents.html b/app/doc/table_of_contents.html
index b1fe53a..9076562 100644
--- a/app/doc/table_of_contents.html
+++ b/app/doc/table_of_contents.html
@@ -64,7 +64,6 @@
diff --git a/app/models/lva.rb b/app/models/lva.rb
index bc4ce8f..279af18 100755
--- a/app/models/lva.rb
+++ b/app/models/lva.rb
@@ -14,10 +14,6 @@
# modul_id :integer
# semester_id :integer
#
-# == Information
-# Author:: Andreas Stephanides
-# License:: GPL
-# Dieses Model repräsentiert eine LVA. Die notwendigen Informationen können mit TISS (dem Online System der TU Wien) synchronisiert werden
class Lva < ActiveRecord::Base
has_paper_trail # Versionsverfolgung
diff --git a/db/schema.rb b/db/schema.rb
index e41f87b..c642d5b 100755
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -13,16 +13,6 @@
ActiveRecord::Schema.define(:version => 20130214233723) do
- create_table "beispiel_translations", :force => true do |t|
- t.string "locale"
- t.text "desc"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
- t.integer "beispiele_id"
- end
-
- add_index "beispiel_translations", ["locale"], :name => "index_beispiel_translations_on_locale"
-
create_table "beispiele", :force => true do |t|
t.string "name"
t.text "desc"
diff --git a/spec/factories/beispiele.rb b/spec/factories/beispiele.rb
new file mode 100644
index 0000000..f9cfcdf
--- /dev/null
+++ b/spec/factories/beispiele.rb
@@ -0,0 +1,6 @@
+# Read about factories at https://github.com/thoughtbot/factory_girl
+
+FactoryGirl.define do
+ factory :beispiel do
+ end
+end
diff --git a/spec/factories/lvas.rb b/spec/factories/lvas.rb
new file mode 100644
index 0000000..7a0091b
--- /dev/null
+++ b/spec/factories/lvas.rb
@@ -0,0 +1,6 @@
+# Read about factories at https://github.com/thoughtbot/factory_girl
+
+FactoryGirl.define do
+ factory :lva do
+ end
+end
diff --git a/spec/factories/modulgruppen.rb b/spec/factories/modulgruppen.rb
new file mode 100644
index 0000000..0d43b62
--- /dev/null
+++ b/spec/factories/modulgruppen.rb
@@ -0,0 +1,10 @@
+# Read about factories at https://github.com/thoughtbot/factory_girl
+
+FactoryGirl.define do
+ factory :modulgruppe do
+ typ "Pflicht"
+ phase 1
+ name "Pflichtmodule 1"
+ desc "ASDFASDF"
+ end
+end
diff --git a/spec/factories/moduls.rb b/spec/factories/moduls.rb
new file mode 100644
index 0000000..ef48c30
--- /dev/null
+++ b/spec/factories/moduls.rb
@@ -0,0 +1,6 @@
+# Read about factories at https://github.com/thoughtbot/factory_girl
+
+FactoryGirl.define do
+ factory :modul do
+ end
+end
diff --git a/spec/factories/studien.rb b/spec/factories/studien.rb
new file mode 100644
index 0000000..071a60e
--- /dev/null
+++ b/spec/factories/studien.rb
@@ -0,0 +1,12 @@
+# Read about factories at https://github.com/thoughtbot/factory_girl
+
+
+FactoryGirl.define do
+ factory :studium do
+ zahl "066.506"
+ name "Automatisierung"
+ desc "TEST DESC"
+ typ "Master"
+ end
+
+end
diff --git a/spec/factories/studium_factory.rb b/spec/factories/studium_factory.rb
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/spec/factories/studium_factory.rb
@@ -0,0 +1 @@
+
diff --git a/spec/models/beispiel_spec.rb b/spec/models/beispiel_spec.rb
new file mode 100644
index 0000000..cfaeb19
--- /dev/null
+++ b/spec/models/beispiel_spec.rb
@@ -0,0 +1,5 @@
+require 'spec_helper'
+
+describe Beispiel do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/models/lva_spec.rb b/spec/models/lva_spec.rb
new file mode 100644
index 0000000..4209553
--- /dev/null
+++ b/spec/models/lva_spec.rb
@@ -0,0 +1,5 @@
+require 'spec_helper'
+
+describe Lva do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/models/modul_spec.rb b/spec/models/modul_spec.rb
new file mode 100644
index 0000000..c4af626
--- /dev/null
+++ b/spec/models/modul_spec.rb
@@ -0,0 +1,5 @@
+require 'spec_helper'
+
+describe Modul do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/models/modulgruppe_spec.rb b/spec/models/modulgruppe_spec.rb
new file mode 100644
index 0000000..7a39d6c
--- /dev/null
+++ b/spec/models/modulgruppe_spec.rb
@@ -0,0 +1,16 @@
+require 'spec_helper'
+
+describe Modulgruppe do
+ it "modulgruppe should not be valid without studium" do
+ mg=FactoryGirl.build(:modulgruppe)
+ mg.should_not be_valid
+ mg.should have(1).errors_on(:studium_id)
+ end
+ it "modulgruppe should be valid with studium" do
+ s=FactoryGirl.create(:studium)
+ mg=FactoryGirl.build(:modulgruppe)
+ mg.studium=s
+ mg.should be_valid
+ end
+
+end
diff --git a/spec/models/studium_spec.rb b/spec/models/studium_spec.rb
new file mode 100644
index 0000000..0297604
--- /dev/null
+++ b/spec/models/studium_spec.rb
@@ -0,0 +1,27 @@
+require 'spec_helper'
+
+describe Studium do
+ [:name, :zahl].each do |attr|
+ it "should not be valid without #{attr}" do
+ s = FactoryGirl.build(:studium, attr=>nil)
+ s.should_not be_valid
+ end
+ end
+ it "should create studium with valid data" do
+ s=FactoryGirl.build(:studium)
+ lambda {
+ s.save!}.should change {Studium.count()}.by(1)
+ end
+ it "should not accept double entrys" do
+ FactoryGirl.create(:studium)
+ s=FactoryGirl.build(:studium)
+ s.should_not be_valid
+ s.should have_at_least(1).error_on(:name)
+ s.should have_at_least(1).error_on(:zahl)
+ end
+ it "should expect zahl to be 000.000" do
+ s=FactoryGirl.build(:studium, :zahl=>"000000")
+ s.should_not be_valid
+ s.should have_at_least(1).error_on(:zahl)
+ end
+end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
new file mode 100644
index 0000000..d2cbea7
--- /dev/null
+++ b/spec/spec_helper.rb
@@ -0,0 +1,38 @@
+# This file is copied to spec/ when you run 'rails generate rspec:install'
+ENV["RAILS_ENV"] ||= 'test'
+require File.expand_path("../../config/environment", __FILE__)
+require 'rspec/rails'
+require 'rspec/autorun'
+
+# Requires supporting ruby files with custom matchers and macros, etc,
+# in spec/support/ and its subdirectories.
+Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
+
+RSpec.configure do |config|
+ # ## Mock Framework
+ #
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
+ #
+ # config.mock_with :mocha
+ # config.mock_with :flexmock
+ # config.mock_with :rr
+
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
+
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
+ # examples within a transaction, remove the following line or assign false
+ # instead of true.
+ config.use_transactional_fixtures = true
+
+ # If true, the base class of anonymous controllers will be inferred
+ # automatically. This will be the default behavior in future versions of
+ # rspec-rails.
+ config.infer_base_class_for_anonymous_controllers = false
+
+ # Run specs in random order to surface order dependencies. If you find an
+ # order dependency and want to debug it, you can fix the order by providing
+ # the seed, which is printed after each run.
+ # --seed 1234
+ config.order = "random"
+end
diff --git a/test/unit/modulgruppe_test.rb b/test/unit/modulgruppe_test.rb
index 0d9ff9f..5a0d98f 100755
--- a/test/unit/modulgruppe_test.rb
+++ b/test/unit/modulgruppe_test.rb
@@ -1,7 +1,8 @@
require 'test_helper'
class ModulgruppeTest < ActiveSupport::TestCase
- # test "the truth" do
- # assert true
- # end
+ test "should not be valid without name" do
+ mg=Modulgruppe.new();
+ mg.should_not be_valid;
+ end
end