mirror of
https://github.com/discourse/discourse.git
synced 2026-09-05 04:40:41 -05:00
FEATURE: Allow a user to upload an image for their expansion background.
This commit is contained in:
@@ -1156,6 +1156,21 @@ describe UsersController do
|
||||
json['height'].should == 200
|
||||
end
|
||||
|
||||
it 'is successful for expansion backgrounds' do
|
||||
upload = Fabricate(:upload)
|
||||
Upload.expects(:create_for).returns(upload)
|
||||
xhr :post, :upload_user_image, username: user.username, file: user_image, image_type: "expansion_background"
|
||||
user.reload
|
||||
|
||||
user.user_profile.expansion_background.should == "/uploads/default/1/1234567890123456.png"
|
||||
|
||||
# returns the url, width and height of the uploaded image
|
||||
json = JSON.parse(response.body)
|
||||
json['url'].should == "/uploads/default/1/1234567890123456.png"
|
||||
json['width'].should == 100
|
||||
json['height'].should == 200
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "with url" do
|
||||
@@ -1204,6 +1219,20 @@ describe UsersController do
|
||||
json['width'].should == 100
|
||||
json['height'].should == 200
|
||||
end
|
||||
|
||||
it 'is successful for expansion backgrounds' do
|
||||
upload = Fabricate(:upload)
|
||||
Upload.expects(:create_for).returns(upload)
|
||||
xhr :post, :upload_user_image, username: user.username, file: user_image_url, image_type: "expansion_background"
|
||||
user.reload
|
||||
user.user_profile.expansion_background.should == "/uploads/default/1/1234567890123456.png"
|
||||
|
||||
# returns the url, width and height of the uploaded image
|
||||
json = JSON.parse(response.body)
|
||||
json['url'].should == "/uploads/default/1/1234567890123456.png"
|
||||
json['width'].should == 100
|
||||
json['height'].should == 200
|
||||
end
|
||||
end
|
||||
|
||||
it "should handle malformed urls" do
|
||||
|
||||
@@ -32,6 +32,16 @@ describe UserSerializer do
|
||||
end
|
||||
end
|
||||
|
||||
context "with filled out expansion background" do
|
||||
before do
|
||||
user.user_profile.expansion_background = 'http://expansion.com'
|
||||
end
|
||||
|
||||
it "has a profile background" do
|
||||
expect(json[:expansion_background]).to eq 'http://expansion.com'
|
||||
end
|
||||
end
|
||||
|
||||
context "with filled out profile background" do
|
||||
before do
|
||||
user.user_profile.profile_background = 'http://background.com'
|
||||
|
||||
Reference in New Issue
Block a user