This commit is contained in:
Thomas Blazek
2013-07-27 17:54:35 +02:00
23 changed files with 183 additions and 48 deletions

6
.gitignore vendored
View File

@@ -15,8 +15,8 @@
/log/*.log
/tmp
/config/initializers/devise.rb
/console
/app/doc/*
console
/server
/public/uploads/
*~

1
.rspec Normal file
View File

@@ -0,0 +1 @@
--color

View File

@@ -70,4 +70,8 @@ gem 'haml'
#gem 'gollum'
gem 'awesome_nested_set'
gem 'annotate', ">=2.5.0"
gem 'carrierwave'
gem 'carrierwave'
group :development, :test do
gem 'factory_girl_rails'
gem 'rspec-rails'
end

View File

@@ -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

View File

@@ -168,18 +168,6 @@ updated_at :datetime not null
modul_id :integer
semester_id :integer</pre>
<h2 id="label-Information">Information</h2>
<dl class="rdoc-list note-list"><dt>Author
<dd>
<p>Andreas Stephanides</p>
</dd><dt>License
<dd>
<p>GPL</p>
</dd></dl>
<p>Dieses Model repräsentiert eine LVA. Die notwendigen Informationen können
mit TISS (dem Online System der TU Wien) synchronisiert werden</p>
</div><!-- description -->

View File

@@ -215,9 +215,9 @@
<span class="ruby-keyword">def</span> <span class="ruby-identifier">create</span>
<span class="ruby-ivar">@modulgruppe</span> = <span class="ruby-constant">Modulgruppe</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">params</span>[<span class="ruby-value">:modulgruppe</span>])
<span class="ruby-keyword">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">params</span>[<span class="ruby-value">:studium_id</span>].<span class="ruby-identifier">nil?</span>
<span class="ruby-ivar">@studium</span>=<span class="ruby-constant">Studium</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">params</span>[<span class="ruby-value">:studium_id</span>])
<span class="ruby-ivar">@studium</span>=<span class="ruby-constant">Studium</span>.<span class="ruby-identifier">find_by_id</span>(<span class="ruby-identifier">params</span>[<span class="ruby-value">:studium_id</span>])
<span class="ruby-keyword">else</span>
<span class="ruby-ivar">@studium</span>=<span class="ruby-constant">Studium</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">params</span>[<span class="ruby-value">:modulgruppe</span>][<span class="ruby-value">:studium_id</span>])
<span class="ruby-ivar">@studium</span>=<span class="ruby-constant">Studium</span>.<span class="ruby-identifier">find_by_id</span>(<span class="ruby-identifier">params</span>[<span class="ruby-value">:modulgruppe</span>][<span class="ruby-value">:studium_id</span>])
<span class="ruby-keyword">end</span>
<span class="ruby-identifier">respond_to</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">format</span><span class="ruby-operator">|</span>
<span class="ruby-keyword">if</span> <span class="ruby-ivar">@modulgruppe</span>.<span class="ruby-identifier">save</span>

View File

@@ -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

View File

@@ -64,7 +64,6 @@
<img class="toc-toggle" src="images/transparent.png" alt="" title="toggle headings">
<ul class="initially-hidden">
<li><a href="Lva.html#label-Schema+Information">Schema Information</a>
<li><a href="Lva.html#label-Information">Information</a>
</ul>
</li>
<li class="class">

View File

@@ -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

View File

@@ -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"

View File

@@ -0,0 +1,6 @@
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :beispiel do
end
end

6
spec/factories/lvas.rb Normal file
View File

@@ -0,0 +1,6 @@
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :lva do
end
end

View File

@@ -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

6
spec/factories/moduls.rb Normal file
View File

@@ -0,0 +1,6 @@
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :modul do
end
end

12
spec/factories/studien.rb Normal file
View File

@@ -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

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1,5 @@
require 'spec_helper'
describe Beispiel do
pending "add some examples to (or delete) #{__FILE__}"
end

5
spec/models/lva_spec.rb Normal file
View File

@@ -0,0 +1,5 @@
require 'spec_helper'
describe Lva do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@@ -0,0 +1,5 @@
require 'spec_helper'
describe Modul do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@@ -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

View File

@@ -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

38
spec/spec_helper.rb Normal file
View File

@@ -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

View File

@@ -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