diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 5c2bfe753..6361e11c2 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -17,8 +17,8 @@ class ApplicationController < ActionController::Base def set_friends_and_status if current_user - @group = :all - @groups = current_user.groups + @aspect = :all + @aspects = current_user.aspects @friends = current_user.friends end end diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb new file mode 100644 index 000000000..951dcdb1a --- /dev/null +++ b/app/controllers/aspects_controller.rb @@ -0,0 +1,70 @@ +class AspectsController < ApplicationController + before_filter :authenticate_user! + + respond_to :html + respond_to :json, :only => :show + + def index + @posts = current_user.visible_posts(:by_members_of => :all).paginate :page => params[:page], :per_page => 15, :order => 'created_at DESC' + @aspect = :all + end + + def create + @aspect = current_user.aspect params[:aspect] + respond_with @aspect + end + + def new + @aspect = Aspect.new + end + + def destroy + @aspect = Aspect.find_by_id params[:id] + @aspect.destroy + respond_with :location => aspects_url + end + + def show + @aspect = Aspect.find_by_id params[:id] + @friends = @aspect.people + @posts = current_user.visible_posts( :by_members_of => @aspect ).paginate :per_page => 15, :order => 'created_at DESC' + + respond_with @aspect + end + + def edit + @aspects = current_user.aspects + @remote_requests = Request.for_user current_user + end + + def update + @aspect = Aspect.find_by_id(params[:id]) + @aspect.update_attributes(params[:aspect]) + respond_with @aspect + end + + def move_friends + params[:moves].each{ |move| + move = move[1] + unless current_user.move_friend(move) + flash[:error] = "Aspect editing failed for friend #{Person.find_by_id( move[:friend_id] ).real_name}." + redirect_to Aspect.first, :action => "edit" + return + end + } + + flash[:notice] = "Aspects edited successfully." + redirect_to Aspect.first, :action => "edit" + end + + def move_friend + unless current_user.move_friend( :friend_id => params[:friend_id], :from => params[:from], :to => params[:to][:to]) + flash[:error] = "didn't work #{params.inspect}" + end + if aspect = Aspect.first(:id => params[:to][:to]) + redirect_to aspect + else + redirect_to Person.first(:id => params[:friend_id]) + end + end +end diff --git a/app/controllers/dev_utilities_controller.rb b/app/controllers/dev_utilities_controller.rb index cba9368a0..78fdc14c7 100644 --- a/app/controllers/dev_utilities_controller.rb +++ b/app/controllers/dev_utilities_controller.rb @@ -30,8 +30,8 @@ def warzombie backer_email = "#{backer['username']}@#{backer['username']}.joindiaspora.com" rel_hash = relationship_flow(backer_email) logger.info "Zombefriending #{backer['given_name']} #{backer['family_name']}" - logger.info "Calling send_friend_request with #{rel_hash[:friend]} and #{current_user.groups.first}" - current_user.send_friend_request_to(rel_hash[:friend], current_user.groups.first) + logger.info "Calling send_friend_request with #{rel_hash[:friend]} and #{current_user.aspects.first}" + current_user.send_friend_request_to(rel_hash[:friend], current_user.aspects.first) end end end @@ -39,7 +39,7 @@ def warzombie def zombiefriendaccept render :nothing => true Request.all.each{|r| - current_user.accept_and_respond(r.id, current_user.groups.first.id) + current_user.accept_and_respond(r.id, current_user.aspects.first.id) } end diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb deleted file mode 100644 index 1e47b7a8b..000000000 --- a/app/controllers/groups_controller.rb +++ /dev/null @@ -1,70 +0,0 @@ -class GroupsController < ApplicationController - before_filter :authenticate_user! - - respond_to :html - respond_to :json, :only => :show - - def index - @posts = current_user.visible_posts(:by_members_of => :all).paginate :page => params[:page], :per_page => 15, :order => 'created_at DESC' - @group = :all - end - - def create - @group = current_user.group params[:group] - respond_with @group - end - - def new - @group = Group.new - end - - def destroy - @group = Group.find_by_id params[:id] - @group.destroy - respond_with :location => groups_url - end - - def show - @group = Group.find_by_id params[:id] - @friends = @group.people - @posts = current_user.visible_posts( :by_members_of => @group ).paginate :per_page => 15, :order => 'created_at DESC' - - respond_with @group - end - - def edit - @groups = current_user.groups - @remote_requests = Request.for_user current_user - end - - def update - @group = Group.find_by_id(params[:id]) - @group.update_attributes(params[:group]) - respond_with @group - end - - def move_friends - params[:moves].each{ |move| - move = move[1] - unless current_user.move_friend(move) - flash[:error] = "Group editing failed for friend #{Person.find_by_id( move[:friend_id] ).real_name}." - redirect_to Group.first, :action => "edit" - return - end - } - - flash[:notice] = "Groups edited successfully." - redirect_to Group.first, :action => "edit" - end - - def move_friend - unless current_user.move_friend( :friend_id => params[:friend_id], :from => params[:from], :to => params[:to][:to]) - flash[:error] = "didn't work #{params.inspect}" - end - if group = Group.first(:id => params[:to][:to]) - redirect_to group - else - redirect_to Person.first(:id => params[:friend_id]) - end - end -end diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index d4dea8a80..1a9012589 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -5,7 +5,7 @@ class PeopleController < ApplicationController respond_to :json, :only => [:index, :show] def index - @groups_dropdown_array = current_user.groups.collect{|x| [x.to_s, x.id]} + @aspects_dropdown_array = current_user.aspects.collect{|x| [x.to_s, x.id]} @people = Person.search params[:q] respond_with @people end @@ -13,8 +13,8 @@ class PeopleController < ApplicationController def show @person = current_user.visible_person_by_id(params[:id]) @profile = @person.profile - @groups_with_person = current_user.groups_with_person(@person) - @groups_dropdown_array = current_user.groups.collect{|x| [x.to_s, x.id]} + @aspects_with_person = current_user.aspects_with_person(@person) + @aspects_dropdown_array = current_user.aspects.collect{|x| [x.to_s, x.id]} @posts = current_user.visible_posts_from_others(:from => @person).paginate :page => params[:page], :order => 'created_at DESC' @latest_status_message = current_user.raw_visible_posts.find_all_by__type_and_person_id("StatusMessage", params[:id]).last @post_count = @posts.count diff --git a/app/controllers/requests_controller.rb b/app/controllers/requests_controller.rb index 59e58ba3c..97be87a3f 100644 --- a/app/controllers/requests_controller.rb +++ b/app/controllers/requests_controller.rb @@ -14,12 +14,12 @@ class RequestsController < ApplicationController def destroy if params[:accept] - if params[:group_id] - @friend = current_user.accept_and_respond( params[:id], params[:group_id]) + if params[:aspect_id] + @friend = current_user.accept_and_respond( params[:id], params[:aspect_id]) flash[:notice] = "you are now friends" - respond_with :location => current_user.group_by_id(params[:group_id]) + respond_with :location => current_user.aspect_by_id(params[:aspect_id]) else - flash[:error] = "please select a group!" + flash[:error] = "please select a aspect!" respond_with :location => requests_url end else @@ -33,32 +33,32 @@ class RequestsController < ApplicationController end def create - group = current_user.group_by_id(params[:request][:group_id]) + aspect = current_user.aspect_by_id(params[:request][:aspect_id]) begin rel_hash = relationship_flow(params[:request][:destination_url]) rescue Exception => e - respond_with :location => group, :error => "No diaspora seed found with this email!" + respond_with :location => aspect, :error => "No diaspora seed found with this email!" return end Rails.logger.debug("Sending request: #{rel_hash}") begin - @request = current_user.send_friend_request_to(rel_hash[:friend], group) + @request = current_user.send_friend_request_to(rel_hash[:friend], aspect) rescue Exception => e raise e unless e.message.include? "already friends" message = "You are already friends with #{params[:request][:destination_url]}!" - respond_with :location => group, :notice => message + respond_with :location => aspect, :notice => message return end if @request message = "A friend request was sent to #{@request.destination_url}." - respond_with :location => group, :notice => message + respond_with :location => aspect, :notice => message else message = "Something went horribly wrong." - respond_with :location => group, :error => message + respond_with :location => aspect, :error => message end end diff --git a/app/controllers/status_messages_controller.rb b/app/controllers/status_messages_controller.rb index 5b7ac3e6e..8643183c8 100644 --- a/app/controllers/status_messages_controller.rb +++ b/app/controllers/status_messages_controller.rb @@ -5,7 +5,7 @@ class StatusMessagesController < ApplicationController respond_to :json, :only => :show def create - params[:status_message][:to] = params[:group_ids] + params[:status_message][:to] = params[:aspect_ids] @status_message = current_user.post(:status_message, params[:status_message]) respond_with @status_message end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index d8b4a05aa..61b33dbd8 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,7 +1,7 @@ module ApplicationHelper - def current_group?(group) - @group != :all && @group.id == group.id + def current_aspect?(aspect) + @aspect != :all && @aspect.id == aspect.id end def object_path(object) diff --git a/app/helpers/aspects_helper.rb b/app/helpers/aspects_helper.rb new file mode 100644 index 000000000..b6764f44d --- /dev/null +++ b/app/helpers/aspects_helper.rb @@ -0,0 +1,5 @@ +module AspectsHelper + def link_for_aspect( aspect ) + link_to aspect.name, aspect + end +end diff --git a/app/helpers/groups_helper.rb b/app/helpers/groups_helper.rb deleted file mode 100644 index 2d9724914..000000000 --- a/app/helpers/groups_helper.rb +++ /dev/null @@ -1,5 +0,0 @@ -module GroupsHelper - def link_for_group( group ) - link_to group.name, group - end -end diff --git a/app/models/group.rb b/app/models/aspect.rb similarity index 95% rename from app/models/group.rb rename to app/models/aspect.rb index 385d1a5a2..7271327b1 100644 --- a/app/models/group.rb +++ b/app/models/aspect.rb @@ -1,4 +1,4 @@ -class Group +class Aspect include MongoMapper::Document key :name, String @@ -27,7 +27,7 @@ class Group def as_json(opts = {}) { - :group => { + :aspect => { :name => self.name, :people => self.people.each{|person| person.as_json}, :posts => self.posts.each {|post| post.as_json }, diff --git a/app/models/request.rb b/app/models/request.rb index a4466ad52..b92357d69 100644 --- a/app/models/request.rb +++ b/app/models/request.rb @@ -11,7 +11,7 @@ class Request xml_accessor :exported_key, :cdata => true key :person_id, ObjectId - key :group_id, ObjectId + key :aspect_id, ObjectId key :destination_url, String key :callback_url, String key :exported_key, String @@ -30,7 +30,7 @@ class Request :callback_url => person.receive_url, :person => person, :exported_key => person.exported_key, - :group_id => options[:into]) + :aspect_id => options[:into]) end def reverse_for accepting_user diff --git a/app/models/user.rb b/app/models/user.rb index 71f23efee..449c99745 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -25,7 +25,7 @@ class User many :pending_requests, :in => :pending_request_ids, :class_name => 'Request' many :raw_visible_posts, :in => :visible_post_ids, :class_name => 'Post' - many :groups, :class_name => 'Group' + many :aspects, :class_name => 'Aspect' before_validation_on_create :setup_person before_validation :do_bad_things @@ -49,26 +49,26 @@ class User "#{person.profile.first_name.to_s} #{person.profile.last_name.to_s}" end - ######### Groups ###################### - def group( opts = {} ) + ######### Aspects ###################### + def aspect( opts = {} ) opts[:user] = self - Group.create(opts) + Aspect.create(opts) end def move_friend( opts = {}) return true if opts[:to] == opts[:from] friend = Person.first(:_id => opts[:friend_id]) if self.friend_ids.include?(friend.id) - from_group = self.group_by_id(opts[:from]) - to_group = self.group_by_id(opts[:to]) - if from_group && to_group - posts_to_move = from_group.posts.find_all_by_person_id(friend.id) - to_group.people << friend - to_group.posts << posts_to_move - from_group.person_ids.delete(friend.id.to_id) - posts_to_move.each{ |x| from_group.post_ids.delete(x.id)} - from_group.save - to_group.save + from_aspect = self.aspect_by_id(opts[:from]) + to_aspect = self.aspect_by_id(opts[:to]) + if from_aspect && to_aspect + posts_to_move = from_aspect.posts.find_all_by_person_id(friend.id) + to_aspect.people << friend + to_aspect.posts << posts_to_move + from_aspect.person_ids.delete(friend.id.to_id) + posts_to_move.each{ |x| from_aspect.post_ids.delete(x.id)} + from_aspect.save + to_aspect.save return true end end @@ -80,19 +80,19 @@ class User if class_name == :photo raise ArgumentError.new("No album_id given") unless options[:album_id] - group_ids = groups_with_post( options[:album_id] ) - group_ids.map!{ |group| group.id } + aspect_ids = aspects_with_post( options[:album_id] ) + aspect_ids.map!{ |aspect| aspect.id } else - group_ids = options.delete(:to) + aspect_ids = options.delete(:to) end - group_ids = [group_ids.to_s] if group_ids.is_a? BSON::ObjectId - raise ArgumentError.new("You must post to someone.") if group_ids.nil? || group_ids.empty? + aspect_ids = [aspect_ids.to_s] if aspect_ids.is_a? BSON::ObjectId + raise ArgumentError.new("You must post to someone.") if aspect_ids.nil? || aspect_ids.empty? post = build_post(class_name, options) - post.socket_to_uid(id, :group_ids => group_ids) if post.respond_to?(:socket_to_uid) - push_to_groups(post, group_ids) + post.socket_to_uid(id, :aspect_ids => aspect_ids) if post.respond_to?(:socket_to_uid) + push_to_aspects(post, aspect_ids) post end @@ -107,21 +107,21 @@ class User post end - def push_to_groups( post, group_ids ) - if group_ids == :all || group_ids == "all" - groups = self.groups - elsif group_ids.is_a?(Array) && group_ids.first.class == Group - groups = group_ids + def push_to_aspects( post, aspect_ids ) + if aspect_ids == :all || aspect_ids == "all" + aspects = self.aspects + elsif aspect_ids.is_a?(Array) && aspect_ids.first.class == Aspect + aspects = aspect_ids else - groups = self.groups.find_all_by_id( group_ids ) + aspects = self.aspects.find_all_by_id( aspect_ids ) end - #send to the groups + #send to the aspects target_people = [] - groups.each{ |group| - group.posts << post - group.save - target_people = target_people | group.people + aspects.each{ |aspect| + aspect.posts << post + aspect.save + target_people = target_people | aspect.people } push_to_people(post, target_people) end @@ -171,7 +171,7 @@ class User if owns? comment.post comment.post_creator_signature = comment.sign_with_key(encryption_key) comment.save - push_to_people comment, people_in_groups(groups_with_post(comment.post.id)) + push_to_people comment, people_in_aspects(aspects_with_post(comment.post.id)) elsif owns? comment comment.save salmon comment, :to => comment.post.person @@ -180,12 +180,12 @@ class User ######### Posts and Such ############### def retract( post ) - group_ids = groups_with_post( post.id ) - group_ids.map!{|group| group.id.to_s} + aspect_ids = aspects_with_post( post.id ) + aspect_ids.map!{|aspect| aspect.id.to_s} - post.unsocket_from_uid(self.id, :group_ids => group_ids) if post.respond_to? :unsocket_from_uid + post.unsocket_from_uid(self.id, :aspect_ids => aspect_ids) if post.respond_to? :unsocket_from_uid retraction = Retraction.for(post) - push_to_people retraction, people_in_groups(groups_with_post(post.id)) + push_to_people retraction, people_in_aspects(aspects_with_post(post.id)) retraction end @@ -194,7 +194,7 @@ class User params[:profile].delete(:image_url) if params[:profile][:image_url].empty? if self.person.update_attributes(params) - push_to_groups profile, :all + push_to_aspects profile, :all true else false @@ -225,9 +225,9 @@ class User else object.perform self.id - groups = self.groups_with_person(object.person) - groups.each{ |group| group.post_ids.delete(object.post_id.to_id) - group.save + aspects = self.aspects_with_person(object.person) + aspects.each{ |aspect| aspect.post_ids.delete(object.post_id.to_id) + aspect.save } end elsif object.is_a? Request @@ -236,7 +236,7 @@ class User object.person = person object.person.save old_request = Request.first(:id => object.id) - object.group_id = old_request.group_id if old_request + object.aspect_id = old_request.aspect_id if old_request object.save receive_friend_request(object) elsif object.is_a? Profile @@ -265,11 +265,11 @@ class User self.raw_visible_posts << object self.save - groups = self.groups_with_person(object.person) - groups.each{ |group| - group.posts << object - group.save - object.socket_to_uid(id, :group_ids => [group.id]) if (object.respond_to?(:socket_to_uid) && !self.owns?(object)) + aspects = self.aspects_with_person(object.person) + aspects.each{ |aspect| + aspect.posts << object + aspect.save + object.socket_to_uid(id, :aspect_ids => [aspect.id]) if (object.respond_to?(:socket_to_uid) && !self.owns?(object)) } end @@ -310,7 +310,7 @@ class User :user => { :posts => self.raw_visible_posts.each{|post| post.as_json}, :friends => self.friends.each {|friend| friend.as_json}, - :groups => self.groups.each {|group| group.as_json}, + :aspects => self.aspects.each {|aspect| aspect.as_json}, :pending_requests => self.pending_requests.each{|request| request.as_json}, } } diff --git a/app/views/albums/index.html.haml b/app/views/albums/index.html.haml index 2be4bace9..f3f0c9b44 100644 --- a/app/views/albums/index.html.haml +++ b/app/views/albums/index.html.haml @@ -8,7 +8,7 @@ = link_to "Albums", albums_path - content_for :left_pane do - = render "shared/group_friends" + = render "shared/aspect_friends" %h1.big_text Albums diff --git a/app/views/albums/show.html.haml b/app/views/albums/show.html.haml index 3d24b1c09..0bc2dc094 100644 --- a/app/views/albums/show.html.haml +++ b/app/views/albums/show.html.haml @@ -9,7 +9,7 @@ = link_to @album.name, @album - content_for :left_pane do - = render "shared/group_friends" + = render "shared/aspect_friends" .album_id{:id => @album.id, :style => "display:hidden;"} diff --git a/app/views/groups/_new_group.haml b/app/views/aspects/_new_aspect.haml similarity index 69% rename from app/views/groups/_new_group.haml rename to app/views/aspects/_new_aspect.haml index 5ac136eae..1533d4f5d 100644 --- a/app/views/groups/_new_group.haml +++ b/app/views/aspects/_new_aspect.haml @@ -1,5 +1,5 @@ -%h1 Add a new group -= form_for Group.new do |f| +%h1 Add a new aspect += form_for Aspect.new do |f| = f.error_messages %p = f.label :name diff --git a/app/views/groups/edit.html.haml b/app/views/aspects/edit.html.haml similarity index 60% rename from app/views/groups/edit.html.haml rename to app/views/aspects/edit.html.haml index fd251e6ef..91ab0149f 100644 --- a/app/views/groups/edit.html.haml +++ b/app/views/aspects/edit.html.haml @@ -1,6 +1,6 @@ - content_for :head do = javascript_include_tag 'jquery-ui-1.8.4.custom.min.js' - = javascript_include_tag 'group-edit.js' + = javascript_include_tag 'aspect-edit.js' - content_for :left_pane do %h1 @@ -21,29 +21,29 @@ %ul -%h1{:id => 'group_title'} - Relations +%h1{:id => 'aspect_title'} + Aspects -%ul#group_list +%ul#aspect_list -- for group in @groups +- for aspect in @aspects - %li.group - %h3{:contenteditable => true}= group.name + %li.aspect + %h3{:contenteditable => true}= aspect.name - %ul{:id => group.id} - -if group.people.size < 1 + %ul{:id => aspect.id} + -if aspect.people.size < 1 %li.grey Drag to add people -else - -for person in group.people + -for person in aspect.people - %li.person{:id => person.id, :from_group_id => group.id} + %li.person{:id => person.id, :from_aspect_id => aspect.id} = person_image_tag(person) .name = person.real_name %p %br - = link_to 'Update Groups', '#', :class => 'button', :id => "move_friends_link" + = link_to 'Update Aspects', '#', :class => 'button', :id => "move_friends_link" #content_bottom diff --git a/app/views/groups/index.html.haml b/app/views/aspects/index.html.haml similarity index 85% rename from app/views/groups/index.html.haml rename to app/views/aspects/index.html.haml index d41f596e1..aea12cfe5 100644 --- a/app/views/groups/index.html.haml +++ b/app/views/aspects/index.html.haml @@ -2,7 +2,7 @@ Home - content_for :left_pane do - = render "shared/group_friends" + = render "shared/aspect_friends" %ul#stream - for post in @posts diff --git a/app/views/aspects/new.html.haml b/app/views/aspects/new.html.haml new file mode 100644 index 000000000..423725d9f --- /dev/null +++ b/app/views/aspects/new.html.haml @@ -0,0 +1,14 @@ +%h1.big_text + =link_to 'aspects', aspects_path + >> + new aspect + += form_for @aspect do |f| + = f.error_messages + %p + = f.label :name + = f.text_field :name + %p + = f.submit + +%p= link_to "Back to List", aspects_path diff --git a/app/views/groups/show.html.haml b/app/views/aspects/show.html.haml similarity index 84% rename from app/views/groups/show.html.haml rename to app/views/aspects/show.html.haml index 4163d118d..5925354f0 100644 --- a/app/views/groups/show.html.haml +++ b/app/views/aspects/show.html.haml @@ -2,7 +2,7 @@ Home - content_for :left_pane do - = render "shared/group_friends" + = render "shared/aspect_friends" %ul#stream - for post in @posts diff --git a/app/views/groups/new.html.haml b/app/views/groups/new.html.haml deleted file mode 100644 index c899fd9ae..000000000 --- a/app/views/groups/new.html.haml +++ /dev/null @@ -1,14 +0,0 @@ -%h1.big_text - =link_to 'groups', groups_path - >> - new group - -= form_for @group do |f| - = f.error_messages - %p - = f.label :name - = f.text_field :name - %p - = f.submit - -%p= link_to "Back to List", groups_path diff --git a/app/views/js/_websocket_js.haml b/app/views/js/_websocket_js.haml index 05f7dce40..9e87800c9 100644 --- a/app/views/js/_websocket_js.haml +++ b/app/views/js/_websocket_js.haml @@ -10,7 +10,7 @@ ws.onmessage = function(evt) { var obj = jQuery.parseJSON(evt.data); //console.log(obj); - debug("got a " + obj['class'] + " for groups " + obj['group_ids']); + debug("got a " + obj['class'] + " for aspects " + obj['aspect_ids']); if (obj['class']=="retractions"){ processRetraction(obj['post_id']); @@ -21,7 +21,7 @@ }else if (obj['class']=='photos' && onPageForClass('albums')){ processPhotoInAlbum(obj['photo_hash']) }else{ - processPost(obj['class'], obj['html'], obj['group_ids']) + processPost(obj['class'], obj['html'], obj['aspect_ids']) } @@ -55,8 +55,8 @@ } } - function processPost(className, html, groupIds){ - if(onPageForGroups(groupIds)){ + function processPost(className, html, aspectIds){ + if(onPageForAspects(aspectIds)){ $("#stream").prepend( $(html).fadeIn("fast", function(){ $("#stream label:first").inFieldLabels(); @@ -83,19 +83,19 @@ return (location.href.indexOf(className) != -1 ); } - function onPageForGroups(groupIds){ + function onPageForAspects(aspectIds){ if(location.pathname == '/' && onPageOne()){ return true } var found = false; - $.each(groupIds, function(index, value) { - if(onPageForGroup(value)){ found = true }; + $.each(aspectIds, function(index, value) { + if(onPageForAspect(value)){ found = true }; }); return found; } - function onPageForGroup(groupId){ - return (location.href.indexOf(groupId) != -1 ) + function onPageForAspect(aspectId){ + return (location.href.indexOf(aspectId) != -1 ) } function onPageOne() { diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 3e3a37ecd..5fe36a67a 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -19,7 +19,7 @@ = javascript_include_tag 'fancybox/jquery.fancybox-1.3.1.pack' = javascript_include_tag 'fileuploader' - = javascript_include_tag 'view', 'image_picker', 'group_nav', 'stream' + = javascript_include_tag 'view', 'image_picker', 'aspect_nav', 'stream' = render 'js/websocket_js' = csrf_meta_tag @@ -51,27 +51,27 @@ %li= link_to "edit profile", edit_user_path(current_user) %li= link_to "logout", destroy_user_session_path - = render "shared/group_nav" + = render "shared/aspect_nav" - #group_header + #aspect_header .container .span-5.last - if @person %h1 = @person.real_name - else - - if @group == :all + - if @aspect == :all %h1 - = link_to "All Relations", root_path + = link_to "All Aspects", root_path - else %h1 - = link_to @group.name, @group + = link_to @aspect.name, @aspect .page_title = yield :page_title .span-19.last - = render "shared/publisher", :group_ids => :all + = render "shared/publisher", :aspect_ids => :all .container .span-5.last diff --git a/app/views/people/index.html.haml b/app/views/people/index.html.haml index 2b89fb17d..423814349 100644 --- a/app/views/people/index.html.haml +++ b/app/views/people/index.html.haml @@ -41,6 +41,6 @@ %td %td = form_for Request.new do |f| - = f.select(:group_id, @groups_dropdown_array) + = f.select(:aspect_id, @aspects_dropdown_array) = f.hidden_field :destination_url, :value => person.email = f.submit "add friend" diff --git a/app/views/people/show.html.haml b/app/views/people/show.html.haml index acd52eef3..e9c445299 100644 --- a/app/views/people/show.html.haml +++ b/app/views/people/show.html.haml @@ -14,8 +14,8 @@ %i= "friends since: #{how_long_ago(@person)}" %li = form_tag move_friend_path - = select :to, :to, @groups_dropdown_array, :selected => @groups_with_person.first.id - = hidden_field_tag :from, :from, :value => @groups_with_person.first.id + = select :to, :to, @aspects_dropdown_array, :selected => @aspects_with_person.first.id + = hidden_field_tag :from, :from, :value => @aspects_with_person.first.id = hidden_field_tag :friend_id, :friend_id, :value => @person.id = submit_tag "save" diff --git a/app/views/photos/show.html.haml b/app/views/photos/show.html.haml index d582bc095..cbe3505f9 100644 --- a/app/views/photos/show.html.haml +++ b/app/views/photos/show.html.haml @@ -14,7 +14,7 @@ = link_to "Photo", @photo - content_for :left_pane do - = render "shared/group_friends" + = render "shared/aspect_friends" %h1.big_text diff --git a/app/views/requests/_new_request.haml b/app/views/requests/_new_request.haml index 87b9776b8..5f4391f51 100644 --- a/app/views/requests/_new_request.haml +++ b/app/views/requests/_new_request.haml @@ -1,6 +1,6 @@ %h1 Add a new friend to - %i= @group.name + %i= @aspect.name = form_for Request.new do |f| = f.error_messages @@ -12,6 +12,6 @@ %p = f.label :destination_url, "Friend's username" = f.text_field :destination_url - = f.hidden_field :group_id, :value => @group.id + = f.hidden_field :aspect_id, :value => @aspect.id = f.submit diff --git a/app/views/requests/_request.html.haml b/app/views/requests/_request.html.haml index 3cd2c398f..ff1ca8da4 100644 --- a/app/views/requests/_request.html.haml +++ b/app/views/requests/_request.html.haml @@ -1,8 +1,8 @@ :javascript $(document).ready(function(){ - $(".group_selector").change( function() { + $(".aspect_selector").change( function() { var id = $(this).children(":selected").val(); - $(this).parent().children(".accept").html( "Accept"); + $(this).parent().children(".accept").html( "Accept"); }); }); @@ -13,11 +13,11 @@ = link_to "#{request.person.real_name}", '#' %ul.request_buttons - %select{ :class => "group_selector", :style=>"display:inline;"} - %option Add to group + %select{ :class => "aspect_selector", :style=>"display:inline;"} + %option Add to aspect %option - - for group in current_user.groups - %option{:value => group.id}= group.name + - for aspect in current_user.aspects + %option{:value => aspect.id}= aspect.name %li.accept= link_to 'Accept', request_path(request, :accept => true), :method => :delete, :class => "button" %li.ignore= link_to 'Ignore', request_path(request), :confirm => 'Are you sure?', :method => :delete, :class => "button" diff --git a/app/views/shared/_group_friends.haml b/app/views/shared/_aspect_friends.haml similarity index 92% rename from app/views/shared/_group_friends.haml rename to app/views/shared/_aspect_friends.haml index 206d588c1..0a79085f9 100644 --- a/app/views/shared/_group_friends.haml +++ b/app/views/shared/_aspect_friends.haml @@ -2,7 +2,7 @@ - for friend in @friends = person_image_link(friend) - - unless @group == :all + - unless @aspect == :all = link_to (image_tag('add_friend_button.png', :height => "50px", :width => "50px")), "#add_request_pane", :id => 'add_request_button' .yo{:style => 'display:none'} diff --git a/app/views/shared/_aspect_nav.haml b/app/views/shared/_aspect_nav.haml new file mode 100644 index 000000000..257a1d1c9 --- /dev/null +++ b/app/views/shared/_aspect_nav.haml @@ -0,0 +1,21 @@ +#aspect_nav + %ul + - for aspect in @aspects + %li{:id => aspect.id, :class => ("selected" if current_aspect?(aspect))} + = link_for_aspect aspect + + %li.new_aspect= link_to("+", "#add_aspect_pane", :id => "add_aspect_button", :title => "Add a new relation") + + #aspect_manage_button + + %ul{ :style => "position:absolute;right:0;bottom:0;"} + %li{:class => ("selected" if @aspect == :all)} + = link_to "All Aspects", root_url + + %li{ :style => "margin-right:0;" } + = link_to "manage", edit_aspect_path(Aspect.first), :class => "edit_aspect_button", :title => "Manage your Aspects" + + .yo{ :style => "display:none;"} + #add_aspect_pane + = render "aspects/new_aspect" + diff --git a/app/views/shared/_group_nav.haml b/app/views/shared/_group_nav.haml deleted file mode 100644 index dbf531eb0..000000000 --- a/app/views/shared/_group_nav.haml +++ /dev/null @@ -1,20 +0,0 @@ -#group_nav - %ul - - for group in @groups - %li{:id => group.id, :class => ("selected" if current_group?(group))} - = link_for_group group - - %li.new_group= link_to("+", "#add_group_pane", :id => "add_group_button", :title => "Add a new relation") - - #group_manage_button - - %ul{ :style => "position:absolute;right:0;bottom:0;"} - %li{:class => ("selected" if @group == :all)} - = link_to "All Relations", root_url - %li{ :style => "margin-right:0;" } - = link_to "manage", edit_group_path(Group.first), :class => "edit_group_button", :title => "Manage your relations" - - .yo{ :style => "display:none;"} - #add_group_pane - = render "groups/new_group" - diff --git a/app/views/shared/_publisher.haml b/app/views/shared/_publisher.haml index 5fae9abff..584f30ebe 100644 --- a/app/views/shared/_publisher.haml +++ b/app/views/shared/_publisher.haml @@ -7,11 +7,11 @@ %label{:for => "status_message_message"} Message = f.text_area :message, :rows => 2 - %ul.group_selector{ :style => "display:none;"} + %ul.aspect_selector{ :style => "display:none;"} going to... - - for group in @groups + - for aspect in @aspects %li - = check_box_tag("group_ids[]", group.id, @group == :all || current_group?(group) ) - = group.name + = check_box_tag("aspect_ids[]", aspect.id, @aspect == :all || current_aspect?(aspect) ) + = aspect.name = f.submit "Share" diff --git a/config/routes.rb b/config/routes.rb index 43149ba57..110644b27 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -7,9 +7,9 @@ Diaspora::Application.routes.draw do resources :photos, :except => [:index] resources :albums - resources :groups - match 'groups/move_friends', :to => 'groups#move_friends', :as => 'move_friends' - match 'groups/move_friend', :to => 'groups#move_friend', :as => 'move_friend' + resources :aspects + match 'aspects/move_friends', :to => 'aspects#move_friends', :as => 'move_friends' + match 'aspects/move_friend', :to => 'aspects#move_friend', :as => 'move_friend' match 'warzombie', :to => "dev_utilities#warzombie" match 'zombiefriends', :to => "dev_utilities#zombiefriends" @@ -34,5 +34,5 @@ Diaspora::Application.routes.draw do match 'log', :to => "dev_utilities#log" #root - root :to => 'groups#index' + root :to => 'aspects#index' end diff --git a/db/seeds/backer.rb b/db/seeds/backer.rb index e4635b339..139ca5fa2 100644 --- a/db/seeds/backer.rb +++ b/db/seeds/backer.rb @@ -26,6 +26,6 @@ def create ) user.person.save - user.group(:name => "Presidents") + user.aspect(:name => "Presidents") end diff --git a/db/seeds/dev.rb b/db/seeds/dev.rb index 92653b8d9..2dc820394 100644 --- a/db/seeds/dev.rb +++ b/db/seeds/dev.rb @@ -24,7 +24,7 @@ user2 = User.instantiate!( :email => "korth@tom.joindiaspora.com", user2.person.save! # friending users -group = user.group(:name => "other dudes") -request = user.send_friend_request_to(user2, group) -reversed_request = user2.accept_friend_request( request.id, user2.group(:name => "presidents").id ) +aspect = user.aspect(:name => "other dudes") +request = user.send_friend_request_to(user2, aspect) +reversed_request = user2.accept_friend_request( request.id, user2.aspect(:name => "presidents").id ) user.receive reversed_request.to_diaspora_xml diff --git a/db/seeds/tom.rb b/db/seeds/tom.rb index 7a4a52f3a..9bff57251 100644 --- a/db/seeds/tom.rb +++ b/db/seeds/tom.rb @@ -25,8 +25,8 @@ user2 = User.instantiate!( :email => "korth@tom.joindiaspora.com", user2.person.save! # friending users -group = user.group(:name => "other dudes") -request = user.send_friend_request_to(user2, group) -reversed_request = user2.accept_friend_request( request.id, user2.group(:name => "presidents").id ) +aspect = user.aspect(:name => "other dudes") +request = user.send_friend_request_to(user2, aspect) +reversed_request = user2.accept_friend_request( request.id, user2.aspect(:name => "presidents").id ) user.receive reversed_request.to_diaspora_xml -user.group(:name => "Presidents") +user.aspect(:name => "Presidents") diff --git a/lib/diaspora/user/friending.rb b/lib/diaspora/user/friending.rb index 0d8be0635..a32e1439c 100644 --- a/lib/diaspora/user/friending.rb +++ b/lib/diaspora/user/friending.rb @@ -1,19 +1,19 @@ module Diaspora module UserModules module Friending - def send_friend_request_to(desired_friend, group) + def send_friend_request_to(desired_friend, aspect) raise "You are already friends with that person!" if self.friends.detect{ |x| x.receive_url == desired_friend.receive_url} request = Request.instantiate( :to => desired_friend.receive_url, :from => self.person, - :into => group.id) + :into => aspect.id) if request.save self.pending_requests << request self.save - group.requests << request - group.save + aspect.requests << request + aspect.save salmon request, :to => desired_friend end @@ -21,11 +21,11 @@ module Diaspora end - def accept_friend_request(friend_request_id, group_id) + def accept_friend_request(friend_request_id, aspect_id) request = Request.find_by_id(friend_request_id) pending_requests.delete(request) - activate_friend(request.person, group_by_id(group_id)) + activate_friend(request.person, aspect_by_id(aspect_id)) request.reverse_for(self) request @@ -36,9 +36,9 @@ module Diaspora request.destroy unless request.callback_url.include? url end - def accept_and_respond(friend_request_id, group_id) + def accept_and_respond(friend_request_id, aspect_id) requester = Request.find_by_id(friend_request_id).person - reversed_request = accept_friend_request(friend_request_id, group_id) + reversed_request = accept_friend_request(friend_request_id, aspect_id) dispatch_friend_acceptance reversed_request, requester end @@ -59,8 +59,8 @@ module Diaspora Rails.logger.info("receiving friend request #{friend_request.to_json}") if request_from_me?(friend_request) - group = self.group_by_id(friend_request.group_id) - activate_friend(friend_request.person, group) + aspect = self.aspect_by_id(friend_request.aspect_id) + activate_friend(friend_request.person, aspect) Rails.logger.info("#{self.real_name}'s friend request has been accepted") @@ -85,7 +85,7 @@ module Diaspora def remove_friend(bad_friend) raise "Friend not deleted" unless self.friend_ids.delete( bad_friend.id ) - groups.each{|g| g.person_ids.delete( bad_friend.id )} + aspects.each{|g| g.person_ids.delete( bad_friend.id )} self.save self.raw_visible_posts.find_all_by_person_id( bad_friend.id ).each{|post| @@ -104,13 +104,13 @@ module Diaspora remove_friend bad_friend end - def activate_friend(person, group) + def activate_friend(person, aspect) person.user_refs += 1 - group.people << person + aspect.people << person friends << person save person.save - group.save + aspect.save end def request_from_me?(request) diff --git a/lib/diaspora/user/querying.rb b/lib/diaspora/user/querying.rb index ed2bcb115..50f7650fe 100644 --- a/lib/diaspora/user/querying.rb +++ b/lib/diaspora/user/querying.rb @@ -4,7 +4,7 @@ module Diaspora def visible_posts_from_others(opts ={}) if opts[:from].class == Person Post.where(:person_id => opts[:from].id, :_id.in => self.visible_post_ids) - elsif opts[:from].class == Group + elsif opts[:from].class == Aspect Post.where(:_id.in => opts[:from].post_ids) unless opts[:from].user != self else Post.where(:_id.in => self.visible_post_ids) @@ -14,8 +14,8 @@ module Diaspora def visible_posts( opts = {} ) if opts[:by_members_of] return raw_visible_posts if opts[:by_members_of] == :all - group = self.groups.find_by_id( opts[:by_members_of].id ) - group.posts + aspect = self.aspects.find_by_id( opts[:by_members_of].id ) + aspect.posts end end @@ -27,9 +27,9 @@ module Diaspora result end - def group_by_id( id ) + def aspect_by_id( id ) id = id.to_id - groups.detect{|x| x.id == id } + aspects.detect{|x| x.id == id } end def album_by_id( id ) @@ -37,25 +37,25 @@ module Diaspora albums.detect{|x| x.id == id } end - def groups_with_post( id ) - self.groups.find_all_by_post_ids( id.to_id ) + def aspects_with_post( id ) + self.aspects.find_all_by_post_ids( id.to_id ) end - def groups_with_person person + def aspects_with_person person id = person.id.to_id - groups.select { |g| g.person_ids.include? id} + aspects.select { |g| g.person_ids.include? id} end - def people_in_groups groups + def people_in_aspects aspects people = [] - groups.each{ |group| - people = people | group.people + aspects.each{ |aspect| + people = people | aspect.people } people end - def all_group_ids - self.groups.all.collect{|x| x.id} + def all_aspect_ids + self.aspects.all.collect{|x| x.id} end end end diff --git a/public/javascripts/group-edit.js b/public/javascripts/aspect-edit.js similarity index 72% rename from public/javascripts/group-edit.js rename to public/javascripts/aspect-edit.js index 434c671ac..a6b62b2a3 100644 --- a/public/javascripts/group-edit.js +++ b/public/javascripts/aspect-edit.js @@ -1,11 +1,11 @@ $('#move_friends_link').live( 'click', function(){ - $.post('/groups/move_friends', - { 'moves' : $('#group_list').data() }, - function(){ $('#group_title').html("Groups edited successfully!");}); + $.post('/aspects/move_friends', + { 'moves' : $('#aspect_list').data() }, + function(){ $('#aspect_title').html("Groups edited successfully!");}); $(".person").css('background-color','white'); - $('#group_list').removeData(); - $(".person").attr('from_group_id', function(){return $(this).parent().attr('id')}) + $('#aspect_list').removeData(); + $(".person").attr('from_aspect_id', function(){return $(this).parent().attr('id')}) }); @@ -18,26 +18,26 @@ $(function() { revert: true }); - $(".group ul").droppable({ + $(".aspect ul").droppable({ drop: function(event, ui) { if ($(ui.draggable[0]).hasClass('requested_person')){ $.ajax({ type: "DELETE", url: "/requests/" + ui.draggable[0].getAttribute('request_id') , - data: {"accept" : true , "group_id" : $(this)[0].id } + data: {"accept" : true , "aspect_id" : $(this)[0].id } }); alert("Sent the ajax, check it out!") }else { var move = {}; move[ 'friend_id' ] = ui.draggable[0].id move[ 'to' ] = $(this)[0].id; - move[ 'from' ] = ui.draggable[0].getAttribute('from_group_id'); + move[ 'from' ] = ui.draggable[0].getAttribute('from_aspect_id'); if (move['to'] == move['from']){ - $('#group_list').data( ui.draggable[0].id, []); + $('#aspect_list').data( ui.draggable[0].id, []); ui.draggable.css('background-color','white'); } else { - $('#group_list').data( ui.draggable[0].id, move); + $('#aspect_list').data( ui.draggable[0].id, move); ui.draggable.css('background-color','orange'); } $(this).closest("ul").append(ui.draggable); @@ -68,11 +68,11 @@ $(function() { }); }); -$(".group h3").live( 'click', function() { +$(".aspect h3").live( 'click', function() { var $this = $(this); var id = $this.closest("li").children("ul").attr("id"); - var link = "/groups/"+ id; + var link = "/aspects/"+ id; $this.keypress(function(e) { if (e.which == 13) { @@ -83,10 +83,10 @@ $(".group h3").live( 'click', function() { $.ajax({ type: "PUT", url: link, - data: {"group" : {"name" : $this.text() }} + data: {"aspect" : {"name" : $this.text() }} }); } - //update all other group links + //update all other aspect links $this.keyup(function(e) { $("a[href='"+link+"']").text($this.text()); }); diff --git a/public/javascripts/group_nav.js b/public/javascripts/aspect_nav.js similarity index 100% rename from public/javascripts/group_nav.js rename to public/javascripts/aspect_nav.js diff --git a/public/javascripts/view.js b/public/javascripts/view.js index 9881c9c57..b72a9fa72 100644 --- a/public/javascripts/view.js +++ b/public/javascripts/view.js @@ -16,7 +16,7 @@ $(document).ready(function(){ }); //buttons////// - $("#add_group_button").fancybox({ 'titleShow' : false }); + $("#add_aspect_button").fancybox({ 'titleShow' : false }); $("#add_request_button").fancybox({ 'titleShow': false }); $("input[type='submit']").addClass("button"); diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 79f7941aa..92c9c8408 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -117,20 +117,21 @@ header { margin-right: 1em; } header #session_action ul li:last-child { margin-right: 0; } - header #group_header { + header #aspect_header { + z-index: 5; text-shadow: 0 2px 0 white; background-color: #eeeeee; border-top: 1px solid #555555; height: 85px; } - header #group_header h1 { + header #aspect_header h1 { margin-bottom: 0; margin-top: 15px; } - header #group_header a { + header #aspect_header a { color: #111111; } - header #group_header a:hover { + header #aspect_header a:hover { background: none; color: #333333; } - header #group_header .page_title { + header #aspect_header .page_title { text-transform: uppercase; } ul#stream { @@ -443,33 +444,33 @@ h1.big_text { .image_cycle img { display: none; } -#group_nav { +#aspect_nav { z-index: 4; position: relative; color: black; margin-top: 8px; margin-bottom: 1px; } - #group_nav #group_manage_button { + #aspect_nav #aspect_manage_button { display: inline; } - #group_nav #group_manage_button a { + #aspect_nav #aspect_manage_button a { color: #999999; } - #group_nav ul { + #aspect_nav ul { margin: 0; padding: 0; list-style: none; } - #group_nav ul > li { + #aspect_nav ul > li { padding: 0; display: inline; margin-right: 0.5em; } - #group_nav ul > li a { + #aspect_nav ul > li a { background-color: #444444; border: 1px solid #555555; padding: 3px 8px; color: #999999; } - #group_nav ul > li a:hover { + #aspect_nav ul > li a:hover { background-color: #555555; color: #cccccc; } - #group_nav ul > li.selected a { + #aspect_nav ul > li.selected a { padding-top: 5px; padding-bottom: 3px; line-height: 18px; @@ -477,9 +478,9 @@ h1.big_text { background-color: #eeeeee; border-bottom: 1px solid #eeeeee; color: black; } - #group_nav ul > li.selected a:hover { + #aspect_nav ul > li.selected a:hover { background-color: #efefef; } - #group_nav ul > li.selected a a { + #aspect_nav ul > li.selected a a { color: black; } #global_search { @@ -489,31 +490,25 @@ h1.big_text { #global_search form { display: inline; } #global_search form input { - margin-top: 5px; display: inline; font-size: 12px; - border: none; - border-radius: 0; } + border: none; } #global_search form input[type='text'] { width: 200px; - padding: 2px; - background-image: url("/images/glyphish-icons/icons/06-magnifying-glass.png"); - background-repeat: no-repeat; - background-position: 187px; - background-size: 12px; } + padding: 2px; } #global_search form label { font-size: 12px; margin-top: -3px; } -.group, +.aspect, .requests, .remove { list-style: none; } - .group h3, + .aspect h3, .requests h3, .remove h3 { display: inline-block; } - .group ul, + .aspect ul, .requests ul, .remove ul { min-height: 20px; @@ -525,8 +520,8 @@ h1.big_text { border-radius: 3px; list-style: none; padding: 15px; } - .group .person, - .group .requested_person, + .aspect .person, + .aspect .requested_person, .requests .person, .requests .requested_person, .remove .person, @@ -543,8 +538,8 @@ h1.big_text { height: 75px; padding: 5px; border: 1px solid #999999; } - .group .person img, - .group .requested_person img, + .aspect .person img, + .aspect .requested_person img, .requests .person img, .requests .requested_person img, .remove .person img, @@ -552,8 +547,8 @@ h1.big_text { height: 50px; width: 50px; display: inline-block; } - .group .person .grey, - .group .requested_person .grey, + .aspect .person .grey, + .aspect .requested_person .grey, .requests .person .grey, .requests .requested_person .grey, .remove .person .grey, diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 3e1e23c15..445979917 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -140,7 +140,8 @@ header :margin :right 0 - #group_header + #aspect_header + :z-index 5 :text-shadow 0 2px 0 #fff :background :color #eee @@ -574,7 +575,7 @@ h1.big_text img :display none -#group_nav +#aspect_nav :z-index 4 :position relative :color #000 @@ -583,7 +584,7 @@ h1.big_text :bottom 1px - #group_manage_button + #aspect_manage_button :display inline a @@ -644,22 +645,14 @@ h1.big_text :display inline input - :margin - :top 5px :display inline :font :size 12px :border none - :border-radius 0 input[type='text'] :width 200px :padding 2px - :background - :image url('/images/glyphish-icons/icons/06-magnifying-glass.png') - :repeat no-repeat - :position 187px - :size 12px label :font @@ -667,7 +660,8 @@ h1.big_text :margin :top -3px -.group, + +.aspect, .requests, .remove :list diff --git a/public/stylesheets/sessions.css b/public/stylesheets/sessions.css index c480c899c..96c4bf30c 100644 --- a/public/stylesheets/sessions.css +++ b/public/stylesheets/sessions.css @@ -6,9 +6,11 @@ weight: normal; style: normal; } } +/* via blueprint */ html { font-size: 100.01%; } +/* via blueprint */ body { font-size: 75%; font-family: "Helvetica Neue", Arial, Helvetica, sans-serif; @@ -16,12 +18,14 @@ body { background: white; margin-left: 2em; } +/* via blueprint */ input[type=text], input[type=password], textarea, select { background-color: white; border: 1px solid #bbbbbb; } +/* via blueprint */ input[type=text]:focus, input[type=password]:focus, input.text:focus, diff --git a/spec/controllers/groups_controller_spec.rb b/spec/controllers/aspects_controller_spec.rb similarity index 86% rename from spec/controllers/groups_controller_spec.rb rename to spec/controllers/aspects_controller_spec.rb index 590739e6a..fffddd1fb 100644 --- a/spec/controllers/groups_controller_spec.rb +++ b/spec/controllers/aspects_controller_spec.rb @@ -1,10 +1,10 @@ require File.dirname(__FILE__) + '/../spec_helper' include ApplicationHelper -describe GroupsController do +describe AspectsController do render_views before do @user = Factory.create(:user) - @user.group(:name => "lame-os") + @user.aspect(:name => "lame-os") @person = Factory.create(:person) sign_in :user, @user end diff --git a/spec/controllers/people_controller_spec.rb b/spec/controllers/people_controller_spec.rb index 584d32f83..5eb052c23 100644 --- a/spec/controllers/people_controller_spec.rb +++ b/spec/controllers/people_controller_spec.rb @@ -6,7 +6,7 @@ describe PeopleController do @user = Factory.create(:user) sign_in :user, @user - @user.group(:name => "lame-os") + @user.aspect(:name => "lame-os") end it "index should yield search results for substring of person name" do diff --git a/spec/controllers/publics_controller_spec.rb b/spec/controllers/publics_controller_spec.rb index cc9f3064d..69c79bcb6 100644 --- a/spec/controllers/publics_controller_spec.rb +++ b/spec/controllers/publics_controller_spec.rb @@ -33,11 +33,11 @@ describe PublicsController do describe 'friend requests' do before do @user2 = Factory.create(:user) - group = @user2.group(:name => 'disciples') + aspect = @user2.aspect(:name => 'disciples') @user3 = Factory.create(:user) - req = @user2.send_friend_request_to(@user.person, group) + req = @user2.send_friend_request_to(@user.person, aspect) @xml = @user.person.encrypt(@user2.salmon(req, :to => @user.person).to_xml) diff --git a/spec/controllers/sockets_controller_spec.rb b/spec/controllers/sockets_controller_spec.rb index 26318dad6..78e84c6d1 100644 --- a/spec/controllers/sockets_controller_spec.rb +++ b/spec/controllers/sockets_controller_spec.rb @@ -20,15 +20,15 @@ describe SocketsController do describe 'actionhash' do before do - @group = @user.group :name => "losers" - @message = @user.post :status_message, :message => "post through user for victory", :to => @group.id + @aspect = @user.aspect :name => "losers" + @message = @user.post :status_message, :message => "post through user for victory", :to => @aspect.id @fixture_name = File.dirname(__FILE__) + '/../fixtures/button.png' end it 'should actionhash photos' do - @album = @user.post(:album, :name => "Loser faces", :to => @group.id) + @album = @user.post(:album, :name => "Loser faces", :to => @aspect.id) photo = @user.post(:photo, :album_id => @album.id, :user_file => [File.open(@fixture_name)]) - json = @controller.action_hash(@user.id, photo, :group_ids => @user.groups_with_post(@album.id).map{|g| g.id}) + json = @controller.action_hash(@user.id, photo, :aspect_ids => @user.aspects_with_post(@album.id).map{|g| g.id}) json.include?('photo').should be_true end diff --git a/spec/lib/diaspora_parser_spec.rb b/spec/lib/diaspora_parser_spec.rb index 3d4dc3727..8f8ca877a 100644 --- a/spec/lib/diaspora_parser_spec.rb +++ b/spec/lib/diaspora_parser_spec.rb @@ -8,7 +8,7 @@ include Diaspora::Parser describe Diaspora::Parser do before do @user = Factory.create(:user, :email => "bob@aol.com") - @group = @user.group(:name => 'spies') + @aspect = @user.aspect(:name => 'spies') @person = Factory.create(:person_with_private_key, :email => "bill@gates.com") @user2 = Factory.create(:user) end @@ -32,9 +32,9 @@ describe Diaspora::Parser do it 'should be able to correctly handle person on a comment with person not in db' do commenter = Factory.create(:user) - commenter_group = commenter.group :name => "bruisers" - friend_users(@user, @group, commenter, commenter_group) - post = @user.post :status_message, :message => "hello", :to => @group.id + commenter_aspect = commenter.aspect :name => "bruisers" + friend_users(@user, @aspect, commenter, commenter_aspect) + post = @user.post :status_message, :message => "hello", :to => @aspect.id comment = commenter.comment "Fool!", :on => post xml = comment.to_diaspora_xml @@ -96,7 +96,7 @@ describe Diaspora::Parser do end it "should activate the Person if I initiated a request to that url" do - request = @user.send_friend_request_to( @user2.person, @group) + request = @user.send_friend_request_to( @user2.person, @aspect) request.reverse_for @user2 @@ -110,15 +110,15 @@ describe Diaspora::Parser do new_person.nil?.should be false @user.reload - @group.reload - @group.people.include?(new_person).should be true + @aspect.reload + @aspect.people.include?(new_person).should be true @user.friends.include?(new_person).should be true end it 'should process retraction for a person' do person_count = Person.all.count - request = @user.send_friend_request_to( @user2.person, @group) + request = @user.send_friend_request_to( @user2.person, @aspect) request.reverse_for @user2 xml = request.to_diaspora_xml @@ -129,8 +129,8 @@ describe Diaspora::Parser do @user2.destroy @user.receive xml - @group.reload - group_people_count = @group.people.size + @aspect.reload + aspect_people_count = @aspect.people.size #They are now friends @@ -138,8 +138,8 @@ describe Diaspora::Parser do @user.receive retraction_xml Person.count.should == person_count-1 - @group.reload - @group.people.size.should == group_people_count -1 + @aspect.reload + @aspect.people.size.should == aspect_people_count -1 end it 'should marshal a profile for a person' do diff --git a/spec/lib/salmon_salmon_spec.rb b/spec/lib/salmon_salmon_spec.rb index de85fe838..c48e5db15 100644 --- a/spec/lib/salmon_salmon_spec.rb +++ b/spec/lib/salmon_salmon_spec.rb @@ -4,7 +4,7 @@ describe Salmon do before do @user = Factory.create :user - @post = @user.post :status_message, :message => "hi", :to => @user.group(:name => "sdg").id + @post = @user.post :status_message, :message => "hi", :to => @user.aspect(:name => "sdg").id @sent_salmon = Salmon::SalmonSlap.create(@user, @post.to_diaspora_xml) @parsed_salmon = Salmon::SalmonSlap.parse @sent_salmon.to_xml end diff --git a/spec/lib/web_hooks_spec.rb b/spec/lib/web_hooks_spec.rb index 43f55b4d7..7a14152bc 100644 --- a/spec/lib/web_hooks_spec.rb +++ b/spec/lib/web_hooks_spec.rb @@ -7,10 +7,10 @@ describe Diaspora do describe Webhooks do before do @user = Factory.create(:user) - @group = @user.group(:name => "losers") + @aspect = @user.aspect(:name => "losers") @user2 = Factory.create(:user) - @group2 = @user2.group(:name => "losers") - friend_users(@user, @group, @user2, @group2) + @aspect2 = @user2.aspect(:name => "losers") + friend_users(@user, @aspect, @user2, @aspect2) end describe "body" do diff --git a/spec/models/album_spec.rb b/spec/models/album_spec.rb index 973c2a083..751d1427f 100644 --- a/spec/models/album_spec.rb +++ b/spec/models/album_spec.rb @@ -5,8 +5,8 @@ describe Album do @fixture_name = File.dirname(__FILE__) + '/../fixtures/button.png' @user = Factory.create(:user) @user.person.save - @group = @user.group(:name => "Foo") - @album = @user.post(:album, :name => "test collection", :to => @group.id) + @aspect = @user.aspect(:name => "Foo") + @album = @user.post(:album, :name => "test collection", :to => @aspect.id) end it 'should require a name' do diff --git a/spec/models/aspect_spec.rb b/spec/models/aspect_spec.rb new file mode 100644 index 000000000..67e7a0c94 --- /dev/null +++ b/spec/models/aspect_spec.rb @@ -0,0 +1,168 @@ +require File.dirname(__FILE__) + '/../spec_helper' + +describe Aspect do + before do + @user = Factory.create(:user) + @friend = Factory.create(:person) + @user2 = Factory.create(:user) + @friend_2 = Factory.create(:person) + end + + describe 'creation' do + it 'should have a name' do + aspect = @user.aspect(:name => 'losers') + aspect.name.should == "losers" + end + + it 'should be able to have people' do + aspect = @user.aspect(:name => 'losers', :people => [@friend, @friend_2]) + aspect.people.size.should == 2 + end + + it 'should be able to have other users' do + aspect = @user.aspect(:name => 'losers', :people => [@user2.person]) + aspect.people.include?(@user.person).should be false + aspect.people.include?(@user2.person).should be true + aspect.people.size.should == 1 + end + + it 'should be able to have users and people' do + aspect = @user.aspect(:name => 'losers', :people => [@user2.person, @friend_2]) + aspect.people.include?(@user.person).should be false + aspect.people.include?(@user2.person).should be true + aspect.people.include?(@friend_2).should be true + aspect.people.size.should == 2 + end + end + + describe 'querying' do + before do + @aspect = @user.aspect(:name => 'losers') + @user.activate_friend(@friend, @aspect) + @aspect2 = @user2.aspect(:name => 'failures') + friend_users(@user, @aspect, @user2, @aspect2) + @aspect.reload + end + + it 'belong to a user' do + @aspect.user.id.should == @user.id + @user.aspects.size.should == 1 + @user.aspects.first.id.should == @aspect.id + end + + it 'should have people' do + @aspect.people.all.include?(@friend).should be true + @aspect.people.size.should == 2 + end + + it 'should be accessible through the user' do + aspects = @user.aspects_with_person(@friend) + aspects.size.should == 1 + aspects.first.id.should == @aspect.id + aspects.first.people.size.should == 2 + aspects.first.people.include?(@friend).should be true + aspects.first.people.include?(@user2.person).should be true + end + end + + describe 'posting' do + + it 'should add post to aspect via post method' do + aspect = @user.aspect(:name => 'losers', :people => [@friend]) + + status_message = @user.post( :status_message, :message => "hey", :to => aspect.id ) + + aspect.reload + aspect.posts.include?(status_message).should be true + end + + it 'should add post to aspect via receive method' do + aspect = @user.aspect(:name => 'losers') + aspect2 = @user2.aspect(:name => 'winners') + friend_users(@user, aspect, @user2, aspect2) + + message = @user2.post(:status_message, :message => "Hey Dude", :to => aspect2.id) + + @user.receive message.to_diaspora_xml + + aspect.reload + aspect.posts.include?(message).should be true + @user.visible_posts(:by_members_of => aspect).include?(message).should be true + end + + it 'should retract the post from the aspects as well' do + aspect = @user.aspect(:name => 'losers') + aspect2 = @user2.aspect(:name => 'winners') + friend_users(@user, aspect, @user2, aspect2) + + message = @user2.post(:status_message, :message => "Hey Dude", :to => aspect2.id) + + @user.receive message.to_diaspora_xml + aspect.reload + + aspect.post_ids.include?(message.id).should be true + + retraction = @user2.retract(message) + @user.receive retraction.to_diaspora_xml + + aspect.reload + aspect.post_ids.include?(message.id).should be false + end + end + + describe "aspect editing" do + before do + @aspect = @user.aspect(:name => 'losers') + @aspect2 = @user2.aspect(:name => 'failures') + friend_users(@user, @aspect, @user2, @aspect2) + @aspect.reload + @aspect3 = @user.aspect(:name => 'cats') + @user.reload + end + + it 'should be able to move a friend from one of users existing aspects to another' do + @user.move_friend(:friend_id => @user2.person.id, :from => @aspect.id, :to => @aspect3.id) + @aspect.reload + @aspect3.reload + + @aspect.person_ids.include?(@user2.person.id).should be false + @aspect3.people.include?(@user2.person).should be true + end + + it "should not move a person who is not a friend" do + @user.move_friend(:friend_id => @friend.id, :from => @aspect.id, :to => @aspect3.id) + @aspect.reload + @aspect3.reload + @aspect.people.include?(@friend).should be false + @aspect3.people.include?(@friend).should be false + end + + it "should not move a person to a aspect that's not his" do + @user.move_friend(:friend_id => @user2.person.id, :from => @aspect.id, :to => @aspect2.id) + @aspect.reload + @aspect2.reload + @aspect.people.include?(@user2.person).should be true + @aspect2.people.include?(@user2.person).should be false + end + + it 'should move all the by that user to the new aspect' do + message = @user2.post(:status_message, :message => "Hey Dude", :to => @aspect2.id) + + @user.receive message.to_diaspora_xml + @aspect.reload + + @aspect.posts.count.should be 1 + @aspect3.posts.count.should be 0 + + @user.reload + @user.move_friend(:friend_id => @user2.person.id, :from => @aspect.id, :to => @aspect3.id) + @aspect.reload + @aspect3.reload + + @aspect3.posts.count.should be 1 + @aspect.posts.count.should be 0 + + end + + end +end diff --git a/spec/models/comments_spec.rb b/spec/models/comments_spec.rb index d442b22b3..0d394bc5c 100644 --- a/spec/models/comments_spec.rb +++ b/spec/models/comments_spec.rb @@ -4,10 +4,10 @@ describe Comment do describe "user" do before do @user = Factory.create :user - @group = @user.group(:name => "Doofuses") + @aspect = @user.aspect(:name => "Doofuses") @user2 = Factory.create(:user) - @group2 = @user2.group(:name => "Lame-faces") + @aspect2 = @user2.aspect(:name => "Lame-faces") end it "should be able to comment on his own status" do status = Factory.create(:status_message, :person => @user.person) @@ -34,25 +34,25 @@ describe Comment do describe 'comment propagation' do before do - friend_users(@user, Group.first(:id => @group.id), @user2, @group2) + friend_users(@user, Aspect.first(:id => @aspect.id), @user2, @aspect2) @person = Factory.create(:person) - @user.activate_friend(@person, Group.first(:id => @group.id)) + @user.activate_friend(@person, Aspect.first(:id => @aspect.id)) @person2 = Factory.create(:person) @person_status = Factory.build(:status_message, :person => @person) @user.reload - @user_status = @user.post :status_message, :message => "hi", :to => @group.id + @user_status = @user.post :status_message, :message => "hi", :to => @aspect.id - @group.reload + @aspect.reload @user.reload end - it 'should have the post in the groups post list' do - group = Group.first(:id => @group.id) - group.people.size.should == 2 - group.post_ids.include?(@user_status.id).should be true + it 'should have the post in the aspects post list' do + aspect = Aspect.first(:id => @aspect.id) + aspect.people.size.should == 2 + aspect.post_ids.include?(@user_status.id).should be true end it "should send a user's comment on a person's post to that person" do @@ -91,22 +91,22 @@ describe Comment do @user.receive(comment.to_diaspora_xml) end - it 'should not clear the group post array on receiving a comment' do - @group.post_ids.include?(@user_status.id).should be true + it 'should not clear the aspect post array on receiving a comment' do + @aspect.post_ids.include?(@user_status.id).should be true comment = Comment.new(:person_id => @person.id, :text => "balls", :post => @user_status) @user.receive(comment.to_diaspora_xml) - @group.reload - @group.post_ids.include?(@user_status.id).should be true + @aspect.reload + @aspect.post_ids.include?(@user_status.id).should be true end end describe 'serialization' do it 'should serialize the commenter' do commenter = Factory.create(:user) - commenter_group = commenter.group :name => "bruisers" - friend_users(@user, @group, commenter, commenter_group) - post = @user.post :status_message, :message => "hello", :to => @group.id + commenter_aspect = commenter.aspect :name => "bruisers" + friend_users(@user, @aspect, commenter, commenter_aspect) + post = @user.post :status_message, :message => "hello", :to => @aspect.id comment = commenter.comment "Fool!", :on => post comment.person.should_not == @user.person comment.to_diaspora_xml.include?(commenter.person.id.to_s).should be true diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb deleted file mode 100644 index 936deb6b7..000000000 --- a/spec/models/group_spec.rb +++ /dev/null @@ -1,168 +0,0 @@ -require File.dirname(__FILE__) + '/../spec_helper' - -describe Group do - before do - @user = Factory.create(:user) - @friend = Factory.create(:person) - @user2 = Factory.create(:user) - @friend_2 = Factory.create(:person) - end - - describe 'creation' do - it 'should have a name' do - group = @user.group(:name => 'losers') - group.name.should == "losers" - end - - it 'should be able to have people' do - group = @user.group(:name => 'losers', :people => [@friend, @friend_2]) - group.people.size.should == 2 - end - - it 'should be able to have other users' do - group = @user.group(:name => 'losers', :people => [@user2.person]) - group.people.include?(@user.person).should be false - group.people.include?(@user2.person).should be true - group.people.size.should == 1 - end - - it 'should be able to have users and people' do - group = @user.group(:name => 'losers', :people => [@user2.person, @friend_2]) - group.people.include?(@user.person).should be false - group.people.include?(@user2.person).should be true - group.people.include?(@friend_2).should be true - group.people.size.should == 2 - end - end - - describe 'querying' do - before do - @group = @user.group(:name => 'losers') - @user.activate_friend(@friend, @group) - @group2 = @user2.group(:name => 'failures') - friend_users(@user, @group, @user2, @group2) - @group.reload - end - - it 'belong to a user' do - @group.user.id.should == @user.id - @user.groups.size.should == 1 - @user.groups.first.id.should == @group.id - end - - it 'should have people' do - @group.people.all.include?(@friend).should be true - @group.people.size.should == 2 - end - - it 'should be accessible through the user' do - groups = @user.groups_with_person(@friend) - groups.size.should == 1 - groups.first.id.should == @group.id - groups.first.people.size.should == 2 - groups.first.people.include?(@friend).should be true - groups.first.people.include?(@user2.person).should be true - end - end - - describe 'posting' do - - it 'should add post to group via post method' do - group = @user.group(:name => 'losers', :people => [@friend]) - - status_message = @user.post( :status_message, :message => "hey", :to => group.id ) - - group.reload - group.posts.include?(status_message).should be true - end - - it 'should add post to group via receive method' do - group = @user.group(:name => 'losers') - group2 = @user2.group(:name => 'winners') - friend_users(@user, group, @user2, group2) - - message = @user2.post(:status_message, :message => "Hey Dude", :to => group2.id) - - @user.receive message.to_diaspora_xml - - group.reload - group.posts.include?(message).should be true - @user.visible_posts(:by_members_of => group).include?(message).should be true - end - - it 'should retract the post from the groups as well' do - group = @user.group(:name => 'losers') - group2 = @user2.group(:name => 'winners') - friend_users(@user, group, @user2, group2) - - message = @user2.post(:status_message, :message => "Hey Dude", :to => group2.id) - - @user.receive message.to_diaspora_xml - group.reload - - group.post_ids.include?(message.id).should be true - - retraction = @user2.retract(message) - @user.receive retraction.to_diaspora_xml - - group.reload - group.post_ids.include?(message.id).should be false - end - end - - describe "group editing" do - before do - @group = @user.group(:name => 'losers') - @group2 = @user2.group(:name => 'failures') - friend_users(@user, @group, @user2, @group2) - @group.reload - @group3 = @user.group(:name => 'cats') - @user.reload - end - - it 'should be able to move a friend from one of users existing groups to another' do - @user.move_friend(:friend_id => @user2.person.id, :from => @group.id, :to => @group3.id) - @group.reload - @group3.reload - - @group.person_ids.include?(@user2.person.id).should be false - @group3.people.include?(@user2.person).should be true - end - - it "should not move a person who is not a friend" do - @user.move_friend(:friend_id => @friend.id, :from => @group.id, :to => @group3.id) - @group.reload - @group3.reload - @group.people.include?(@friend).should be false - @group3.people.include?(@friend).should be false - end - - it "should not move a person to a group that's not his" do - @user.move_friend(:friend_id => @user2.person.id, :from => @group.id, :to => @group2.id) - @group.reload - @group2.reload - @group.people.include?(@user2.person).should be true - @group2.people.include?(@user2.person).should be false - end - - it 'should move all the by that user to the new group' do - message = @user2.post(:status_message, :message => "Hey Dude", :to => @group2.id) - - @user.receive message.to_diaspora_xml - @group.reload - - @group.posts.count.should be 1 - @group3.posts.count.should be 0 - - @user.reload - @user.move_friend(:friend_id => @user2.person.id, :from => @group.id, :to => @group3.id) - @group.reload - @group3.reload - - @group3.posts.count.should be 1 - @group.posts.count.should be 0 - - end - - end -end diff --git a/spec/models/person_spec.rb b/spec/models/person_spec.rb index fc203d593..a816a84d5 100644 --- a/spec/models/person_spec.rb +++ b/spec/models/person_spec.rb @@ -5,8 +5,8 @@ describe Person do @user = Factory.create(:user) @user2 = Factory.create(:user) @person = Factory.create(:person) - @group = @user.group(:name => "Dudes") - @group2 = @user2.group(:name => "Abscence of Babes") + @aspect = @user.aspect(:name => "Dudes") + @aspect2 = @user2.aspect(:name => "Abscence of Babes") end it 'should not allow two people with the same email' do @@ -60,9 +60,9 @@ describe Person do describe "unfriending" do it 'should delete an orphaned friend' do - request = @user.send_friend_request_to @person, @group + request = @user.send_friend_request_to @person, @aspect - @user.activate_friend(@person, @group) + @user.activate_friend(@person, @aspect) @user.reload Person.all.count.should == 3 @@ -74,11 +74,11 @@ describe Person do end it 'should not delete an un-orphaned friend' do - request = @user.send_friend_request_to @person, @group - request2 = @user2.send_friend_request_to @person, @group2 + request = @user.send_friend_request_to @person, @aspect + request2 = @user2.send_friend_request_to @person, @aspect2 - @user.activate_friend(@person, @group) - @user2.activate_friend(@person, @group2) + @user.activate_friend(@person, @aspect) + @user2.activate_friend(@person, @aspect2) @user.reload @user2.reload @@ -153,8 +153,8 @@ describe Person do describe 'wall posting' do it 'should be able to post on another persons wall' do pending - #user2 is in user's group, user is in group2 on user - friend_users(@user, @group, @user2, @group2) + #user2 is in user's aspect, user is in aspect2 on user + friend_users(@user, @aspect, @user2, @aspect2) @user.person.post_to_wall(:person => @user2.person, :message => "youve got a great smile") @user.person.wall_posts.count.should == 1 diff --git a/spec/models/photo_spec.rb b/spec/models/photo_spec.rb index 3c4b4f1ba..77e4e3208 100644 --- a/spec/models/photo_spec.rb +++ b/spec/models/photo_spec.rb @@ -3,8 +3,8 @@ require File.dirname(__FILE__) + '/../spec_helper' describe Photo do before do @user = Factory.create(:user) - @group = @user.group(:name => "losers") - @album = @user.post :album, :name => "foo", :to => @group.id + @aspect = @user.aspect(:name => "losers") + @album = @user.post :album, :name => "foo", :to => @aspect.id @fixture_filename = 'button.png' @fixture_name = File.dirname(__FILE__) + '/../fixtures/button.png' diff --git a/spec/models/request_spec.rb b/spec/models/request_spec.rb index b02d6e682..24e748a5f 100644 --- a/spec/models/request_spec.rb +++ b/spec/models/request_spec.rb @@ -3,7 +3,7 @@ require File.dirname(__FILE__) + '/../spec_helper' describe Request do before do @user = Factory.create(:user) - @group = @user.group(:name => "dudes") + @aspect = @user.aspect(:name => "dudes") end it 'should require a destination and callback url' do person_request = Request.new @@ -15,7 +15,7 @@ describe Request do it 'should generate xml for the User as a Person' do - request = @user.send_friend_request_to Factory.create(:person), @group + request = @user.send_friend_request_to Factory.create(:person), @aspect xml = request.to_xml.to_s @@ -28,10 +28,10 @@ describe Request do it 'should allow me to see only friend requests sent to me' do remote_person = Factory.build(:person, :email => "robert@grimm.com", :url => "http://king.com/") - Request.instantiate(:into => @group.id, :from => @user.person, :to => remote_person.receive_url).save - Request.instantiate(:into => @group.id, :from => @user.person, :to => remote_person.receive_url).save - Request.instantiate(:into => @group.id, :from => @user.person, :to => remote_person.receive_url).save - Request.instantiate(:into => @group.id, :from => remote_person, :to => @user.receive_url).save + Request.instantiate(:into => @aspect.id, :from => @user.person, :to => remote_person.receive_url).save + Request.instantiate(:into => @aspect.id, :from => @user.person, :to => remote_person.receive_url).save + Request.instantiate(:into => @aspect.id, :from => @user.person, :to => remote_person.receive_url).save + Request.instantiate(:into => @aspect.id, :from => remote_person, :to => @user.receive_url).save Request.for_user(@user).all.count.should == 1 end diff --git a/spec/models/retraction_spec.rb b/spec/models/retraction_spec.rb index 8b6802ea1..889d85fa9 100644 --- a/spec/models/retraction_spec.rb +++ b/spec/models/retraction_spec.rb @@ -4,9 +4,9 @@ describe Retraction do before do @user = Factory.create(:user) @person = Factory.create(:person) - @group = @user.group(:name => "Bruisers") - @user.activate_friend(@person, @group) - @post = @user.post :status_message, :message => "Destroy!", :to => @group.id + @aspect = @user.aspect(:name => "Bruisers") + @user.activate_friend(@person, @aspect) + @post = @user.post :status_message, :message => "Destroy!", :to => @aspect.id end describe 'serialization' do it 'should have a post id after serialization' do diff --git a/spec/models/status_message_spec.rb b/spec/models/status_message_spec.rb index 08c66dfdc..af58ecea8 100644 --- a/spec/models/status_message_spec.rb +++ b/spec/models/status_message_spec.rb @@ -3,7 +3,7 @@ require File.dirname(__FILE__) + '/../spec_helper' describe StatusMessage do before do @user = Factory.create(:user, :email => "bob@aol.com") - @group = @user.group(:name => "losers") + @aspect = @user.aspect(:name => "losers") end it "should have a message" do @@ -14,7 +14,7 @@ describe StatusMessage do end it 'should be postable through the user' do - status = @user.post(:status_message, :message => "Users do things", :to => @group.id) + status = @user.post(:status_message, :message => "Users do things", :to => @aspect.id) end describe "XML" do diff --git a/spec/models/user/posting_spec.rb b/spec/models/user/posting_spec.rb index 2365912da..74fb8c2cf 100644 --- a/spec/models/user/posting_spec.rb +++ b/spec/models/user/posting_spec.rb @@ -3,45 +3,45 @@ require File.dirname(__FILE__) + '/../../spec_helper' describe User do before do @user = Factory.create :user - @group = @user.group(:name => 'heroes') - @group1 = @user.group(:name => 'heroes') + @aspect = @user.aspect(:name => 'heroes') + @aspect1 = @user.aspect(:name => 'heroes') @user2 = Factory.create(:user) - @group2 = @user2.group(:name => 'losers') + @aspect2 = @user2.aspect(:name => 'losers') @user3 = Factory.create(:user) - @group3 = @user3.group(:name => 'heroes') + @aspect3 = @user3.aspect(:name => 'heroes') @user4 = Factory.create(:user) - @group4 = @user4.group(:name => 'heroes') + @aspect4 = @user4.aspect(:name => 'heroes') - friend_users(@user, @group, @user2, @group2) - friend_users(@user, @group, @user3, @group3) - friend_users(@user, @group1, @user4, @group4) + friend_users(@user, @aspect, @user2, @aspect2) + friend_users(@user, @aspect, @user3, @aspect3) + friend_users(@user, @aspect1, @user4, @aspect4) end - it 'should not be able to post without a group' do + it 'should not be able to post without a aspect' do proc {@user.post(:status_message, :message => "heyheyhey")}.should raise_error /You must post to someone/ end - it 'should put the post in the group post array' do - post = @user.post(:status_message, :message => "hey", :to => @group.id) - @group.reload - @group.post_ids.include?(post.id).should be true + it 'should put the post in the aspect post array' do + post = @user.post(:status_message, :message => "hey", :to => @aspect.id) + @aspect.reload + @aspect.post_ids.include?(post.id).should be true end describe 'dispatching' do before do @post = @user.build_post :status_message, :message => "hey" end - it 'should push a post to a group' do + it 'should push a post to a aspect' do @user.should_receive(:salmon).twice - @user.push_to_groups(@post, @group.id) + @user.push_to_aspects(@post, @aspect.id) end - it 'should push a post to all groups' do + it 'should push a post to all aspects' do @user.should_receive(:salmon).exactly(3).times - @user.push_to_groups(@post, :all) + @user.push_to_aspects(@post, :all) end it 'should push to people' do diff --git a/spec/models/user/receive_spec.rb b/spec/models/user/receive_spec.rb index 4d2827545..fe432959b 100644 --- a/spec/models/user/receive_spec.rb +++ b/spec/models/user/receive_spec.rb @@ -4,19 +4,19 @@ describe User do before do @user = Factory.create :user - @group = @user.group(:name => 'heroes') + @aspect = @user.aspect(:name => 'heroes') @user2 = Factory.create(:user) - @group2 = @user2.group(:name => 'losers') + @aspect2 = @user2.aspect(:name => 'losers') @user3 = Factory.create(:user) - @group3 = @user3.group(:name => 'heroes') + @aspect3 = @user3.aspect(:name => 'heroes') - friend_users(@user, @group, @user2, @group2) + friend_users(@user, @aspect, @user2, @aspect2) end it 'should be able to parse and store a status message from xml' do - status_message = @user2.post :status_message, :message => 'store this!', :to => @group2.id + status_message = @user2.post :status_message, :message => 'store this!', :to => @aspect2.id person = @user2.person xml = status_message.to_diaspora_xml @@ -29,16 +29,16 @@ describe User do StatusMessage.all.size.should == 1 end - it 'should not create new groups on message receive' do - num_groups = @user.groups.size + it 'should not create new aspects on message receive' do + num_aspects = @user.aspects.size (0..5).each{ |n| - status_message = @user2.post :status_message, :message => "store this #{n}!", :to => @group2.id + status_message = @user2.post :status_message, :message => "store this #{n}!", :to => @aspect2.id xml = status_message.to_diaspora_xml @user.receive( xml ) } - @user.groups.size.should == num_groups + @user.aspects.size.should == num_aspects end describe 'post refs' do @@ -47,13 +47,13 @@ describe User do end it "should add the post to that user's posts when a user posts it" do - status_message = @user.post :status_message, :message => "hi", :to => @group.id + status_message = @user.post :status_message, :message => "hi", :to => @aspect.id @user.reload @user.raw_visible_posts.include?(status_message).should be true end it 'should be removed on unfriending' do - status_message = @user2.post :status_message, :message => "hi", :to => @group2.id + status_message = @user2.post :status_message, :message => "hi", :to => @aspect2.id @user.receive status_message.to_diaspora_xml @user.reload @@ -68,7 +68,7 @@ describe User do end it 'should be remove a post if the noone links to it' do - status_message = @user2.post :status_message, :message => "hi", :to => @group2.id + status_message = @user2.post :status_message, :message => "hi", :to => @aspect2.id @user.receive status_message.to_diaspora_xml @user.reload @@ -85,7 +85,7 @@ describe User do end it 'should keep track of user references for one person ' do - status_message = @user2.post :status_message, :message => "hi", :to => @group2.id + status_message = @user2.post :status_message, :message => "hi", :to => @aspect2.id @user.receive status_message.to_diaspora_xml @user.reload @@ -107,9 +107,9 @@ describe User do end it 'should not override userrefs on receive by another person' do - @user3.activate_friend(@user2.person, @group3) + @user3.activate_friend(@user2.person, @aspect3) - status_message = @user2.post :status_message, :message => "hi", :to => @group2.id + status_message = @user2.post :status_message, :message => "hi", :to => @aspect2.id @user.receive status_message.to_diaspora_xml @user3.receive status_message.to_diaspora_xml @@ -137,8 +137,8 @@ describe User do describe 'comments' do it 'should correctly marshal a stranger for the downstream user' do - friend_users(@user, @group, @user3, @group3) - post = @user.post :status_message, :message => "hello", :to => @group.id + friend_users(@user, @aspect, @user3, @aspect3) + post = @user.post :status_message, :message => "hello", :to => @aspect.id @user2.receive post.to_diaspora_xml @user3.receive post.to_diaspora_xml @@ -168,7 +168,7 @@ describe User do describe 'salmon' do before do - @post = @user.post :status_message, :message => "hello", :to => @group.id + @post = @user.post :status_message, :message => "hello", :to => @aspect.id @salmon = @user.salmon( @post, :to => @user2.person ) end diff --git a/spec/models/user/user_friending_spec.rb b/spec/models/user/user_friending_spec.rb index 50e5817fc..59fe300ab 100644 --- a/spec/models/user/user_friending_spec.rb +++ b/spec/models/user/user_friending_spec.rb @@ -3,19 +3,19 @@ require File.dirname(__FILE__) + '/../../spec_helper' describe User do before do @user = Factory.create(:user) - @group = @user.group(:name => 'heroes') + @aspect = @user.aspect(:name => 'heroes') end describe 'friend requesting' do - it "should assign a request to a group" do + it "should assign a request to a aspect" do friend = Factory.create(:person) - group = @user.group(:name => "Dudes") - group.requests.size.should == 0 + aspect = @user.aspect(:name => "Dudes") + aspect.requests.size.should == 0 - @user.send_friend_request_to(friend, group) + @user.send_friend_request_to(friend, aspect) - group.reload - group.requests.size.should == 1 + aspect.reload + aspect.requests.size.should == 1 end @@ -25,7 +25,7 @@ describe User do r.save Person.all.count.should == 2 Request.for_user(@user).all.count.should == 1 - @user.accept_friend_request(r.id, @group.id) + @user.accept_friend_request(r.id, @aspect.id) Request.for_user(@user).all.count.should == 0 end @@ -48,7 +48,7 @@ describe User do @user.save - proc {@user.send_friend_request_to( friend, @group)}.should raise_error + proc {@user.send_friend_request_to( friend, @aspect)}.should raise_error end @@ -59,7 +59,7 @@ describe User do @person_one.save @user2 = Factory.create :user - @group2 = @user2.group(:name => "group two") + @aspect2 = @user2.aspect(:name => "aspect two") @user.pending_requests.empty?.should be true @user.friends.empty?.should be true @@ -83,7 +83,7 @@ describe User do @user2.receive @req_three_xml @user2.pending_requests.size.should be 1 - @user2.accept_friend_request @request_three.id, @group2.id + @user2.accept_friend_request @request_three.id, @aspect2.id @user2.friends.include?(@user.person).should be true Person.all.count.should be 3 end @@ -101,12 +101,12 @@ describe User do @user.receive @req_xml @user.pending_requests.size.should be 1 - @user.accept_friend_request @request.id, @group.id + @user.accept_friend_request @request.id, @aspect.id @user.friends.include?(@person_one).should be true @user2.receive @req_two_xml @user2.pending_requests.size.should be 1 - @user2.accept_friend_request @request_two.id, @group2.id + @user2.accept_friend_request @request_two.id, @aspect2.id @user2.friends.include?(@person_one).should be true Person.all.count.should be 3 end @@ -115,7 +115,7 @@ describe User do @user.receive @req_xml @user.pending_requests.size.should be 1 - @user.accept_friend_request @request.id, @group.id + @user.accept_friend_request @request.id, @aspect.id @user.friends.include?(@person_one).should be true @user2.receive @req_two_xml @@ -164,7 +164,7 @@ describe User do @user.pending_requests.size.should be 2 @user.friends.size.should be 0 - @user.accept_friend_request @request.id, @group.id + @user.accept_friend_request @request.id, @aspect.id @user.pending_requests.size.should be 1 @user.friends.size.should be 1 @user.friends.include?(@person_one).should be true @@ -181,11 +181,11 @@ describe User do describe 'unfriending' do before do @user2 = Factory.create :user - @group2 = @user2.group(:name => "Gross people") + @aspect2 = @user2.aspect(:name => "Gross people") - request = @user.send_friend_request_to( @user2, @group) + request = @user.send_friend_request_to( @user2, @aspect) request.reverse_for @user2 - @user2.activate_friend(@user.person, @group2) + @user2.activate_friend(@user.person, @aspect2) @user.receive request.to_diaspora_xml end @@ -211,10 +211,10 @@ describe User do @user2.person.reload @user2.person.user_refs.should == 0 - @group.reload - @group2.reload - @group.people.count.should == 0 - @group2.people.count.should == 0 + @aspect.reload + @aspect2.reload + @aspect.people.count.should == 0 + @aspect2.people.count.should == 0 end end diff --git a/spec/models/user/visible_posts_spec.rb b/spec/models/user/visible_posts_spec.rb index 079586138..e948a98a6 100644 --- a/spec/models/user/visible_posts_spec.rb +++ b/spec/models/user/visible_posts_spec.rb @@ -3,40 +3,40 @@ require File.dirname(__FILE__) + '/../../spec_helper' describe User do before do @user = Factory.create(:user) - @group = @user.group(:name => 'heroes') - @group2 = @user.group(:name => 'losers') + @aspect = @user.aspect(:name => 'heroes') + @aspect2 = @user.aspect(:name => 'losers') @user2 = Factory.create :user - @user2_group = @user2.group(:name => 'dudes') + @user2_aspect = @user2.aspect(:name => 'dudes') - friend_users(@user, @group, @user2, @user2_group) + friend_users(@user, @aspect, @user2, @user2_aspect) @user3 = Factory.create :user - @user3_group = @user3.group(:name => 'dudes') - friend_users(@user, @group2, @user3, @user3_group) + @user3_aspect = @user3.aspect(:name => 'dudes') + friend_users(@user, @aspect2, @user3, @user3_aspect) @user4 = Factory.create :user - @user4_group = @user4.group(:name => 'dudes') - friend_users(@user, @group2, @user4, @user4_group) + @user4_aspect = @user4.aspect(:name => 'dudes') + friend_users(@user, @aspect2, @user4, @user4_aspect) end - it 'should generate a valid stream for a group of people' do - status_message1 = @user2.post :status_message, :message => "hi", :to => @user2_group.id - status_message2 = @user3.post :status_message, :message => "heyyyy", :to => @user3_group.id - status_message3 = @user4.post :status_message, :message => "yooo", :to => @user4_group.id + it 'should generate a valid stream for a aspect of people' do + status_message1 = @user2.post :status_message, :message => "hi", :to => @user2_aspect.id + status_message2 = @user3.post :status_message, :message => "heyyyy", :to => @user3_aspect.id + status_message3 = @user4.post :status_message, :message => "yooo", :to => @user4_aspect.id @user.receive status_message1.to_diaspora_xml @user.receive status_message2.to_diaspora_xml @user.receive status_message3.to_diaspora_xml @user.reload - @user.visible_posts(:by_members_of => @group).include?(status_message1).should be true - @user.visible_posts(:by_members_of => @group).include?(status_message2).should be false - @user.visible_posts(:by_members_of => @group).include?(status_message3).should be false + @user.visible_posts(:by_members_of => @aspect).include?(status_message1).should be true + @user.visible_posts(:by_members_of => @aspect).include?(status_message2).should be false + @user.visible_posts(:by_members_of => @aspect).include?(status_message3).should be false - @user.visible_posts(:by_members_of => @group2).include?(status_message1).should be false - @user.visible_posts(:by_members_of => @group2).include?(status_message2).should be true - @user.visible_posts(:by_members_of => @group2).include?(status_message3).should be true + @user.visible_posts(:by_members_of => @aspect2).include?(status_message1).should be false + @user.visible_posts(:by_members_of => @aspect2).include?(status_message2).should be true + @user.visible_posts(:by_members_of => @aspect2).include?(status_message3).should be true end end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 54dfe9632..8727d290e 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -3,7 +3,7 @@ require File.dirname(__FILE__) + '/../spec_helper' describe User do before do @user = Factory.create(:user) - @group = @user.group(:name => 'heroes') + @aspect = @user.aspect(:name => 'heroes') end describe 'profiles' do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 3c5526e0d..d354cce6e 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -61,8 +61,8 @@ end Post.send(:class_variable_get, :@@queue) end - def friend_users(user1, group1, user2, group2) - request = user1.send_friend_request_to(user2.person, group1) - reversed_request = user2.accept_friend_request( request.id, group2.id) + def friend_users(user1, aspect1, user2, aspect2) + request = user1.send_friend_request_to(user2.person, aspect1) + reversed_request = user2.accept_friend_request( request.id, aspect2.id) user1.receive reversed_request.to_diaspora_xml end diff --git a/spec/user_encryption_spec.rb b/spec/user_encryption_spec.rb index 99ddcc4ca..ca2d28977 100644 --- a/spec/user_encryption_spec.rb +++ b/spec/user_encryption_spec.rb @@ -6,7 +6,7 @@ describe 'user encryption' do before do unstub_mocha_stubs @user = Factory.create(:user) - @group = @user.group(:name => 'dudes') + @aspect = @user.aspect(:name => 'dudes') @person = Factory.create(:person_with_private_key, :profile => Profile.new(:first_name => 'Remote', :last_name => 'Friend'), @@ -32,7 +32,7 @@ describe 'user encryption' do describe 'key exchange on friending' do it 'should send over a public key' do message_queue.stub!(:add_post_request) - request = @user.send_friend_request_to(Factory.create(:person), @group) + request = @user.send_friend_request_to(Factory.create(:person), @aspect) request.to_diaspora_xml.include?( @user.exported_key).should be true end @@ -44,7 +44,7 @@ describe 'user encryption' do original_key = remote_user.exported_key request = remote_user.send_friend_request_to( - @user.person, remote_user.group(:name => "temp")) + @user.person, remote_user.aspect(:name => "temp")) xml = request.to_diaspora_xml @@ -61,7 +61,7 @@ describe 'user encryption' do describe 'encryption' do before do - @message = @user.post :status_message, :message => "hi", :to => @group.id + @message = @user.post :status_message, :message => "hi", :to => @aspect.id end it 'should encrypt large messages' do ciphertext = @user.encrypt @message.to_diaspora_xml @@ -73,7 +73,7 @@ describe 'user encryption' do describe 'comments' do before do @remote_message = Factory.create(:status_message, :person => @person) - @message = @user.post :status_message, :message => "hi", :to => @group.id + @message = @user.post :status_message, :message => "hi", :to => @aspect.id end it 'should attach the creator signature if the user is commenting' do @user.comment "Yeah, it was great", :on => @remote_message @@ -81,7 +81,7 @@ describe 'user encryption' do end it 'should sign the comment if the user is the post creator' do - message = @user.post :status_message, :message => "hi", :to => @group.id + message = @user.post :status_message, :message => "hi", :to => @aspect.id @user.comment "Yeah, it was great", :on => message message.comments.first.signature_valid?.should be true message.comments.first.verify_post_creator_signature.should be true diff --git a/test/selenium/diaspora_selenium b/test/selenium/diaspora_selenium deleted file mode 100644 index 25be2c9a0..000000000 --- a/test/selenium/diaspora_selenium +++ /dev/null @@ -1,14 +0,0 @@ - - - -
- -| Test Suite |
| post_and_delete_status_message_not_testing_websocket |