Put photos create spec back in. I am not going to check who left it pending.
This commit is contained in:
parent
4daebfd147
commit
3ca89bde57
2 changed files with 12 additions and 11 deletions
|
|
@ -34,6 +34,8 @@ class PhotosController < ApplicationController
|
||||||
def create
|
def create
|
||||||
begin
|
begin
|
||||||
|
|
||||||
|
raise unless params[:photo][:aspect_ids]
|
||||||
|
|
||||||
if params[:photo][:aspect_ids] == "all"
|
if params[:photo][:aspect_ids] == "all"
|
||||||
params[:photo][:aspect_ids] = current_user.aspects.collect{|x| x.id}
|
params[:photo][:aspect_ids] = current_user.aspects.collect{|x| x.id}
|
||||||
end
|
end
|
||||||
|
|
@ -110,7 +112,7 @@ class PhotosController < ApplicationController
|
||||||
else
|
else
|
||||||
respond_with :location => photos_path
|
respond_with :location => photos_path
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
|
@ -163,7 +165,7 @@ class PhotosController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def file_handler(params)
|
def file_handler(params)
|
||||||
######################## dealing with local files #############
|
######################## dealing with local files #############
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ describe PhotosController do
|
||||||
|
|
||||||
let!(:aspect) {user.aspects.create(:name => 'winners')}
|
let!(:aspect) {user.aspects.create(:name => 'winners')}
|
||||||
let(:aspect2) {user2.aspects.create(:name => 'winners')}
|
let(:aspect2) {user2.aspects.create(:name => 'winners')}
|
||||||
|
|
||||||
let(:filename) {'button.png'}
|
let(:filename) {'button.png'}
|
||||||
let(:fixture_name) {File.join(File.dirname(__FILE__), '..', 'fixtures', filename)}
|
let(:fixture_name) {File.join(File.dirname(__FILE__), '..', 'fixtures', filename)}
|
||||||
let(:image) {File.open(fixture_name)}
|
let(:image) {File.open(fixture_name)}
|
||||||
|
|
@ -31,8 +31,7 @@ describe PhotosController do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'can make a photo' do
|
it 'can make a photo' do
|
||||||
pending
|
proc{ post :create, :photo => {:user_file => image, :aspect_ids => "all"} }.should change(Photo, :count).by(1)
|
||||||
proc{ post :create, :qqfile => fixture_name }.should change(Photo, :count).by(1)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -45,7 +44,7 @@ describe PhotosController do
|
||||||
|
|
||||||
it 'sets the person to a contact if person_id is set' do
|
it 'sets the person to a contact if person_id is set' do
|
||||||
get :index, :person_id => user2.person.id.to_s
|
get :index, :person_id => user2.person.id.to_s
|
||||||
|
|
||||||
assigns[:person].should == user2.person
|
assigns[:person].should == user2.person
|
||||||
assigns[:posts].should == []
|
assigns[:posts].should == []
|
||||||
end
|
end
|
||||||
|
|
@ -57,19 +56,19 @@ describe PhotosController do
|
||||||
response.code.should == "200"
|
response.code.should == "200"
|
||||||
|
|
||||||
assigns[:photo].should == photo
|
assigns[:photo].should == photo
|
||||||
assigns[:ownership].should == true
|
assigns[:ownership].should == true
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#edit' do
|
describe '#edit' do
|
||||||
it 'should let you edit a photo' do
|
it 'should let you edit a photo' do
|
||||||
get :edit, :id => photo.id
|
get :edit, :id => photo.id
|
||||||
response.code.should == "200"
|
response.code.should == "200"
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should not let you edit a photo that is not yours' do
|
it 'should not let you edit a photo that is not yours' do
|
||||||
get :edit, :id => photo2.id
|
get :edit, :id => photo2.id
|
||||||
response.should redirect_to(:action => :index, :person_id => user.person.id.to_s)
|
response.should redirect_to(:action => :index, :person_id => user.person.id.to_s)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -92,7 +91,7 @@ describe PhotosController do
|
||||||
put :update, :id => photo.id, :photo => { :caption => "now with lasers!"}
|
put :update, :id => photo.id, :photo => { :caption => "now with lasers!"}
|
||||||
photo.reload.caption.should == "now with lasers!"
|
photo.reload.caption.should == "now with lasers!"
|
||||||
end
|
end
|
||||||
|
|
||||||
it "doesn't overwrite random attributes" do
|
it "doesn't overwrite random attributes" do
|
||||||
new_user = Factory.create :user
|
new_user = Factory.create :user
|
||||||
params = { :caption => "now with lasers!", :person_id => new_user.id}
|
params = { :caption => "now with lasers!", :person_id => new_user.id}
|
||||||
|
|
@ -109,7 +108,7 @@ describe PhotosController do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#make_profile_photo" do
|
describe "#make_profile_photo" do
|
||||||
|
|
||||||
it 'should return a 201 on a js success' do
|
it 'should return a 201 on a js success' do
|
||||||
get :make_profile_photo, :photo_id => photo.id, :format => 'js'
|
get :make_profile_photo, :photo_id => photo.id, :format => 'js'
|
||||||
response.code.should == "201"
|
response.code.should == "201"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue