diff
stringlengths
65
26.7k
message
stringlengths
7
9.92k
diff --git a/lib/super_settings/config.rb b/lib/super_settings/config.rb index abc1234..def5678 100644 --- a/lib/super_settings/config.rb +++ b/lib/super_settings/config.rb @@ -7,7 +7,7 @@ # fetch! returns the value of they key if it exists. If it does not, # it then either yields to a block if given, or throws an exception. def fetch!(param, &_block) - return value(param) if method_exists param + return self[param] if method_exists param return yield if block_given? fail SuperSettings::Error, "#{param} does not exist" @@ -23,8 +23,8 @@ end # Ruby 1.9.3 does not support the [] call. - def value(param) - @table[param.to_sym] + def [](name) + @table[name.to_sym] end end end
Use [] method from 2.0 openstruct rather than a different method name
diff --git a/lib/tankard/configuration.rb b/lib/tankard/configuration.rb index abc1234..def5678 100644 --- a/lib/tankard/configuration.rb +++ b/lib/tankard/configuration.rb @@ -8,14 +8,8 @@ def configure yield self validate_api_key! + reset_client self - end - - def reset! - Tankard::Configuration::KEYS.each do |key| - instance_variable_set(:"@#{key}", nil) - end - reset_client end private
Remove reset and have configure call reset client. allows configuration to be changed after tankard is already initialized. updating the configuration would reset the tankard client so next time it is called it is regenerated.
diff --git a/euler7.rb b/euler7.rb index abc1234..def5678 100644 --- a/euler7.rb +++ b/euler7.rb @@ -0,0 +1,33 @@+=begin + +By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. + +What is the 10 001st prime number? + +=end + +def is_prime?(n) + !(2...n).any? { |k| n % k == 0 } +end + +def next_prime(n) + n += 1 + until is_prime?(n) + n += 1 + end + n +end + +def nth_prime(n) + prime_count = 1 + k = 2 + until prime_count == n + k = next_prime(k) + prime_count += 1 + end + k +end + +# Driver tests +p nth_prime(6) == 13 +p nth_prime(10_001) == 104743
Add unoptimized solution to problem 7
diff --git a/lib/whatsapp/request/code.rb b/lib/whatsapp/request/code.rb index abc1234..def5678 100644 --- a/lib/whatsapp/request/code.rb +++ b/lib/whatsapp/request/code.rb @@ -15,10 +15,10 @@ cc: country_code, in: number, id: IDENTITY, - lg: options[:language] || 'en', - lc: (options[:locale] || 'EN').to_s.upcase, - mnc: (options[:mnc] || '000').to_s.rjust(3, ?0), - mcc: (options[:mcc] || '000').to_s.rjust(3, ?0), + lg: (options[:language] || 'en').downcase, + lc: (options[:locale] || 'EN').upcase, + mnc: options[:mnc].to_s.rjust(3, ?0), + mcc: options[:mcc].to_s.rjust(3, ?0), method: method, reason: options[:reason] || '', token: token(number.to_s)
Change named parameters to options hash
diff --git a/mysite/ruby/deploy.rb b/mysite/ruby/deploy.rb index abc1234..def5678 100644 --- a/mysite/ruby/deploy.rb +++ b/mysite/ruby/deploy.rb @@ -11,7 +11,7 @@ task :migrate do if exists?(:webserver_user) - run "sudo su #{webserver_user} -c '#{latest_release}/#{sake_path} dev/build flush=1'", :roles => :db + run "sudo -u #{webserver_user} #{latest_release}/#{sake_path} dev/build flush=1", :roles => :db else run "mkdir -p #{latest_release}/silverstripe-cache", :roles => :db run "#{latest_release}/#{sake_path} dev/build flush=1", :roles => :db @@ -20,7 +20,7 @@ # Initialise the cache, in case dev/build wasn't executed on all hosts if exists?(:webserver_user) - run "sudo su #{webserver_user} -c '#{latest_release}/#{sake_path} dev" + run "sudo -u #{webserver_user} #{latest_release}/#{sake_path} dev" end end
Change sudo su to sudo -u.
diff --git a/app/calculators/term_estimation_calculator.rb b/app/calculators/term_estimation_calculator.rb index abc1234..def5678 100644 --- a/app/calculators/term_estimation_calculator.rb +++ b/app/calculators/term_estimation_calculator.rb @@ -0,0 +1,61 @@+class TermEstimationCalculator < ConditionEstimationCalculator + + # Estimates the condition rating of an asset using approximations of + # TERM condition decay splines. The condition is only associated with + # the age of the asset + # + def calculate(asset) + + Rails.logger.debug "TERMEstimationCalculator.calculate(asset)" + + years = asset.age + + if asset.asset_type.name == 'Vehicle' + if years <= 3 + return -1.75 / 3 * years + 5 + 1.75 / 3; + else + return 3.29886 * Math.exp(-0.0178422 * years) + end + elsif asset.asset_type.name == 'Rail Car' + if years <= 2.5 + return -3.75/5 * years + 5 + 3.75/5 + else + return 4.54794 * Math.exp(-0.0204658 * years) + end + elsif asset.asset_type.name == 'Support Facility' + if years <= 18 + return 5.08593 * Math.exp(-0.0196381 * years) + elsif years <= 19 + return -2.08 / 5 * years + 11.236 + else + return 3.48719 * Math.exp(-0.0042457 * years) + end + elsif asset.asset_type.name == 'Transit Facility' + return scaled_sigmoid(6.689 - 0.255 * years) + + elsif asset.asset_type.name == 'Fixed Guideway' + return 4.94961 * Math.exp(-0.0162812 * years) + + else + # If we don't have a term curve then default to a Straight Line Estimation + slc = StraightLineEstimationCalculator.new(@policy) + return slc.calculate(asset) + end + + end + + # Estimates the last servicable year for the asset based on the last reported condition. If no + # condition has been reported, the policy year is returned + def last_servicable_year(asset) + + Rails.logger.debug "TERMEstimationCalculator.last_servicable_year(asset)" + year = asset.in_service_date.year + @policy.get_policy_item(asset).max_service_life_years + + end + + def scaled_sigmoid(val) + x = Math.exp(val) + return x / (1.0 + x) * 4 + 1 + end + +end
Add TERM condition estimation calculator
diff --git a/app/serializers/teaching_period_serializer.rb b/app/serializers/teaching_period_serializer.rb index abc1234..def5678 100644 --- a/app/serializers/teaching_period_serializer.rb +++ b/app/serializers/teaching_period_serializer.rb @@ -1,5 +1,5 @@ class TeachingPeriodSerializer < ActiveModel::Serializer - attributes :id, :period, :year, :start_date, :end_date, :active_until, :active, :breaks + attributes :id, :period, :year, :start_date, :end_date, :active_until, :active, :breaks, :units def active object.active_until > DateTime.now
FIX: Add units to teaching period serializer
diff --git a/rails/spec/requests/policies_controller_spec.rb b/rails/spec/requests/policies_controller_spec.rb index abc1234..def5678 100644 --- a/rails/spec/requests/policies_controller_spec.rb +++ b/rails/spec/requests/policies_controller_spec.rb @@ -11,11 +11,11 @@ describe "#show" do it { compare("/policy.php?id=1") } - # compare("/policy.php?id=1&display=motions") + it { compare("/policy.php?id=1&display=motions") } it { compare("/policy.php?id=1&display=editdefinition", true) } it { compare("/policy.php?id=2") } - # compare("/policy.php?id=2&display=motions") + it { compare("/policy.php?id=2&display=motions") } it { compare("/policy.php?id=2&display=editdefinition", true) } end
Enable tests for Policy => Details of votes page
diff --git a/railties/lib/rails/command/spellchecker.rb b/railties/lib/rails/command/spellchecker.rb index abc1234..def5678 100644 --- a/railties/lib/rails/command/spellchecker.rb +++ b/railties/lib/rails/command/spellchecker.rb @@ -7,50 +7,8 @@ def suggest(word, from:) if defined?(DidYouMean::SpellChecker) DidYouMean::SpellChecker.new(dictionary: from.map(&:to_s)).correct(word).first - else - from.sort_by { |w| levenshtein_distance(word, w) }.first end end - - private - # This code is based directly on the Text gem implementation. - # Copyright (c) 2006-2013 Paul Battley, Michael Neumann, Tim Fletcher. - # - # Returns a value representing the "cost" of transforming str1 into str2. - def levenshtein_distance(str1, str2) # :doc: - s = str1 - t = str2 - n = s.length - m = t.length - - return m if 0 == n - return n if 0 == m - - d = (0..m).to_a - x = nil - - # avoid duplicating an enumerable object in the loop - str2_codepoint_enumerable = str2.each_codepoint - - str1.each_codepoint.with_index do |char1, i| - e = i + 1 - - str2_codepoint_enumerable.with_index do |char2, j| - cost = (char1 == char2) ? 0 : 1 - x = [ - d[j + 1] + 1, # insertion - e + 1, # deletion - d[j] + cost # substitution - ].min - d[j] = e - e = x - end - - d[m] = x - end - - x - end end end end
Remove DidYouMean fallback for Rails::Command::Spellchecker In Ruby 2.7 DidYouMean is included as a default gem. The included version of DidYouMean (1.4.0) includes DidYouMean::Spellchecker: https://github.com/ruby/did_you_mean/blob/v1.4.0/lib/did_you_mean/spell_checker.rb As the SpellChecker is included by default, we no longer need to add a levenshtein fallback. Someone might still run Rails with DidYouMean disabled by using the --disable-did_you_mean flag. In that case we return nil as they probably don't expect suggestions.
diff --git a/spec/controllers/ci/projects_controller_spec.rb b/spec/controllers/ci/projects_controller_spec.rb index abc1234..def5678 100644 --- a/spec/controllers/ci/projects_controller_spec.rb +++ b/spec/controllers/ci/projects_controller_spec.rb @@ -9,7 +9,7 @@ # Specs for *deprecated* CI badge # describe '#badge' do - context 'user not signed in' + context 'user not signed in' do before { get(:badge, id: ci_id) } context 'project has no ci_id reference' do @@ -35,6 +35,7 @@ expect(response.status).to eq 302 end end + end context 'user signed in' do let(:user) { create(:user) }
Fix specs for deprecated CI build status badge
diff --git a/app/controllers/ask_controller.rb b/app/controllers/ask_controller.rb index abc1234..def5678 100644 --- a/app/controllers/ask_controller.rb +++ b/app/controllers/ask_controller.rb @@ -3,7 +3,7 @@ # Controller for ask.wikiedu.org search form class AskController < ApplicationController - ASK_ROOT = 'http://ask.wikiedu.org/questions/scope:all/sort:activity-desc/' + ASK_ROOT = 'http://ask.wikiedu.org/questions/scope:all/sort:relevance-desc/' def search if params[:q].blank?
Use 'relevance' sorting for ask.wikiedu.org queries This sorting has better results than sorting by activity, according to Ian and Samantha.
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index abc1234..def5678 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -9,11 +9,11 @@ def working(agent) if agent.disabled? - '<span class="label label-warning">Disabled</span>'.html_safe + link_to '<span class="label label-warning">Disabled</span>'.html_safe, agent_path(agent) elsif agent.working? '<span class="label label-success">Yes</span>'.html_safe else - link_to '<span class="label btn-danger">No</span>'.html_safe, agent_path(agent, :tab => (agent.recent_error_logs? ? 'logs' : 'details')) + link_to '<span class="label label-danger">No</span>'.html_safe, agent_path(agent, :tab => (agent.recent_error_logs? ? 'logs' : 'details')) end end end
Add 'working' link for disabled agents
diff --git a/app/models/system_activity_log.rb b/app/models/system_activity_log.rb index abc1234..def5678 100644 --- a/app/models/system_activity_log.rb +++ b/app/models/system_activity_log.rb @@ -6,5 +6,5 @@ validates :message, :category, presence: true scope :for_category, ->(category) { where(category: category) } - scope :on_date, ->(date) { where("DATE(updated_at) = ?", date) } + scope :on_date, ->(date) { where("DATE(created_at) = ?", date) } end
Change on_date lookup field to created_at for accuracy
diff --git a/lib/middleman-deploy/methods/rsync.rb b/lib/middleman-deploy/methods/rsync.rb index abc1234..def5678 100644 --- a/lib/middleman-deploy/methods/rsync.rb +++ b/lib/middleman-deploy/methods/rsync.rb @@ -17,7 +17,7 @@ def process # Append "@" to user if provided. - user = "#{self.user}@" if user && !user.empty? + user = "#{self.user}@" if self.user && !self.user.empty? dest_url = "#{user}#{host}:#{path}" flags = self.flags || '-avz'
Fix bug that user can not be specified
diff --git a/lib/omniauth/strategies/wunderlist.rb b/lib/omniauth/strategies/wunderlist.rb index abc1234..def5678 100644 --- a/lib/omniauth/strategies/wunderlist.rb +++ b/lib/omniauth/strategies/wunderlist.rb @@ -4,25 +4,46 @@ module Strategies class Wunderlist < OmniAuth::Strategies::OAuth2 option :name, 'wunderlist' + option :provider_ignores_state, true option :client_options, { site: "https://a.wunderlist.com/api", authorize_url: "https://provider.wunderlist.com/login/oauth/authorize", - token_url: "https://provider.wunderlist.com/login/oauth/access_token" + token_url: "https://provider.wunderlist.com/login/oauth/access_token", + connection_opts: { + headers: { + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + } + } } + + def request_phase + redirect client.auth_code.authorize_url + end uid { raw_info['id'] } + info do + { + email: raw_info['email'], + name: raw_info['name'] + } + end + extra do - {:raw_info => raw_info} + { raw_info: raw_info } end def raw_info access_token.options[:mode] = :query - access_token.options[:param_name] = :access_token - @raw_info ||= access_token.get('/1/user.json').parsed + @raw_info ||= access_token.get('/api/v1/user', { + headers: { + 'X-Client-ID' => ENV['CLIENT_ID'], + 'X-Access-Token' => access_token.token + } + }).parsed end - end end end
Fix headers for token and info retrieval
diff --git a/lib/woocommerce_api/resources/meta.rb b/lib/woocommerce_api/resources/meta.rb index abc1234..def5678 100644 --- a/lib/woocommerce_api/resources/meta.rb +++ b/lib/woocommerce_api/resources/meta.rb @@ -13,5 +13,6 @@ attribute :ssl_enabled, Boolean attribute :permalinks_enabled, Boolean attribute :links, Hash + attribute :generate_password, Boolean end end
Add new attribute `generate_password` according to api v3
diff --git a/Casks/handbrakecli-nightly.rb b/Casks/handbrakecli-nightly.rb index abc1234..def5678 100644 --- a/Casks/handbrakecli-nightly.rb +++ b/Casks/handbrakecli-nightly.rb @@ -1,6 +1,6 @@ cask :v1 => 'handbrakecli-nightly' do - version '6675svn' - sha256 'd64d63700af9eb77ed1e90ae4288f0f8d171657d7fb91f84d519203e9458cf44' + version '6685svn' + sha256 'c3d0633c3f486c14880532561e3e9d59c9d213445cafec7c68077110608004d5' url "http://download.handbrake.fr/nightly/HandBrake-#{version}-MacOSX.6_CLI_x86_64.dmg" homepage 'http://handbrake.fr'
Update HandbrakeCLI Nightly to v6685svn HandBrakeCLI Nightly v6685svn built 2015-01-05.
diff --git a/lib/cloud_conductor/terraform/parent.rb b/lib/cloud_conductor/terraform/parent.rb index abc1234..def5678 100644 --- a/lib/cloud_conductor/terraform/parent.rb +++ b/lib/cloud_conductor/terraform/parent.rb @@ -10,11 +10,11 @@ case cloud.type when 'aws' - @variables = %w(bootstrap_expect aws_access_key aws_secret_key aws_region ssh_key_file) + @variables = %w(bootstrap_expect aws_access_key aws_secret_key aws_region ssh_key_file ssh_username) when 'openstack' - @variables = %w(bootstrap_expect os_user_name os_tenant_name os_password os_auth_url ssh_key_file) + @variables = %w(bootstrap_expect os_user_name os_tenant_name os_password os_auth_url ssh_key_file ssh_username) when 'wakame-vdc' - @variables = %w(bootstrap_expect api_endpoint ssh_key_file) + @variables = %w(bootstrap_expect api_endpoint ssh_key_file ssh_username) end end
Add ssh_username variable when execute terraform
diff --git a/lib/cd.rb b/lib/cd.rb index abc1234..def5678 100644 --- a/lib/cd.rb +++ b/lib/cd.rb @@ -10,8 +10,8 @@ def self.all output_Cds = [] - @@all_Cds.each do |key, value| - output_Cds << value + @@all_Cds.each_value do |album| + output_Cds << album end output_Cds end @@ -23,9 +23,9 @@ def self.search_album_names(name) output_Cds = [] name = name.downcase - @@all_Cds.each do |key, value| - if key.downcase.include? name - output_Cds << value + @@all_Cds.each_value do |album| + if album.name.downcase.include? name + output_Cds << album end end output_Cds @@ -34,9 +34,9 @@ def self.search_artist_names(name) output_Cds = [] name = name.downcase - @@all_Cds.each do |key, value| - if value.artist.downcase.include? name - output_Cds << value + @@all_Cds.each_value do |album| + if album.artist.downcase.include? name + output_Cds << album end end output_Cds
Refactor variable names etc in search Cd methods.
diff --git a/spec/bundler/fetcher/compact_index_spec.rb b/spec/bundler/fetcher/compact_index_spec.rb index abc1234..def5678 100644 --- a/spec/bundler/fetcher/compact_index_spec.rb +++ b/spec/bundler/fetcher/compact_index_spec.rb @@ -0,0 +1,25 @@+# frozen_string_literal: true +require "spec_helper" + +describe Bundler::Fetcher::CompactIndex do + let(:downloader) { double(:downloader) } + let(:remote) { double(:remote, :cache_slug => "lsjdf") } + let(:display_uri) { URI("http://sample_uri.com") } + let(:compact_index) { described_class.new(downloader, remote, display_uri) } + + # Testing private method. Do not commit. + describe '#specs_for_names' do + it "has only one thread open at the end of the run" do + compact_index.specs_for_names(['lskdjf']) + + thread_count = Thread.list.select {|thread| thread.status == "run" }.count + expect(thread_count).to eq 1 + end + + it "calls worker#stop during the run" do + expect_any_instance_of(Bundler::Worker).to receive(:stop).at_least(:once) + + compact_index.specs_for_names(['lskdjf']) + end + end +end
Add test for thread issue
diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb index abc1234..def5678 100644 --- a/spec/controllers/photos_controller_spec.rb +++ b/spec/controllers/photos_controller_spec.rb @@ -0,0 +1,38 @@+# Copyright (c) 2010, Diaspora Inc. This file is +# licensed under the Affero General Public License version 3 or later. See +# the COPYRIGHT file. + +require 'spec_helper' + +describe PhotosController do + render_views + before do + @user = Factory.create(:user) + @aspect = @user.aspect(:name => "lame-os") + @album = @user.post :album, :to => @aspect.id, :name => 'things on fire' + @fixture_filename = 'button.png' + @fixture_name = File.join(File.dirname(__FILE__), '..', 'fixtures', @fixture_filename) + image = File.open(@fixture_name) + #@photo = Photo.instantiate( + # :person => @user.person, :album => @album, :user_file => image) + @photo = @user.post(:photo, :album_id => @album.id, :user_file => image, :to => @aspect.id) + sign_in :user, @user + end + + describe '#create' do + end + + describe "#update" do + it "should update the caption of a photo" do + put :update, :id => @photo.id, :photo => { :caption => "now with lasers!"} + @photo.reload.caption.should == "now with lasers!" + end + + it "doesn't overwrite random attributes" do + new_user = Factory.create :user + params = { :caption => "now with lasers!", :person_id => new_user.id} + put('update', :id => @photo.id, :photo => params) + @photo.reload.person_id.should == @user.person.id + end + end +end
Add specs for photo mass assignment
diff --git a/increments-schedule.gemspec b/increments-schedule.gemspec index abc1234..def5678 100644 --- a/increments-schedule.gemspec +++ b/increments-schedule.gemspec @@ -8,10 +8,6 @@ spec.version = Increments::Schedule::VERSION spec.authors = ["Yuji Nakayama"] spec.email = ["nkymyj@gmail.com"] - - if spec.respond_to?(:metadata) - spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com' to prevent pushes to rubygems.org, or delete to allow pushes to any server." - end spec.summary = %q{TODO: Write a short summary, because Rubygems requires one.} spec.description = %q{TODO: Write a longer description or delete this line.}
Remove allowed_push_host definition in gemspec
diff --git a/test/test_helper.rb b/test/test_helper.rb index abc1234..def5678 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -2,9 +2,8 @@ require 'rubygems' require 'bundler' +Bundler.require(:default, :development) require 'minitest/autorun' - -Bundler.require(:default, :development) unless RUBY_VERSION =~ /^1\.8/ SimpleCov.start
Fix for SimpleCov require minitest after simplecov
diff --git a/test/test_helper.rb b/test/test_helper.rb index abc1234..def5678 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -40,7 +40,7 @@ width.to_f / height end - def temp_dir(child_path = '') - File.join '/tmp/jpt', child_path + def temp_dir(*descendents) + File.join '/tmp/jpt', *descendents end end
Add unlimited descendents to temp_dir test helper
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index abc1234..def5678 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -23,4 +23,8 @@ def devise_mapping @devise_mapping ||= Devise.mappings[:user] end + + def trim_length(content, max_length) + content.length > max_length ? "#{content[0...max_length]}..." : content + end end
Add Method for Trimming Content in Views Add a helper method that can be used to trim content to a certain length in views and adds ellipses '...' if the content has been trimmed.
diff --git a/examples/timeout.rb b/examples/timeout.rb index abc1234..def5678 100644 --- a/examples/timeout.rb +++ b/examples/timeout.rb @@ -4,4 +4,4 @@ cmd = TTY::Command.new -cmd.run("while test 1; do echo 'hello'; sleep 1; done", timeout: 5) +cmd.run("while test 1; do echo 'hello'; sleep 1; done", timeout: 5, signal: :KILL)
Change example to use signal
diff --git a/db/migrate/20150402004952_create_menus_items_table.rb b/db/migrate/20150402004952_create_menus_items_table.rb index abc1234..def5678 100644 --- a/db/migrate/20150402004952_create_menus_items_table.rb +++ b/db/migrate/20150402004952_create_menus_items_table.rb @@ -0,0 +1,14 @@+class CreateMenusItemsTable < ActiveRecord::Migration + def up + create_table :menus_items, :id => false do |t| + t.references :menu + t.references :item + end + add_index :menus_items, [:menu_id, :item_id] + add_index :menus_items, :item_id + end + + def down + drop_table :menus_items + end +end
Add migration for menus_items table
diff --git a/test/integration/search_with_trait_sets_test.rb b/test/integration/search_with_trait_sets_test.rb index abc1234..def5678 100644 --- a/test/integration/search_with_trait_sets_test.rb +++ b/test/integration/search_with_trait_sets_test.rb @@ -4,7 +4,6 @@ fixtures :projects, :taxa, :trait_sets, :categorical_traits setup do Capybara.current_driver = Capybara.javascript_driver - Capybara.default_wait_time = 5 end test 'can select trait sets' do visit '/' @@ -17,11 +16,15 @@ select trait_sets(:trait_set_reproductive_sub).name, :from => 'level1_0' select 'Continuous', :from => 'trait_type_0' select 'Categorical', :from => 'trait_type_0' + # Find to force capybara to wait for javascript + find 'option', :text => categorical_traits(:categorical_trait2).name select categorical_traits(:categorical_trait2).name, :from => 'trait_name_0' select trait_sets(:trait_set_demographic).name, :from => 'level0_0' select trait_sets(:trait_set_demographic_group_size).name, :from => 'level1_0' select 'Continuous', :from => 'trait_type_0' select 'Categorical', :from => 'trait_type_0' + # Find to force capybara to wait for javascript + find 'option', :text => categorical_traits(:categorical_trait1).name select categorical_traits(:categorical_trait1).name, :from => 'trait_name_0' end end
Use find to force capybara to wait for javascript
diff --git a/lib/authlogic_cas/session.rb b/lib/authlogic_cas/session.rb index abc1234..def5678 100644 --- a/lib/authlogic_cas/session.rb +++ b/lib/authlogic_cas/session.rb @@ -9,7 +9,12 @@ module Methods def self.included(klass) klass.class_eval do - persist.reject{|cb| [:persist_by_params,:persist_by_session,:persist_by_http_auth].include?(cb.method)} + skips = [:persist_by_params,:persist_by_session,:persist_by_http_auth] + if respond_to? :skip_callback + skips.each {|cb| skip_callback :persist, cb } + else + persist.reject {|cb| skips.include?(cb.method)} + end persist :persist_by_cas, :if => :authenticating_with_cas? end end
Fix for skipping callbacks in Rails 3
diff --git a/lib/rails_config/integration/sinatra.rb b/lib/rails_config/integration/sinatra.rb index abc1234..def5678 100644 --- a/lib/rails_config/integration/sinatra.rb +++ b/lib/rails_config/integration/sinatra.rb @@ -21,7 +21,11 @@ RailsConfig.load_and_set_settings( File.join(root.to_s, "config", "settings.yml").to_s, File.join(root.to_s, "config", "settings", "#{env}.yml").to_s, - File.join(root.to_s, "config", "environments", "#{env}.yml").to_s + File.join(root.to_s, "config", "environments", "#{env}.yml").to_s, + + File.join(root.to_s, "config", "settings.local.yml").to_s, + File.join(root.to_s, "config", "settings", "#{env}.local.yml").to_s, + File.join(root.to_s, "config", "environments", "#{env}.local.yml").to_s ) inner_app.use(::RailsConfig::Rack::Reloader) if inner_app.development?
Load .local.yml files in Sinatra too. .local.yml file are loaded by default in Rails. This patches loads them in Sinatra too.
diff --git a/lib/boxcar/command/update.rb b/lib/boxcar/command/update.rb index abc1234..def5678 100644 --- a/lib/boxcar/command/update.rb +++ b/lib/boxcar/command/update.rb @@ -15,7 +15,7 @@ puts "Fetching..." FileUtils.cd('/tmp') do # Fetch - FileUtils.mkdir_p("build/#{dest}") + FileUtils.mkdir_p("build/#{dest}/log") `wget -q --no-check-certificate #{host}#{version}.zip` `unzip -q #{version}` `mv boxcar-#{version}/* build/#{dest}` @@ -28,16 +28,14 @@ end FileUtils.cd('/tmp/build') do - FileUtils.mkdir("#{dest}/log") - - # Pack puts "Packing..." `makepkg -c y /boot/extra/boxcar-#{version}.txz` - # Install puts "Installing..." `installpkg /boot/extra/boxcar-#{version}.txz >/dev/null` + end + FileUtils.cd('/tmp') do puts "Clean up..." FileUtils.rm_rf(%W(build boxcar-#{version} #{version})) end
Split cleanup to it's own cd block
diff --git a/command_line/dash_upper_i_spec.rb b/command_line/dash_upper_i_spec.rb index abc1234..def5678 100644 --- a/command_line/dash_upper_i_spec.rb +++ b/command_line/dash_upper_i_spec.rb @@ -8,4 +8,16 @@ it "adds the path to the load path ($:)" do ruby_exe(@script, options: "-I fixtures").should include("fixtures") end + + it "adds the path at the front of $LOAD_PATH" do + ruby_exe(@script, options: "-I fixtures").lines[0].should include("fixtures") + end + + it "adds the path expanded from CWD to $LOAD_PATH" do + ruby_exe(@script, options: "-I fixtures").lines[0].should == "#{Dir.pwd}/fixtures\n" + end + + it "expands a path from CWD even if it does not exist" do + ruby_exe(@script, options: "-I not_exist/not_exist").lines[0].should == "#{Dir.pwd}/not_exist/not_exist\n" + end end
Add more specs for -I include_dir
diff --git a/lib/danger/ci_source/surf.rb b/lib/danger/ci_source/surf.rb index abc1234..def5678 100644 --- a/lib/danger/ci_source/surf.rb +++ b/lib/danger/ci_source/surf.rb @@ -0,0 +1,24 @@+# http://github.com/surf-build/surf + +module Danger + module CISource + class Surf < CI + def self.validates?(env) + return ['SURF_REPO', 'SURF_NWO'].all? {|x| env[x]} + end + + def supported_request_sources + @supported_request_sources ||= [Danger::RequestSources::GitHub] + end + + def initialize(env) + self.repo_slug = env['SURF_NWO'] + if env['SURF_PR_NUM'].to_i > 0 + self.pull_request_id = env['SURF_PR_NUM'] + end + + self.repo_url = env['SURF_REPO']; + end + end + end +end
Add Surf as a CI source
diff --git a/lib/debug_extras/injector.rb b/lib/debug_extras/injector.rb index abc1234..def5678 100644 --- a/lib/debug_extras/injector.rb +++ b/lib/debug_extras/injector.rb @@ -17,7 +17,7 @@ def response_is_html? return false unless @response.headers['Content-Type'].include?('html') - tags = %w[<html <head </head <body </body </html>] + tags = %w[<html <head </head> <body </body> </html>] tags.each do |tag| return false unless @response.body.include? tag end
Improve tests for valid html.
diff --git a/spec/helpers/items_helper_spec.rb b/spec/helpers/items_helper_spec.rb index abc1234..def5678 100644 --- a/spec/helpers/items_helper_spec.rb +++ b/spec/helpers/items_helper_spec.rb @@ -8,16 +8,16 @@ end describe "item_tell_types" do - it "should show comma-separated list of tell types" do + it "should list multiple tell types" do item = Item.make(:best_in_slot => true, :rot => true) - item_tell_types(item).should match (/Best in Slot<\/span>, .+Rot<\/span>$/) + item_tell_types(item).should match(/Best in Slot.+Rot/) end it "should show Disenchanted for items without a buyer" do item = Item.make(:member => nil) - item_tell_types(item).should == "<span class='item_de'>Disenchanted</span>" + item_tell_types(item).should match(/Disenchanted/) end end
Fix ItemsHelper spec for latest changes.
diff --git a/spec/import-js/mock_vim_buffer.rb b/spec/import-js/mock_vim_buffer.rb index abc1234..def5678 100644 --- a/spec/import-js/mock_vim_buffer.rb +++ b/spec/import-js/mock_vim_buffer.rb @@ -8,7 +8,9 @@ end def append(index, string) - @buffer_lines.insert(index, string) + # We replace newlines with "^@" because that's what a real vim buffer will + # output if you append such a string. + @buffer_lines.insert(index, string.gsub("\n", '^@')) end def count
Make mock buffer behave more like a real buffer If you try to append a string with \n newline characters in it, a real vim buffer will output "^@" in place of the newline characters. The mock buffer that we've been using didn't do that which led to a bug fixed in https://github.com/trotzig/import-js/commit/5f91595aa4. Making the mock behave more like a real buffer will prevent us from making this mistake again. Fixes #13
diff --git a/lib/gitlab/user_extractor.rb b/lib/gitlab/user_extractor.rb index abc1234..def5678 100644 --- a/lib/gitlab/user_extractor.rb +++ b/lib/gitlab/user_extractor.rb @@ -16,12 +16,9 @@ def users return User.none unless @text.present? + return User.none if references.empty? - relations = union_relations - - return User.none unless relations.any? - - @users ||= User.from_union(relations) + @users ||= User.from_union(union_relations) end def usernames
Return early if there were no references in text
diff --git a/spec/models/badges/ashcat_spec.rb b/spec/models/badges/ashcat_spec.rb index abc1234..def5678 100644 --- a/spec/models/badges/ashcat_spec.rb +++ b/spec/models/badges/ashcat_spec.rb @@ -1,6 +1,6 @@ require 'vcr_helper' -RSpec.describe Ashcat, type: :model, skip: ENV['TRAVIS'] do +RSpec.describe Ashcat, type: :model do let(:profile) { Fabricate(:github_profile) } let(:contributor) { Fabricate(:user, github_id: profile.github_id, github: 'dhh') }
Remove skip flag from Ashcat spec
diff --git a/lib/librato/rails/railtie.rb b/lib/librato/rails/railtie.rb index abc1234..def5678 100644 --- a/lib/librato/rails/railtie.rb +++ b/lib/librato/rails/railtie.rb @@ -23,7 +23,7 @@ config.librato_rails.log_target = ::Rails.logger end - tracker.log :info, "starting up..." + tracker.log :info, "starting up (pid #{$$}, using #{config.librato_rails.config_by})..." app.middleware.use Librato::Rack, :config => config.librato_rails end
Add pid and config type to startup message
diff --git a/spec/unit/recipes/default_spec.rb b/spec/unit/recipes/default_spec.rb index abc1234..def5678 100644 --- a/spec/unit/recipes/default_spec.rb +++ b/spec/unit/recipes/default_spec.rb @@ -26,7 +26,7 @@ context 'installs modules based on attributes' do it 'includes a module recipe when specified' do - chef_run.node.set['nginx']['modules'] = ['module_http_ssl'] + chef_run.node.set['nginx']['modules'] = ['module_http_geoip'] chef_run.converge(described_recipe) expect(chef_run).to include_recipe('et_nginx::module_http_geoip')
Test module inclusion using a module we still have
diff --git a/tasks/ship-v3-buildpack/run.rb b/tasks/ship-v3-buildpack/run.rb index abc1234..def5678 100644 --- a/tasks/ship-v3-buildpack/run.rb +++ b/tasks/ship-v3-buildpack/run.rb @@ -24,7 +24,12 @@ File.write('release-artifacts/name', "v#{next_version.to_s}") File.write('release-artifacts/tag', "v#{next_version.to_s}") FileUtils.cp('buildpack/CHANGELOG', 'release-artifacts/body') - output = `buildpack/scripts/package.sh` + + output = "" + Dir.chdir('buildpack') do + output = `scripts/package.sh` + end + packaged_buildpack = /^Buildpack packaged into: (.*)$/.match(output)[1] `tar cvzf release-artifacts/#{language}-cnb-#{next_version.to_s}.tgz -C #{packaged_buildpack} .` else
Rework ship-v3 to properly use new packaging scripts Co-authored-by: Chhavi Kankaria <a45f933d80ef78816bcf302f872972e3887e5115@pivotal.io>
diff --git a/gem_tasks/yard.rake b/gem_tasks/yard.rake index abc1234..def5678 100644 --- a/gem_tasks/yard.rake +++ b/gem_tasks/yard.rake @@ -2,26 +2,30 @@ require 'yard/rake/yardoc_task' require File.expand_path(File.dirname(__FILE__) + '/../lib/cucumber/platform') +DOC_DIR = File.expand_path(File.dirname(__FILE__) + '/../doc') SITE_DIR = File.expand_path(File.dirname(__FILE__) + '/../../cucumber.github.com') API_DIR = File.join(SITE_DIR, 'api', 'cucumber', 'ruby', 'yardoc') TEMPLATE_DIR = File.expand_path(File.join(File.dirname(__FILE__), 'yard')) YARD::Templates::Engine.register_template_path(TEMPLATE_DIR) namespace :api do - task :dir do + YARD::Rake::YardocTask.new(:yard) do |yard| + yard.options = ["--out", DOC_DIR] + end + + task :sync_with_git do unless File.directory?(SITE_DIR) raise "You need to git clone git@github.com:cucumber/cucumber.github.com.git #{SITE_DIR}" end Dir.chdir(SITE_DIR) do sh 'git pull -u' - mkdir_p API_DIR end end - YARD::Rake::YardocTask.new(:yard) do |yard| - yard.options = ["--out", API_DIR] + task :copy_to_website do + rm_rf API_DIR + cp_r DOC_DIR, API_DIR end - task :yard => :dir task :release do Dir.chdir(SITE_DIR) do @@ -32,5 +36,5 @@ end desc "Generate YARD docs for Cucumber's API" - task :doc => [:yard, :release] + task :doc => [:yard, :sync_with_git, :copy_to_website, :release] end
Split up YARD doc tasks. This will make it easier to work on docs locally.
diff --git a/acts_as_shopping_cart.gemspec b/acts_as_shopping_cart.gemspec index abc1234..def5678 100644 --- a/acts_as_shopping_cart.gemspec +++ b/acts_as_shopping_cart.gemspec @@ -24,4 +24,5 @@ s.add_development_dependency "rspec" s.add_development_dependency "sqlite3" s.add_development_dependency "simplecov" + s.add_development_dependency "rake" end
Add rake to dev dependencies
diff --git a/hummingbird-rails-api/app/controllers/users_controller.rb b/hummingbird-rails-api/app/controllers/users_controller.rb index abc1234..def5678 100644 --- a/hummingbird-rails-api/app/controllers/users_controller.rb +++ b/hummingbird-rails-api/app/controllers/users_controller.rb @@ -21,10 +21,10 @@ @client = Twilio::REST::Client.new(account_sid, auth_token) end - def send_sms(deliver_to, body) + def send_sms(to, body) @client.messages.create( from: ENV['TWILIO_NUMBER'], - to: deliver_to, + to: to, body: body) end
Rename deliver_to as 'to' coinciding with decision to change the column name in the migration
diff --git a/config/software/opscode-erchef.rb b/config/software/opscode-erchef.rb index abc1234..def5678 100644 --- a/config/software/opscode-erchef.rb +++ b/config/software/opscode-erchef.rb @@ -1,5 +1,5 @@ name "opscode-erchef" -version "pc-rc-0.8.0-tag" +version "pc-rc-0.8.1-tag" dependencies ["erlang", "rsync"]
Bring in first-build fixes for erchef
diff --git a/core/lib/spree/testing_support/common_rake.rb b/core/lib/spree/testing_support/common_rake.rb index abc1234..def5678 100644 --- a/core/lib/spree/testing_support/common_rake.rb +++ b/core/lib/spree/testing_support/common_rake.rb @@ -16,15 +16,10 @@ Spree::InstallGenerator.start ["--lib_name=#{ENV['LIB_NAME']}", "--auto-accept", "--migrate=false", "--seed=false", "--sample=false", "--quiet", "--user_class=#{args[:user_class]}"] puts "Setting up dummy database..." - cmd = "bundle exec rake db:drop db:create db:migrate" - if RUBY_PLATFORM =~ /mswin/ #windows - cmd += " >nul" - else - cmd += " >/dev/null" + silence_stream(STDOUT) do + sh "bundle exec rake db:drop db:create db:migrate" end - - system(cmd) begin require "generators/#{ENV['LIB_NAME']}/install/install_generator" @@ -37,14 +32,9 @@ task :seed do |t, args| puts "Seeding ..." - cmd = "bundle exec rake db:seed RAILS_ENV=test" - if RUBY_PLATFORM =~ /mswin/ #windows - cmd += " >nul" - else - cmd += " >/dev/null" + silence_stream(STDOUT) do + sh "bundle exec rake db:seed RAILS_ENV=test" end - - system(cmd) end end
Use silence_stream to quiet output This should behave the same as before, except output any messages appearing on STDERR.
diff --git a/lib/celluloid/io/mailbox.rb b/lib/celluloid/io/mailbox.rb index abc1234..def5678 100644 --- a/lib/celluloid/io/mailbox.rb +++ b/lib/celluloid/io/mailbox.rb @@ -4,7 +4,7 @@ module IO # An alternative implementation of Celluloid::Mailbox using Wakers class Mailbox < Celluloid::Mailbox - attr_reader :reactor + attr_reader :reactor, :waker def initialize @messages = []
Add an attr_reader for Celluloid::IO::Mailbox's waker object
diff --git a/lib/multipart_post/parts.rb b/lib/multipart_post/parts.rb index abc1234..def5678 100644 --- a/lib/multipart_post/parts.rb +++ b/lib/multipart_post/parts.rb @@ -2,10 +2,17 @@ require 'parts' Parts::ParamPart.class_eval do - def build_part(boundary, name, value) + def build_part(boundary, name, value, headers = {}) part = "" part << "--#{boundary}\r\n" - part << "Content-Type: application/json\r\n" #Add the content type which isn't present in the multipart-post gem, but DocuSign requires + + # TODO (2014-02-03) jonk => multipart-post seems to allow for adding + # a configurable header, hence the headers param in the method definition + # above. However, I can't seem to figure out how to acctually get it passed + # all the way through to line 42 of the Parts module in the parts.rb file. + # So for now, we still monkeypatch the content-type in directly. + + part << "Content-Type: application/json\r\n" part << "Content-Disposition: form-data; name=\"#{name.to_s}\"\r\n" part << "\r\n" part << "#{value}\r\n"
Update monkeypatch for multipart-post to be compatible with version 2.0 Just needed to add another option to the method definition to pass along the headers hash. I made some notes in the file, but it seems like I should be able to pass along the proper content-type and remove this patch entirely, I just can't figure out exactly how multipart-post passes along the headers yet
diff --git a/lib/s3_relay/private_url.rb b/lib/s3_relay/private_url.rb index abc1234..def5678 100644 --- a/lib/s3_relay/private_url.rb +++ b/lib/s3_relay/private_url.rb @@ -0,0 +1,32 @@+module S3Relay + class PrivateUrl < S3Relay::Base + + attr_reader :expires, :path + + def initialize(public_url, options={}) + @path = URI.parse(public_url).path + @expires = (options[:expires] || 1.minute.from_now).to_i + end + + def generate + "#{endpoint}#{path}?#{params}" + end + + private + + def params + [ + "AWSAccessKeyId=#{ACCESS_KEY_ID}", + "Expires=#{expires}", + "Signature=#{signature}" + ].join("&") + end + + def signature + string = "GET\n\n\n#{expires}\n/#{BUCKET}#{path}" + hmac = OpenSSL::HMAC.digest(digest, SECRET_ACCESS_KEY, string) + CGI.escape(Base64.encode64(hmac).strip) + end + + end +end
Add PrivateUrl class to generate signed URLs.
diff --git a/lib/generators/rails_backend/install/install_generator.rb b/lib/generators/rails_backend/install/install_generator.rb index abc1234..def5678 100644 --- a/lib/generators/rails_backend/install/install_generator.rb +++ b/lib/generators/rails_backend/install/install_generator.rb @@ -1,5 +1,5 @@ class RailsBackend::InstallGenerator < Rails::Generators::Base - source_root File.expand_path('../templates', __FILE__) + source_root File.expand_path('../../../../../app', __FILE__) def create copy_applications_file '_navigation.html.erb'
Remove symbolick links and replace for the path.
diff --git a/lib/zen/package/dashboard/lib/dashboard/widget/welcome.rb b/lib/zen/package/dashboard/lib/dashboard/widget/welcome.rb index abc1234..def5678 100644 --- a/lib/zen/package/dashboard/lib/dashboard/widget/welcome.rb +++ b/lib/zen/package/dashboard/lib/dashboard/widget/welcome.rb @@ -4,6 +4,6 @@ w.name = :welcome w.title = 'dashboard.widgets.titles.welcome' w.data = lambda do |instance| - return render_view(:widget__welcome) + return render_file(__DIR__('../view/admin/dashboard/widget/welcome.xhtml')) end end
Use render_file for the "Welcome" widget. Signed-off-by: Yorick Peterse <82349cb6397bb932b4bf3561b4ea2fad50571f50@gmail.com>
diff --git a/lib/fluent/plugin/filter_script.rb b/lib/fluent/plugin/filter_script.rb index abc1234..def5678 100644 --- a/lib/fluent/plugin/filter_script.rb +++ b/lib/fluent/plugin/filter_script.rb @@ -11,7 +11,7 @@ def load_script_file(path) raise ConfigError, "Ruby script file does not exist: #{path}" unless File.exist?(path) - eval "self.instance_eval do;" + IO.read(path) + ";end" + eval "self.instance_eval do;" + IO.read(path) + ";\nend" end end end
Fix eval issue if file ends in a comment
diff --git a/lib/puppet/type/firewalld_ipset.rb b/lib/puppet/type/firewalld_ipset.rb index abc1234..def5678 100644 --- a/lib/puppet/type/firewalld_ipset.rb +++ b/lib/puppet/type/firewalld_ipset.rb @@ -26,6 +26,7 @@ newparam(:type) do desc "Type of the ipset (default: hash:ip)" defaultto "hash:ip" + newvalues(:'bitmap:ip', :'bitmap:ip,mac', :'bitmap:port', :'hash:ip', :'hash:ip,mark', :'hash:ip,port', :'hash:ip,port,ip', :'hash:ip,port,net', :'hash:mac', :'hash:net', :'hash:net,iface', :'hash:net,net', :'hash:net,port', :'hash:net,port,net', :'list:set') end newparam(:options) do
Add constraint for ipset types
diff --git a/lib/fog/core/mock.rb b/lib/fog/core/mock.rb index abc1234..def5678 100644 --- a/lib/fog/core/mock.rb +++ b/lib/fog/core/mock.rb @@ -63,6 +63,16 @@ selection end + def self.reset + providers = Fog.providers.map{|p| eval("Fog::#{p}")} + providers.select!{|m| m.constants.include?(:Compute)} + + providers.each do |provider| + next unless provider::Compute::Mock.respond_to?(:reset) + provider::Compute::Mock.reset + end + end + end end
Add a reset method to Fog::Mock that resets all providers/services.
diff --git a/lib/notes-cli/web.rb b/lib/notes-cli/web.rb index abc1234..def5678 100644 --- a/lib/notes-cli/web.rb +++ b/lib/notes-cli/web.rb @@ -24,7 +24,7 @@ # TODO: cache this somehow options = Notes::Options.defaults if flags = params[:flags] - options[:flags].concat(flags) + options[:flags] = flags end tasks = Notes::Tasks.all(options)
Replace query flags instead of concatenating This allows one to remove the default flags.
diff --git a/lib/part_time/job.rb b/lib/part_time/job.rb index abc1234..def5678 100644 --- a/lib/part_time/job.rb +++ b/lib/part_time/job.rb @@ -1,10 +1,12 @@ module PartTime module Job def self.included(klass) - klass.class_eval do - def self.perform_async(*args) - PartTime.queue.push([self, *args]) - end + klass.extend(ClassMethods) + end + + module ClassMethods + def perform_async(*args) + PartTime.queue.push([self, *args]) end end end
Extend including class instead of using class_eval
diff --git a/lib/rake/chef/dsl.rb b/lib/rake/chef/dsl.rb index abc1234..def5678 100644 --- a/lib/rake/chef/dsl.rb +++ b/lib/rake/chef/dsl.rb @@ -16,7 +16,7 @@ @chef_client.load_node @chef_client.build_node run_context = ::Chef::RunContext.new(@chef_client.node, {}, @chef_client.events) - recipe = ::Chef::Recipe.new("(rake-chef cookbook)", "(rake-chef recipe)", run_context) + recipe = ::Chef::Recipe.new("rake-chef", id, run_context) recipe.instance_eval(&block) runner = ::Chef::Runner.new(run_context) runner.converge
Use task name as recipe name in output
diff --git a/libraries/default.rb b/libraries/default.rb index abc1234..def5678 100644 --- a/libraries/default.rb +++ b/libraries/default.rb @@ -16,7 +16,7 @@ # determine config dir based on platform def mce_config_dir - if platform_family?('rhel', 'fedora') + if platform_family?('rhel', 'fedora') # rubocop: disable Style/GuardClause return '/etc/' else return '/etc/mcelog'
Disable rubocop rule for 0.36 Using a conditional here doesn't make sense
diff --git a/sql.rb b/sql.rb index abc1234..def5678 100644 --- a/sql.rb +++ b/sql.rb @@ -17,6 +17,12 @@ Db.falsey_value end + # Parse a single string value into an object using the supplied type logic. + # + # @param r [Array] an array (table) of arrays (rows), usually resulting from a database query + # @param &type_logic [Block] code that takes the first + # @raise [TypeError] if r contains more than one row or column + # @returns [Object] the return value of &type_logic on the value in r def self.parse_single_value r, &type_logic if r.nil? || r.empty? || r == [[]] || r == [[nil]] return nil @@ -28,6 +34,10 @@ yield(r) end + # Get a single integer via SQL. + # + # @param sql [String] the SQL to produce the integer + # @returns [Integer] any valid value for this Ruby type def self.get_single_int sql r = get_array(sql) parse_single_value r do @@ -35,6 +45,10 @@ end end + # Get a single time via SQL. + # + # @param sql [String] the SQL to produce the time string with timezone info + # @returns [Time] the time produced by the SQL, converted to Ruby's local time def self.get_single_time sql r = get_array(sql) parse_single_value r do
Add method docstrings to the Sql module
diff --git a/app/helpers/compare_helper.rb b/app/helpers/compare_helper.rb index abc1234..def5678 100644 --- a/app/helpers/compare_helper.rb +++ b/app/helpers/compare_helper.rb @@ -1,6 +1,8 @@ module CompareHelper def compare_to_mr_button? - params[:from].present? && params[:to].present? && + @project.merge_requests_enabled && + params[:from].present? && + params[:to].present? && @repository.branch_names.include?(params[:from]) && @repository.branch_names.include?(params[:to]) && params[:from] != params[:to] &&
Fix bug with showing create merge request button while merge request are disabled in project settings
diff --git a/app/models/poll_email_info.rb b/app/models/poll_email_info.rb index abc1234..def5678 100644 --- a/app/models/poll_email_info.rb +++ b/app/models/poll_email_info.rb @@ -40,7 +40,12 @@ end def utm_hash(args = {}) - { utm_medium: 'email', utm_campaign: 'poll_mailer', utm_source: action_name }.merge(args) + { + utm_medium: 'email', + utm_campaign: 'poll_mailer', + utm_source: action_name, + participant_token: @recipient.participation_token + }.merge(args) end private
Add participation token to utm hash
diff --git a/tests/spec/requests/cors_spec.rb b/tests/spec/requests/cors_spec.rb index abc1234..def5678 100644 --- a/tests/spec/requests/cors_spec.rb +++ b/tests/spec/requests/cors_spec.rb @@ -1,7 +1,9 @@+ + require 'net/http' require 'spec_helper' -RSpec.feature "Cross-origin requests", type: :request do +RSpec.feature "Cross-origin requests", :cors, type: :request do let(:evaluate_json_uri) { URI.join(Capybara.app_host, '/evaluate.json') } it "allows preflight requests for POSTing to evaluate.json" do
Add a tag to allow ignoring the CORS test
diff --git a/lib/active_scaffold/extensions/action_controller_rendering.rb b/lib/active_scaffold/extensions/action_controller_rendering.rb index abc1234..def5678 100644 --- a/lib/active_scaffold/extensions/action_controller_rendering.rb +++ b/lib/active_scaffold/extensions/action_controller_rendering.rb @@ -6,14 +6,10 @@ @rendering_adapter = true # recursion control # if we need an adapter, then we render the actual stuff to a string and insert it into the adapter template opts = args.blank? ? Hash.new : args.first - unless opts[:js] || opts[:formats] == [:js] || opts[:partial].blank? - render :partial => params[:adapter][1..-1], - :locals => {:payload => render_to_string(opts.merge(:layout => false), &block).html_safe}, - :use_full_path => true, :layout => false, :content_type => :html - @rendering_adapter = nil # recursion control - else - render_without_active_scaffold(*args, &block) - end + render :partial => params[:adapter][1..-1], + :locals => {:payload => render_to_string(opts.merge(:layout => false), &block).html_safe}, + :use_full_path => true, :layout => false, :content_type => :html + @rendering_adapter = nil # recursion control else render_without_active_scaffold(*args, &block) end
Revert "don't render adapter if response is js" This reverts commit f8a6288249550e948040a51f1b82b9645d35ff45. Conflicts: lib/active_scaffold/extensions/action_controller_rendering.rb
diff --git a/spec/factories/fee.rb b/spec/factories/fee.rb index abc1234..def5678 100644 --- a/spec/factories/fee.rb +++ b/spec/factories/fee.rb @@ -4,6 +4,6 @@ factory :fee do garage { FactoryGirl.create(:garage) } name Faker::Commerce.department - price Faker::Number.number(3) + price Faker::Commerce.price end end
Change type faker price generate.
diff --git a/interrogate.gemspec b/interrogate.gemspec index abc1234..def5678 100644 --- a/interrogate.gemspec +++ b/interrogate.gemspec @@ -7,7 +7,7 @@ s.version = Interrogate::VERSION s.authors = ["Morgan Brown"] s.email = ["brown.mhg@gmail.com"] - s.homepage = "https://github.com/mhgbrown/interrogate" + s.homepage = "https://github.com/discom4rt/interrogate" s.summary = "Scheme-like class predication for Ruby" s.description = "String?(\"Hello\") Interrogate attempts to bring Scheme-like class predication to Ruby. It provides an alternate syntax using Module#==="
Change gem spec to reflect new homepage url
diff --git a/mongoid-undo.gemspec b/mongoid-undo.gemspec index abc1234..def5678 100644 --- a/mongoid-undo.gemspec +++ b/mongoid-undo.gemspec @@ -13,7 +13,7 @@ gem.files = `git ls-files`.split("\n") gem.require_path = 'lib' - gem.add_dependency 'activesupport' + gem.add_dependency 'activesupport', '~> 4.2.0' gem.add_dependency 'mongoid', '~> 4.0.0' gem.add_dependency 'mongoid-paranoia', '~> 1.0.0' gem.add_dependency 'mongoid-versioning', '~> 1.0.0'
Set explicit activesupport dependency to 4.2
diff --git a/lib/beanstalk_integration_tests/other_test.rb b/lib/beanstalk_integration_tests/other_test.rb index abc1234..def5678 100644 --- a/lib/beanstalk_integration_tests/other_test.rb +++ b/lib/beanstalk_integration_tests/other_test.rb @@ -0,0 +1,17 @@+require 'beanstalk_integration_tests/test_helper' + +class OtherTest < BeanstalkIntegrationTest + + context 'Bad commands' do + + should 'return UNKNOWN_COMMAND for a variery of bad commands' do + ['', "st\r\nats", '123', 'st ats', ' stats'].each do |command| + assert_raises(Beaneater::UnknownCommandError, 'Expected bad command to raise UNKNOWN_COMMAND') do + client.transmit(command) + end + end + end + + end + +end
Test bad commands return UNKNOWN_COMMAND
diff --git a/app/jobs/update_clinical_trials.rb b/app/jobs/update_clinical_trials.rb index abc1234..def5678 100644 --- a/app/jobs/update_clinical_trials.rb +++ b/app/jobs/update_clinical_trials.rb @@ -1,13 +1,15 @@ class UpdateClinicalTrials < ApplicationJob def perform - Source.where(source_type: 'PubMed').each do |source| + Source.eager_load(:clinical_trials).where(source_type: 'PubMed').each do |source| resp = Scrapers::PubMed.call_pubmed_api(source.citation_id) clinical_trials = resp.clinical_trial_ids.uniq.map do |nct_id| ClinicalTrial.where(nct_id: nct_id).first_or_create end - source.clinical_trials = clinical_trials - source.save + if clinical_trials.sort != source.clinical_trials.sort + source.clinical_trials = clinical_trials + source.save + end sleep 1 end end
Speed up clinical trial processing
diff --git a/app/controllers/admin/server_state_controller.rb b/app/controllers/admin/server_state_controller.rb index abc1234..def5678 100644 --- a/app/controllers/admin/server_state_controller.rb +++ b/app/controllers/admin/server_state_controller.rb @@ -4,7 +4,9 @@ @autorizedIps = ServerStatus.first.ips @authorizedIps = nil if(!@authorizedIps.is_a?(Array)) if request.path_parameters['controller'] != 'admin/server_state' - render :partial => 'index_less' + render :partial => 'index' + else + render 'index_less' end end
Correct index view main render
diff --git a/app/mailers/notification_mailer.rb b/app/mailers/notification_mailer.rb index abc1234..def5678 100644 --- a/app/mailers/notification_mailer.rb +++ b/app/mailers/notification_mailer.rb @@ -9,10 +9,12 @@ mail(to: notification_subscription.email, subject: 'Confirm to get notifications') end +=begin def weekly_activity(notification_subscription) @property = notification_subscription.property mail(to: notification_subscription.email, subject: 'New Activity on CityVoice') end +=end # properties array: [{property: property_object, unsubscribe_token: '23423jfsdf', activity: [feedback_input1, feedback_input2]}] def weekly_activity2(email, properties_array)
Comment out old mailer method
diff --git a/app/models/spreadsheet_exporter.rb b/app/models/spreadsheet_exporter.rb index abc1234..def5678 100644 --- a/app/models/spreadsheet_exporter.rb +++ b/app/models/spreadsheet_exporter.rb @@ -34,7 +34,7 @@ def initialize super sheet1 = create_sheet("All Items") - sheet1 << %w(Category Description Quantity\ On\ hand SKU Value) + sheet1 << %w(itemRef Category Description Quantity\ On\ hand SKU Value) fill_sheet_with_inventory(sheet1) end @@ -45,7 +45,7 @@ sheet << [category.description] category.items.all.find_each do |item| - sheet << ["", item.description.to_s, item.current_quantity.to_s, item.sku.to_s, item.value.to_s] + sheet << ["Item-#{item.id}", "", item.description.to_s, item.current_quantity.to_s, item.sku.to_s, item.value.to_s] end end end
Add item ref to master inventory
diff --git a/features/functions/create_data.rb b/features/functions/create_data.rb index abc1234..def5678 100644 --- a/features/functions/create_data.rb +++ b/features/functions/create_data.rb @@ -25,19 +25,3 @@ borrowers: [new_borrower1] } end - -def create_deed_hash_no_mid(title_number = generate_title_number, - new_borrower1 = generate_new_borrower_no_middle) - { - title_number: title_number, - borrowers: [new_borrower1] - } -end - -def create_deed_hash_with_mid(title_number = generate_title_number, - new_borrower1 = generate_new_borrower_with_middle) - { - title_number: title_number, - borrowers: [new_borrower1] - } -end
Remove unused borrower generate functions
diff --git a/app/graphql/types/mutation_type.rb b/app/graphql/types/mutation_type.rb index abc1234..def5678 100644 --- a/app/graphql/types/mutation_type.rb +++ b/app/graphql/types/mutation_type.rb @@ -4,5 +4,6 @@ description 'The mutation root of this schema for creating or changing data.' field :UpdateDeveloper, field: UpdateDeveloper.field field :UpdateEmployer, field: Employers::UpdateEmployer.field + field :ToggleFavourite, field: Developers::ToggleFavourite.field field :EmployerFileUpload, field: Employers::FileUpload.field end
Add mutation to root mutation type
diff --git a/app/models/medical_safety_alert.rb b/app/models/medical_safety_alert.rb index abc1234..def5678 100644 --- a/app/models/medical_safety_alert.rb +++ b/app/models/medical_safety_alert.rb @@ -5,4 +5,16 @@ medical_specialism ) end + + def self.date_metadata_keys + %w( + issued_date + ) + end + + def self.metadata_name_mappings + { + "issued_date" => "Issued", + } + end end
Add issued date to medical safety alerts Add the issued date attribute to the medical safety alert date metadata in the model so that it can be shown in the frontend. This corresponds to this commit in specialist publisher: alphagov/specialist-publisher#281 The trello ticket can be found here: https://trello.com/c/QFE3nYlc/361-add-issued-date-to-medical-safety-alerts-2
diff --git a/app/policies/macro_policy/scope.rb b/app/policies/macro_policy/scope.rb index abc1234..def5678 100644 --- a/app/policies/macro_policy/scope.rb +++ b/app/policies/macro_policy/scope.rb @@ -8,9 +8,9 @@ scope.all elsif user.permissions?('ticket.agent') scope - .left_joins(:groups) - .group('macros.id') - .having(agent_having_groups) + .joins('LEFT OUTER JOIN groups_macros ON groups_macros.macro_id = macros.id') + .distinct + .where(agent_having_groups) else scope.none end @@ -19,18 +19,16 @@ private def agent_having_groups - base_query = 'SELECT Count(*) FROM groups_macros WHERE groups_macros.macro_id = macros.id' - - having = "((#{base_query}) = 0)" + no_assigned_groups = 'groups_macros.group_id IS NULL' groups = user.groups.access(:change, :create) if groups.any? groups_matcher = groups.map(&:id).join(',') - having += " OR ((#{base_query} AND groups_macros.group_id IN (#{groups_matcher})) > 0)" + return "#{no_assigned_groups} OR groups_macros.group_id IN (#{groups_matcher})" end - having + no_assigned_groups end end end
Maintenance: Simplify MacroPolicy::Scope to work without sub-selects.
diff --git a/app/serializers/task_serializer.rb b/app/serializers/task_serializer.rb index abc1234..def5678 100644 --- a/app/serializers/task_serializer.rb +++ b/app/serializers/task_serializer.rb @@ -3,7 +3,7 @@ has_one :assignment def url - project_story_task_path(project, story, id) + api_v1_project_story_task_path(project, story, id) end def project_users
Fix url path in task serializer
diff --git a/spec/controllers/middleware_server_controller_spec.rb b/spec/controllers/middleware_server_controller_spec.rb index abc1234..def5678 100644 --- a/spec/controllers/middleware_server_controller_spec.rb +++ b/spec/controllers/middleware_server_controller_spec.rb @@ -30,4 +30,18 @@ end end end + + # FIXME: should test for nested entities: %w(middleware_datasources middleware_deployments middleware_messagings) + describe '#show' do + before do + EvmSpecHelper.create_guid_miq_server_zone + end + + let(:server) { FactoryGirl.create(:middleware_server) } + let(:deployment) { FactoryGirl.create(:middleware_deployment, :middleware_server => server) } + + it "show associated server groups" do + assert_nested_list(server, [deployment], 'middleware_deployments', 'All Middleware Deployments') + end + end end
Add a sample nested list test for MiddlewareServerController.
diff --git a/lib/aggro/cluster_config.rb b/lib/aggro/cluster_config.rb index abc1234..def5678 100644 --- a/lib/aggro/cluster_config.rb +++ b/lib/aggro/cluster_config.rb @@ -21,6 +21,11 @@ def nodes @nodes ||= {}.freeze + end + + def server_node=(value) + @is_server_node = value + persist_config end def server_node?
Allow server node bool to be changed via config.
diff --git a/lib/elasticity/hive_step.rb b/lib/elasticity/hive_step.rb index abc1234..def5678 100644 --- a/lib/elasticity/hive_step.rb +++ b/lib/elasticity/hive_step.rb @@ -33,8 +33,8 @@ def to_aws_step(job_flow) args = %w(s3://elasticmapreduce/libs/hive/hive-script --run-hive-script --args) args.concat(['-f', @script]) - @variables.each do |name, value| - args.concat(['-d', "#{name}=#{value}"]) + @variables.keys.sort.each do |name| + args.concat(['-d', "#{name}=#{@variables[name]}"]) end { :name => @name,
Sort options on step creation for testability
diff --git a/lib/furnace/ssa/constant.rb b/lib/furnace/ssa/constant.rb index abc1234..def5678 100644 --- a/lib/furnace/ssa/constant.rb +++ b/lib/furnace/ssa/constant.rb @@ -1,7 +1,7 @@ module Furnace class SSA::Constant < SSA::Value - attr_reader :type - attr_reader :value + attr_accessor :type + attr_accessor :value def initialize(type, value) super()
Allow to change type and value of SSA::Constant.
diff --git a/lib/interactor/organizer.rb b/lib/interactor/organizer.rb index abc1234..def5678 100644 --- a/lib/interactor/organizer.rb +++ b/lib/interactor/organizer.rb @@ -1,5 +1,17 @@ module Interactor + # Public: Interactor::Organizer methods. Because Interactor::Organizer is a + # module, custom Interactor::Organizer classes should include + # Interactor::Organizer rather than inherit from it. + # + # Examples + # + # class MyOrganizer + # include Interactor::Organizer + # + # organizer InteractorOne, InteractorTwo + # end module Organizer + # Internal: Install Interactor::Organizer's behavior in the given class. def self.included(base) base.class_eval do include Interactor @@ -9,17 +21,59 @@ end end + # Internal: Interactor::Organizer class methods. module ClassMethods + # Public: Declare Interactors to be invoked as part of the + # Interactor::Organizer's invocation. These interactors will invoked in + # the order in which they are declared. + # + # interactors - Zero or more (or an Array of) Interactor classes. + # + # Examples + # + # class MyFirstOrganizer + # include Interactor::Organizer + # + # organize InteractorOne, InteractorTwo + # end + # + # class MySecondOrganizer + # include Interactor::Organizer + # + # organize [InteractorThree, InteractorFour] + # end + # + # Returns nothing. def organize(*interactors) @organized = interactors.flatten end + # Internal: An Array of declared Interactors to be invoked. + # + # Examples + # + # class MyOrganizer + # include Interactor::Organizer + # + # organizer InteractorOne, InteractorTwo + # end + # + # MyOrganizer.organized + # # => [InteractorOne, InteractorTwo] + # + # Returns an Array of Interactor classes or an empty Array. def organized @organized ||= [] end end + # Internal: Interactor::Organizer instance methods. module InstanceMethods + # Internal: Invoke the organized Interactors. An Interactor::Organizer is + # expected not to define its own "call" method in favor of this default + # implementation. + # + # Returns nothing. def call self.class.organized.each do |interactor| interactor.call!(context)
Add TomDoc documentation to the Interactor::Organizer module [ci skip]
diff --git a/lib/paperclip-s3/railtie.rb b/lib/paperclip-s3/railtie.rb index abc1234..def5678 100644 --- a/lib/paperclip-s3/railtie.rb +++ b/lib/paperclip-s3/railtie.rb @@ -14,7 +14,7 @@ class Railtie def self.insert in_production = false - s3_environments = ENV['S3_ENVIRONMENTS'] || ['production'] + s3_environments = ENV['S3_ENVIRONMENTS'] ? ENV['S3_ENVIRONMENTS'].split(',') : ['production'] if (defined?(Rails.env) && Rails.env) in_production = s3_environments.include?(Rails.env) elsif (defined?(RAILS_ENV) && RAILS_ENV)
Fix S3_ENVIRONMENTS to expect comma-separated list
diff --git a/lib/apostle_rails.rb b/lib/apostle_rails.rb index abc1234..def5678 100644 --- a/lib/apostle_rails.rb +++ b/lib/apostle_rails.rb @@ -1,2 +1,9 @@+require 'apostle' require "apostle_rails/version" require "apostle_rails/mailer" + +if defined?(Rails) && Rails.env.test? + Apostle.configure do |config| + config.deliver = false + end +end
Set apostle config if in rails test mode
diff --git a/lib/frisky/device.rb b/lib/frisky/device.rb index abc1234..def5678 100644 --- a/lib/frisky/device.rb +++ b/lib/frisky/device.rb @@ -5,7 +5,6 @@ module Frisky class Device - # Multicasts discovery messages to advertise its root device, any embedded # devices, and any services. def start @@ -20,9 +19,12 @@ end end - # Do advertisement - # Listen for subscribers + yield if block_given? end + end + + def stop + EM.stop if EM.reactor_running? end end end
Make control flow more manageable here.
diff --git a/lib/sprockets/rails/task.rb b/lib/sprockets/rails/task.rb index abc1234..def5678 100644 --- a/lib/sprockets/rails/task.rb +++ b/lib/sprockets/rails/task.rb @@ -12,8 +12,6 @@ # Override this task change the loaded dependencies desc "Load asset compile environment" task :environment do - # Load gems in assets group of Gemfile - Bundler.require(:assets) if defined?(Bundler) # Load full Rails environment by default Rake::Task['environment'].invoke end
Revert "Load gems of assets group before of precompile" This reverts commit bbc19aa2f54abb5dcddfc0a9bb0ec79b34bde128. The assets group doesn't exist anymore in Rails default Gemfile
diff --git a/delayed_job_active_record.gemspec b/delayed_job_active_record.gemspec index abc1234..def5678 100644 --- a/delayed_job_active_record.gemspec +++ b/delayed_job_active_record.gemspec @@ -1,17 +1,15 @@ # frozen_string_literal: true Gem::Specification.new do |spec| - spec.add_dependency "activerecord", [">= 3.0", "< 7.1"] + spec.add_dependency "activerecord", [">= 3.0", "< 8.0"] spec.add_dependency "delayed_job", [">= 3.0", "< 5"] - spec.metadata = { - "rubygems_mfa_required" => "true" - } spec.authors = ["Brian Ryckbost", "Matt Griffin", "Erik Michaels-Ober"] spec.description = "ActiveRecord backend for Delayed::Job, originally authored by Tobias Lütke" spec.email = ["bryckbost@gmail.com", "matt@griffinonline.org", "sferik@gmail.com"] spec.files = %w[CONTRIBUTING.md LICENSE.md README.md delayed_job_active_record.gemspec] + Dir["lib/**/*.rb"] spec.homepage = "http://github.com/collectiveidea/delayed_job_active_record" spec.licenses = ["MIT"] + spec.metadata = { "rubygems_mfa_required" => "true" } spec.name = "delayed_job_active_record" spec.require_paths = ["lib"] spec.summary = "ActiveRecord backend for DelayedJob"
Allow less than Active Record 8 Active Record shouldn't introduce any breaking changes until version 8
diff --git a/config/initializers/carrierwave.rb b/config/initializers/carrierwave.rb index abc1234..def5678 100644 --- a/config/initializers/carrierwave.rb +++ b/config/initializers/carrierwave.rb @@ -12,11 +12,6 @@ if Rails.env.production? config.fog_directory = 'brigade-production' elsif Rails.env.test? - config.fog_credentials = { - :provider => 'AWS', - :aws_access_key_id => 'AKIAJM7D4ASWWMB6TOTA', - :aws_secret_access_key => 'abc123' - } config.fog_directory = 'brigade-test' else config.fog_directory = 'brigade-dev'
Revert "Added aws_secret_acces_key on test for travis" This reverts commit 5918d24986c426b024bd7e7b9c4ba3ef5494210d.
diff --git a/lib/zuck/facebook/ad_set.rb b/lib/zuck/facebook/ad_set.rb index abc1234..def5678 100644 --- a/lib/zuck/facebook/ad_set.rb +++ b/lib/zuck/facebook/ad_set.rb @@ -12,15 +12,33 @@ known_keys :id, :name, :account_id, - :campaign_group_id, + :bid_amount, + :bid_info, + :buying_type, + :campaign_group_id, #DEPRECATED + :created_time, + :end_time, + :frequency_cap, + :frequency_cap_reset_period, + :is_autobid, + :lifetime_fequency_cap, + :lifetime_imps, + :optimization_goal, + :product_ad_behavior, + :promoted_object, + :rf_prediction_id, + :rtb_flag, :start_time, + :targeting, :updated_time, - :created_time, - :promoted_object + :pacing_type, + :budget_remaining, + :daily_budget, + :lifetime_budget parent_object :ad_account, as: :account_id list_path :adcampaigns # Yes, this is correct, "for legacy reasons" - connections :ad_groups, :ad_creatives + connections :ad_groups, :ad_creatives, :insights end end
Update AdSet to pull down all available v2.4 fields, add insights connection
diff --git a/Casks/spotifybeta.rb b/Casks/spotifybeta.rb index abc1234..def5678 100644 --- a/Casks/spotifybeta.rb +++ b/Casks/spotifybeta.rb @@ -1,6 +1,6 @@ cask :v1 => 'spotifybeta' do - version '1.0.0.974.ga39487e3-1439' - sha256 '55ab8ed9446654f007a8dc1782f26d836b3ddd585a6dbc36b19148f7d624c18b' + version '1.0.0.995.gcdfee982-1486' + sha256 '1de2c2a4f33ef8fbee384b0d5b04e9dde7a30540f1a627dd1dba378096a1c9ff' url "http://download.spotify.com/beta/spotify-app-#{version}.dmg" name 'Spotify Beta'
Update SpotifyBeta.app to version 1.0.0.995.gcdfee982-1486
diff --git a/lib/generators/templates/table.rb b/lib/generators/templates/table.rb index abc1234..def5678 100644 --- a/lib/generators/templates/table.rb +++ b/lib/generators/templates/table.rb @@ -1,4 +1,7 @@ class <%= class_name %>Table < TableCloth::Base + # To include actions on this table, uncomment this line + # include TableCloth::Extensions::Actions + # Define columns with the #column method # column :name, :email @@ -22,8 +25,12 @@ # Actions give you the ability to create a column for any actions you'd like to provide. # Pass a block with an arity of 2, (object, view context). # You can add as many actions as you want. + # Make sure you include the actions extension. # # actions do # action {|object| link_to "Edit", edit_object_path(object) } + # action(if: :valid?) {|object| link_to "Invalidate", invalidate_object_path(object) } # end + # + # If action provides an "if:" option, it will call that method on the object. It can also take a block with an arity of 1. end
Change instructions on actions in README.
diff --git a/lib/lotus/assets/configuration.rb b/lib/lotus/assets/configuration.rb index abc1234..def5678 100644 --- a/lib/lotus/assets/configuration.rb +++ b/lib/lotus/assets/configuration.rb @@ -10,8 +10,7 @@ end class Configuration - PATH_SEPARATOR = '/'.freeze - ASSET_TYPES = ->{Hash.new{|h,k| h[k] = Config::AssetType.new }.merge!({ + ASSET_TYPES = ->{Hash.new{|h,k| h[k] = Config::AssetType.new }.merge!({ javascript: Config::AssetType.new { tag %(<script src="%s" type="text/javascript"></script>) source %(%s.js)
Remove unused constant from Configuration
diff --git a/lib/omniauth/strategies/gitlab.rb b/lib/omniauth/strategies/gitlab.rb index abc1234..def5678 100644 --- a/lib/omniauth/strategies/gitlab.rb +++ b/lib/omniauth/strategies/gitlab.rb @@ -6,18 +6,18 @@ option :name, 'gitlab' option :client_options, { - :site => 'https://gitlab.com', - :authorize_url => '/oauth/authorize/', - :token_url => '/oauth/token/' + site: 'https://gitlab.com', + authorize_url: '/oauth/authorize/', + token_url: '/oauth/token/' } uid { raw_info["id"] } info do { - :email => raw_info["email"] - :username => raw_info["username"] - :name => raw_info["name"] + email: raw_info["email"], + username: raw_info["username"], + name: raw_info["name"] } end
Use ruby1.9 hash syntax, add commas to info hash.
diff --git a/lib/rack/insight/enable-button.rb b/lib/rack/insight/enable-button.rb index abc1234..def5678 100644 --- a/lib/rack/insight/enable-button.rb +++ b/lib/rack/insight/enable-button.rb @@ -1,47 +1,35 @@ module Rack::Insight - class EnableButton + class EnableButton < Struct.new :app, :insight include Render - MIME_TYPES = ["text/plain", "text/html", "application/xhtml+xml"] + CONTENT_TYPE_REGEX = /text\/(html|plain)|application\/xhtml\+xml/ - def initialize(app, insight) - @app = app - @insight = insight + def call(env) + status, headers, response = app.call(env) + + if okay_to_modify?(env, headers) + body = response.inject("") do |memo, part| + memo << part + memo + end + index = body.rindex("</body>") + if index + body.insert(index, render) + headers["Content-Length"] = body.bytesize.to_s + response = [body] + end + end + + [status, headers, response] end - def call(env) - @env = env - status, headers, body = @app.call(@env) - - if !body.nil? && body.respond_to?('body') && !body.body.empty? - response = Rack::Response.new(body, status, headers) - inject_button(response) if okay_to_modify?(env, response) - - response.to_a - else - # Do not inject into assets served by rails or other detritus without a body. - [status, headers, body] - end + def okay_to_modify?(env, headers) + return false unless headers["Content-Type"] =~ CONTENT_TYPE_REGEX + return !(filters.find { |filter| env["REQUEST_PATH"] =~ filter }) end - def okay_to_modify?(env, response) - return false unless response.ok? - - req = Rack::Request.new(env) - content_type, charset = response.content_type.split(";") - filters = (env['rack-insight.path_filters'] || []).map { |str| %r(^#{str}) } - filter = filters.find { |filter| env['REQUEST_PATH'] =~ filter } - - !filter && MIME_TYPES.include?(content_type) && !req.xhr? - end - - def inject_button(response) - full_body = response.body.join - full_body.sub! /<\/body>/, render + "</body>" - - response["Content-Length"] = full_body.bytesize.to_s - - response.body = [full_body] + def filters + (env["rack-insight.path_filters"] || []).map { |str| %r(^#{str}) } end def render
Complete rewrite of `EnableButton` to ensure compatibility with all other Rack apps
diff --git a/lib/stradivari/xlsx/controller.rb b/lib/stradivari/xlsx/controller.rb index abc1234..def5678 100644 --- a/lib/stradivari/xlsx/controller.rb +++ b/lib/stradivari/xlsx/controller.rb @@ -3,15 +3,15 @@ module Controller def render_xlsx(options = {}) - xlsx = render_to_string + filename = options.delete(:filename) || 'export' + filename << '.xlsx' unless filename =~ /\.xlsx$/ + + xlsx = render_to_string(options) if xlsx[-1] == "\n" # HACK FIXME bypass HAML xlsx.slice! -1 xlsx.concat "\x00".force_encoding('BINARY')*4 end - - filename = options.fetch(:filename, nil) - filename << '.xlsx' unless filename =~ /\.xlsx$/ send_data xlsx, type: :xlsx, disposition: options.fetch(:disposition, 'attachment'),
Add ability to override the XLSX template name
diff --git a/lib/tasks/spending_proposals.rake b/lib/tasks/spending_proposals.rake index abc1234..def5678 100644 --- a/lib/tasks/spending_proposals.rake +++ b/lib/tasks/spending_proposals.rake @@ -0,0 +1,16 @@+namespace :spending_proposals do + + desc "Check if there are any spending proposals in DB" + task check: :environment do + if Rails.env.production? && SpendingProposal.any? + puts "WARNING" + puts "You have spending proposals in your database." + puts "This model has been deprecated in favor of budget investments." + puts "In the next CONSUL release spending proposals will be deleted." + puts "If you do not need to keep this data, you don't have to do anything else." + print "If you would like to migrate the data from spending proposals to budget investments " + puts "please check this PR https://github.com/consul/consul/pull/3431." + end + end + +end
Add rake task to check for spending proposals
diff --git a/lib/thingfish/processor/sha256.rb b/lib/thingfish/processor/sha256.rb index abc1234..def5678 100644 --- a/lib/thingfish/processor/sha256.rb +++ b/lib/thingfish/processor/sha256.rb @@ -11,6 +11,9 @@ class Thingfish::Processor::SHA256 < Thingfish::Processor extend Loggability + # The chunk size to read + CHUNK_SIZE = 32 * 1024 + # Loggability API -- log to the :thingfish logger log_to :thingfish @@ -20,8 +23,15 @@ ### Synchronous processor API -- generate a checksum during upload. def on_request( request ) - digest = Digest::SHA256.file( request.body.path ).hexdigest - request.add_metadata( :checksum => digest ) + digest = Digest::SHA256.new + buf = '' + + while request.body.read( CHUNK_SIZE, buf ) + digest.update( buf ) + end + + request.body.rewind + request.add_metadata( :checksum => digest.hexdigest ) end end # class Thingfish::Processor::SHA256
Fix the checksum processor for IOs without a path.
diff --git a/lib/right_on/role.rb b/lib/right_on/role.rb index abc1234..def5678 100644 --- a/lib/right_on/role.rb +++ b/lib/right_on/role.rb @@ -6,7 +6,7 @@ validates_uniqueness_of :title def to_s - self.title.titleize + self.title.try(:titleize) end alias_method :name, :to_s
Handle case of new object not having title yet
diff --git a/lib/tasks/blank.rake b/lib/tasks/blank.rake index abc1234..def5678 100644 --- a/lib/tasks/blank.rake +++ b/lib/tasks/blank.rake @@ -22,5 +22,5 @@ end end - task :build => ['blank:session_config', 'auth:gen:site_key', :environment, 'db:migrate', :test] + task :build => ['blank:session_config', 'auth:gen:site_key', 'gems:install', 'db:migrate', :test] end
Make sure gems are installed prior to going forward
diff --git a/lib/tasks/rekey.rake b/lib/tasks/rekey.rake index abc1234..def5678 100644 --- a/lib/tasks/rekey.rake +++ b/lib/tasks/rekey.rake @@ -1,4 +1,6 @@ namespace :rekey do + # Generates new keys for all images, useful if you have public images + # indexed on Google that you want to get rid of. desc 'Re-key all images' task :all => :environment do @@ -9,6 +11,8 @@ tmp = SecureRandom.urlsafe_base64(4, false) break tmp unless Image.where(key: tmp).exists? end + + puts "#{ old_key } being renamed to #{ image.key }" # Rename stored thumbnails. and original by reassigning them. # Get filepaths of thumbnail and original.
Make task more verbose, comment
diff --git a/lib/tasks/setup.rake b/lib/tasks/setup.rake index abc1234..def5678 100644 --- a/lib/tasks/setup.rake +++ b/lib/tasks/setup.rake @@ -0,0 +1,19 @@+require 'SUPPORT' +require 'awesome_print' + +namespace :support do + desc "Initialize a new SUPPORT Server" + task :setup, :server_name do |t, args| + args.with_defaults(:server_name => "primary") + server = SUPPORT::Server.new(args[:server_name]) + puts "[#{server.hostname}]" + puts " Copying SSH Key..." + response = server.scp_pubkey + if response.success == true + puts " >> SSH Key successfully uploaded." + else + puts " >> There was an error uploading your SSH Key." + raise ap response + end + end +end
Add Rake Task to Setup Server