Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

finished adding in unit tests for owning, need to start with views now

  • Loading branch information...
commit 45a151b6e3a0c88d48e125631fde8649fa6d924b 1 parent 804e725
@HangingClowns authored
Showing with 380 additions and 168 deletions.
  1. +1 −1  Gemfile
  2. +12 −7 Gemfile.lock
  3. +5 −5 Guardfile
  4. +2 −0  app/assets/javascripts/possessions.js
  5. +4 −0 app/assets/stylesheets/possessions.css
  6. +91 −0 app/controllers/possessions_controller.rb
  7. +2 −0  app/helpers/possessions_helper.rb
  8. +24 −22 app/models/album.rb
  9. +6 −0 app/models/possession.rb
  10. +14 −12 app/models/user.rb
  11. +17 −0 app/views/possessions/_form.html.erb
  12. +6 −0 app/views/possessions/edit.html.erb
  13. +21 −0 app/views/possessions/index.html.erb
  14. +5 −0 app/views/possessions/new.html.erb
  15. +5 −0 app/views/possessions/show.html.erb
  16. +6 −61 config/routes.rb
  17. +131 −0 spec/controllers/possessions_controller_spec.rb
  18. +6 −0 spec/factories/possessions.rb
  19. +0 −11 spec/helpers/albums_helper_spec.rb
  20. +0 −11 spec/helpers/artists_helper_spec.rb
  21. +0 −11 spec/helpers/home_helper_spec.rb
  22. +4 −0 spec/helpers/possessions_helper_spec.rb
  23. +0 −11 spec/helpers/recordings_helper_spec.rb
  24. +0 −11 spec/helpers/works_helper_spec.rb
  25. +1 −1  spec/models/album_spec.rb
  26. +0 −1  spec/models/artist_spec.rb
  27. +6 −0 spec/models/possession_spec.rb
  28. +1 −1  spec/models/user_spec.rb
  29. +0 −1  spec/models/work_spec.rb
  30. +10 −1 spec/spec_helper.rb
View
2  Gemfile
@@ -36,7 +36,7 @@ group :development, :test do
gem 'guard-rspec'
gem 'guard-spork', "~> 1.4.1"
gem 'rspec-rails'
- # gem 'mongoid-rspec'
+ gem 'mongoid-rspec'
gem 'database_cleaner'
gem 'therubyracer'
gem 'spork', "~> 1.0.0rc3"
View
19 Gemfile.lock
@@ -103,7 +103,7 @@ GEM
factory_girl (~> 4.2.0)
railties (>= 3.0.0)
fast-stemmer (1.0.2)
- ffi (1.4.0)
+ ffi (1.5.0)
gherkin (2.11.6)
json (>= 1.7.6)
guard (1.6.2)
@@ -125,7 +125,7 @@ GEM
childprocess (>= 0.2.3)
guard (>= 1.1)
spork (>= 0.8.4)
- haml (4.0.0)
+ haml (4.0.1)
tilt
hike (1.2.1)
i18n (0.6.1)
@@ -141,7 +141,7 @@ GEM
addressable (~> 2.3)
libv8 (3.11.8.13)
listen (0.7.3)
- lumberjack (1.0.2)
+ lumberjack (1.0.3)
mail (2.5.3)
i18n (>= 0.4.0)
mime-types (~> 1.16)
@@ -157,13 +157,17 @@ GEM
activesupport
easy_diff
mongoid (~> 3.0)
+ mongoid-rspec (1.7.0)
+ mongoid (>= 3.0.1)
+ rake
+ rspec (>= 2.9)
mongoid_search (0.3.1)
fast-stemmer (~> 1.0.0)
mongoid (>= 3.0.0)
moped (1.4.3)
multi_json (1.7.1)
- newrelic_rpm (3.5.8.72)
- nokogiri (1.5.7)
+ newrelic_rpm (3.6.0.78)
+ nokogiri (1.5.9)
open4 (1.3.0)
origin (1.0.11)
orm_adapter (0.4.0)
@@ -200,7 +204,7 @@ GEM
ffi (>= 0.5.0)
rdoc (3.12.2)
json (~> 1.4)
- ref (1.0.2)
+ ref (1.0.4)
rspec (2.13.0)
rspec-core (~> 2.13.0)
rspec-expectations (~> 2.13.0)
@@ -233,7 +237,7 @@ GEM
therubyracer (0.11.4)
libv8 (~> 3.11.8.12)
ref
- thin (1.5.0)
+ thin (1.5.1)
daemons (>= 1.0.9)
eventmachine (>= 0.12.6)
rack (>= 1.0.0)
@@ -279,6 +283,7 @@ DEPENDENCIES
launchy
mongoid (~> 3.0.0)
mongoid-history
+ mongoid-rspec
mongoid_search
newrelic_rpm
rails (= 3.2.13)
View
10 Guardfile
@@ -1,13 +1,13 @@
-guard 'bundler' do
+guard 'bundler', cli: "--verbose" do
watch('Gemfile')
# Uncomment next line if Gemfile contain `gemspec' command
# watch(/^.+\.gemspec/)
end
-# guard 'rails' do
-# watch('Gemfile.lock')
-# watch(%r{^(config|lib)/.*})
-# end
+guard 'rails' do
+ watch('Gemfile.lock')
+ watch(%r{^(config|lib)/.*})
+end
guard 'spork', cucumber_env: { 'RAILS_ENV' => 'test' }, rspec_env: { 'RAILS_ENV' => 'test' }, test_unit: false, wait: 90 do
watch('config/application.rb')
View
2  app/assets/javascripts/possessions.js
@@ -0,0 +1,2 @@
+// Place all the behaviors and hooks related to the matching controller here.
+// All this logic will automatically be available in application.js.
View
4 app/assets/stylesheets/possessions.css
@@ -0,0 +1,4 @@
+/*
+ Place all the styles related to the matching controller here.
+ They will automatically be included in application.css.
+*/
View
91 app/controllers/possessions_controller.rb
@@ -0,0 +1,91 @@
+class PossessionsController < ApplicationController
+ before_filter :authenticate_user!
+ before_filter :find_possession, only: [:show, :edit, :destroy, :update]
+ # GET /possessions
+ # GET /possessions.json
+ def index
+ @possessions = current_user.possessions
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.json { render json: @possessions }
+ end
+ end
+
+ # GET /possessions/1
+ # GET /possessions/1.json
+ def show
+ respond_to do |format|
+ format.html # show.html.erb
+ format.json { render json: @possession }
+ end
+ end
+
+ # GET /possessions/new
+ # GET /possessions/new.json
+ def new
+ @possession = current_user.possessions.build
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.json { render json: @possession }
+ end
+ end
+
+ # GET /possessions/1/edit
+ def edit
+ end
+
+ # POST /possessions
+ # POST /possessions.json
+ def create
+ @possession = current_user.possessions.build(params[:possession])
+
+ respond_to do |format|
+ if @possession.save
+ format.html { redirect_to @possession, notice: 'Possession was successfully created.' }
+ format.json { render json: @possession, status: :created, location: @possession }
+ else
+ format.html { render action: "new" }
+ format.json { render json: @possession.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # PUT /possessions/1
+ # PUT /possessions/1.json
+ def update
+
+ respond_to do |format|
+ if @possession.update_attributes(params[:possession])
+ format.html { redirect_to @possession, notice: 'Possession was successfully updated.' }
+ format.json { head :no_content }
+ else
+ format.html { render action: "edit" }
+ format.json { render json: @possession.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /possessions/1
+ # DELETE /possessions/1.json
+ def destroy
+ @possession.destroy
+
+ respond_to do |format|
+ format.html { redirect_to possessions_url }
+ format.json { head :no_content }
+ end
+ end
+
+ private
+
+ def find_possession
+ begin
+ @possession = current_user.possessions.find(params[:id])
+ rescue Mongoid::Errors::DocumentNotFound
+ redirect_to possessions_url
+ end
+ end
+
+end
View
2  app/helpers/possessions_helper.rb
@@ -0,0 +1,2 @@
+module PossessionsHelper
+end
View
46 app/models/album.rb
@@ -4,47 +4,49 @@ class Album
include Mongoid::Search
include Mongoid::History::Trackable
- field :title, :type => String
- field :date_released, :type => IncDate
- field :label, :type => String
- field :media_type, :type => String
- field :reference_code, :type => String
- field :number_of_recordings, :type => Integer
- field :origalbumid, :type => String
+ field :title, type: String
+ field :date_released, type: IncDate
+ field :label, type: String
+ field :media_type, type: String
+ field :reference_code, type: String
+ field :number_of_recordings, type: Integer
+ field :origalbumid, type: String
#
# calculated values so we can index and sort
#
- field :cache_normalized_title, :type => String, :default => ""
- field :cache_first_letter, :type => String, :default => ""
+ field :cache_normalized_title, type: String, default: ""
+ field :cache_first_letter, type: String, default: ""
before_save :update_cached_fields
index({ cache_normalized_title: 1 }, { background: true })
index({ cache_first_letter: 1, cache_normalized_title: 1 }, { background: true })
- search_in :title, :label, {:match => :all}
+ search_in :title, :label, {match: :all}
validates_presence_of :title
- embeds_many :artist_wiki_links, :as=>:linkable, :class_name=>"AlbumArtistWikiLink"
+ embeds_many :artist_wiki_links, as: :linkable, class_name: "AlbumArtistWikiLink"
accepts_nested_attributes_for :artist_wiki_links
validates_associated :artist_wiki_links
- embeds_many :recording_wiki_links, :as=>:linkable, :class_name=>"AlbumRecordingWikiLink"
+ embeds_many :recording_wiki_links, as: :linkable, class_name: "AlbumRecordingWikiLink"
accepts_nested_attributes_for :recording_wiki_links
validates_associated :recording_wiki_links
- embeds_many :supplementary_sections, :class_name=>"SupplementarySection"
+ embeds_many :supplementary_sections, class_name: "SupplementarySection"
accepts_nested_attributes_for :supplementary_sections
validates_associated :supplementary_sections
+
+ has_many :possessions
# telling Mongoid::History how you want to track changes
- track_history :modifier_field => :modifier, # adds "referenced_in :modifier" to track who made the change, default is :modifier
- :version_field => :version, # adds "field :version, :type => Integer" to track current version, default is :version
- :track_create => true, # track document creation, default is false
- :track_update => true, # track document updates, default is true
- :track_destroy => true # track document destruction, default is false
+ track_history modifier_field: :modifier, # adds "referenced_in :modifier" to track who made the change, default is :modifier
+ version_field: :version, # adds "field :version, :type => Integer" to track current version, default is :version
+ track_create: true, # track document creation, default is false
+ track_update: true, # track document updates, default is true
+ track_destroy: true # track document destruction, default is false
def artist_wiki_links_text
@@ -58,7 +60,7 @@ def artist_wiki_links_combined_links
def artist_wiki_links_text=(value)
self.artist_wiki_links.reverse.each{|a| a.destroy} #TODO find a way to do it at large since the self.artist_wiki_links.clear does not work
value.split(",").each{|q|
- self.artist_wiki_links.build(:reference_text=>q.strip)
+ self.artist_wiki_links.build(reference_text: q.strip)
}
end
@@ -75,7 +77,7 @@ def recording_wiki_links_combined_links
end
def recording_wiki_links_combined_links_renamed
- mappings = {:title => :name}
+ mappings = {title: :name}
recording_wiki_links_combined_links.collect do |x|
Hash[x.map {|k,v| [mappings[k] || k, v] }]
end
@@ -84,7 +86,7 @@ def recording_wiki_links_combined_links_renamed
def recording_wiki_links_text=(value)
self.recording_wiki_links.reverse.each{|a| a.destroy} #TODO find a way to do it at large since the self.recording_wiki_links.clear does not work
value.split(",").each{|q|
- self.recording_wiki_links.build(:reference_text=>q.strip)
+ self.recording_wiki_links.build(reference_text: q.strip)
}
end
@@ -114,7 +116,7 @@ def update_cached_fields
end
def to_wiki_link
- AlbumWikiLink.new(:reference_text=>"oid:#{self.id}", :album=>self)
+ AlbumWikiLink.new(reference_text: "oid:#{self.id}", album: self)
end
scope :queried, ->(q) {
View
6 app/models/possession.rb
@@ -0,0 +1,6 @@
+class Possession
+ include Mongoid::Document
+
+ belongs_to :owner, class_name: "User", index: true
+ belongs_to :album, index: true
+end
View
26 app/models/user.rb
@@ -6,22 +6,22 @@ class User
:recoverable, :rememberable, :trackable, :validatable
## Database authenticatable
- field :email, :type => String#, null: false
- field :encrypted_password, :type => String#, null: false
+ field :email, type: String#, null: false
+ field :encrypted_password, type: String#, null: false
## Recoverable
- field :reset_password_token, :type => String
- field :reset_password_sent_at, :type => Time
+ field :reset_password_token, type: String
+ field :reset_password_sent_at, type: Time
## Rememberable
- field :remember_created_at, :type => Time
+ field :remember_created_at, type: Time
## Trackable
- field :sign_in_count, :type => Integer
- field :current_sign_in_at, :type => Time
- field :last_sign_in_at, :type => Time
- field :current_sign_in_ip, :type => String
- field :last_sign_in_ip, :type => String
+ field :sign_in_count, type: Integer
+ field :current_sign_in_at, type: Time
+ field :last_sign_in_at, type: Time
+ field :current_sign_in_ip, type: String
+ field :last_sign_in_ip, type: String
## Encryptable
# field :password_salt, :type => String
@@ -48,11 +48,13 @@ class User
validates_uniqueness_of :nickname
validates_presence_of :nickname
- field :groups, :type=>Array, :default=>["user"]
+ field :groups, type: Array, default: ["user"]
- embeds_many :album_wiki_links, :as=>:linkable
+ embeds_many :album_wiki_links, as: :linkable
accepts_nested_attributes_for :album_wiki_links
validates_associated :album_wiki_links
+
+ has_many :possessions, foreign_key: "owner_id"
def album_wiki_links_text
album_wiki_links.collect{|v| v.reference_text }.join(",")
View
17 app/views/possessions/_form.html.erb
@@ -0,0 +1,17 @@
+<%= form_for(@possession) do |f| %>
+ <% if @possession.errors.any? %>
+ <div id="error_explanation">
+ <h2><%= pluralize(@possession.errors.count, "error") %> prohibited this possession from being saved:</h2>
+
+ <ul>
+ <% @possession.errors.full_messages.each do |msg| %>
+ <li><%= msg %></li>
+ <% end %>
+ </ul>
+ </div>
+ <% end %>
+
+ <div class="actions">
+ <%= f.submit %>
+ </div>
+<% end %>
View
6 app/views/possessions/edit.html.erb
@@ -0,0 +1,6 @@
+<h1>Editing possession</h1>
+
+<%= render 'form' %>
+
+<%= link_to 'Show', @possession %> |
+<%= link_to 'Back', possessions_path %>
View
21 app/views/possessions/index.html.erb
@@ -0,0 +1,21 @@
+<h1>Listing possessions</h1>
+
+<table>
+ <tr>
+ <th></th>
+ <th></th>
+ <th></th>
+ </tr>
+
+<% @possessions.each do |possession| %>
+ <tr>
+ <td><%= link_to 'Show', possession %></td>
+ <td><%= link_to 'Edit', edit_possession_path(possession) %></td>
+ <td><%= link_to 'Destroy', possession, method: :delete, data: { confirm: 'Are you sure?' } %></td>
+ </tr>
+<% end %>
+</table>
+
+<br />
+
+<%= link_to 'New Possession', new_possession_path %>
View
5 app/views/possessions/new.html.erb
@@ -0,0 +1,5 @@
+<h1>New possession</h1>
+
+<%= render 'form' %>
+
+<%= link_to 'Back', possessions_path %>
View
5 app/views/possessions/show.html.erb
@@ -0,0 +1,5 @@
+<p id="notice"><%= notice %></p>
+
+
+<%= link_to 'Edit', edit_possession_path(@possession) %> |
+<%= link_to 'Back', possessions_path %>
View
67 config/routes.rb
@@ -1,5 +1,7 @@
KiungoWiki::Application.routes.draw do
+ resources :possessions
+
resources :changes
resources :portal_articles
@@ -10,7 +12,7 @@
collection do
get 'lookup'
get 'portal'
- get 'letter_:letter', :action=>"alphabetic_index", :as=>:alphabetic
+ get 'letter_:letter', action: "alphabetic_index", as: :alphabetic
get 'recent_changes' #, :action=>"recent_changes", :recent_changes=>1, :as=>:recent_changes
get 'search'
end
@@ -23,7 +25,7 @@
collection do
get 'lookup'
get 'portal'
- get 'letter_:letter', :action=>"alphabetic_index", :as=>:alphabetic
+ get 'letter_:letter', action: "alphabetic_index", as: :alphabetic
get 'recent_changes' #, :action=>"recent_changes", :recent_changes=>1, :as=>:recent_changes
get 'search'
get 'list'
@@ -37,7 +39,7 @@
collection do
get 'lookup'
get 'portal'
- get 'letter_:letter', :action=>"alphabetic_index", :as=>:alphabetic
+ get 'letter_:letter', action: "alphabetic_index", as: :alphabetic
get 'recent_changes' #, :action=>"recent_changes", :recent_changes=>1, :as=>:recent_changes
get 'search'
end
@@ -50,7 +52,7 @@
collection do
get 'lookup'
get 'portal'
- get 'letter_:letter', :action=>"alphabetic_index", :as=>:alphabetic
+ get 'letter_:letter', action: "alphabetic_index", as: :alphabetic
get 'recent_changes' #, :action=>"recent_changes", :recent_changes=>1, :as=>:recent_changes
get 'search'
end
@@ -70,61 +72,4 @@
match 'site_plan' => "home#site_plan"
root :to => "home#index"
-
- # The priority is based upon order of creation:
- # first created -> highest priority.
-
- # Sample of regular route:
- # match 'products/:id' => 'catalog#view'
- # Keep in mind you can assign values other than :controller and :action
-
- # Sample of named route:
- # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
- # This route can be invoked with purchase_url(:id => product.id)
-
- # Sample resource route (maps HTTP verbs to controller actions automatically):
- # resources :products
-
- # Sample resource route with options:
- # resources :products do
- # member do
- # get 'short'
- # post 'toggle'
- # end
- #
- # collection do
- # get 'sold'
- # end
- # end
-
- # Sample resource route with sub-resources:
- # resources :products do
- # resources :comments, :sales
- # resource :seller
- # end
-
- # Sample resource route with more complex sub-resources
- # resources :products do
- # resources :comments
- # resources :sales do
- # get 'recent', :on => :collection
- # end
- # end
-
- # Sample resource route within a namespace:
- # namespace :admin do
- # # Directs /admin/products/* to Admin::ProductsController
- # # (app/controllers/admin/products_controller.rb)
- # resources :products
- # end
-
- # You can have the root of your site routed with "root"
- # just remember to delete public/index.html.
- # root :to => "welcome#index"
-
- # See how all your routes lay out with "rake routes"
-
- # This is a legacy wild controller route that's not recommended for RESTful applications.
- # Note: This route will make all actions in every controller accessible via GET requests.
- # match ':controller(/:action(/:id(.:format)))'
end
View
131 spec/controllers/possessions_controller_spec.rb
@@ -0,0 +1,131 @@
+require 'spec_helper'
+
+# This spec was generated by rspec-rails when you ran the scaffold generator.
+# It demonstrates how one might use RSpec to specify the controller code that
+# was generated by Rails when you ran the scaffold generator.
+#
+# It assumes that the implementation code is generated by the rails scaffold
+# generator. If you are using any extension libraries to generate different
+# controller code, this generated spec may or may not pass.
+#
+# It only uses APIs available in rails and/or rspec-rails. There are a number
+# of tools you can use to make these specs even more expressive, but we're
+# sticking to rails and rspec-rails APIs to keep things simple and stable.
+#
+# Compared to earlier versions of this generator, there is very limited use of
+# stubs and message expectations in this spec. Stubs are only used when there
+# is no simpler way to get a handle on the object needed for the example.
+# Message expectations are only used when there is no simpler way to specify
+# that an instance is receiving a specific message.
+
+describe PossessionsController do
+ let(:user) { User.new }
+ let(:possession) { Possession.new }
+ let(:possessions) { Object.new }
+ let(:id) { 99.to_param }
+ before :each do
+ allow_message_expectations_on_nil
+ ApplicationController.any_instance.stub(:current_user).and_return user
+ request.env['warden'].stub(:authenticate!).and_return user
+ end
+
+ # This should return the minimal set of values that should be in the session
+ # in order to pass any filters (e.g. authentication) defined in
+ # PossessionsController. Be sure to keep this updated too.
+ def valid_session
+ {}
+ end
+
+ describe "GET index" do
+ it "assigns all possessions as @possessions" do
+ user.should_receive(:possessions).and_return [possession]
+ get :index, {}, valid_session
+ assigns(:possessions).should eq([possession])
+ end
+ end
+
+ describe "GET show" do
+ before :each do
+ user.should_receive(:possessions).and_return possessions
+ @find_mock = possessions.should_receive(:find).with(id)
+ end
+ it "assigns the requested possession as @possession" do
+ @find_mock.and_return possession
+ get :show, {id: id}, valid_session
+ assigns(:possession).should eq(possession)
+ end
+ it "will redirect to possessions path if cannot find a possesion" do
+ @find_mock.and_raise Mongoid::Errors::DocumentNotFound.new Object, {}
+ get :show, {id: id}, valid_session
+ response.should redirect_to possessions_url
+ end
+ end
+
+ describe "GET new" do
+ it "assigns a new possession as @possession" do
+ user.should_receive(:possessions).and_return user
+ user.should_receive(:build).and_return possession
+ get :new, {}, valid_session
+ assigns(:possession).should be_a_new(Possession)
+ end
+ end
+
+ describe "GET edit" do
+ it "assigns the requested possession as @possession" do
+ user.should_receive(:possessions).and_return possessions
+ possessions.should_receive(:find).with(id).and_return possession
+ get :edit, {id: id}, valid_session
+ assigns(:possession).should eq(possession)
+ end
+ end
+
+ describe "POST create" do
+ before :each do
+ user.should_receive(:possessions).and_return user
+ user.should_receive(:build).with({}).and_return possession
+ @save_mock = possession.should_receive(:save)
+ end
+ it "can create with valid params" do
+ @save_mock.and_return true
+ post :create, {possession: {}}, valid_session
+ assigns(:possession).should be_a(Possession)
+ response.status.should eq(302)
+ end
+ it "cannot create with invalid params" do
+ @save_mock.and_return(false)
+ post :create, {possession: {}}, valid_session
+ response.should render_template("new")
+ end
+ end
+
+ describe "PUT update" do
+ before :each do
+ user.should_receive(:possessions).and_return possessions
+ possessions.should_receive(:find).with(id).and_return possession
+ end
+ it "with valid params can update" do
+ params = { "these" => "params" }
+ possession.should_receive(:update_attributes).with(params).and_return true
+ put :update, {id: id, possession: params}, valid_session
+ assigns(:possession).should eq(possession)
+ response.status.should eq(302)
+ end
+ it "with invalid params cannot update" do
+ params = { "these" => "params" }
+ possession.should_receive(:update_attributes).with(params).and_return false
+ put :update, {id: id, possession: params}, valid_session
+ assigns(:possession).should eq(possession)
+ response.should render_template("edit")
+ end
+ end
+
+ describe "DELETE destroy" do
+ it "destroys the requested possession" do
+ user.should_receive(:possessions).and_return possessions
+ possessions.should_receive(:find).with(id).and_return possession
+ possession.should_receive(:destroy)
+ delete :destroy, {id: id}, valid_session
+ response.should redirect_to(possessions_url)
+ end
+ end
+end
View
6 spec/factories/possessions.rb
@@ -0,0 +1,6 @@
+# Read about factories at https://github.com/thoughtbot/factory_girl
+
+FactoryGirl.define do
+ factory :possession do
+ end
+end
View
11 spec/helpers/albums_helper_spec.rb
@@ -1,15 +1,4 @@
require 'spec_helper'
-# Specs in this file have access to a helper object that includes
-# the AlbumsHelper. For example:
-#
-# describe AlbumsHelper do
-# describe "string concat" do
-# it "concats two strings with spaces" do
-# helper.concat_strings("this","that").should == "this that"
-# end
-# end
-# end
describe AlbumsHelper do
- pending "add some examples to (or delete) #{__FILE__}"
end
View
11 spec/helpers/artists_helper_spec.rb
@@ -1,15 +1,4 @@
require 'spec_helper'
-# Specs in this file have access to a helper object that includes
-# the ArtistsHelper. For example:
-#
-# describe ArtistsHelper do
-# describe "string concat" do
-# it "concats two strings with spaces" do
-# helper.concat_strings("this","that").should == "this that"
-# end
-# end
-# end
describe ArtistsHelper do
- pending "add some examples to (or delete) #{__FILE__}"
end
View
11 spec/helpers/home_helper_spec.rb
@@ -1,15 +1,4 @@
require 'spec_helper'
-# Specs in this file have access to a helper object that includes
-# the HomeHelper. For example:
-#
-# describe HomeHelper do
-# describe "string concat" do
-# it "concats two strings with spaces" do
-# helper.concat_strings("this","that").should == "this that"
-# end
-# end
-# end
describe HomeHelper do
- pending "add some examples to (or delete) #{__FILE__}"
end
View
4 spec/helpers/possessions_helper_spec.rb
@@ -0,0 +1,4 @@
+require 'spec_helper'
+
+describe PossessionsHelper do
+end
View
11 spec/helpers/recordings_helper_spec.rb
@@ -1,15 +1,4 @@
require 'spec_helper'
-# Specs in this file have access to a helper object that includes
-# the RecordingsHelper. For example:
-#
-# describe RecordingsHelper do
-# describe "string concat" do
-# it "concats two strings with spaces" do
-# helper.concat_strings("this","that").should == "this that"
-# end
-# end
-# end
describe RecordingsHelper do
- pending "add some examples to (or delete) #{__FILE__}"
end
View
11 spec/helpers/works_helper_spec.rb
@@ -1,15 +1,4 @@
require 'spec_helper'
-# Specs in this file have access to a helper object that includes
-# the WorksHelper. For example:
-#
-# describe WorksHelper do
-# describe "string concat" do
-# it "concats two strings with spaces" do
-# helper.concat_strings("this","that").should == "this that"
-# end
-# end
-# end
describe WorksHelper do
- pending "add some examples to (or delete) #{__FILE__}"
end
View
2  spec/models/album_spec.rb
@@ -1,5 +1,5 @@
require 'spec_helper'
describe Album do
- pending "add some examples to (or delete) #{__FILE__}"
+ it { should have_many(:possessions) }
end
View
1  spec/models/artist_spec.rb
@@ -1,5 +1,4 @@
require 'spec_helper'
describe Artist do
- pending "add some examples to (or delete) #{__FILE__}"
end
View
6 spec/models/possession_spec.rb
@@ -0,0 +1,6 @@
+require 'spec_helper'
+
+describe Possession do
+ it { should belong_to(:owner).of_type(User).with_index }
+ it { should belong_to(:album).with_index }
+end
View
2  spec/models/user_spec.rb
@@ -1,5 +1,5 @@
require 'spec_helper'
describe User do
- pending "add some examples to (or delete) #{__FILE__}"
+ it { should have_many(:possessions).with_foreign_key(:owner_id) }
end
View
1  spec/models/work_spec.rb
@@ -1,5 +1,4 @@
require 'spec_helper'
describe Work do
- pending "add some examples to (or delete) #{__FILE__}"
end
View
11 spec/spec_helper.rb
@@ -39,6 +39,7 @@
# config.use_transactional_fixtures = true
config.include FactoryGirl::Syntax::Methods
+ config.include Mongoid::Matchers
config.before(:each) do
DatabaseCleaner.orm = "mongoid"
DatabaseCleaner.strategy = :truncation
@@ -48,7 +49,15 @@
end
Spork.each_run do
-
+ ActiveSupport::Dependencies.clear
+ ActiveRecord::Base.instantiate_observers
+ FactoryGirl.reload
+ Dir["#{Rails.root}/app/controllers/*.rb"].each do |controller|
+ load controller
+ end
+ Dir["#{Rails.root}/app/models/*.rb"].each do |model|
+ load model
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.