Skip to content
This repository
  • 2 commits
  • 9 files changed
  • 0 comments
  • 1 contributor
Apr 28, 2012
Michael Bumann bumi added basic models and relations a9716ff
Michael Bumann bumi Merge branch 'master' of github.com:sebastiandeutsch/digital-media-map
* 'master' of github.com:sebastiandeutsch/digital-media-map:
  about seite
  Factored GoogleMaps into a class
d4929b2
1  Gemfile
@@ -49,6 +49,7 @@ group :test do
49 49 gem "mocha", "~> 0.10"
50 50 gem "factory_girl_rails", "~> 1.7", require: false
51 51 gem "database_cleaner", "~> 0.7"
  52 + gem 'mongoid-rspec'
52 53 end
53 54
54 55 group :development, :test do
4 Gemfile.lock
@@ -134,6 +134,9 @@ GEM
134 134 activemodel (~> 3.1)
135 135 mongo (~> 1.3)
136 136 tzinfo (~> 0.3.22)
  137 + mongoid-rspec (1.4.4)
  138 + mongoid (~> 2.0)
  139 + rspec (~> 2)
137 140 multi_json (1.3.2)
138 141 net-scp (1.0.4)
139 142 net-ssh (>= 1.99.1)
@@ -254,6 +257,7 @@ DEPENDENCIES
254 257 mini_magick
255 258 mocha (~> 0.10)
256 259 mongoid
  260 + mongoid-rspec
257 261 rabl
258 262 rails (= 3.2.3)
259 263 rspec-rails (~> 2.8)
11 app/models/category.rb
... ... @@ -0,0 +1,11 @@
  1 +class Category
  2 + include Mongoid::Document
  3 +
  4 + has_many :companies
  5 + has_many :tags
  6 +
  7 + field :name, type: String
  8 +
  9 + validates :name, presence: true
  10 +
  11 +end
4 app/models/company.rb
@@ -2,6 +2,10 @@ class Company
2 2 include Mongoid::Document
3 3 include Mongoid::Timestamps
4 4
  5 +
  6 + belongs_to :category
  7 + has_many :tags
  8 +
5 9 field :name, :type => String
6 10 field :description, :type => String
7 11 field :street, :type => String
10 app/models/tag.rb
... ... @@ -0,0 +1,10 @@
  1 +class Tag
  2 + include Mongoid::Document
  3 +
  4 + has_many :companies
  5 +
  6 + field :name, type: String
  7 +
  8 + validates :name, presence: true
  9 +
  10 +end
9 spec/models/category_spec.rb
... ... @@ -0,0 +1,9 @@
  1 +require 'spec_helper'
  2 +
  3 +describe Category do
  4 +
  5 + it { should have_many(:companies) }
  6 + it { should have_many(:tags) }
  7 + it { should validate_presence_of(:name) }
  8 +
  9 +end
8 spec/models/company_spec.rb
... ... @@ -0,0 +1,8 @@
  1 +require 'spec_helper'
  2 +
  3 +describe Company do
  4 +
  5 + it { should belong_to :category }
  6 + it { should have_many :tags }
  7 +
  8 +end
7 spec/models/tag_spec.rb
... ... @@ -0,0 +1,7 @@
  1 +require 'spec_helper'
  2 +
  3 +describe Tag do
  4 +
  5 + it { should have_many(:companies) }
  6 +
  7 +end
3  spec/spec_helper.rb
@@ -7,7 +7,8 @@
7 7 RSpec.configure do |config|
8 8 config.mock_with :mocha
9 9 config.extend VCR::RSpec::Macros
10   -
  10 + config.include Mongoid::Matchers
  11 +
11 12 config.before :suite do
12 13 #DatabaseCleaner.strategy = :transaction
13 14 DatabaseCleaner.clean_with(:truncation)

No commit comments for this range

Something went wrong with that request. Please try again.