Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
84 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
class Photo < ActiveRecord::Base | ||
attr_accessible :caption, :image | ||
mount_uploader :image, ImageUploader | ||
validates :image, :presence => true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
if Rails.env.test? | ||
CarrierWave.configure do |config| | ||
config.storage = :file | ||
config.enable_processing = false | ||
end | ||
|
||
RecordingUploader | ||
ImageUploader | ||
|
||
CarrierWave::Uploader::Base.descendants.each do |klass| | ||
next if klass.anonymous? | ||
klass.class_eval do | ||
def cache_dir | ||
"#{Rails.root}/spec/support/uploads/tmp" | ||
end | ||
|
||
def store_dir | ||
"#{Rails.root}/spec/support/uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" | ||
end | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,15 @@ | ||
require 'spec_helper' | ||
|
||
describe Photo do | ||
pending "add some examples to (or delete) #{__FILE__}" | ||
|
||
it "is valid with an image" do | ||
photo = create(:photo) | ||
expect(photo).to be_valid | ||
end | ||
|
||
it "is invalid without an image" do | ||
photo = build(:photo, image: nil) | ||
expect(photo).to have(1).error_on :image | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,20 @@ | ||
require 'spec_helper' | ||
|
||
describe Song do | ||
pending "add some examples to (or delete) #{__FILE__}" | ||
|
||
it "is valid with a title and recording" do | ||
song = create(:song) | ||
expect(song).to be_valid | ||
end | ||
|
||
it "is invalid without a title" do | ||
song = build(:song, title: nil) | ||
expect(song).to have(1).error_on :title | ||
end | ||
|
||
it "is invalid without a recording" do | ||
song = build(:song, recording: nil) | ||
expect(song).to have(1).error_on :recording | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,16 @@ | ||
require 'spec_helper' | ||
|
||
describe User do | ||
pending "add some examples to (or delete) #{__FILE__}" | ||
|
||
it "is valid with a good email address" do | ||
user = create :user | ||
expect(user).to be_valid | ||
end | ||
|
||
it "is invalid if that email has already been used" do | ||
user1 = create(:user) | ||
user2 = build(:user) | ||
expect(user2).to have(1).error_on :email | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module ControllerMacros | ||
def login_user | ||
before(:each) do | ||
@request.env["devise.mapping"] = Devise.mappings[:user] | ||
user = FactoryGirl.create(:user) | ||
sign_in user | ||
end | ||
end | ||
end |