Skip to content

Commit

Permalink
change to mysql and fucking AR
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonatan Reiners committed Oct 9, 2011
1 parent 8a75e85 commit f75675f
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 10 deletions.
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ gem 'rails', '3.1.0'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'sqlite3'
# gem 'sqlite3'
gem 'mysql2'
gem 'haml-rails'


Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ GEM
ruby_parser (~> 2.0.5)
mime-types (1.16)
multi_json (1.0.3)
mysql2 (0.3.7)
nokogiri (1.5.0)
polyglot (0.3.2)
pry (0.9.6.2)
Expand Down Expand Up @@ -158,7 +159,6 @@ GEM
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.4)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
Expand All @@ -184,12 +184,12 @@ DEPENDENCIES
guard-spork
haml-rails
jquery-rails
mysql2
pry
rails (= 3.1.0)
rails3-generators
rspec-rails
sass-rails (~> 3.1.0)
spork (> 0.9.0.rc)
sqlite3
turn
uglifier
1 change: 0 additions & 1 deletion Guardfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ guard 'spork', :rspec_env => { 'RAILS_ENV' => 'test' }, :test_unit => false do
watch('config/environment.rb')
watch(%r{^config/environments/.+\.rb$})
watch(%r{^config/initializers/.+\.rb$})
watch('Gemfile')
watch('Gemfile.lock')
watch('spec/spec_helper.rb')
watch(%r{^spec/support/.+\.rb$})
Expand Down
2 changes: 1 addition & 1 deletion app/models/role.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ def all_tasks
end

def all_childs
(childs + childs.collect { |i| i.all_childs } ).flatten
(childs.all + childs.all.collect { |i| i.all_childs } ).flatten
end
end
22 changes: 17 additions & 5 deletions spec/models/role_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,25 @@
end

it "returns all children, no matter how deep nested" do
subrole = Factory(:role)
role.add_subrole subrole
subrole.add_subrole Factory(:role)
subrole = Factory.create(:role)
subrole.name.should eq("Rolle7")
role.add_subrole subrole # 1 Kind

srole2 = Factory(:role) # 1 Kindeskind, 2. Kind
srole2.name.should eq("Rolle9")
role.childs.first.add_subrole srole2

role.relations.count.should eq(1)
role.all_childs.count.should eq(2)
role.add_subrole Factory(:role)

srole3 = Factory(:role) # 2. Kind, 3 Kinder gesammt
srole3.name.should eq("Rolle10")
role.add_subrole srole3
role.relations.count.should eq(2)
role.all_childs.count.should eq(3)
role.childs.count.should eq(2)
role.childs.first.childs.count.should eq(1)

role.all_childs[0].name.should eq("Rolle7")
role.all_childs.size.should eq(3)
end
end

0 comments on commit f75675f

Please sign in to comment.