Testing dragonfly image attachment

Hi people.

I have the following problem when testing a project model with an
attached dragonfly logo: When building a project test record through
factory girl the project seems valid, but testing project.should be_valid fails. I have tried printing the errors array to check, but
there seems to be no errors present on the project object. So what is
the deal? Am I simply missing something?

I have posted my code snippets below, and I would appreciate any input
you have, that could point me towards a solution.

project.rb

class Project
include Mongoid::Document
include Mongoid::Slug
include Mongoid::Timestamps

field :logo_uid
field :name
field :description
field :url
field :featured, :type => Boolean, :default => false
field :done_back_end, :type => Boolean, :default => false
field :done_front_end, :type => Boolean, :default => false
field :done_concept, :type => Boolean, :default => false
field :done_design, :type => Boolean, :default => false
field :done_identity, :type => Boolean, :default => false
slug :name
image_accessor :logo

attr_accessible :name, :description, :new_file, :logo, :url, :featured,
:done_back_end,
:done_front_end, :done_concept, :done_design,
:done_identity

belongs_to :user
embeds_many :project_images

validates :logo, :presence => true, :on => :create
validates :name, :presence => true
validates :name, :uniqueness => true

scope :featured, where(:featured => true)
end

project_spec.rb

require ‘spec_helper’
describe Project do
let(:project) { Factory.build(:project) }
context “validations” do
it “should be valid when build” do
project.should be_valid
end
end
end

factories.rb

FactoryGirl.define do
factory :project do
name Faker::Name.name
description Faker::Lorem.paragraphs
url Faker::Internet.domain_name
user Factory.build(:user)
project_images [Factory.build(:project_image),
Factory.build(:project_image)]
logo “#{Rails.root}/spec/assets/test-image.jpg” # This image
exists
end
end

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs