Merge branch 'profile-bg'

This commit is contained in:
danielgrippi 2012-05-06 12:35:52 -07:00
commit 3f6a862a45
26 changed files with 301 additions and 149 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

@ -1,11 +1,35 @@
app.forms.Picture = app.views.Base.extend({ app.forms.PictureBase = app.views.Base.extend({
templateName : "picture-form",
events : { events : {
'ajax:complete .new_photo' : "photoUploaded", 'ajax:complete .new_photo' : "photoUploaded",
"change input[name='photo[user_file]']" : "submitForm" "change input[name='photo[user_file]']" : "submitForm"
}, },
onSubmit : $.noop,
uploadSuccess : $.noop,
postRenderTemplate : function(){
this.$("input[name=authenticity_token]").val($("meta[name=csrf-token]").attr("content"))
},
submitForm : function (){
this.$("form").submit();
this.onSubmit();
},
photoUploaded : function(evt, xhr) {
resp = JSON.parse(xhr.responseText)
if(resp.success) {
this.uploadSuccess(resp)
} else {
alert("Upload failed! Please try again. " + resp.error);
}
}
});
/* multi photo uploader */
app.forms.Picture = app.forms.PictureBase.extend({
templateName : "picture-form",
initialize : function() { initialize : function() {
this.photos = new Backbone.Collection() this.photos = new Backbone.Collection()
this.photos.bind("add", this.render, this) this.photos.bind("add", this.render, this)
@ -17,18 +41,12 @@ app.forms.Picture = app.views.Base.extend({
this.renderPhotos(); this.renderPhotos();
}, },
submitForm : function (){ onSubmit : function (){
this.$("form").submit();
this.$(".photos").append($('<span class="loader" style="margin-left: 80px;"></span>')) this.$(".photos").append($('<span class="loader" style="margin-left: 80px;"></span>'))
}, },
photoUploaded : function(evt, xhr) { uploadSuccess : function(resp) {
resp = JSON.parse(xhr.responseText)
if(resp.success) {
this.photos.add(new Backbone.Model(resp.data)) this.photos.add(new Backbone.Model(resp.data))
} else {
alert("Upload failed! Please try again. " + resp.error);
}
}, },
renderPhotos : function(){ renderPhotos : function(){
@ -39,3 +57,12 @@ app.forms.Picture = app.views.Base.extend({
}) })
} }
}); });
/* wallpaper uploader */
app.forms.Wallpaper = app.forms.PictureBase.extend({
templateName : "wallpaper-form",
uploadSuccess : function(resp) {
$("#profile").css("background-image", "url(" + resp.data.wallpaper + ")")
}
});

View file

@ -2,13 +2,15 @@
//= require ../views/profile_info_view //= require ../views/profile_info_view
app.pages.Profile = app.views.Base.extend({ app.pages.Profile = app.views.Base.extend({
className : "container",
id : "profile",
templateName : "profile", templateName : "profile",
subviews : { subviews : {
"#profile-info" : "profileInfo", "#profile-info" : "profileInfo",
"#canvas" : "canvasView" "#canvas" : "canvasView",
"#wallpaper-upload" : "wallpaperForm"
}, },
events : { events : {
@ -37,7 +39,7 @@ app.pages.Profile = app.views.Base.extend({
this.model = new app.models.Profile.findByGuid(options.personId) this.model = new app.models.Profile.findByGuid(options.personId)
this.stream = options && options.stream || new app.models.Stream() this.stream = options && options.stream || new app.models.Stream()
this.model.bind("change", this.setPageTitle, this) this.model.bind("change", this.setPageTitleAndBackground, this)
/* binds for getting started pulsation */ /* binds for getting started pulsation */
this.stream.bind("fetched", this.pulsateNewPostControl, this) this.stream.bind("fetched", this.pulsateNewPostControl, this)
@ -46,6 +48,7 @@ app.pages.Profile = app.views.Base.extend({
this.stream.preloadOrFetch(); this.stream.preloadOrFetch();
this.canvasView = new app.views.Canvas({ model : this.stream }) this.canvasView = new app.views.Canvas({ model : this.stream })
this.wallpaperForm = new app.forms.Wallpaper()
// send in isOwnProfile data // send in isOwnProfile data
this.profileInfo = new app.views.ProfileInfo({ model : this.model.set({isOwnProfile : this.isOwnProfile()}) }) this.profileInfo = new app.views.ProfileInfo({ model : this.model.set({isOwnProfile : this.isOwnProfile()}) })
@ -59,9 +62,11 @@ app.pages.Profile = app.views.Base.extend({
]("pulse") ]("pulse")
}, },
setPageTitle : function() { setPageTitleAndBackground : function() {
if(this.model.get("name")) if(this.model.get("name")) {
document.title = this.model.get("name") document.title = this.model.get("name")
this.$el.css("background-image", "url(" + this.model.get("wallpaper") + ")")
}
}, },
toggleEdit : function(evt) { toggleEdit : function(evt) {

View file

@ -29,6 +29,7 @@ app.views.Canvas = app.views.Base.extend(_.extend({}, app.views.infiniteScrollMi
itemSelector : '.canvas-frame', itemSelector : '.canvas-frame',
visibleStyle : {scale : 1}, visibleStyle : {scale : 1},
hiddenStyle : {scale : 0.001}, hiddenStyle : {scale : 0.001},
containerStyle : {position : "relative"},
masonry : { masonry : {
columnWidth : 292.5 columnWidth : 292.5
} }

View file

@ -1,3 +1,7 @@
body {
background-image : image_url("pattern.png");
}
/* new link color */ /* new link color */
a { color : rgb(42,156,235) } a { color : rgb(42,156,235) }
@ -437,19 +441,6 @@ div[data-template=flow] {
right : 10px; right : 10px;
top : 10px; top : 10px;
.label {
padding : 2px 5px;
padding-bottom : 3px;
span {
display : inline-block;
position : relative;
top : 1px;
font-family : Roboto-Bold;
}
}
& > a { & > a {
@include transition(opacity); @include transition(opacity);
@include opacity(0.4); @include opacity(0.4);
@ -462,3 +453,16 @@ div[data-template=flow] {
} }
} }
} }
/* bootstrap label fixes for Roboto */
.label {
padding : 2px 5px;
padding-bottom : 3px;
span {
display : inline-block;
position : relative;
top : 1px;
font-family : Roboto-Bold;
}
}

View file

@ -1,18 +1,13 @@
@mixin wide() { @mixin wide() {
width : $two-column-width + px; width : $two-column-width + px;
min-width : $two-column-width + px; min-width : $two-column-width + px;
max-width : $two-column-width + px; max-width : $two-column-width + px;
} }
body {
background-color : #F6F6F6;
background-image : image_url('pattern.png')
}
.canvas-frame { .canvas-frame {
float : left; float : left;
margin : 10px; margin : 10px;
margin-bottom : 18px;
/* expand / contract cursor declarations */ /* expand / contract cursor declarations */
&.x2 .content { &.x2 .content {
@ -28,12 +23,12 @@ body {
.content { .content {
@include transition(box-shadow); @include transition(box-shadow);
@include box-shadow(0,1px,3px,rgba(0,0,0,0.2)); @include box-shadow(0, 8px, 50px, rgba(0,0,0,0.9));
background-image : image_url("paper-texture-1.jpg"); background-image : image_url("paper-texture-1.jpg");
&:hover { &:hover {
@include box-shadow(0,1px,5px,rgba(0,0,0,0.5)); @include box-shadow(0, 3px, 10px,rgba(0,0,0,0.9));
.info { .info {
top : 0; top : 0;
@ -59,11 +54,9 @@ body {
max-width : $column-width + px; max-width : $column-width + px;
overflow : hidden; overflow : hidden;
//padding : 20px;
/* used in masking photos with overflow: hidden; */ /* used in masking photos with overflow: hidden; */
.image-container { .image-container {
overflow : hidden; overflow : hidden;
width : 100%; width : 100%;
@ -128,6 +121,8 @@ body {
background-color : rgba(255,255,255,0.8); background-color : rgba(255,255,255,0.8);
border-bottom : 1px solid #fff; border-bottom : 1px solid #fff;
color : #000;
position : absolute; position : absolute;
top : -32px; top : -32px;
right : 0; right : 0;

View file

@ -11,9 +11,7 @@
#photo_upload_button { #photo_upload_button {
position: relative; position: relative;
margin : { margin-bottom : 9px;
bottom : 9px;
}
input{ input{
@include opacity(0); @include opacity(0);
@ -21,6 +19,7 @@
top: 0; top: 0;
left: 0; left: 0;
height:100%; height:100%;
cursor : pointer;
} }
} }

View file

@ -1,3 +1,25 @@
#profile {
color : #fff;
background : {
color : #333;
/* The background-image property will be user-generated and set in `app.pages.Profile` (app/assets/javascripts/app/pages/profile.js)
and should ONLY be set once the image is fully loaded.
Optimal imagemagick manipulation settings for uploaded image (via trial & error):
`convert -brightness-contrast -40x-50`
NOTE: I noticed that just turning the brightness down had an adverse affect on contrast,
thus the "washing out" at -50 contrast. For more info on this specific command, read the documentation
on it here: http://www.imagemagick.org/script/command-line-options.php#brightness-contrast */
//image : url('/imagetest.jpg');
size : cover;
attachment : fixed;
}
}
/* getting started pulse animation */ /* getting started pulse animation */
#composer-button.pulse { #composer-button.pulse {
-webkit-animation: opacity-pulse 1s infinite; -webkit-animation: opacity-pulse 1s infinite;

View file

@ -8,7 +8,7 @@
{{#if location}} {{#if location}}
<span class="stat"> <span class="stat">
<a href="http://maps.google.com/maps?q={{location}}" target="_blank"> <a href="http://maps.google.com/maps?q={{location}}" target="_blank">
<i class="icon-map-marker"></i> <i class="icon-map-marker icon-white"></i>
</a> </a>
{{location}} {{location}}
</span> </span>
@ -17,7 +17,7 @@
{{#if birthday}} {{#if birthday}}
<span class="stat"> <span class="stat">
<img src='{{imageUrl "buttons/bday@2x.png"}}' class="cake" /> <img src='{{imageUrl "buttons/bday@2x-white.png"}}' class="cake" />
{{birthday}} {{birthday}}
</span> </span>
<span class="divider">•</span> <span class="divider">•</span>
@ -25,20 +25,20 @@
<span class="stat services"> <span class="stat services">
<a href="https://facebook.com" class="service" target="_blank"> <a href="https://facebook.com" class="service" target="_blank">
<img src='{{imageUrl "buttons/service-icons/fb@2x.png"}}' /> <img src='{{imageUrl "buttons/service-icons/fb@2x-white.png"}}' />
</a> </a>
<a href="https://twitter.com" class="service" target="_blank"> <a href="https://twitter.com" class="service" target="_blank">
<img src='{{imageUrl "buttons/service-icons/twitter@2x.png"}}' /> <img src='{{imageUrl "buttons/service-icons/twitter@2x-white.png"}}' />
</a> </a>
<a href="https://tumblr.com" class="service" target="_blank"> <a href="https://tumblr.com" class="service" target="_blank">
<img src='{{imageUrl "buttons/service-icons/tumblr@2x.png"}}' /> <img src='{{imageUrl "buttons/service-icons/tumblr@2x-white.png"}}' />
</a> </a>
</span> </span>
{{#if isOwnProfile}} {{#if isOwnProfile}}
<span class="divider">•</span> <span class="divider">•</span>
<a href="/profile/edit" title="Edit Profile" rel="tooltip" style="margin-left:2px;"> <a href="/profile/edit" title="Edit Profile" rel="tooltip" style="margin-left:2px;">
<i class="icon-cog"></i> <i class="icon-cog icon-white"></i>
</a> </a>
{{/if}} {{/if}}
</div> </div>

View file

@ -1,3 +1,8 @@
{{#if isOwnProfile}}
<div id="wallpaper-upload"></div>
{{/if}}
<div class="container">
<div id="top-right-nav"> <div id="top-right-nav">
{{#if showFollowButton}} {{#if showFollowButton}}
<a href="#" onClick="alert('Not yet implemented!')" id="follow-button"> <a href="#" onClick="alert('Not yet implemented!')" id="follow-button">
@ -58,3 +63,4 @@
<section id="canvas"></section> <section id="canvas"></section>
<div id="paginate"><span class="loader hidden"/></div> <div id="paginate"><span class="loader hidden"/></div>
</div>

View file

@ -0,0 +1,13 @@
<form accept-charset="UTF-8" action="/upload_wallpaper" class="new_photo" data-remote="true" enctype="multipart/form-data" method="post" style="position:absolute; left:10px; top: 10px; opacity:0.4;">
<input name="authenticity_token" type="hidden"/>
<div style="margin:0;padding:0;display:inline">
<input name="utf8" type="hidden" value="✓"/>
</div>
<div id='photo_upload_button'>
<a href="#" class='label label-inverse'>
<i class="icon-picture icon-white" style="margin-right:4px;"></i>CHANGE WALLPAPER
</a>
<input name="photo[user_file]" type="file"/>
</div>
</form>

View file

@ -16,14 +16,14 @@ class ProfilesController < ApplicationController
respond_to do |format| respond_to do |format|
format.json { format.json {
public_json = @person.as_api_response(:backbone) public_json = @person.as_api_response(:backbone)
extra_json = {} extra_json = {:wallpaper => @person.profile.wallpaper.url}
if(current_user && (current_user.person == @person || current_user.contacts.receiving.where(:person_id => @person.id).first)) if(current_user && (current_user.person == @person || current_user.contacts.receiving.where(:person_id => @person.id).first))
extra_json = { extra_json = extra_json.merge({
:location => @person.profile.location, :location => @person.profile.location,
:birthday => @person.profile.formatted_birthday, :birthday => @person.profile.formatted_birthday,
:bio => @person.profile.bio :bio => @person.profile.bio
} })
end end
render :json => public_json.merge(extra_json) render :json => public_json.merge(extra_json)
@ -77,6 +77,30 @@ class ProfilesController < ApplicationController
end end
end end
def upload_wallpaper_image
unless params[:photo].present?
respond_to do |format|
format.json { render :json => {"success" => false} }
end
return
end
if remotipart_submitted?
profile = current_user.person.profile
profile.wallpaper.store! params[:photo][:user_file]
if profile.save
respond_to do |format|
format.json { render :json => {"success" => true, "data" => {"wallpaper" => profile.wallpaper.url}} }
end
else
respond_to do |format|
format.json { render :json => {"success" => false} }
end
end
end
end
protected protected
def munge_tag_string def munge_tag_string

View file

@ -5,6 +5,8 @@
class Profile < ActiveRecord::Base class Profile < ActiveRecord::Base
self.include_root_in_json = false self.include_root_in_json = false
mount_uploader :wallpaper, WallpaperUploader
include Diaspora::Federated::Base include Diaspora::Federated::Base
include Diaspora::Taggable include Diaspora::Taggable

View file

@ -0,0 +1,27 @@
class WallpaperUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
def store_dir
"uploads/images/wallpaper"
end
def extension_white_list
%w(jpg jpeg png tiff)
end
# Filename is associated with the user's diaspora handle, ensuring uniqueness
# and that only one copy is kept in the filesystem.
def filename
Digest::MD5.hexdigest(model.diaspora_handle) + File.extname(@filename) if @filename
end
process :darken
def darken
manipulate! do |img|
img.brightness_contrast "-40x-50"
img = yield(img) if block_given?
img
end
end
end

View file

@ -54,6 +54,8 @@ Diaspora::Application.routes.draw do
put :make_profile_photo put :make_profile_photo
end end
post "upload_wallpaper" => 'profiles#upload_wallpaper_image'
# ActivityStreams routes # ActivityStreams routes
scope "/activity_streams", :module => "activity_streams", :as => "activity_streams" do scope "/activity_streams", :module => "activity_streams", :as => "activity_streams" do
resources :photos, :controller => "photos", :only => [:create] resources :photos, :controller => "photos", :only => [:create]

View file

@ -0,0 +1,5 @@
class AddWallpaperToProfile < ActiveRecord::Migration
def change
add_column :profiles, :wallpaper, :string
end
end

View file

@ -11,7 +11,7 @@
# #
# It's strongly recommended to check this file into your version control system. # It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20120427152648) do ActiveRecord::Schema.define(:version => 20120506053156) do
create_table "account_deletions", :force => true do |t| create_table "account_deletions", :force => true do |t|
t.string "diaspora_handle" t.string "diaspora_handle"
@ -369,6 +369,7 @@ ActiveRecord::Schema.define(:version => 20120427152648) do
t.string "location" t.string "location"
t.string "full_name", :limit => 70 t.string "full_name", :limit => 70
t.boolean "nsfw", :default => false t.boolean "nsfw", :default => false
t.string "wallpaper"
end end
add_index "profiles", ["full_name", "searchable"], :name => "index_profiles_on_full_name_and_searchable" add_index "profiles", ["full_name", "searchable"], :name => "index_profiles_on_full_name_and_searchable"

Binary file not shown.

After

Width:  |  Height:  |  Size: 239 KiB

BIN
public/imagetest.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 189 KiB

BIN
public/imagetest2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

View file

@ -6,37 +6,36 @@ require 'spec_helper'
describe ProfilesController do describe ProfilesController do
before do before do
@user = eve sign_in :user, eve
sign_in :user, @user
end end
describe '#show' do describe '#show' do
it "returns the user as json" do it "returns the user as json" do
get :show, :id => @user.person.guid, :format => :json get :show, :id => eve.person.guid, :format => :json
JSON.parse(response.body).should include(JSON.parse(@user.person.as_api_response(:backbone).to_json)) JSON.parse(response.body).should include(JSON.parse(eve.person.as_api_response(:backbone).to_json))
end end
it "returns the user's public information if a user is not logged in" do it "returns the user's public information if a user is not logged in" do
sign_out :user sign_out :user
get :show, :id => @user.person.guid, :format => :json get :show, :id => eve.person.guid, :format => :json
JSON.parse(response.body).should include(JSON.parse(@user.person.as_api_response(:backbone).to_json)) JSON.parse(response.body).should include(JSON.parse(eve.person.as_api_response(:backbone).to_json))
end end
it "returns the user's public information if a user is logged in and the visiting user is not receiving" do it "returns the user's public information if a user is logged in and the visiting user is not receiving" do
sign_in :user, alice sign_in :user, alice
get :show, :id => @user.person.guid, :format => :json get :show, :id => eve.person.guid, :format => :json
response.body.should_not match(/.location./) response.body.should_not match(/.location./)
end end
it "returns the user's private information if a user is logged in and the visiting user is receiving" do it "returns the user's private information if a user is logged in and the visiting user is receiving" do
sign_in :user, bob sign_in :user, bob
get :show, :id => @user.person.guid, :format => :json get :show, :id => eve.person.guid, :format => :json
response.body.should match(/.location./) response.body.should match(/.location./)
end end
it "returns the user's private information if a user is logged in as herself" do it "returns the user's private information if a user is logged in as herself" do
sign_in :user, eve sign_in :user, eve
get :show, :id => @user.person.guid, :format => :json get :show, :id => eve.person.guid, :format => :json
response.body.should match(/.location./) response.body.should match(/.location./)
end end
end end
@ -49,7 +48,7 @@ describe ProfilesController do
it 'sets the profile to the current users profile' do it 'sets the profile to the current users profile' do
get :edit get :edit
assigns[:profile].should == @user.person.profile assigns[:profile].should == eve.person.profile
end end
it 'sets the aspect to "person_edit" ' do it 'sets the aspect to "person_edit" ' do
@ -59,7 +58,7 @@ describe ProfilesController do
it 'sets the person to the current users person' do it 'sets the person to the current users person' do
get :edit get :edit
assigns[:person].should == @user.person assigns[:person].should == eve.person
end end
end end
@ -74,48 +73,48 @@ describe ProfilesController do
end end
it "sets nsfw" do it "sets nsfw" do
@user.person(true).profile.nsfw.should == false eve.person(true).profile.nsfw.should == false
put :update, :profile => { :id => @user.person.id, :nsfw => "1" } put :update, :profile => { :id => eve.person.id, :nsfw => "1" }
@user.person(true).profile.nsfw.should == true eve.person(true).profile.nsfw.should == true
end end
it "unsets nsfw" do it "unsets nsfw" do
@user.person.profile.nsfw = true eve.person.profile.nsfw = true
@user.person.profile.save eve.person.profile.save
@user.person(true).profile.nsfw.should == true eve.person(true).profile.nsfw.should == true
put :update, :profile => { :id => @user.person.id } put :update, :profile => { :id => eve.person.id }
@user.person(true).profile.nsfw.should == false eve.person(true).profile.nsfw.should == false
end end
it 'sets tags' do it 'sets tags' do
params = { :id => @user.person.id, params = { :id => eve.person.id,
:tags => '#apples #oranges'} :tags => '#apples #oranges'}
put :update, params put :update, params
@user.person(true).profile.tag_list.to_set.should == ['apples', 'oranges'].to_set eve.person(true).profile.tag_list.to_set.should == ['apples', 'oranges'].to_set
end end
it 'sets plaintext tags' do it 'sets plaintext tags' do
params = { :id => @user.person.id, params = { :id => eve.person.id,
:tags => ',#apples,#oranges,', :tags => ',#apples,#oranges,',
:profile => {:tag_string => '#pears'} } :profile => {:tag_string => '#pears'} }
put :update, params put :update, params
@user.person(true).profile.tag_list.to_set.should == ['apples', 'oranges', 'pears'].to_set eve.person(true).profile.tag_list.to_set.should == ['apples', 'oranges', 'pears'].to_set
end end
it 'sets plaintext tags without #' do it 'sets plaintext tags without #' do
params = { :id => @user.person.id, params = { :id => eve.person.id,
:tags => ',#apples,#oranges,', :tags => ',#apples,#oranges,',
:profile => {:tag_string => 'bananas'} } :profile => {:tag_string => 'bananas'} }
put :update, params put :update, params
@user.person(true).profile.tag_list.to_set.should == ['apples', 'oranges', 'bananas'].to_set eve.person(true).profile.tag_list.to_set.should == ['apples', 'oranges', 'bananas'].to_set
end end
it 'sets valid birthday' do it 'sets valid birthday' do
params = { :id => @user.person.id, params = { :id => eve.person.id,
:profile => { :profile => {
:date => { :date => {
:year => '2001', :year => '2001',
@ -123,13 +122,13 @@ describe ProfilesController do
:day => '28' } } } :day => '28' } } }
put :update, params put :update, params
@user.person(true).profile.birthday.year.should == 2001 eve.person(true).profile.birthday.year.should == 2001
@user.person(true).profile.birthday.month.should == 2 eve.person(true).profile.birthday.month.should == 2
@user.person(true).profile.birthday.day.should == 28 eve.person(true).profile.birthday.day.should == 28
end end
it 'displays error for invalid birthday' do it 'displays error for invalid birthday' do
params = { :id => @user.person.id, params = { :id => eve.person.id,
:profile => { :profile => {
:date => { :date => {
:year => '2001', :year => '2001',
@ -142,21 +141,21 @@ describe ProfilesController do
context 'with a profile photo set' do context 'with a profile photo set' do
before do before do
@params = { :id => @user.person.id, @params = { :id => eve.person.id,
:profile => :profile =>
{:image_url => "", {:image_url => "",
:last_name => @user.person.profile.last_name, :last_name => eve.person.profile.last_name,
:first_name => @user.person.profile.first_name }} :first_name => eve.person.profile.first_name }}
@user.person.profile.image_url = "http://tom.joindiaspora.com/images/user/tom.jpg" eve.person.profile.image_url = "http://tom.joindiaspora.com/images/user/tom.jpg"
@user.person.profile.save eve.person.profile.save
end end
it "doesn't overwrite the profile photo when an empty string is passed in" do it "doesn't overwrite the profile photo when an empty string is passed in" do
image_url = @user.person.profile.image_url image_url = eve.person.profile.image_url
put :update, @params put :update, @params
Person.find(@user.person.id).profile.image_url.should == image_url Person.find(eve.person.id).profile.image_url.should == image_url
end end
end end
@ -168,7 +167,7 @@ describe ProfilesController do
end end
it 'person_id' do it 'person_id' do
person = @user.person person = eve.person
profile = person.profile profile = person.profile
put :update, @profile_params put :update, @profile_params
profile.reload.person_id.should == person.id profile.reload.person_id.should == person.id
@ -176,8 +175,28 @@ describe ProfilesController do
it 'diaspora handle' do it 'diaspora handle' do
put :update, @profile_params put :update, @profile_params
Person.find(@user.person.id).profile[:diaspora_handle].should_not == 'abc@a.com' Person.find(eve.person.id).profile[:diaspora_handle].should_not == 'abc@a.com'
end end
end end
end end
describe '#upload_wallpaper_image' do
it 'returns a success=false response if the photo param is not present' do
post :upload_wallpaper_image, :format => :json
JSON.parse(response.body).should include("success" => false)
end
it 'stores the wallpaper for the current_user' do
# we should have another test here asserting that the wallpaper is set... i was having problems testing
# this behavior though :(
@controller.stub!(:current_user).and_return(eve)
@controller.stub!(:remotipart_submitted?).and_return(true)
@controller.stub!(:file_handler).and_return(uploaded_photo)
@params = {:photo => {:user_file => uploaded_photo} }
eve.person.profile.wallpaper.should_receive(:store!)
post :upload_wallpaper_image, @params.merge(:format => :json)
end
end
end end