diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index d2ef55662..d19a42b57 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -3,8 +3,6 @@ # the COPYRIGHT file. module ApplicationHelper - include Rails.application.routes.url_helpers - def how_long_ago(obj) timeago(obj.created_at) end diff --git a/app/helpers/notifications_helper.rb b/app/helpers/notifications_helper.rb index 5f02020a0..6f25e8cc8 100644 --- a/app/helpers/notifications_helper.rb +++ b/app/helpers/notifications_helper.rb @@ -1,7 +1,5 @@ module NotificationsHelper include PeopleHelper - include Rails.application.routes.url_helpers - def object_link(note, actors) target_type = note.popup_translation_key diff --git a/app/helpers/people_helper.rb b/app/helpers/people_helper.rb index 40084de0b..adf89671a 100644 --- a/app/helpers/people_helper.rb +++ b/app/helpers/people_helper.rb @@ -4,15 +4,14 @@ module PeopleHelper include ERB::Util - include Rails.application.routes.url_helpers def search_header if search_query.blank? content_tag(:h2, t('people.index.no_results')) else - content_tag(:h2, :id => 'search_title') do + content_tag(:h2, :id => 'search_title') do t('people.index.results_for').html_safe + ' ' + - content_tag(:span, search_query, :class => 'term') + content_tag(:span, search_query, :class => 'term') end end end @@ -67,13 +66,13 @@ module PeopleHelper def person_href(person, opts={}) "href=\"#{local_or_remote_person_path(person, opts)}\"".html_safe end - - + + # Rails.application.routes.url_helpers is needed since this is indirectly called from a model def local_or_remote_person_path(person, opts={}) opts.merge!(:protocol => AppConfig[:pod_uri].scheme, :host => AppConfig[:pod_uri].authority) absolute = opts.delete(:absolute) - + if person.local? username = person.diaspora_handle.split('@')[0] unless username.include?('.') @@ -85,7 +84,7 @@ module PeopleHelper end end end - + if absolute return Rails.application.routes.url_helpers.person_url(person, opts) else diff --git a/config/environments/test.rb b/config/environments/test.rb index d66421502..d1ab8b3a7 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -29,7 +29,9 @@ Diaspora::Application.configure do # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test config.active_support.deprecation = :stderr - config.threadsafe! + + # fixes url helper issue in rspec + #config.threadsafe! # Use SQL instead of Active Record's schema dumper when creating the test database. # This is necessary if your schema can't be completely dumped by the schema dumper, diff --git a/spec/controllers/posts_controller_spec.rb b/spec/controllers/posts_controller_spec.rb index 468f61df0..9c97dd1c4 100644 --- a/spec/controllers/posts_controller_spec.rb +++ b/spec/controllers/posts_controller_spec.rb @@ -49,7 +49,7 @@ describe PostsController do get :show, :id => photo.id response.should be_success end - + it 'redirects if the post is missing' do get :show, :id => 1234567 response.should be_redirect @@ -94,7 +94,7 @@ describe PostsController do end it 'assumes guids less than 8 chars are ids and not guids' do - Post.should_receive(:where).with(hash_including(:id => @status.id)).and_return(Post) + Post.should_receive(:where).with(hash_including(:id => @status.id.to_s)).and_return(Post) get :show, :id => @status.id response.should be_success end diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 08cada621..271fd662b 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -5,8 +5,6 @@ require 'spec_helper' describe ApplicationHelper do - include Rails.application.routes.url_helpers - before do @user = alice @person = Factory(:person) diff --git a/spec/helpers/notifications_helper_spec.rb b/spec/helpers/notifications_helper_spec.rb index a4a09d0c5..7ce660bc1 100644 --- a/spec/helpers/notifications_helper_spec.rb +++ b/spec/helpers/notifications_helper_spec.rb @@ -3,8 +3,7 @@ require 'spec_helper' describe NotificationsHelper do include ApplicationHelper - include Rails.application.routes.url_helpers - + before do @user = Factory(:user) @person = Factory(:person) diff --git a/spec/helpers/people_helper_spec.rb b/spec/helpers/people_helper_spec.rb index e9f86c7bc..e6dc2838b 100644 --- a/spec/helpers/people_helper_spec.rb +++ b/spec/helpers/people_helper_spec.rb @@ -5,12 +5,11 @@ require 'spec_helper' describe PeopleHelper do - include Rails.application.routes.url_helpers - before do @user = alice @person = Factory(:person) end + describe "#person_image_link" do it "returns an empty string if person is nil" do person_image_link(nil).should == "" @@ -64,12 +63,12 @@ describe PeopleHelper do describe "#person_href" do it "calls local_or_remote_person_path and passes through the options" do opts = {:absolute => true} - + self.should_receive(:local_or_remote_person_path).with(@person, opts).exactly(1).times - + person_href(@person, opts) end - + it "returns a href attribute" do person_href(@person).should include "href=" end @@ -79,7 +78,7 @@ describe PeopleHelper do before do @user = Factory(:user) end - + it "links by id if there is a period in the user's username" do @user.username = "invalid.username" @user.save(:validate => false).should == true @@ -93,7 +92,7 @@ describe PeopleHelper do it 'links by username for a local user' do local_or_remote_person_path(@user.person).should == user_profile_path(:username => @user.username) end - + it 'links by id for a remote person' do local_or_remote_person_path(@person).should == person_path(@person) end diff --git a/spec/helpers/tags_helper_spec.rb b/spec/helpers/tags_helper_spec.rb index b8f3f1b15..f62edef90 100644 --- a/spec/helpers/tags_helper_spec.rb +++ b/spec/helpers/tags_helper_spec.rb @@ -5,11 +5,13 @@ describe TagsHelper do it 'returns nil if there is a @ in the query' do helper.stub(:search_query).and_return('foo@bar.com') helper.looking_for_tag_link.should be_nil - end + end + it 'returns nil if it normalizes to blank' do helper.stub(:search_query).and_return('++') helper.looking_for_tag_link.should be_nil end + it 'returns a link to the tag otherwise' do helper.stub(:search_query).and_return('foo') helper.looking_for_tag_link.should include(helper.tag_link)