diff --git a/app/controllers/requests_controller.rb b/app/controllers/requests_controller.rb index 0b67d9d4b..52ab8c4c9 100644 --- a/app/controllers/requests_controller.rb +++ b/app/controllers/requests_controller.rb @@ -15,7 +15,7 @@ class RequestsController < ApplicationController if params[:aspect_id] @contact = current_user.accept_and_respond( params[:id], params[:aspect_id]) flash[:notice] = I18n.t 'requests.destroy.success' - respond_with :location => current_user.aspects.where(:id => params[:aspect_id]).first + respond_with @contact, :location => requests_url else flash[:error] = I18n.t 'requests.destroy.error' respond_with @contact, :location => requests_url diff --git a/app/models/photo.rb b/app/models/photo.rb index 549402b0b..46f3b3c64 100644 --- a/app/models/photo.rb +++ b/app/models/photo.rb @@ -41,6 +41,7 @@ class Photo < Post end def remote_photo= remote_path + pp remote_path name_start = remote_path.rindex '/' self.remote_photo_path = remote_path.slice(0, name_start ) self.remote_photo_name = remote_path.slice(name_start + 1, remote_path.length) diff --git a/db/migrate/0000_create_schema.rb b/db/migrate/0000_create_schema.rb index 47207989c..073ec8c4c 100644 --- a/db/migrate/0000_create_schema.rb +++ b/db/migrate/0000_create_schema.rb @@ -85,6 +85,7 @@ class CreateSchema < ActiveRecord::Migration t.text :remote_photo_path t.string :remote_photo_name t.string :random_string + t.string :image #carrierwave's column t.timestamps end diff --git a/db/schema.rb b/db/schema.rb index 7fd4f2296..4a1e22461 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -119,6 +119,7 @@ ActiveRecord::Schema.define(:version => 0) do t.text "remote_photo_path" t.string "remote_photo_name" t.string "random_string" + t.string "image" t.datetime "created_at" t.datetime "updated_at" end diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb index 63e3a7d3b..a483b7d37 100644 --- a/spec/controllers/photos_controller_spec.rb +++ b/spec/controllers/photos_controller_spec.rb @@ -15,9 +15,8 @@ describe PhotosController do let(:filename) { 'button.png' } let(:fixture_name) { File.join(File.dirname(__FILE__), '..', 'fixtures', filename) } - let(:image) { File.open(fixture_name) } - let!(:photo1) { user1.post(:photo, :user_file => image, :to => aspect1.id) } - let!(:photo2) { user2.post(:photo, :user_file => image, :to => aspect2.id) } + let!(:photo1) { user1.post(:photo, :user_file => File.open(fixture_name), :to => aspect1.id) } + let!(:photo2) { user2.post(:photo, :user_file => File.open(fixture_name), :to => aspect2.id) } before do connect_users(user1, aspect1, user2, aspect2) @@ -25,10 +24,17 @@ describe PhotosController do sign_in :user, user1 end + it 'has working context' do + photo1.url.should_not be_nil + Photo.find(photo1.id).url.should_not be_nil + photo2.url.should_not be_nil + Photo.find(photo2.id).url.should_not be_nil + end + describe '#create' do before do - @controller.stub!(:file_handler).and_return(image) - @params = {:photo => {:user_file => image, :aspect_ids => "all"} } + @controller.stub!(:file_handler).and_return(File.open(fixture_name)) + @params = {:photo => {:user_file => File.open(fixture_name), :aspect_ids => "all"} } end it 'can make a photo' do diff --git a/spec/models/user/connecting_spec.rb b/spec/models/user/connecting_spec.rb index 6a9f11550..9dcccc2a0 100644 --- a/spec/models/user/connecting_spec.rb +++ b/spec/models/user/connecting_spec.rb @@ -106,10 +106,10 @@ describe Diaspora::UserModules::Connecting do it "should mark the corresponding notification as 'read'" do notification = Notification.create(:target_id => @received_request.id, - :kind => 'new_request', + :target_type => 'new_request', :unread => true) - Notification.first(:target_id=>@received_request.id).unread.should be_true + Notification.where(:target_id=>@received_request.id).first.unread.should be_true user.accept_contact_request(@received_request, aspect) Notification.first(:target_id=>@received_request.id).unread.should be_false end