Update rspec-instafail, test git headers
This commit is contained in:
parent
981c37d286
commit
e00a033e9e
9 changed files with 52 additions and 21 deletions
2
Gemfile
2
Gemfile
|
|
@ -81,6 +81,6 @@ group :test do
|
||||||
gem 'webmock', :require => false
|
gem 'webmock', :require => false
|
||||||
gem 'jasmine', :path => 'vendor/gems/jasmine', :require => false
|
gem 'jasmine', :path => 'vendor/gems/jasmine', :require => false
|
||||||
gem 'mongrel', :require => false if RUBY_VERSION.include? '1.8'
|
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'
|
gem 'fuubar'
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -324,7 +324,7 @@ GEM
|
||||||
rspec-core (2.5.1)
|
rspec-core (2.5.1)
|
||||||
rspec-expectations (2.5.0)
|
rspec-expectations (2.5.0)
|
||||||
diff-lcs (~> 1.1.2)
|
diff-lcs (~> 1.1.2)
|
||||||
rspec-instafail (0.1.6)
|
rspec-instafail (0.1.7)
|
||||||
rspec-mocks (2.5.0)
|
rspec-mocks (2.5.0)
|
||||||
rspec-rails (2.5.0)
|
rspec-rails (2.5.0)
|
||||||
actionpack (~> 3.0)
|
actionpack (~> 3.0)
|
||||||
|
|
@ -427,7 +427,7 @@ DEPENDENCIES
|
||||||
rest-client (= 1.6.1)
|
rest-client (= 1.6.1)
|
||||||
roxml!
|
roxml!
|
||||||
rspec (>= 2.0.0)
|
rspec (>= 2.0.0)
|
||||||
rspec-instafail
|
rspec-instafail (>= 0.1.7)
|
||||||
rspec-rails (>= 2.0.0)
|
rspec-rails (>= 2.0.0)
|
||||||
ruby-debug
|
ruby-debug
|
||||||
thin (= 1.2.8)
|
thin (= 1.2.8)
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ class ApplicationController < ActionController::Base
|
||||||
before_filter :count_requests
|
before_filter :count_requests
|
||||||
before_filter :set_invites
|
before_filter :set_invites
|
||||||
before_filter :set_locale
|
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
|
before_filter :which_action_and_user
|
||||||
prepend_before_filter :clear_gc_stats
|
prepend_before_filter :clear_gc_stats
|
||||||
before_filter :set_grammatical_gender
|
before_filter :set_grammatical_gender
|
||||||
|
|
@ -43,8 +43,8 @@ class ApplicationController < ActionController::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_git_header
|
def set_git_header
|
||||||
headers['X-Git-Update'] = GIT_UPDATE unless GIT_UPDATE.nil?
|
headers['X-Git-Update'] = AppConfig[:git_update]
|
||||||
headers['X-Git-Revision'] = GIT_REVISION unless GIT_REVISION.nil?
|
headers['X-Git-Revision'] = AppConfig[:git_revision]
|
||||||
end
|
end
|
||||||
|
|
||||||
def which_action_and_user
|
def which_action_and_user
|
||||||
|
|
|
||||||
|
|
@ -12,12 +12,11 @@ class AspectsController < ApplicationController
|
||||||
def index
|
def index
|
||||||
if params[:a_ids]
|
if params[:a_ids]
|
||||||
@aspects = current_user.aspects.where(:id => params[:a_ids]).includes(:contacts => {:person => :profile})
|
@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
|
else
|
||||||
@aspects = current_user.aspects.includes(:contacts => {:person => :profile})
|
@aspects = current_user.aspects.includes(:contacts => {:person => :profile})
|
||||||
@selected_contacts = current_user.contacts.includes(:person => :profile)
|
|
||||||
end
|
end
|
||||||
|
@selected_contacts = @aspects.inject([]){|arr, aspect| arr.concat(aspect.contacts)}
|
||||||
|
@selected_contacts.uniq!
|
||||||
|
|
||||||
# redirect to signup
|
# redirect to signup
|
||||||
if (current_user.getting_started == true || @aspects.blank?) && !request.format.mobile?
|
if (current_user.getting_started == true || @aspects.blank?) && !request.format.mobile?
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,6 @@ module SocketsHelper
|
||||||
end
|
end
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
Rails.logger.error("event=socket_render status=fail user=#{user.diaspora_handle} object=#{object.id.to_s}")
|
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
|
raise e
|
||||||
end
|
end
|
||||||
action_hash = {:class =>object.class.to_s.underscore.pluralize, :html => v, :post_id => obj_id(object)}
|
action_hash = {:class =>object.class.to_s.underscore.pluralize, :html => v, :post_id => obj_id(object)}
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,6 @@
|
||||||
|
|
||||||
git_cmd = `git log -1 --format="%H %ci"`
|
git_cmd = `git log -1 --format="%H %ci"`
|
||||||
if git_cmd =~ /^([\d\w]+?)\s(.+)$/
|
if git_cmd =~ /^([\d\w]+?)\s(.+)$/
|
||||||
GIT_REVISION = $1
|
AppConfig[:git_revision] = $1
|
||||||
GIT_UPDATE = $2.strip
|
AppConfig[:git_update] = $2.strip
|
||||||
else
|
|
||||||
GIT_REVISION = nil
|
|
||||||
GIT_UPDATE = nil
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
40
spec/controllers/application_controller_spec.rb
Normal file
40
spec/controllers/application_controller_spec.rb
Normal file
|
|
@ -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
|
||||||
|
|
@ -308,11 +308,7 @@ describe 'a user receives a post' do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should activate the Person if I initiated a request to that url" do
|
it "should activate the Person if I initiated a request to that url" do
|
||||||
begin
|
|
||||||
@user1.send_contact_request_to(@user3.person, @aspect)
|
@user1.send_contact_request_to(@user3.person, @aspect)
|
||||||
rescue Exception => e
|
|
||||||
raise e.original_exception
|
|
||||||
end
|
|
||||||
request = @user3.request_from(@user1.person)
|
request = @user3.request_from(@user1.person)
|
||||||
fantasy_resque do
|
fantasy_resque do
|
||||||
@user3.accept_and_respond(request.id, @aspect3.id)
|
@user3.accept_and_respond(request.id, @aspect3.id)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue