From 73f0e17f5af29fef343d4ec78e8794180f1ddbac Mon Sep 17 00:00:00 2001 From: Sarah Mei Date: Wed, 20 Oct 2010 20:39:13 -0700 Subject: [PATCH 01/21] Converting to cruisecontrol.rb --- lib/tasks/{ci.rake => cruise.rake} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename lib/tasks/{ci.rake => cruise.rake} (74%) diff --git a/lib/tasks/ci.rake b/lib/tasks/cruise.rake similarity index 74% rename from lib/tasks/ci.rake rename to lib/tasks/cruise.rake index 8887a6cc8..382f87c78 100644 --- a/lib/tasks/ci.rake +++ b/lib/tasks/cruise.rake @@ -1,6 +1,6 @@ -namespace :ci do +namespace :cruise do desc "Run all specs and features" - task :ci => :environment do + task :cruise => :environment do system('/etc/init.d/xvfb start') system('export DISPLAY=:99.0 && bundle exec rake') exit_status = $?.exitstatus @@ -8,4 +8,4 @@ namespace :ci do raise "tests failed!" unless exit_status == 0 end end -task :ci => "ci:ci" +task :cruise => "cruise:cruise" From 560910b53dd3786d99a4222d188a124814f14073 Mon Sep 17 00:00:00 2001 From: Sarah Mei Date: Wed, 20 Oct 2010 20:47:07 -0700 Subject: [PATCH 02/21] More cruisecontrol bits --- Gemfile.lock | 21 +++++++-------------- cruise_config.rb | 5 +++++ lib/cruise/build.rb | 28 ++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 14 deletions(-) create mode 100644 cruise_config.rb create mode 100644 lib/cruise/build.rb diff --git a/Gemfile.lock b/Gemfile.lock index 39b3112e3..5757dfcde 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -97,7 +97,6 @@ GEM activesupport (= 3.0.1) activesupport (3.0.1) addressable (2.2.2) - archive-tar-minitar (0.5.2) arel (1.0.1) activesupport (~> 3.0.0) aws (2.3.22) @@ -164,8 +163,7 @@ GEM i18n (0.4.1) json (1.4.6) json_pure (1.4.6) - linecache19 (0.5.11) - ruby_core_source (>= 0.1.4) + linecache (0.43) mail (2.2.7) activesupport (>= 2.3.6) mime-types @@ -227,16 +225,11 @@ GEM rspec-expectations (~> 2.0.1) rspec-rails (2.0.1) rspec (~> 2.0.0) - ruby-debug-base19 (0.11.24) - columnize (>= 0.3.1) - linecache19 (>= 0.5.11) - ruby_core_source (>= 0.1.4) - ruby-debug19 (0.11.6) - columnize (>= 0.3.1) - linecache19 (>= 0.5.11) - ruby-debug-base19 (>= 0.11.19) - ruby_core_source (0.1.4) - archive-tar-minitar (>= 0.5.2) + ruby-debug (0.10.3) + columnize (>= 0.1) + ruby-debug-base (~> 0.10.3.0) + ruby-debug-base (0.10.3) + linecache (>= 0.3) rubyzip (0.9.4) selenium-webdriver (0.0.29) childprocess (>= 0.0.7) @@ -294,7 +287,7 @@ DEPENDENCIES roxml! rspec (>= 2.0.0) rspec-rails (>= 2.0.0) - ruby-debug19 + ruby-debug sprinkle! thin webmock diff --git a/cruise_config.rb b/cruise_config.rb new file mode 100644 index 000000000..7968ea55d --- /dev/null +++ b/cruise_config.rb @@ -0,0 +1,5 @@ +require 'fileutils' + +Project.configure do |project| + project.build_command = 'sudo gem update --system && ruby lib/cruise/build.rb' +end diff --git a/lib/cruise/build.rb b/lib/cruise/build.rb new file mode 100644 index 000000000..df4c3250b --- /dev/null +++ b/lib/cruise/build.rb @@ -0,0 +1,28 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +def root_dir + @root_dir ||= File.expand_path(File.dirname(__FILE__) + '/../..') +end + +def rake(*tasks) + tasks.each do |task| + return false unless system("#{root_dir}/bin/rake", task, 'RAILS_ENV=test') + end +end + +build_results = {} + +cd root_dir do + build_results[:bundle] = system 'bundle install' # bundling here, rather than in a task (not in Rails context) + build_results[:spec] = rake 'cruise' +end + +failures = build_results.select { |key, value| value == false } + +if failures.empty? + exit(0) +else + exit(-1) +end From 55914827db1b7d05797a337e80004d0078be33d5 Mon Sep 17 00:00:00 2001 From: Sarah Mei Date: Wed, 20 Oct 2010 21:06:33 -0700 Subject: [PATCH 03/21] cruisecontrol uses rvm --- cruise_config.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cruise_config.rb b/cruise_config.rb index 7968ea55d..4d6211719 100644 --- a/cruise_config.rb +++ b/cruise_config.rb @@ -1,5 +1,5 @@ require 'fileutils' Project.configure do |project| - project.build_command = 'sudo gem update --system && ruby lib/cruise/build.rb' + project.build_command = 'cd .. && cd work && sudo gem update --system && ruby lib/cruise/build.rb' end From ddc24e1c471a1a666581db122424f079abc0a3ec Mon Sep 17 00:00:00 2001 From: Sarah Mei Date: Wed, 20 Oct 2010 21:21:55 -0700 Subject: [PATCH 04/21] Duh. rvm doesn't want sudo. --- cruise_config.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cruise_config.rb b/cruise_config.rb index 4d6211719..4806fb3db 100644 --- a/cruise_config.rb +++ b/cruise_config.rb @@ -1,5 +1,5 @@ require 'fileutils' Project.configure do |project| - project.build_command = 'cd .. && cd work && sudo gem update --system && ruby lib/cruise/build.rb' + project.build_command = 'cd .. && cd work && gem update --system && ruby lib/cruise/build.rb' end From 29dd5bc727be15fe0cb29309a03aaecedc3f8608 Mon Sep 17 00:00:00 2001 From: Sarah Mei Date: Wed, 20 Oct 2010 21:25:16 -0700 Subject: [PATCH 05/21] Let's actually use rvm this time. --- cruise_config.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cruise_config.rb b/cruise_config.rb index 4806fb3db..1e19998ae 100644 --- a/cruise_config.rb +++ b/cruise_config.rb @@ -1,5 +1,5 @@ require 'fileutils' Project.configure do |project| - project.build_command = 'cd .. && cd work && gem update --system && ruby lib/cruise/build.rb' + project.build_command = 'source /usr/local/rvm/scripts/rvm && rvm use ruby-1.8.7-p249 && gem update --system && ruby lib/cruise/build.rb' end From 669a7cabb2d0028f67a6be50435e22a10b91d2c3 Mon Sep 17 00:00:00 2001 From: Sarah Mei Date: Wed, 20 Oct 2010 21:43:03 -0700 Subject: [PATCH 06/21] Use diaspora gemset. Simplify rake runner. --- cruise_config.rb | 2 +- lib/cruise/build.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cruise_config.rb b/cruise_config.rb index 1e19998ae..ee3c7f72b 100644 --- a/cruise_config.rb +++ b/cruise_config.rb @@ -1,5 +1,5 @@ require 'fileutils' Project.configure do |project| - project.build_command = 'source /usr/local/rvm/scripts/rvm && rvm use ruby-1.8.7-p249 && gem update --system && ruby lib/cruise/build.rb' + project.build_command = 'source /usr/local/rvm/scripts/rvm && rvm use ruby-1.8.7-p249@diaspora && gem update --system && ruby lib/cruise/build.rb' end diff --git a/lib/cruise/build.rb b/lib/cruise/build.rb index df4c3250b..90bd5a7fb 100644 --- a/lib/cruise/build.rb +++ b/lib/cruise/build.rb @@ -8,7 +8,7 @@ end def rake(*tasks) tasks.each do |task| - return false unless system("#{root_dir}/bin/rake", task, 'RAILS_ENV=test') + return false unless system("rake", task, 'RAILS_ENV=test') end end From e5f1975dcfc45b17b83379c5181d763345db6b98 Mon Sep 17 00:00:00 2001 From: Sarah Mei Date: Wed, 20 Oct 2010 21:54:33 -0700 Subject: [PATCH 07/21] Remove Gemfile.lock before doing rake cruise --- cruise_config.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cruise_config.rb b/cruise_config.rb index ee3c7f72b..922a03a0f 100644 --- a/cruise_config.rb +++ b/cruise_config.rb @@ -1,5 +1,5 @@ require 'fileutils' Project.configure do |project| - project.build_command = 'source /usr/local/rvm/scripts/rvm && rvm use ruby-1.8.7-p249@diaspora && gem update --system && ruby lib/cruise/build.rb' + project.build_command = 'source /usr/local/rvm/scripts/rvm && rvm use ruby-1.8.7-p249@diaspora && rm Gemfile.lock && gem update --system && ruby lib/cruise/build.rb' end From 48c13d81c511399dfdb75503ab11307ee2b8298c Mon Sep 17 00:00:00 2001 From: Sarah Mei Date: Wed, 20 Oct 2010 21:56:59 -0700 Subject: [PATCH 08/21] rly rly remove Gemfile.lock. rly! --- cruise_config.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cruise_config.rb b/cruise_config.rb index 922a03a0f..a52297ead 100644 --- a/cruise_config.rb +++ b/cruise_config.rb @@ -1,5 +1,5 @@ require 'fileutils' Project.configure do |project| - project.build_command = 'source /usr/local/rvm/scripts/rvm && rvm use ruby-1.8.7-p249@diaspora && rm Gemfile.lock && gem update --system && ruby lib/cruise/build.rb' + project.build_command = 'source /usr/local/rvm/scripts/rvm && rvm use ruby-1.8.7-p249@diaspora && rm -f Gemfile.lock && gem update --system && ruby lib/cruise/build.rb' end From d98b551464051163a73e745edddaa862088de22b Mon Sep 17 00:00:00 2001 From: Sarah Mei Date: Wed, 20 Oct 2010 22:22:34 -0700 Subject: [PATCH 09/21] Let's try something a little simpler. --- ci.sh | 4 ++-- cruise_config.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ci.sh b/ci.sh index dd78a9b2c..516deaf2e 100755 --- a/ci.sh +++ b/ci.sh @@ -8,7 +8,7 @@ rm Gemfile.lock && source /usr/local/rvm/scripts/rvm && rvm use ruby-1.8.7-p249 && bundle install && -bundle exec rake ci && +bundle exec rake cruise && echo "" && echo "*************************************************************************************************" && echo "* ruby 1.9.2-p0 build *" && @@ -18,4 +18,4 @@ rm Gemfile.lock && source /usr/local/rvm/scripts/rvm && rvm use ruby-1.9.2-p0 && bundle install && -bundle exec rake ci +bundle exec rake cruise diff --git a/cruise_config.rb b/cruise_config.rb index a52297ead..b6a53d3cb 100644 --- a/cruise_config.rb +++ b/cruise_config.rb @@ -1,5 +1,5 @@ require 'fileutils' Project.configure do |project| - project.build_command = 'source /usr/local/rvm/scripts/rvm && rvm use ruby-1.8.7-p249@diaspora && rm -f Gemfile.lock && gem update --system && ruby lib/cruise/build.rb' + project.build_command = 'ci.sh' end From 2bab775973e8a5c89a71192446076c3c7631c3aa Mon Sep 17 00:00:00 2001 From: Sarah Mei Date: Wed, 20 Oct 2010 22:37:50 -0700 Subject: [PATCH 10/21] ci.sh uses @diaspora gemset and forces removal of Gemfile.lock --- ci.sh | 8 ++++---- cruise_config.rb | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ci.sh b/ci.sh index 516deaf2e..6604548c6 100755 --- a/ci.sh +++ b/ci.sh @@ -4,9 +4,9 @@ echo "************************************************************************** echo "* ruby 1.8.7-p249 build *" && echo "*************************************************************************************************" && echo "" && -rm Gemfile.lock && +rm -f Gemfile.lock && source /usr/local/rvm/scripts/rvm && -rvm use ruby-1.8.7-p249 && +rvm use ruby-1.8.7-p249@diaspora && bundle install && bundle exec rake cruise && echo "" && @@ -14,8 +14,8 @@ echo "************************************************************************** echo "* ruby 1.9.2-p0 build *" && echo "*************************************************************************************************" && echo "" && -rm Gemfile.lock && +rm -f Gemfile.lock && source /usr/local/rvm/scripts/rvm && -rvm use ruby-1.9.2-p0 && +rvm use ruby-1.9.2-p0@diaspora && bundle install && bundle exec rake cruise diff --git a/cruise_config.rb b/cruise_config.rb index b6a53d3cb..a5efcd3d7 100644 --- a/cruise_config.rb +++ b/cruise_config.rb @@ -1,5 +1,5 @@ require 'fileutils' Project.configure do |project| - project.build_command = 'ci.sh' + project.build_command = './ci.sh' end From 82e947a74a57e9ca394a45f5fbe2fe1c8f80428a Mon Sep 17 00:00:00 2001 From: Sarah Mei Date: Wed, 20 Oct 2010 22:44:18 -0700 Subject: [PATCH 11/21] Disabling ruby 1.9 build until we can move off capybara --- ci.sh | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/ci.sh b/ci.sh index 6604548c6..e24ba0ec0 100755 --- a/ci.sh +++ b/ci.sh @@ -8,14 +8,15 @@ rm -f Gemfile.lock && source /usr/local/rvm/scripts/rvm && rvm use ruby-1.8.7-p249@diaspora && bundle install && -bundle exec rake cruise && -echo "" && -echo "*************************************************************************************************" && -echo "* ruby 1.9.2-p0 build *" && -echo "*************************************************************************************************" && -echo "" && -rm -f Gemfile.lock && -source /usr/local/rvm/scripts/rvm && -rvm use ruby-1.9.2-p0@diaspora && -bundle install && bundle exec rake cruise +# bundle exec rake cruise && +# echo "" && +# echo "*************************************************************************************************" && +# echo "* ruby 1.9.2-p0 build *" && +# echo "*************************************************************************************************" && +# echo "" && +# rm -f Gemfile.lock && +# source /usr/local/rvm/scripts/rvm && +# rvm use ruby-1.9.2-p0@diaspora && +# bundle install && +# bundle exec rake cruise From 8e175be2ba0706b83c7242eb4a116dd668bc724c Mon Sep 17 00:00:00 2001 From: danielvincent Date: Wed, 20 Oct 2010 23:40:48 -0700 Subject: [PATCH 12/21] fixed comments not showing up through websocket on photo show page --- app/views/albums/index.html.haml | 10 ++- app/views/js/_websocket_js.haml | 12 +-- app/views/photos/show.html.haml | 106 +++++++++++------------ app/views/status_messages/show.html.haml | 2 +- public/javascripts/view.js | 2 +- public/stylesheets/sass/application.sass | 8 +- 6 files changed, 72 insertions(+), 68 deletions(-) diff --git a/app/views/albums/index.html.haml b/app/views/albums/index.html.haml index 81455b85b..b9e62113f 100644 --- a/app/views/albums/index.html.haml +++ b/app/views/albums/index.html.haml @@ -8,10 +8,14 @@ $("#add_album_button").fancybox(); }); -.span-4.append-1.last - = render "shared/aspect_friends" +%h2 + = @aspect + .friend_pictures.horizontal + = owner_image_link + - for friend in @friends + = person_image_link(friend) -.span-15.last +.span-24.last %h3 = @aspect Albums diff --git a/app/views/js/_websocket_js.haml b/app/views/js/_websocket_js.haml index 78312f5fe..ec7381bf4 100644 --- a/app/views/js/_websocket_js.haml +++ b/app/views/js/_websocket_js.haml @@ -44,17 +44,19 @@ } function processComment(post_id, html){ - post = $('#' + post_id)[0] + post = $("*[data-guid='"+post_id+"']'"); $(' .comment_set li:last', post ).before( $(html).fadeIn("fast", function(){}) ); toggler = $('.show_post_comments', post) - toggler.html( - toggler.html().replace(/\d+/,$('.comment_set', post)[0].childElementCount -1)); + if(toggler.length > 0){ + toggler.html( + toggler.html().replace(/\d+/,$('.comment_set', post)[0].childElementCount -1)); - if( !$(".comments", post).is(':visible') ){ - toggler.click(); + if( !$(".comments", post).is(':visible') ){ + toggler.click(); + } } } diff --git a/app/views/photos/show.html.haml b/app/views/photos/show.html.haml index afdf1ebf3..e4ae23170 100644 --- a/app/views/photos/show.html.haml +++ b/app/views/photos/show.html.haml @@ -2,57 +2,58 @@ -# licensed under the Affero General Public License version 3 or later. See -# the COPYRIGHT file. -:javascript - $(document).keydown(function(e){ - switch(e.keyCode) { - case 37: - if(!$("textarea").hasClass("hasfocus")){//prevent redirect if textarea has focus - window.location.replace( "#{url_to_prev(@photo,@album)}" ); +- content_for :head do + :javascript + $(document).keydown(function(e){ + switch(e.keyCode) { + case 37: + if(!$("textarea").hasClass("hasfocus")){//prevent redirect if textarea has focus + window.location.replace( "#{url_to_prev(@photo,@album)}" ); + } + break; + case 39: + if(!$("textarea").hasClass("hasfocus")){ + window.location.replace( "#{url_to_next(@photo,@album)}" ); + } + break; } - break; - case 39: - if(!$("textarea").hasClass("hasfocus")){ - window.location.replace( "#{url_to_next(@photo,@album)}" ); - } - break; - } - }); - - $(document).ready(function(){ - //add a clas to verify if a textarea has focus - $("textarea").live('focus',function(){ - $(this).addClass("hasfocus"); - }); - $("textarea").live('blur',function(){ - $(this).removeClass("hasfocus"); }); - //show form to add description - $(".edit-desc").click(function(){ - $(".edit_photo").toggle(); - }); + $(document).ready(function(){ + //add a clas to verify if a textarea has focus + $("textarea").live('focus',function(){ + $(this).addClass("hasfocus"); + }); + $("textarea").live('blur',function(){ + $(this).removeClass("hasfocus"); + }); - //Add a description with ajax request - $("#photo_submit").click(function(evenet){ - event.preventDefault(); - var method = $(".edit_photo").attr("method"); - var url = $(".edit_photo").attr("action"); - var data = $(".edit_photo").serialize(); - $(".description").text($("#photo_caption").val()); - $(".edit_photo").toggle(); + //show form to add description + $(".edit-desc").click(function(){ + $(".edit_photo").toggle(); + }); - $.ajax({ - type: method, - url: url, - data: data, - success: function(response){ - $("#add-description").remove(); - } - }); + //Add a description with ajax request + $("#photo_submit").click(function(evenet){ + event.preventDefault(); + var method = $(".edit_photo").attr("method"); + var url = $(".edit_photo").attr("action"); + var data = $(".edit_photo").serialize(); + $(".description").text($("#photo_caption").val()); + $(".edit_photo").toggle(); - }); + $.ajax({ + type: method, + url: url, + data: data, + success: function(response){ + $("#add-description").remove(); + } + }); - });//end document ready + }); + + });//end document ready %h2 = @aspect @@ -64,6 +65,12 @@ %h3 = link_to @photo.album.name, @photo.album += link_to "<< #{t('.prev')}", url_to_prev(@photo, @album), :rel => 'prefetch' +| += link_to "#{t('.full_size')}", @photo.url +| += link_to "#{t('.next')} >>", url_to_next(@photo, @album), :rel => 'prefetch' + .span-14.append-1.last %div{:data=>{:guid=>@photo.id}} #show_photo @@ -72,8 +79,6 @@ .edit_pane .controls{:data=>{:actor=>"#{@photo.person.owner.id}",:actor_person=>"#{@photo.person.id}",:image_url=>"#{@photo.url(:thumb_medium)}"}} = link_to 'make profile photo', '#', :class => "make_profile_photo" - | - = link_to 'edit', '#', :class => "make_profile_photo" = linked_scaled_photo @photo, @album -else = linked_scaled_photo @photo, @album @@ -100,13 +105,6 @@ = link_to t('.delete_photo'), @photo, :confirm => t('.are_you_sure'), :method => :delete, :class => 'button' .span-9.last - = link_to "<< #{t('.prev')}", url_to_prev(@photo, @album), :rel => 'prefetch' - | - = link_to "#{t('.full_size')}", @photo.url - | - = link_to "#{t('.next')} >>", url_to_next(@photo, @album), :rel => 'prefetch' - %br - %br #stream.show - %li.message{:id => @photo.id} + %li.message{:data=>{:guid=>@photo.id}} = render "comments/comments", :post => @photo diff --git a/app/views/status_messages/show.html.haml b/app/views/status_messages/show.html.haml index e9dbd4816..398b3a536 100644 --- a/app/views/status_messages/show.html.haml +++ b/app/views/status_messages/show.html.haml @@ -26,5 +26,5 @@ .span-9.last #stream.show - %li.message{:id => @status_message.id} + %li.message{:data=>{:guid=>@status_message.id}} = render "comments/comments", :post => @status_message diff --git a/public/javascripts/view.js b/public/javascripts/view.js index 907602743..7e809f978 100644 --- a/public/javascripts/view.js +++ b/public/javascripts/view.js @@ -47,7 +47,7 @@ $(document).ready(function(){ } ); - $("#publisher textarea, .comment textarea").keydown( function(e) { + $("#publisher textarea, .comment_box").keydown( function(e) { if (e.keyCode == 13) { $(this).closest("form").submit(); } diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 7bbaeea4b..f2f0959e3 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -180,7 +180,7 @@ header #global_search :margin - :left 425px + :left 432px #stream :margin 0 @@ -1015,8 +1015,8 @@ ul#settings_nav :left 20px img - :width 20px - :height 20px + :width 30px + :height 30px :margin-right -4px #thumbnails @@ -1070,7 +1070,7 @@ input[type="search"] header input[type="search"] - :width 200px + :width 192px .fancybox_content :display none From 06e2b43516f88fc170afc323a456e513e6f710cf Mon Sep 17 00:00:00 2001 From: danielvincent Date: Wed, 20 Oct 2010 23:46:24 -0700 Subject: [PATCH 13/21] 252,252,252 rgb for body background. you won't even notice. --- public/stylesheets/sass/application.sass | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index f2f0959e3..399e77afb 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -14,6 +14,7 @@ body :padding 2em :margin 0 + :background-color rgba(252,252,252,1) a :color #107FC9 :text @@ -845,7 +846,7 @@ h1.big_text :font :weight bold :background - :color #fff + :color rgba(252,252,252,1) :color #444 &:hover From e414b1c553a195e29e0a7fe7c5eef81b56fef43e Mon Sep 17 00:00:00 2001 From: Sarah Mei Date: Thu, 21 Oct 2010 06:45:15 -0700 Subject: [PATCH 14/21] Fix some comment specs (still one failing). Remove warning from receive spec. --- .../{comments_spec.rb => comment_spec.rb} | 52 ++++++++++--------- spec/models/user/receive_spec.rb | 2 +- 2 files changed, 28 insertions(+), 26 deletions(-) rename spec/models/{comments_spec.rb => comment_spec.rb} (78%) diff --git a/spec/models/comments_spec.rb b/spec/models/comment_spec.rb similarity index 78% rename from spec/models/comments_spec.rb rename to spec/models/comment_spec.rb index 248e9b640..e8c3c3ef4 100644 --- a/spec/models/comments_spec.rb +++ b/spec/models/comment_spec.rb @@ -10,18 +10,22 @@ describe Comment do let(:user2) {Factory.create(:user)} let(:aspect2) {user2.aspect(:name => "Lame-faces")} - describe 'User#comment' do - let(:status) {user.post(:status_message, :message => "hello", :to => aspect)} - it "should be able to comment on his own status" do - status.comments.should == [] - user.comment "Yeah, it was great", :on => status - status.reload.comments.first.text.should == "Yeah, it was great" + describe 'User#comment' do + before do + @status = user.post(:status_message, :message => "hello", :to => aspect.id) + end + + it "should be able to comment on his own status" do + @status.comments.should == [] + + user.comment "Yeah, it was great", :on => @status + @status.reload.comments.first.text.should == "Yeah, it was great" end it "should be able to comment on a person's status" do - user2.comment "sup dog", :on => status - status.reload.comments.first.text.should == "sup dog" + user2.comment "sup dog", :on => @status + @status.reload.comments.first.text.should == "sup dog" end end @@ -42,34 +46,32 @@ describe Comment do @person_status = Factory.build(:status_message, :person => @person) user.reload - user_status = user.post :status_message, :message => "hi", :to => aspect.id + @user_status = user.post :status_message, :message => "hi", :to => aspect.id aspect.reload user.reload end it 'should receive a comment from a person not on the pod' do - user3 = Factory.create :user + user3 = Factory.create(:user) aspect3 = user3.aspect(:name => "blah") friend_users(user, aspect, user3, aspect3) - comment = Comment.new(:person_id => user3.person.id, :text => "hey", :post => user_status) + comment = Comment.new(:person_id => user3.person.id, :text => "hey", :post => @user_status) comment.creator_signature = comment.sign_with_key(user3.encryption_key) - - comment.post_creator_signature = comment.sign_with_key(user.encryption_key) - xml = user.salmon(comment).xml_for(user2) + + xml = user.salmon(comment).xml_for(user3) user3.person.delete user3.delete - - user_status.reload - user_status.comments.should == [] + @user_status.reload + @user_status.comments.should == [] user.receive_salmon(xml) - user_status.reload - user_status.comments.include?(comment).should be true + @user_status.reload + @user_status.comments.include?(comment).should be true end it "should send a user's comment on a person's post to that person" do @@ -80,17 +82,17 @@ describe Comment do it 'should send a user comment on his own post to lots of people' do User::QUEUE.should_receive(:add_post_request).twice - user.comment "yo", :on => user_status + user.comment "yo", :on => @user_status end it 'should send a comment a person made on your post to all people' do - comment = Comment.new(:person_id => @person.id, :text => "balls", :post => user_status) + comment = Comment.new(:person_id => @person.id, :text => "balls", :post => @user_status) User::QUEUE.should_receive(:add_post_request).twice user.receive comment.to_diaspora_xml, @person end it 'should send a comment a user made on your post to all people' do - comment = user2.comment( "balls", :on => user_status) + comment = user2.comment( "balls", :on => @user_status) User::QUEUE.should_receive(:add_post_request).twice user.receive comment.to_diaspora_xml, user2.person end @@ -108,13 +110,13 @@ describe Comment do end 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) + 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, @person aspect.reload - aspect.post_ids.include?(user_status.id).should be true + aspect.post_ids.include?(@user_status.id).should be true end end describe 'serialization' do diff --git a/spec/models/user/receive_spec.rb b/spec/models/user/receive_spec.rb index beca56c49..07b481b17 100644 --- a/spec/models/user/receive_spec.rb +++ b/spec/models/user/receive_spec.rb @@ -27,7 +27,7 @@ describe User do status_message.destroy user - lambda {user.receive xml , user2.person}.should change (Post,:count).by(1) + lambda {user.receive xml , user2.person}.should change(Post,:count).by(1) end it 'should not create new aspects on message receive' do From c58b4706a56504951be1edfefd648be0da5212e5 Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 21 Oct 2010 10:01:06 -0700 Subject: [PATCH 15/21] Update carrierwave in Gemfile.lock --- Gemfile.lock | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 5757dfcde..6d809ac87 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -43,10 +43,11 @@ GIT GIT remote: git://github.com/rsofaer/carrierwave.git - revision: 9edb8bdddd2236742a85bfd7b260387498d01f88 + revision: c3dfbdda2fa227af91fe383bb126f59b991a318f branch: master specs: - carrierwave (0.4.4) + carrierwave (0.5.0) + activesupport (~> 3.0) GIT remote: git://github.com/rsofaer/redfinger.git From 35a830aa03cfa27b1bbc84db1da686c9ff4b8e79 Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 21 Oct 2010 10:39:19 -0700 Subject: [PATCH 16/21] Fix profile update spec --- spec/models/user_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 427b6b74f..ab1c005ee 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -143,13 +143,13 @@ describe User do context 'profiles' do it 'should be able to update their profile and send it to their friends' do - updated_profile = {:profile => { + updated_profile = { :first_name => 'bob', :last_name => 'billytown', - :image_url => "http://clown.com"}} + :image_url => "http://clown.com"} user.update_profile(updated_profile).should be true - user.profile.image_url.should == "http://clown.com" + user.reload.profile.image_url.should == "http://clown.com" end end From 705cef36965f3d49cb9ff4d0169218b24f760746 Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 21 Oct 2010 10:55:17 -0700 Subject: [PATCH 17/21] Fix comment spec --- spec/models/comment_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb index e8c3c3ef4..1cd8e9b9d 100644 --- a/spec/models/comment_spec.rb +++ b/spec/models/comment_spec.rb @@ -62,14 +62,14 @@ describe Comment do comment.creator_signature = comment.sign_with_key(user3.encryption_key) comment.post_creator_signature = comment.sign_with_key(user.encryption_key) - xml = user.salmon(comment).xml_for(user3) + xml = user.salmon(comment).xml_for(user2) user3.person.delete user3.delete @user_status.reload @user_status.comments.should == [] - user.receive_salmon(xml) + user2.receive_salmon(xml) @user_status.reload @user_status.comments.include?(comment).should be true end From fe1a6bce201388c95128c0e4768eb48938830f33 Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 21 Oct 2010 12:49:50 -0700 Subject: [PATCH 18/21] Attr-accessible on aspects, check whether built user is persisted --- app/controllers/aspects_controller.rb | 3 +-- app/models/aspect.rb | 1 + app/models/user.rb | 6 ++++-- spec/models/aspect_spec.rb | 16 +++++++--------- spec/models/user_spec.rb | 1 + 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index 43e0b7f33..ddde8a725 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -73,8 +73,7 @@ class AspectsController < ApplicationController def update @aspect = current_user.aspect_by_id(params[:id]) - data = clean_hash(params[:aspect]) - @aspect.update_attributes( data ) + @aspect.update_attributes( params[:aspect] ) flash[:notice] = I18n.t 'aspects.update.success',:name => @aspect.name respond_with @aspect end diff --git a/app/models/aspect.rb b/app/models/aspect.rb index e58318569..0fceedead 100644 --- a/app/models/aspect.rb +++ b/app/models/aspect.rb @@ -18,6 +18,7 @@ class Aspect validates_presence_of :name validates_uniqueness_of :name, :scope => :user_id + attr_accessible :name timestamps! diff --git a/app/models/user.rb b/app/models/user.rb index 6f8219765..273cc209b 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -92,8 +92,10 @@ class User ######### Aspects ###################### def aspect(opts = {}) - opts[:user] = self - Aspect.create(opts) + aspect = Aspect.new(opts) + aspect.user = self + aspect.save + aspect end def drop_aspect(aspect) diff --git a/spec/models/aspect_spec.rb b/spec/models/aspect_spec.rb index 484f5f66e..336d22cb3 100644 --- a/spec/models/aspect_spec.rb +++ b/spec/models/aspect_spec.rb @@ -18,29 +18,27 @@ describe Aspect do let(:aspect3) {user3.aspect(:name => "lala")} describe 'creation' do + let(:aspect){user.aspect(:name => 'losers')} it 'should have a name' do - aspect = user.aspect(:name => 'losers') aspect.name.should == "losers" end - it 'should be creatable with people' do + it 'should not be creatable with people' do aspect = user.aspect(:name => 'losers', :people => [friend, friend_2]) - aspect.people.size.should == 2 + aspect.people.size.should == 0 end it 'should be able to have other users' do - aspect = user.aspect(:name => 'losers', :people => [user2.person]) + aspect.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 + aspect.people << user2.person + aspect.people << friend_2 + aspect.save.should be_true end end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index ab1c005ee..2ae80e7f9 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -103,6 +103,7 @@ describe User do end it "makes a valid user" do @user.should be_valid + @user.persisted?.should be_false User.find_by_username("ohai").should be_nil end it 'saves successfully' do From 41cfd36b194e89286a42db2c847a727e900b6a9f Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 21 Oct 2010 16:06:47 -0700 Subject: [PATCH 19/21] Refactor user_spec a little --- spec/models/user_spec.rb | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 2ae80e7f9..4b2a4d02d 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -9,8 +9,6 @@ describe User do let(:aspect) { user.aspect(:name => 'heroes') } let(:user2) { Factory(:user) } let(:aspect2) { user2.aspect(:name => 'stuff') } - let(:user3) { Factory(:user) } - let(:aspect3) { user3.aspect(:name => 'stuff') } describe "validation" do describe "of associated person" do @@ -168,12 +166,7 @@ describe User do end end - context 'account removal' do - before do - friend_users(user, aspect, user2, aspect2) - friend_users(user, aspect, user3, aspect3) - end - + describe 'account removal' do it 'should unfriend everyone' do user.should_receive(:unfriend_everyone) user.destroy @@ -185,11 +178,8 @@ describe User do end it 'should remove all aspects' do - aspects = user.aspects - aspects.count.should > 0 - user.destroy - aspects.reload - aspects.count.should == 0 + aspect + lambda {user.destroy}.should change{user.aspects.reload.count}.by(-1) end describe '#remove_person' do @@ -209,20 +199,18 @@ describe User do end describe '#unfriend_everyone' do - before do - user3.delete - end it 'should send retractions to remote poeple' do + user2.delete + user.activate_friend(user2.person, aspect) + user.should_receive(:unfriend).once user.destroy end it 'should unfriend local people' do - user2.friends.count.should be 1 - user.destroy - user2.reload - user2.friends.count.should be 0 + friend_users(user, aspect, user2, aspect2) + lambda {user.destroy}.should change{user2.reload.friends.count}.by(-1) end end end From e677e4782e73c569783143865603aa69e3b9b275 Mon Sep 17 00:00:00 2001 From: ilya Date: Thu, 21 Oct 2010 16:07:31 -0700 Subject: [PATCH 20/21] the handle is now in the email if only one user invited the person --- app/views/devise/mailer/invitation.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/devise/mailer/invitation.html.haml b/app/views/devise/mailer/invitation.html.haml index 7bfe190a6..f88ff4411 100644 --- a/app/views/devise/mailer/invitation.html.haml +++ b/app/views/devise/mailer/invitation.html.haml @@ -48,7 +48,7 @@ %p Hello #{@resource.email}! %p - #{(@resource.inviters.count == 1)? ( @resource.inviters.first.real_name + " has") : (@resource.inviters.map{|inv| inv.real_name + " (#{inv.diaspora_handle})"}.join(",") + " have")} invited you to join Diaspora at #{root_url}, you can accept it through the link below. + #{(@resource.inviters.count == 1)? ( @resource.inviters.first.real_name + " (#{@resource.inviters.first.diaspora_handle})" + " has") : (@resource.inviters.map{|inv| inv.real_name + " (#{inv.diaspora_handle})"}.join(",") + " have")} invited you to join Diaspora at #{root_url}, you can accept it through the link below. - @resource.inviters.each do |inv| - if @resource.invite_messages[inv.id.to_s] = "#{inv.real_name}:" From 645685a8fb1bf87b8f47d0d0be241a34276c5b7f Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 21 Oct 2010 23:18:53 -0700 Subject: [PATCH 21/21] Make flash notice CSS less deadly --- public/stylesheets/sass/application.sass | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 399e77afb..bffe9e526 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -59,9 +59,7 @@ h3 #flash_notice :background - :color rgba(127,255,36,0.85) - :border - :bottom solid 1px #6C6 + :color rgba(127,255,36,0.6) :text :shadow 0 1px #6C6