Merge branch 'master' of github.com:diaspora/diaspora
This commit is contained in:
commit
dbc68e69b7
4 changed files with 32 additions and 2 deletions
|
|
@ -71,6 +71,7 @@ class PhotosController < ApplicationController
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.json{ render(:layout => false , :json => {"success" => true, "data" => @photo}.to_json )}
|
format.json{ render(:layout => false , :json => {"success" => true, "data" => @photo}.to_json )}
|
||||||
|
format.html{ render(:layout => false , :json => {"success" => true, "data" => @photo}.to_json )}
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
respond_with @photo, :location => photos_path, :error => message
|
respond_with @photo, :location => photos_path, :error => message
|
||||||
|
|
@ -214,6 +215,11 @@ class PhotosController < ApplicationController
|
||||||
private
|
private
|
||||||
|
|
||||||
def file_handler(params)
|
def file_handler(params)
|
||||||
|
# For XHR file uploads, request.params[:qqfile] will be the path to the temporary file
|
||||||
|
# For regular form uploads (such as those made by Opera), request.params[:qqfile] will be an UploadedFile which can be returned unaltered.
|
||||||
|
if not request.params[:qqfile].is_a?(String)
|
||||||
|
params[:qqfile]
|
||||||
|
else
|
||||||
######################## dealing with local files #############
|
######################## dealing with local files #############
|
||||||
# get file name
|
# get file name
|
||||||
file_name = params[:qqfile]
|
file_name = params[:qqfile]
|
||||||
|
|
@ -235,5 +241,6 @@ class PhotosController < ApplicationController
|
||||||
Tempfile.send(:define_method, "content_type") {return att_content_type}
|
Tempfile.send(:define_method, "content_type") {return att_content_type}
|
||||||
Tempfile.send(:define_method, "original_filename") {return file_name}
|
Tempfile.send(:define_method, "original_filename") {return file_name}
|
||||||
file
|
file
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
# the COPYRIGHT file.
|
# the COPYRIGHT file.
|
||||||
|
|
||||||
require File.join(Rails.root, 'lib', 'stream', 'public')
|
require File.join(Rails.root, 'lib', 'stream', 'public')
|
||||||
require 'newrelic_rpm' if File.exists?(File.expand_path('../newrelic.yml', __FILE__))
|
require 'newrelic_rpm' if File.exists?(File.expand_path("#{Rails.root}/config/newrelic.yml", __FILE__))
|
||||||
|
|
||||||
class PublicsController < ApplicationController
|
class PublicsController < ApplicationController
|
||||||
require File.join(Rails.root, '/lib/diaspora/parser')
|
require File.join(Rails.root, '/lib/diaspora/parser')
|
||||||
|
|
@ -11,7 +11,7 @@ class PublicsController < ApplicationController
|
||||||
require File.join(Rails.root, '/lib/postzord/receiver/private')
|
require File.join(Rails.root, '/lib/postzord/receiver/private')
|
||||||
include Diaspora::Parser
|
include Diaspora::Parser
|
||||||
|
|
||||||
newrelic_ignore if File.exists?(File.expand_path('../newrelic.yml', __FILE__))
|
newrelic_ignore if File.exists?(File.expand_path("#{Rails.root}/config/newrelic.yml", __FILE__))
|
||||||
|
|
||||||
skip_before_filter :set_header_data
|
skip_before_filter :set_header_data
|
||||||
skip_before_filter :which_action_and_user
|
skip_before_filter :which_action_and_user
|
||||||
|
|
|
||||||
|
|
@ -1017,6 +1017,7 @@ qq.extend(qq.UploadHandlerForm.prototype, {
|
||||||
var iframe = this._createIframe(id);
|
var iframe = this._createIframe(id);
|
||||||
var form = this._createForm(iframe, params);
|
var form = this._createForm(iframe, params);
|
||||||
form.appendChild(input);
|
form.appendChild(input);
|
||||||
|
$(form).append($('<input type="hidden" name="authenticity_token" value="'+$("meta[name='csrf-token']").attr("content")+'"/>'));
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
this._attachLoadEvent(iframe, function(){
|
this._attachLoadEvent(iframe, function(){
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,28 @@ describe PhotosController do
|
||||||
sign_in :user, alice
|
sign_in :user, alice
|
||||||
request.env["HTTP_REFERER"] = ''
|
request.env["HTTP_REFERER"] = ''
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#create' do
|
||||||
|
before do
|
||||||
|
@params = {:photo => {:aspect_ids => "all"}, :qqfile => Rack::Test::UploadedFile.new("spec/fixtures/button.png", "image/png") }
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'accepts a photo from a regular form submission' do
|
||||||
|
lambda {
|
||||||
|
post :create, @params
|
||||||
|
}.should change(Photo, :count).by(1)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns application/json when possible' do
|
||||||
|
request.env['HTTP_ACCEPT'] = 'application/json'
|
||||||
|
post(:create, @params).headers['Content-Type'].should match 'application/json.*'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns text/html by default' do
|
||||||
|
request.env['HTTP_ACCEPT'] = 'text/html,*/*'
|
||||||
|
post(:create, @params).headers['Content-Type'].should match 'text/html.*'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe '#create' do
|
describe '#create' do
|
||||||
before do
|
before do
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue