Skip to content

Commit

Permalink
Update rspec-instafail, test git headers
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphael Sofaer committed Mar 6, 2011
1 parent 981c37d commit e00a033
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Expand Up @@ -81,6 +81,6 @@ group :test do
gem 'webmock', :require => false
gem 'jasmine', :path => 'vendor/gems/jasmine', :require => false
gem 'mongrel', :require => false if RUBY_VERSION.include? '1.8'
gem 'rspec-instafail', :require => false
gem 'rspec-instafail', '>= 0.1.7', :require => false
gem 'fuubar'
end
4 changes: 2 additions & 2 deletions Gemfile.lock
Expand Up @@ -324,7 +324,7 @@ GEM
rspec-core (2.5.1)
rspec-expectations (2.5.0)
diff-lcs (~> 1.1.2)
rspec-instafail (0.1.6)
rspec-instafail (0.1.7)
rspec-mocks (2.5.0)
rspec-rails (2.5.0)
actionpack (~> 3.0)
Expand Down Expand Up @@ -427,7 +427,7 @@ DEPENDENCIES
rest-client (= 1.6.1)
roxml!
rspec (>= 2.0.0)
rspec-instafail
rspec-instafail (>= 0.1.7)
rspec-rails (>= 2.0.0)
ruby-debug
thin (= 1.2.8)
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/application_controller.rb
Expand Up @@ -11,7 +11,7 @@ class ApplicationController < ActionController::Base
before_filter :count_requests
before_filter :set_invites
before_filter :set_locale
before_filter :set_git_header
before_filter :set_git_header if (AppConfig[:git_update] && AppConfig[:git_revision])
before_filter :which_action_and_user
prepend_before_filter :clear_gc_stats
before_filter :set_grammatical_gender
Expand Down Expand Up @@ -43,8 +43,8 @@ def set_invites
end

def set_git_header
headers['X-Git-Update'] = GIT_UPDATE unless GIT_UPDATE.nil?
headers['X-Git-Revision'] = GIT_REVISION unless GIT_REVISION.nil?
headers['X-Git-Update'] = AppConfig[:git_update]
headers['X-Git-Revision'] = AppConfig[:git_revision]
end

def which_action_and_user
Expand Down
5 changes: 2 additions & 3 deletions app/controllers/aspects_controller.rb
Expand Up @@ -12,12 +12,11 @@ class AspectsController < ApplicationController
def index
if params[:a_ids]
@aspects = current_user.aspects.where(:id => params[:a_ids]).includes(:contacts => {:person => :profile})
@selected_contacts = @aspects.inject([]){|arr, aspect| arr.concat(aspect.contacts)}
@selected_contacts.uniq!
else
@aspects = current_user.aspects.includes(:contacts => {:person => :profile})
@selected_contacts = current_user.contacts.includes(:person => :profile)
end
@selected_contacts = @aspects.inject([]){|arr, aspect| arr.concat(aspect.contacts)}
@selected_contacts.uniq!

# redirect to signup
if (current_user.getting_started == true || @aspects.blank?) && !request.format.mobile?
Expand Down
1 change: 0 additions & 1 deletion app/helpers/sockets_helper.rb
Expand Up @@ -58,7 +58,6 @@ def action_hash(user, object, opts={})
end
rescue Exception => e
Rails.logger.error("event=socket_render status=fail user=#{user.diaspora_handle} object=#{object.id.to_s}")
raise e.original_exception if e.respond_to?(:original_exception)
raise e
end
action_hash = {:class =>object.class.to_s.underscore.pluralize, :html => v, :post_id => obj_id(object)}
Expand Down
7 changes: 2 additions & 5 deletions config/initializers/version_header.rb
Expand Up @@ -5,9 +5,6 @@

git_cmd = `git log -1 --format="%H %ci"`
if git_cmd =~ /^([\d\w]+?)\s(.+)$/
GIT_REVISION = $1
GIT_UPDATE = $2.strip
else
GIT_REVISION = nil
GIT_UPDATE = nil
AppConfig[:git_revision] = $1
AppConfig[:git_update] = $2.strip
end
40 changes: 40 additions & 0 deletions spec/controllers/application_controller_spec.rb
@@ -0,0 +1,40 @@
require 'spec_helper'

describe ApplicationController do
controller do
def user_signed_in?
nil
end
def current_user
nil
end
def index
render :nothing => true
end
end
describe '#set_git_headers' do
context 'with git info' do
before do
AppConfig[:git_update] = 'yesterday'
AppConfig[:git_revision] = '02395'
end
it 'sets the git header if there is git info' do
get :index
response.headers['X-Git-Update'].should == 'yesterday'
response.headers['X-Git-Revision'].should == '02395'
end
end
#this context is commented out because the code to do it gets applied at environment load.
#context 'without git info' do
# before do
# AppConfig.config_vars.delete(:git_update)
# AppConfig.config_vars.delete(:git_revision)
# end
# it 'does not set the headers if there is no git info' do
# get :index
# response.headers.keys.should_not include('X-Git-Update')
# response.headers.keys.should_not include('X-Git-Revision')
# end
#end
end
end
2 changes: 1 addition & 1 deletion spec/controllers/home_controller_spec.rb
Expand Up @@ -30,7 +30,7 @@
sign_in @user
@aspect0 = @user.aspects.all[0]
@aspect1 = @user.aspects.create(:name => "Yeaaaah!")
@index_params = {:a_ids => [@aspect0.id.to_s, @aspect1.id.to_s]}
@index_params = {:a_ids => [@aspect0.id.to_s, @aspect1.id.to_s]}
@user.aspects.where(:id => @index_params[:a_ids]).update_all(:open => true)
@user.save
get :show
Expand Down
6 changes: 1 addition & 5 deletions spec/intergration/receiving_spec.rb
Expand Up @@ -308,11 +308,7 @@ def receive_with_zord(user, person, xml)
end

it "should activate the Person if I initiated a request to that url" do
begin
@user1.send_contact_request_to(@user3.person, @aspect)
rescue Exception => e
raise e.original_exception
end
@user1.send_contact_request_to(@user3.person, @aspect)
request = @user3.request_from(@user1.person)
fantasy_resque do
@user3.accept_and_respond(request.id, @aspect3.id)
Expand Down

0 comments on commit e00a033

Please sign in to comment.