From aed413b4632f239fa77b46d19e7d2cb841e78788 Mon Sep 17 00:00:00 2001 From: danielgrippi Date: Fri, 13 Jan 2012 12:15:32 -0800 Subject: [PATCH 01/18] remove unused method and controller action (move_contact) --- .../aspect_memberships_controller.rb | 22 -------------- app/models/user.rb | 11 ------- config/routes.rb | 2 +- spec/models/user/querying_spec.rb | 6 ++-- spec/models/user_spec.rb | 30 +------------------ 5 files changed, 5 insertions(+), 66 deletions(-) diff --git a/app/controllers/aspect_memberships_controller.rb b/app/controllers/aspect_memberships_controller.rb index d75832bbf..89327f420 100644 --- a/app/controllers/aspect_memberships_controller.rb +++ b/app/controllers/aspect_memberships_controller.rb @@ -54,29 +54,7 @@ class AspectMembershipsController < ApplicationController end end - def update - @person = Person.find(params[:person_id]) - @from_aspect = current_user.aspects.where(:id => params[:aspect_id]).first - @to_aspect = current_user.aspects.where(:id => params[:to]).first - - response_hash = { } - - unless current_user.move_contact( @person, @to_aspect, @from_aspect) - flash[:error] = I18n.t 'aspects.move_contact.error',:inspect => params.inspect - end - if aspect = current_user.aspects.where(:id => params[:to]).first - response_hash[:notice] = I18n.t 'aspects.move_contact.success' - response_hash[:success] = true - else - response_hash[:notice] = I18n.t 'aspects.move_contact.failure' - response_hash[:success] = false - end - - render :text => response_hash.to_json - end - rescue_from ActiveRecord::StatementInvalid do render :text => "Duplicate record rejected.", :status => 400 end - end diff --git a/app/models/user.rb b/app/models/user.rb index 2b9bc2362..7c91f29bd 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -172,17 +172,6 @@ class User < ActiveRecord::Base end ######### Aspects ###################### - - def move_contact(person, to_aspect, from_aspect) - return true if to_aspect == from_aspect - contact = contact_for(person) - - add_contact_to_aspect(contact, to_aspect) - - membership = contact ? AspectMembership.where(:contact_id => contact.id, :aspect_id => from_aspect.id).first : nil - return(membership && membership.destroy) - end - def add_contact_to_aspect(contact, aspect) return true if AspectMembership.exists?(:contact_id => contact.id, :aspect_id => aspect.id) contact.aspect_memberships.create!(:aspect => aspect) diff --git a/config/routes.rb b/config/routes.rb index 99cce0ee3..b55ea95bd 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -114,7 +114,7 @@ Diaspora::Application.routes.draw do resources :contacts, :except => [:update, :create] do get :sharing, :on => :collection end - resources :aspect_memberships, :only => [:destroy, :create, :update] + resources :aspect_memberships, :only => [:destroy, :create] resources :share_visibilities, :only => [:update] resources :blocks, :only => [:create, :destroy] diff --git a/spec/models/user/querying_spec.rb b/spec/models/user/querying_spec.rb index d70b9500a..a0314aa28 100644 --- a/spec/models/user/querying_spec.rb +++ b/spec/models/user/querying_spec.rb @@ -182,7 +182,7 @@ describe User do time = Time.now Time.stub(:now).and_return(time) alice.send(:prep_opts, Post, {}).should == { - :type => Stream::Base::TYPES_OF_POST_IN_STREAM, + :type => Stream::Base::TYPES_OF_POST_IN_STREAM, :order => 'created_at DESC', :limit => 15, :hidden => false, @@ -198,9 +198,9 @@ describe User do Factory(:status_message, :public => true) bob.visible_shareables(Post).count.should == 0 end + context 'with many posts' do before do - bob.move_contact(eve.person, @bobs_aspect, bob.aspects.create(:name => 'new aspect')) time_interval = 1000 time_past = 1000000 (1..25).each do |n| @@ -229,7 +229,7 @@ describe User do # It should respect the order option opts = {:order => 'updated_at DESC'} bob.visible_shareables(Post, opts).first.updated_at.should > bob.visible_shareables(Post, opts).last.updated_at - + # It should respect the limit option opts = {:limit => 40} bob.visible_shareables(Post, opts).length.should == 40 diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index ff6269599..c2b513d19 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -708,34 +708,6 @@ describe User do alice.add_contact_to_aspect(@contact, @original_aspect).should be_true end end - - context 'moving and removing posts' do - describe 'User#move_contact' do - it 'should be able to move a contact from one of users existing aspects to another' do - alice.move_contact(bob.person, @new_aspect, @original_aspect) - - @original_aspect.contacts(true).include?(@contact).should be_false - @new_aspect.contacts(true).include?(@contact).should be_true - end - - it "should not move a person who is not a contact" do - non_contact = eve.person - - expect { - alice.move_contact(non_contact, @new_aspect, @original_aspect) - }.to raise_error - - @original_aspect.contacts.where(:person_id => non_contact.id).should be_empty - @new_aspect.contacts.where(:person_id => non_contact.id).should be_empty - end - - it 'does not try to delete if add person did not go through' do - alice.should_receive(:add_contact_to_aspect).and_return(false) - alice.should_not_receive(:delete_person_from_aspect) - alice.move_contact(bob.person, @new_aspect, @original_aspect) - end - end - end end context 'likes' do @@ -1000,7 +972,7 @@ describe User do user.should_not_receive(:generate_reset_password_token) user.send_reset_password_instructions end - + it "queues up a job to send the reset password instructions" do user = Factory :user Resque.should_receive(:enqueue).with(Jobs::ResetPassword, user.id) From e1edef9ff10a8912211469f8e1d446c7fc77a64a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonne=20Ha=C3=9F?= Date: Fri, 13 Jan 2012 22:08:44 +0100 Subject: [PATCH 02/18] lets see how all this markdown in the title looks. Attempt to fix #2395 --- app/helpers/posts_helper.rb | 19 +++++++++++++++++++ app/views/posts/show.html.haml | 3 +++ config/locales/diaspora/en.yml | 8 ++++++++ 3 files changed, 30 insertions(+) create mode 100644 app/helpers/posts_helper.rb diff --git a/app/helpers/posts_helper.rb b/app/helpers/posts_helper.rb new file mode 100644 index 000000000..9cc4f6897 --- /dev/null +++ b/app/helpers/posts_helper.rb @@ -0,0 +1,19 @@ +# Copyright (c) 2012, Diaspora Inc. This file is +# licensed under the Affero General Public License version 3 or later. See +# the COPYRIGHT file. + +module PostsHelper + def post_page_title(post) + if post.is_a?(Photo) + I18n.t "posts.show.photos_by", :count => 1, :author => post.status_message.author.name + elsif post.is_a?(Reshare) + I18n.t "posts.show.reshare_by", :author => post.author.name + else + if post.text.present? + truncate(post.text(:plain_text => true), :length => 20) + elsif post.photos.present? + I18n.t "posts.show.photos_by", :count => post.photos.size, :author => post.author.name + end + end + end +end diff --git a/app/views/posts/show.html.haml b/app/views/posts/show.html.haml index 9ecf343dc..d230c583c 100644 --- a/app/views/posts/show.html.haml +++ b/app/views/posts/show.html.haml @@ -2,6 +2,9 @@ -# licensed under the Affero General Public License version 3 or later. See -# the COPYRIGHT file. +- content_for :page_title do + = post_page_title @post + .span-20.append-2.prepend-2.last #main_stream.stream.status_message_show diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index 453483b00..e76e82401 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -614,6 +614,14 @@ en: destroy: "Delete" permalink: "permalink" not_found: "Sorry, we couldn't find that post." + photos_by: + zero: "No photos by %{author}" + one: "One photo by %{author}" + two: "Two photos by %{author}" + few: "%{count} photos by %{author}" + many: "%{count} photos by %{author}" + other: "%{count} photos by %{author}" + reshare_by: "Reshare by %{author}" share_visibilites: update: From 0cc0b152d7f408dd39e55ebb1a6d4ed20306e97e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonne=20Ha=C3=9F?= Date: Fri, 13 Jan 2012 22:09:07 +0100 Subject: [PATCH 03/18] do not call .photo_count on a reshare etc. --- app/models/post.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/post.rb b/app/models/post.rb index 387ce465e..2cdfa5fd3 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -36,7 +36,7 @@ class Post < ActiveRecord::Base t.add :user_like t.add :mentioned_people t.add lambda { |post| - if post.photos_count > 0 + if post.respond_to?(:photos) && post.photos_count > 0 post.photos else [] From 2cbfe75686c5b1336fd8be5a1c89e37fa9eeaa25 Mon Sep 17 00:00:00 2001 From: Maxwell Salzberg Date: Fri, 13 Jan 2012 13:34:04 -0800 Subject: [PATCH 04/18] make this spec WIP, as there is a larger problem with hidden posts that is addressed in teh hidden posts branch that is soon to be merged in --- features/posts_from_main_page.feature | 3 +++ 1 file changed, 3 insertions(+) diff --git a/features/posts_from_main_page.feature b/features/posts_from_main_page.feature index c749c2a24..251b782aa 100644 --- a/features/posts_from_main_page.feature +++ b/features/posts_from_main_page.feature @@ -99,6 +99,7 @@ Feature: posting from the main page Then I should see an uploaded image within the photo drop zone And the publisher should be expanded + @wip Scenario: hide a contact's post Given I expand the publisher When I fill in "status_message_fake_text" with "Here is a post for you to hide" @@ -114,8 +115,10 @@ Feature: posting from the main page And I click to delete the first post And I wait for the ajax to finish And I go to "bob@bob.bob"'s page + And I wait for the ajax to finish Then I should not see "Here is a post for you to hide" When I am on the aspects page + And I wait for the ajax to finish Then I should not see "Here is a post for you to hide" Scenario: delete one of my posts From 26aff017df4be40407ad93fb617198caae39516a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonne=20Ha=C3=9F?= Date: Fri, 13 Jan 2012 22:44:03 +0100 Subject: [PATCH 05/18] do not call pphotos on a non StatusMessage in the page title helper either --- app/helpers/posts_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/posts_helper.rb b/app/helpers/posts_helper.rb index 9cc4f6897..1944752df 100644 --- a/app/helpers/posts_helper.rb +++ b/app/helpers/posts_helper.rb @@ -11,7 +11,7 @@ module PostsHelper else if post.text.present? truncate(post.text(:plain_text => true), :length => 20) - elsif post.photos.present? + elsif post.respond_to?(:photos) && post.photos.present? I18n.t "posts.show.photos_by", :count => post.photos.size, :author => post.author.name end end From 9a9cc8d8260cd2cdc3308ffa5832827d5a298b2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonne=20Ha=C3=9F?= Date: Fri, 13 Jan 2012 22:46:16 +0100 Subject: [PATCH 06/18] remove spec for aspect_memberships#update too (move_contact) --- .../controllers/aspect_memberships_controller_spec.rb | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/spec/controllers/aspect_memberships_controller_spec.rb b/spec/controllers/aspect_memberships_controller_spec.rb index fcbb6c24e..ea7a42076 100644 --- a/spec/controllers/aspect_memberships_controller_spec.rb +++ b/spec/controllers/aspect_memberships_controller_spec.rb @@ -124,15 +124,4 @@ describe AspectMembershipsController do end end end - - describe "#update" do - it 'calls the move_contact method' do - @controller.stub!(:current_user).and_return(alice) - alice.should_receive(:move_contact) - put :update, :id => 123, - :person_id => alice.person.id, - :aspect_id => @aspect0.id, - :to => @aspect1.id - end - end end From efe55f395d7930d5592dd1bfe08072e6bf755a66 Mon Sep 17 00:00:00 2001 From: danielgrippi Date: Fri, 13 Jan 2012 13:39:32 -0800 Subject: [PATCH 07/18] remove ajax_stream? logic from streams now that we're using backbone & never ajaxing on mobile; remove unreferenced community_spotlight stream & controller --- .../community_spotlight_controller.rb | 7 ---- app/helpers/stream_helper.rb | 24 ++++++------- config/routes.rb | 2 -- lib/stream/aspect.rb | 10 ------ lib/stream/base.rb | 6 ---- lib/stream/community_spotlight.rb | 29 --------------- lib/stream/multi.rb | 5 --- lib/stream/public.rb | 1 - .../community_spotlight_controller_spec.rb | 11 ------ spec/helpers/stream_helper_spec.rb | 11 ------ spec/lib/stream/aspect_spec.rb | 36 +------------------ spec/lib/stream/community_spotlight_spec.rb | 12 ------- spec/shared_behaviors/stream.rb | 8 ----- 13 files changed, 12 insertions(+), 150 deletions(-) delete mode 100644 app/controllers/community_spotlight_controller.rb delete mode 100644 lib/stream/community_spotlight.rb delete mode 100644 spec/controllers/community_spotlight_controller_spec.rb delete mode 100644 spec/lib/stream/community_spotlight_spec.rb diff --git a/app/controllers/community_spotlight_controller.rb b/app/controllers/community_spotlight_controller.rb deleted file mode 100644 index 837d77bdb..000000000 --- a/app/controllers/community_spotlight_controller.rb +++ /dev/null @@ -1,7 +0,0 @@ -require File.join(Rails.root, 'lib', 'stream', 'community_spotlight') - -class CommunitySpotlightController < ApplicationController - def index - default_stream_action(Stream::CommunitySpotlight) - end -end diff --git a/app/helpers/stream_helper.rb b/app/helpers/stream_helper.rb index 7420e7cb4..44b882380 100644 --- a/app/helpers/stream_helper.rb +++ b/app/helpers/stream_helper.rb @@ -5,34 +5,32 @@ module StreamHelper def next_page_path(opts ={}) if controller.instance_of?(TagsController) - tag_path(:name => @stream.tag_name, :max_time => time_for_scroll(opts[:ajax_stream], @stream)) + tag_path(:name => @stream.tag_name, :max_time => time_for_scroll(@stream)) elsif controller.instance_of?(AppsController) "/apps/1?#{{:max_time => @posts.last.created_at.to_i}.to_param}" elsif controller.instance_of?(PeopleController) - local_or_remote_person_path(@person, :max_time => time_for_scroll(opts[:ajax_stream], @stream)) + local_or_remote_person_path(@person, :max_time => time_for_scroll(@stream)) elsif controller.instance_of?(TagFollowingsController) - tag_followings_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream)) - elsif controller.instance_of?(CommunitySpotlightController) - spotlight_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream)) + tag_followings_path(:max_time => time_for_scroll(@stream)) elsif controller.instance_of?(MentionsController) - mentions_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream)) + mentions_path(:max_time => time_for_scroll(@stream)) elsif controller.instance_of?(MultisController) - multi_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream)) + multi_path(:max_time => time_for_scroll(@stream)) elsif controller.instance_of?(PostsController) - public_stream_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream)) + public_stream_path(:max_time => time_for_scroll(@stream)) elsif controller.instance_of?(AspectsController) - aspects_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :a_ids => @stream.aspect_ids) + aspects_path(:max_time => time_for_scroll(@stream), :a_ids => @stream.aspect_ids) elsif controller.instance_of?(LikeStreamController) - like_stream_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream)) + like_stream_path(:max_time => time_for_scroll(@stream)) elsif controller.instance_of?(CommentStreamController) - comment_stream_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream)) + comment_stream_path(:max_time => time_for_scroll(@stream)) else raise 'in order to use pagination for this new controller, update next_page_path in stream helper' end end - def time_for_scroll(ajax_stream, stream) - if ajax_stream || stream.stream_posts.empty? + def time_for_scroll(stream) + if stream.stream_posts.empty? (Time.now() + 1).to_i else stream.stream_posts.last.send(stream.order.to_sym).to_i diff --git a/config/routes.rb b/config/routes.rb index b55ea95bd..e85117ea5 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -118,8 +118,6 @@ Diaspora::Application.routes.draw do resources :share_visibilities, :only => [:update] resources :blocks, :only => [:create, :destroy] - get 'spotlight' => 'community_spotlight#index', :as => 'spotlight' - get 'community_spotlight' => "contacts#spotlight", :as => 'community_spotlight' get 'stream' => "multis#index", :as => 'multi' diff --git a/lib/stream/aspect.rb b/lib/stream/aspect.rb index 3ddacf0ae..1af899132 100644 --- a/lib/stream/aspect.rb +++ b/lib/stream/aspect.rb @@ -65,16 +65,6 @@ class Stream::Aspect < Stream::Base end end - # Only ajax in the stream if all aspects are present. - # In this case, we know we're on the first page of the stream, - # as the default view for aspects/index is showing posts from - # all a user's aspects. - # - # @return [Boolean] see #for_all_aspects? - def ajax_stream? - !AppConfig[:redis_cache] && for_all_aspects? - end - # The title that will display at the top of the stream's # publisher box. # diff --git a/lib/stream/base.rb b/lib/stream/base.rb index 869c0dab6..826954183 100644 --- a/lib/stream/base.rb +++ b/lib/stream/base.rb @@ -75,12 +75,6 @@ class Stream::Base Rails.application.routes.url_helpers.contacts_path end - #helpers - # @return [Boolean] - def ajax_stream? - false - end - # @return [Boolean] def for_all_aspects? true diff --git a/lib/stream/community_spotlight.rb b/lib/stream/community_spotlight.rb deleted file mode 100644 index 340bda6c0..000000000 --- a/lib/stream/community_spotlight.rb +++ /dev/null @@ -1,29 +0,0 @@ -class Stream::CommunitySpotlight < Stream::Base - def title - "Community Spotlight doing cool stuff!" - end - - def link(opts={}) - Rails.application.routes.url_helpers.spotlight_path(opts) - end - - def contacts_title - "This week's community spotlight" - end - - def contacts_link - Rails.application.routes.url_helpers.community_spotlight_path - end - - def contacts_link_title - I18n.translate('aspects.selected_contacts.view_all_community_spotlight') - end - - def posts - Post.all_public.where(:author_id => people.map{|x| x.id}) - end - - def people - Person.community_spotlight - end -end diff --git a/lib/stream/multi.rb b/lib/stream/multi.rb index b4963306a..8e6e62cde 100644 --- a/lib/stream/multi.rb +++ b/lib/stream/multi.rb @@ -23,11 +23,6 @@ class Stream::Multi < Stream::Base end.call end - # @return [Boolean] - def ajax_stream? - false - end - #emits an enum of the groups which the post appeared # :spotlight, :aspects, :tags, :mentioned def post_from_group(post) diff --git a/lib/stream/public.rb b/lib/stream/public.rb index f5b6f421a..92efc42fd 100644 --- a/lib/stream/public.rb +++ b/lib/stream/public.rb @@ -16,7 +16,6 @@ class Stream::Public < Stream::Base @posts ||= Post.all_public end - def contacts_title I18n.translate("streams.public.contacts_title") end diff --git a/spec/controllers/community_spotlight_controller_spec.rb b/spec/controllers/community_spotlight_controller_spec.rb deleted file mode 100644 index 75c6da0b6..000000000 --- a/spec/controllers/community_spotlight_controller_spec.rb +++ /dev/null @@ -1,11 +0,0 @@ -require 'spec_helper' - -describe CommunitySpotlightController do - describe "GET 'index'" do - it "should be successful" do - sign_in alice - get 'index' - response.should be_success - end - end -end diff --git a/spec/helpers/stream_helper_spec.rb b/spec/helpers/stream_helper_spec.rb index 37ba469d0..93f5d8b9d 100644 --- a/spec/helpers/stream_helper_spec.rb +++ b/spec/helpers/stream_helper_spec.rb @@ -5,15 +5,4 @@ require 'spec_helper' describe StreamHelper do - before do - @post = Factory(:status_message) - end - - describe '#next_page_path' do - it 'works for apps page' do - stub!(:controller).and_return(AppsController.new) - @posts = [Factory(:activity_streams_photo)] - next_page_path.should include '/apps/1' - end - end end diff --git a/spec/lib/stream/aspect_spec.rb b/spec/lib/stream/aspect_spec.rb index b7e96e52c..45f26fdf1 100644 --- a/spec/lib/stream/aspect_spec.rb +++ b/spec/lib/stream/aspect_spec.rb @@ -62,7 +62,7 @@ describe Stream::Aspect do stream.posts end - it 'respects ordering' do + it 'respects ordering' do stream = Stream::Aspect.new(@alice, [1,2], :order => 'created_at') @alice.should_receive(:visible_shareables).with(Post, hash_including(:order => 'created_at DESC')).and_return(stub.as_null_object) stream.posts @@ -132,40 +132,6 @@ describe Stream::Aspect do end end - describe '.ajax_stream?' do - before do - @original_value = AppConfig[:redis_cache] - @stream = Stream::Aspect.new(stub, stub) - end - - after do - AppConfig[:redis_cache] = @original_value - end - - context 'if we are not caching with redis' do - before do - AppConfig[:redis_cache] = false - end - - it 'is true if stream is for all aspects?' do - @stream.stub(:for_all_aspects?).and_return(true) - @stream.ajax_stream?.should be_true - end - - it 'is false if it is not for all aspects' do - @stream.stub(:for_all_aspects?).and_return(false) - @stream.ajax_stream?.should be_false - end - end - - context 'if we are caching with redis' do - it 'returns false' do - AppConfig[:redis_cache] = true - @stream.ajax_stream?.should be_false - end - end - end - describe 'shared behaviors' do before do @stream = Stream::Aspect.new(alice, alice.aspects.map(&:id)) diff --git a/spec/lib/stream/community_spotlight_spec.rb b/spec/lib/stream/community_spotlight_spec.rb deleted file mode 100644 index b1437c865..000000000 --- a/spec/lib/stream/community_spotlight_spec.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'spec_helper' -require File.join(Rails.root, 'spec', 'shared_behaviors', 'stream') - -describe Stream::CommunitySpotlight do - before do - @stream = Stream::CommunitySpotlight.new(Factory(:user), :max_time => Time.now, :order => 'updated_at') - end - - describe 'shared behaviors' do - it_should_behave_like 'it is a stream' - end -end diff --git a/spec/shared_behaviors/stream.rb b/spec/shared_behaviors/stream.rb index 327d1c47d..d2aea4785 100644 --- a/spec/shared_behaviors/stream.rb +++ b/spec/shared_behaviors/stream.rb @@ -27,14 +27,6 @@ describe 'Streams' do @stream.contacts_link.should_not be_nil end - it 'responds to ajax_stream' do - @stream.ajax_stream?.should_not be_nil - end - - it 'responds to ajax_stream' do - @stream.ajax_stream?.should_not be_nil - end - it 'should make the stream a time object' do @stream.max_time = 123 @stream.max_time.should be_a(Time) From c45057bd94d107e8f995e9c1426bb13d0b5ea3c7 Mon Sep 17 00:00:00 2001 From: Maxwell Salzberg Date: Fri, 13 Jan 2012 01:59:58 -0800 Subject: [PATCH 08/18] update settings logic, and heroku rake task --- Gemfile | 2 +- Gemfile.lock | 9 +++++++-- app/models/app_config.rb | 15 ++++----------- lib/tasks/heroku.rake | 10 +++++----- 4 files changed, 17 insertions(+), 19 deletions(-) diff --git a/Gemfile b/Gemfile index b5df343a6..80798761e 100644 --- a/Gemfile +++ b/Gemfile @@ -40,7 +40,7 @@ group :heroku do gem 'pg' end -gem 'settingslogic', '2.0.6' +gem 'settingslogic', :git => 'https://github.com/binarylogic/settingslogic.git' # database gem 'activerecord-import' diff --git a/Gemfile.lock b/Gemfile.lock index 6beb3d254..49bfd99df 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -40,6 +40,12 @@ GIT specs: http_accept_language (1.0.1) +GIT + remote: https://github.com/binarylogic/settingslogic.git + revision: 4884d455bf18d92723cb8190cfd2dbf87f3aafd5 + specs: + settingslogic (2.0.8) + GEM remote: http://rubygems.org/ specs: @@ -360,7 +366,6 @@ GEM ffi (~> 1.0.9) multi_json (~> 1.0.4) rubyzip - settingslogic (2.0.6) simple_oauth (0.1.5) sinatra (1.2.8) rack (~> 1.1) @@ -479,7 +484,7 @@ DEPENDENCIES ruby-oembed sass selenium-webdriver (~> 2.16.0) - settingslogic (= 2.0.6) + settingslogic! sqlite3 thin (~> 1.3.1) timecop diff --git a/app/models/app_config.rb b/app/models/app_config.rb index 88857781e..12e266bac 100644 --- a/app/models/app_config.rb +++ b/app/models/app_config.rb @@ -6,9 +6,11 @@ require 'uri' require File.join(Rails.root, 'lib', 'enviroment_configuration') class AppConfig < Settingslogic - ARRAY_VARS = [:community_spotlight, :admins] - def self.source_file_name + if ENV['application_yml'].present? + puts "using remote application.yml" + return ENV['application_yml'] + end config_file = File.join(Rails.root, "config", "application.yml") if !File.exists?(config_file) && (Rails.env == 'test' || Rails.env.include?("integration") || EnviromentConfiguration.heroku?) config_file = File.join(Rails.root, "config", "application.yml.example") @@ -121,18 +123,9 @@ HELP def self.[] (key) return self.pod_uri if key == :pod_uri - return fetch_from_env(key.to_s) if EnviromentConfiguration.heroku? super end - def fetch_from_env(key) - if ARRAY_VARS.include?(key.to_sym) - ENV[key].split(EnviromentConfiguration::ARRAY_SEPERATOR) - else - ENV[key] if ENV[key] - end - end - def self.[]= (key, value) super if key.to_sym == :pod_url diff --git a/lib/tasks/heroku.rake b/lib/tasks/heroku.rake index b786eabb1..22ddd78c7 100644 --- a/lib/tasks/heroku.rake +++ b/lib/tasks/heroku.rake @@ -12,15 +12,15 @@ namespace :heroku do application_config = YAML.load_file('config/application.yml')['production'] rescue {} application_config.delete_if { |k, v| v.nil? or v.to_s.empty? } - heroku_env = application_config.map do|key, value| - value =value.join(EnviromentConfiguration::ARRAY_SEPERATOR) if value.respond_to?(:join) + #heroku_env = application_config.map do|key, value| + #value =value.join(EnviromentConfiguration::ARRAY_SEPERATOR) if value.respond_to?(:join) - "#{key}=\"#{value}\"" - end.join(' ') + #"#{key}=\"#{value}\"" + #end.join(' ') puts "Generating and setting a new secret token" token = ActiveSupport::SecureRandom.hex(40)#reloads secret token every time you reload vars.... this expires cookies, and kinda sucks - system "#{HEROKU_CONFIG_ADD_COMMAND} #{heroku_env} SECRET_TOKEN=#{token}" + system "#{HEROKU_CONFIG_ADD_COMMAND} HEROKU=true SECRET_TOKEN=#{token}" end task :install_requirements do From 9dbe644b2521ce7e58570007ccb18b04983aaaec Mon Sep 17 00:00:00 2001 From: Maxwell Salzberg Date: Fri, 13 Jan 2012 15:03:44 -0800 Subject: [PATCH 09/18] fix app_config spec --- spec/models/app_config_spec.rb | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/spec/models/app_config_spec.rb b/spec/models/app_config_spec.rb index 69140746e..7ba7180ba 100644 --- a/spec/models/app_config_spec.rb +++ b/spec/models/app_config_spec.rb @@ -144,28 +144,6 @@ describe AppConfig do end end - context 'configurations which are arrays' do - - it 'should be set to be admins or community_spotlight' do - AppConfig::ARRAY_VARS.should =~ [:community_spotlight, :admins] - end - - context 'on heroku' do - before do - ENV['admins'] = "maxwell#{EnviromentConfiguration::ARRAY_SEPERATOR}daniel" - EnviromentConfiguration.stub(:heroku?).and_return(true) - end - - after do - EnviromentConfiguration.stub(:heroku?).and_return(false) - end - - it 'converts a string with ARRAY_SEPERATOR to an array' do - AppConfig[:admins].should be_a Array - end - end - end - describe ".pod_uri" do it "properly parses the pod_url" do AppConfig.pod_uri = nil From fedd864082fef557a2eb89665e6fd3b7714f038b Mon Sep 17 00:00:00 2001 From: Maxwell Salzberg Date: Fri, 13 Jan 2012 15:16:59 -0800 Subject: [PATCH 10/18] update heroku bundle to always include mysql --- Gemfile | 1 + Gemfile.lock | 2 ++ Procfile | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 80798761e..67348ab3e 100644 --- a/Gemfile +++ b/Gemfile @@ -38,6 +38,7 @@ end group :heroku do gem 'pg' + gem 'mysql' end gem 'settingslogic', :git => 'https://github.com/binarylogic/settingslogic.git' diff --git a/Gemfile.lock b/Gemfile.lock index 49bfd99df..66b07582a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -243,6 +243,7 @@ GEM gem_plugin (>= 0.2.3) multi_json (1.0.4) multipart-post (1.1.4) + mysql (2.8.1) mysql2 (0.2.17) net-scp (1.0.4) net-ssh (>= 1.99.1) @@ -455,6 +456,7 @@ DEPENDENCIES mobile-fu mock_redis mongrel + mysql mysql2 (= 0.2.17) newrelic_rpm nokogiri (~> 1.5.0) diff --git a/Procfile b/Procfile index e65f16603..f8e7db76b 100644 --- a/Procfile +++ b/Procfile @@ -1,3 +1,3 @@ -web: bundle exec rails s -p $PORT +web: bundle exec rails s thin -p $PORT redis: redis-server worker: QUEUE=* bundle exec rake resque:work From ca07f5b9a36a5406a3876d614356712b1f83da9e Mon Sep 17 00:00:00 2001 From: Tray Torrance Date: Fri, 13 Jan 2012 21:46:37 -0800 Subject: [PATCH 11/18] Close #2606 and address other FF 3.x deficiencies. --- app/views/layouts/application.html.haml | 11 +++++++++++ public/javascripts/ie.js | 4 ---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 6a5d085bf..cc6ddcad8 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -65,6 +65,17 @@ - if rtl? = include_stylesheets :rtl, :media => 'all' + :javascript + // Support for older browsers + if(Array.isArray === undefined) { + Array.isArray = function (arg) { + return Object.prototype.toString.call(arg) == '[object Array]'; + }; + } + if ((window.history) && (window.history.pushState === undefined)) { + window.history.pushState = function() { }; + } + = csrf_meta_tag