Commit 6e1d9a71

mo khan <mo@mokhan.ca>
2013-07-26 04:04:42
fix some broken specs
1 parent 926258e
app/models/category.rb
@@ -1,7 +1,7 @@
 class Category < ActiveRecord::Base
   has_and_belongs_to_many :creations, :join_table => 'creations_categories'
   attr_accessible :name, :slug
-  default_scope { order(:name) }
+  #default_scope -> { order(:name) }
 
   def to_param
     slug
app/models/creation.rb
@@ -3,11 +3,11 @@ class Creation < ActiveRecord::Base
   attr_accessible :user_id, :story, :name, :category_ids, :is_restricted, :watermark
   belongs_to :user, :counter_cache => true
   has_and_belongs_to_many :categories, -> { where unique: true }, :join_table => 'creations_categories', :autosave => true
-  has_many :photos, -> { where :order => :created_at }, :dependent => :destroy
+  has_many :photos, -> { order :created_at }, :dependent => :destroy
   has_many :favorites, :dependent => :destroy
   acts_as_taggable
 
-  default_scope { order("created_at DESC") }
+  #default_scope -> { order("created_at DESC") }
 
   # to be removed and moved to the DisplayCreationDTO
   def to_param
app/models/tutorial.rb
@@ -4,7 +4,7 @@ class Tutorial < ActiveRecord::Base
   belongs_to :user
   acts_as_taggable
 
-  default_scope { order("created_at DESC") }
+  #default_scope -> { order("created_at DESC") }
 
   def to_param
     "#{id}-#{heading.gsub(/[^a-z0-9]+/i, '-')}"
app/models/user.rb
@@ -19,7 +19,7 @@ class User < ActiveRecord::Base
   has_one :avatar
   acts_as_tagger
   before_save :ensure_authentication_token
-  default_scope { order("creations_count DESC") }
+  #default_scope -> { order("creations_count DESC") }
 
   def add_favorite(creation)
     creation.liked_by(self)
spec/controllers/profiles_controller_spec.rb
@@ -3,21 +3,25 @@ require 'spec_helper'
 describe ProfilesController do
   include Devise::TestHelpers
 
-  let(:user) { FactoryGirl.build(:user, :id => 1002) }
+  let(:user) { FactoryGirl.create(:user) }
 
   before (:each) do
+    user.creations << create(:creation)
     request.env['warden'] = double(Warden, :authenticate => user, :authenticate! => user)
   end
 
   describe "GET 'index'" do
     before :each do
-      User.stub(:all){ [user] }
       get 'index'
     end
 
     it "should be successful" do
       response.should be_success
     end
+
+    it "should include each user" do
+      assigns(:profiles).should include(user)
+    end
   end
 
   describe "GET 'show'" do
spec/factories/creation.rb
@@ -2,6 +2,6 @@ FactoryGirl.define do
   factory :creation, class: Creation do
     name 'cake'
     story 'whats the story morning glory?'
-    image { File.new(File.join( Rails.root, 'spec/fixtures/images/example.png')) }
+    #image { File.new(File.join( Rails.root, 'spec/fixtures/images/example.png')) }
   end
 end