Merge branch 'master' into group-top
This commit is contained in:
commit
5030fbb8b5
13 changed files with 90 additions and 80 deletions
|
|
@ -6,10 +6,9 @@ class AlbumsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@album = Album.new(params[:album])
|
@album = current_user.post(:album, params[:album])
|
||||||
@album.person = current_user
|
|
||||||
|
|
||||||
if @album.save
|
if @album.created_at
|
||||||
flash[:notice] = "Successfully created album."
|
flash[:notice] = "Successfully created album."
|
||||||
redirect_to @album
|
redirect_to @album
|
||||||
else
|
else
|
||||||
|
|
@ -47,4 +46,5 @@ class AlbumsController < ApplicationController
|
||||||
render :action => 'edit'
|
render :action => 'edit'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,9 @@ class BlogsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@blog = Blog.new(params[:blog])
|
@blog = current_user.post(:blog, params[:blog])
|
||||||
@blog.person = current_user
|
|
||||||
if @blog.save
|
if @blog.created_at
|
||||||
flash[:notice] = "Successfully created blog."
|
flash[:notice] = "Successfully created blog."
|
||||||
redirect_to @blog
|
redirect_to @blog
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -31,9 +31,9 @@ class BookmarksController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@bookmark = Bookmark.new(params[:bookmark])
|
@bookmark = current_user.post(:bookmark, params[:bookmark])
|
||||||
@bookmark.person = current_user
|
|
||||||
if @bookmark.save
|
if @bookmark.created_at
|
||||||
flash[:notice] = "Successfully created bookmark."
|
flash[:notice] = "Successfully created bookmark."
|
||||||
redirect_to @bookmark
|
redirect_to @bookmark
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,9 @@ class PhotosController < ApplicationController
|
||||||
|
|
||||||
def create
|
def create
|
||||||
begin
|
begin
|
||||||
#puts params.inspect
|
@photo = current_user.post(:photo, params)
|
||||||
@photo = Photo.instantiate(params)
|
|
||||||
@photo.person = current_user
|
|
||||||
|
|
||||||
if @photo.save
|
if @photo.created_at
|
||||||
flash[:notice] = "Successfully uploaded photo."
|
flash[:notice] = "Successfully uploaded photo."
|
||||||
redirect_to @photo.album
|
redirect_to @photo.album
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -13,10 +13,9 @@ class StatusMessagesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@status_message = StatusMessage.new(params[:status_message])
|
@status_message = current_user.post(:status_message, params[:status_message])
|
||||||
@status_message.person = current_user
|
|
||||||
|
|
||||||
if @status_message.save
|
if @status_message.created_at
|
||||||
flash[:notice] = "Successfully created status message."
|
flash[:notice] = "Successfully created status message."
|
||||||
redirect_to status_messages_url
|
redirect_to status_messages_url
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,10 @@ class Album
|
||||||
after_save :notify_people
|
after_save :notify_people
|
||||||
before_destroy :propagate_retraction
|
before_destroy :propagate_retraction
|
||||||
|
|
||||||
|
def instantiate params
|
||||||
|
self.create params
|
||||||
|
end
|
||||||
|
|
||||||
def self.mine_or_friends(friend_param, current_user)
|
def self.mine_or_friends(friend_param, current_user)
|
||||||
if friend_param
|
if friend_param
|
||||||
Album.where(:person_id.ne => current_user.id)
|
Album.where(:person_id.ne => current_user.id)
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,11 @@ class Post
|
||||||
before_destroy :propagate_retraction
|
before_destroy :propagate_retraction
|
||||||
after_destroy :destroy_comments, :remove_from_view
|
after_destroy :destroy_comments, :remove_from_view
|
||||||
|
|
||||||
|
def self.instantiate params
|
||||||
|
self.create params
|
||||||
|
end
|
||||||
|
|
||||||
|
#Querying
|
||||||
def self.stream
|
def self.stream
|
||||||
Post.sort(:created_at.desc).all
|
Post.sort(:created_at.desc).all
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,13 @@ class User < Person
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
######## Posting ########
|
||||||
|
|
||||||
|
def post(class_name, options = {})
|
||||||
|
options[:person] = self
|
||||||
|
model_class = class_name.to_s.camelize.constantize
|
||||||
|
post = model_class.instantiate(options)
|
||||||
|
end
|
||||||
|
|
||||||
######## Commenting ########
|
######## Commenting ########
|
||||||
def comment(text, options = {})
|
def comment(text, options = {})
|
||||||
|
|
|
||||||
|
|
@ -173,9 +173,10 @@ form {
|
||||||
color: black; }
|
color: black; }
|
||||||
#user_name span {
|
#user_name span {
|
||||||
size: small;
|
size: small;
|
||||||
font-style: italic;
|
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
color: #999999; }
|
color: #999999; }
|
||||||
|
#user_name #latest_message_time {
|
||||||
|
font-style: italic; }
|
||||||
#user_name ul {
|
#user_name ul {
|
||||||
display: inline;
|
display: inline;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
|
|
||||||
|
|
@ -206,11 +206,11 @@ form
|
||||||
|
|
||||||
span
|
span
|
||||||
:size small
|
:size small
|
||||||
:font-style italic
|
|
||||||
:font
|
:font
|
||||||
:weight normal
|
:weight normal
|
||||||
:color #999
|
:color #999
|
||||||
|
#latest_message_time
|
||||||
|
:font-style italic
|
||||||
ul
|
ul
|
||||||
:display inline
|
:display inline
|
||||||
:margin 0
|
:margin 0
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@ describe Post do
|
||||||
it "should associate the owner if none is present" do
|
it "should associate the owner if none is present" do
|
||||||
@post.person.should == User.owner
|
@post.person.should == User.owner
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "newest" do
|
describe "newest" do
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,11 @@ describe StatusMessage do
|
||||||
n.message = "wales"
|
n.message = "wales"
|
||||||
n.valid?.should be true
|
n.valid?.should be true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should be postable through the user' do
|
||||||
|
status = @user.post(:status_message, :message => "Users do things")
|
||||||
|
end
|
||||||
|
|
||||||
describe "XML" do
|
describe "XML" do
|
||||||
it 'should serialize to XML' do
|
it 'should serialize to XML' do
|
||||||
message = Factory.create(:status_message, :message => "I hate WALRUSES!")
|
message = Factory.create(:status_message, :message => "I hate WALRUSES!")
|
||||||
|
|
|
||||||
|
|
@ -7,75 +7,68 @@ describe User do
|
||||||
Person.count.should == n+1
|
Person.count.should == n+1
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should be able to accept a pending friend request" do
|
describe 'friend requesting' do
|
||||||
@user = Factory.create(:user)
|
before do
|
||||||
@friend = Factory.create(:person, :active => false)
|
@user = Factory.create(:user)
|
||||||
r = Request.instantiate(:to => @user.url, :from => @friend)
|
end
|
||||||
r.save
|
|
||||||
Person.all.count.should == 2
|
|
||||||
Request.for_user(@user).all.count.should == 1
|
|
||||||
@user.accept_friend_request(r.id)
|
|
||||||
Request.for_user(@user).all.count.should == 0
|
|
||||||
Person.where(:id => @friend.id).first.active.should == true
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should be able to ignore a pending friend request' do
|
it "should be able to accept a pending friend request" do
|
||||||
@user = Factory.create(:user)
|
friend = Factory.create(:person, :active => false)
|
||||||
@friend = Factory.create(:person, :active => false)
|
r = Request.instantiate(:to => @user.url, :from => friend)
|
||||||
r = Request.instantiate(:to => @user.url, :from => @friend)
|
r.save
|
||||||
r.save
|
Person.all.count.should == 2
|
||||||
|
Request.for_user(@user).all.count.should == 1
|
||||||
|
@user.accept_friend_request(r.id)
|
||||||
|
Request.for_user(@user).all.count.should == 0
|
||||||
|
Person.where(:id => friend.id).first.active.should == true
|
||||||
|
end
|
||||||
|
|
||||||
Person.count.should == 2
|
it 'should be able to ignore a pending friend request' do
|
||||||
@friend.active.should == false
|
friend = Factory.create(:person, :active => false)
|
||||||
|
r = Request.instantiate(:to => @user.url, :from => friend)
|
||||||
|
r.save
|
||||||
|
|
||||||
@user.ignore_friend_request(r.id)
|
Person.count.should == 2
|
||||||
|
friend.active.should == false
|
||||||
|
|
||||||
Person.count.should == 1
|
@user.ignore_friend_request(r.id)
|
||||||
Request.count.should == 0
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should not be able to friend request an existing friend' do
|
Person.count.should == 1
|
||||||
@user = Factory.create(:user)
|
Request.count.should == 0
|
||||||
@friend = Factory.create(:person)
|
end
|
||||||
|
|
||||||
@user.send_friend_request_to( @friend.url ).should be nil
|
it 'should not be able to friend request an existing friend' do
|
||||||
end
|
friend = Factory.create(:person)
|
||||||
|
|
||||||
it 'should be able to give me the terse url for webfinger' do
|
@user.send_friend_request_to( friend.url ).should be nil
|
||||||
user = Factory.create(:user)
|
end
|
||||||
user.terse_url.should == 'example.com'
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should be able to unsubscribe from a status.net user' do
|
it 'should be able to give me the terse url for webfinger' do
|
||||||
@user = Factory.create(:user)
|
@user.terse_url.should == 'example.com'
|
||||||
author = Factory.create(:author)
|
end
|
||||||
Author.all.count.should == 1
|
|
||||||
q = Request.send :class_variable_get, :@@queue
|
|
||||||
q.stub!(:add_hub_unsubscribe_request)
|
|
||||||
q.should_receive(:add_hub_unsubscribe_request)
|
|
||||||
|
|
||||||
@user.unsubscribe_from_pubsub(author.id)
|
it 'should be able to unsubscribe from a status.net user' do
|
||||||
Author.all.count.should == 0
|
author = Factory.create(:author)
|
||||||
end
|
Author.all.count.should == 1
|
||||||
|
q = Request.send :class_variable_get, :@@queue
|
||||||
it 'should be able to update their profile and send it to their friends' do
|
q.stub!(:add_hub_unsubscribe_request)
|
||||||
Factory.create(:person)
|
q.should_receive(:add_hub_unsubscribe_request)
|
||||||
p = {:profile => {:first_name => 'bob', :last_name => 'billytown', :image_url => "http://clowntown.com"}}
|
|
||||||
|
@user.unsubscribe_from_pubsub(author.id)
|
||||||
|
Author.all.count.should == 0
|
||||||
|
end
|
||||||
|
|
||||||
@user = Factory.create(:user)
|
it 'should be able to update their profile and send it to their friends' do
|
||||||
p = {:profile => {:first_name => 'bob', :last_name => 'billytown', :image_url => "http://clown.com"}}
|
Factory.create(:person)
|
||||||
|
|
||||||
n = Profile.send :class_variable_get, :@@queue
|
updated_profile = {:profile => {:first_name => 'bob', :last_name => 'billytown', :image_url => "http://clown.com"}}
|
||||||
n.should_receive(:process)
|
|
||||||
|
queue = Profile.send :class_variable_get, :@@queue
|
||||||
|
queue.should_receive(:process)
|
||||||
@user.update_profile(p).should == true
|
|
||||||
|
@user.update_profile(updated_profile).should == true
|
||||||
@user.profile.image_url.should == "http://clown.com"
|
@user.profile.image_url.should == "http://clown.com"
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue