From 5f3139b538d1ff58b719a72d7c7cf05a5b6136b5 Mon Sep 17 00:00:00 2001 From: Francis Irving Date: Wed, 2 Dec 2009 17:51:30 +0000 Subject: Part of upgrade to rails 2.3.2 --- .../rspec-rails/spec/resources/models/animal.rb | 4 ++++ .../rspec-rails/spec/resources/models/person.rb | 18 ++++++++++++++++++ .../plugins/rspec-rails/spec/resources/models/thing.rb | 3 +++ 3 files changed, 25 insertions(+) create mode 100644 vendor/plugins/rspec-rails/spec/resources/models/animal.rb create mode 100644 vendor/plugins/rspec-rails/spec/resources/models/person.rb create mode 100644 vendor/plugins/rspec-rails/spec/resources/models/thing.rb (limited to 'vendor/plugins/rspec-rails/spec/resources/models') diff --git a/vendor/plugins/rspec-rails/spec/resources/models/animal.rb b/vendor/plugins/rspec-rails/spec/resources/models/animal.rb new file mode 100644 index 000000000..3ce078ad4 --- /dev/null +++ b/vendor/plugins/rspec-rails/spec/resources/models/animal.rb @@ -0,0 +1,4 @@ +class Animal < ActiveRecord::Base + belongs_to :person + validates_uniqueness_of :name +end diff --git a/vendor/plugins/rspec-rails/spec/resources/models/person.rb b/vendor/plugins/rspec-rails/spec/resources/models/person.rb new file mode 100644 index 000000000..7f9607e57 --- /dev/null +++ b/vendor/plugins/rspec-rails/spec/resources/models/person.rb @@ -0,0 +1,18 @@ +class Person < ActiveRecord::Base + has_many :animals do + def pups + find(:all, :conditions => 'age < 1') + end + def adults + find(:all, :conditions => 'age >= 1') + end + end + validates_presence_of :name + + def add_animal animal + animal.person = self + animals << animal + animal.save + end + +end diff --git a/vendor/plugins/rspec-rails/spec/resources/models/thing.rb b/vendor/plugins/rspec-rails/spec/resources/models/thing.rb new file mode 100644 index 000000000..c674804ac --- /dev/null +++ b/vendor/plugins/rspec-rails/spec/resources/models/thing.rb @@ -0,0 +1,3 @@ +class Thing < ActiveRecord::Base + validates_presence_of :name +end -- cgit v1.2.3