diff
stringlengths
65
26.7k
message
stringlengths
7
9.92k
diff --git a/cfg/cfg_helper.rb b/cfg/cfg_helper.rb index abc1234..def5678 100644 --- a/cfg/cfg_helper.rb +++ b/cfg/cfg_helper.rb @@ -6,8 +6,12 @@ require 'yaml' def get_environment + puppet_conf = '/etc/puppetlabs/puppet/puppet.conf' + unless File.exists?(puppet_conf) + puppet_conf = '/etc/puppet/puppet.conf' + end env = ENV['SERVERSPEC_ENV'] || - ParseConfig.new('/etc/puppet/puppet.conf')['main']['environment'] + ParseConfig.new(puppet_conf)['main']['environment'] raise "Environment is not detected, try to set SERVERSPEC_ENV variable..." if env.nil? env end
PC-2552: Add support for upstream (used in PrivateCloud) puppet.conf location Signed-off-by: Igor Raits <c869b0bfe2cf1da26c2efd33f6d6d74ddcbbdd2b@gmail.com>
diff --git a/spec/lottery_picker/drawing_spec.rb b/spec/lottery_picker/drawing_spec.rb index abc1234..def5678 100644 --- a/spec/lottery_picker/drawing_spec.rb +++ b/spec/lottery_picker/drawing_spec.rb @@ -24,6 +24,12 @@ expect(drawing).to be < 49 end end + + it "each element is greater than 0" do + draw.each do |drawing| + expect(drawing).to be > 0 + end + end end end end
Add test for intergers greater than 0
diff --git a/spec/models/project_content_spec.rb b/spec/models/project_content_spec.rb index abc1234..def5678 100644 --- a/spec/models/project_content_spec.rb +++ b/spec/models/project_content_spec.rb @@ -13,4 +13,24 @@ it 'should require a description to be valid' do expect(build(:project_content, :description => nil )).to_not be_valid end + + describe "versioning" do + subject do + create(:project_content) + end + + it { is_expected.to be_versioned } + + it 'should track changes to description', versioning: true do + new_desc = "a boring old project" + subject.update!(description: new_desc) + expect(subject.previous_version.description).to_not eq(new_desc) + end + + it 'should not track changes to language', versioning: true do + new_lang = 'en' + subject.update!(language: new_lang) + expect(subject.previous_version).to be_nil + end + end end
Add Versioning Tests to Project Content
diff --git a/lib/interstate.rb b/lib/interstate.rb index abc1234..def5678 100644 --- a/lib/interstate.rb +++ b/lib/interstate.rb @@ -56,7 +56,7 @@ def perform_transition_by(event: nil, transition_to: nil, from: nil) define_method event do evaluate_transition(event, transition_to, from) - action = constantize(event).call(base_object: self) + action = constantize(event).call(object: self) action.success? ? @state_machine.next : action.error end end
Change argument name passed to interactor change to object from base_object
diff --git a/lib/local-links-manager/check_links/link_checker.rb b/lib/local-links-manager/check_links/link_checker.rb index abc1234..def5678 100644 --- a/lib/local-links-manager/check_links/link_checker.rb +++ b/lib/local-links-manager/check_links/link_checker.rb @@ -1,7 +1,7 @@ module LocalLinksManager module CheckLinks class LinkChecker - TIMEOUT = 5 + TIMEOUT = 10 REDIRECT_LIMIT = 10 def check_link(link)
Increase link check timeout to 10 seconds We have a number of sites that persitently fail link checking with a "Timeout Error" status. I've visited a few pages and found that although they are slow initally, they do render eventually. I suspect that they are low traffic pages and just need a bit of time to "warm up". These errors are frustrating as they list as broken links, but there's not much a link administrator can do about them. We had 284 pages that failed like this last night. If all of those took the maximum time to open a connection and the maximum response time, then this would increase the link checker time by about 45 minutes. Given that the link checker starts at 2am and usually finishes at approx 8:30am, I don't think this is too bad. Tim L-B and I will keep an eye on this to see if it improves matters. It's possible that we might get a really long run once in a while, but I think that's OK.
diff --git a/lib/naught/null_class_builder/commands/traceable.rb b/lib/naught/null_class_builder/commands/traceable.rb index abc1234..def5678 100644 --- a/lib/naught/null_class_builder/commands/traceable.rb +++ b/lib/naught/null_class_builder/commands/traceable.rb @@ -8,7 +8,11 @@ attr_reader :__file__, :__line__ def initialize(options={}) - backtrace = options.fetch(:caller) { Kernel.caller(3) } + backtrace = if RUBY_VERSION.to_f == 1.9 + options.fetch(:caller) { Kernel.caller(4) } + else + options.fetch(:caller) { Kernel.caller(3) } + end @__file__, line, _ = backtrace[0].split(':') @__line__ = line.to_i end
Fix specs on Ruby 1.9
diff --git a/app/jobs/solidus_subscriptions/process_installment_job.rb b/app/jobs/solidus_subscriptions/process_installment_job.rb index abc1234..def5678 100644 --- a/app/jobs/solidus_subscriptions/process_installment_job.rb +++ b/app/jobs/solidus_subscriptions/process_installment_job.rb @@ -2,7 +2,7 @@ module SolidusSubscriptions class ProcessInstallmentJob < ApplicationJob - queue_as SolidusSubscriptions.configuration.processing_queue + queue_as { SolidusSubscriptions.configuration.processing_queue } def perform(installment) Checkout.new(installment).process
Set queue on `ProcessInstallmentJob` dynamically By setting the queue through a block rather than a boot-time method call, we ensure to play nicely with configuration stubs and in other non-obvious scenarios.
diff --git a/lib/ghtorrent/refresher.rb b/lib/ghtorrent/refresher.rb index abc1234..def5678 100644 --- a/lib/ghtorrent/refresher.rb +++ b/lib/ghtorrent/refresher.rb @@ -7,18 +7,23 @@ def refresh_repo(owner, repo, db_entry) - return db_entry if Time.now.to_i - db_entry[:updated_at].to_i > 3600 * 24 + return db_entry if Time.now - db_entry[:updated_at] < 3600 * 24 etag = db_entry[:etag] url = ghurl "repos/#{owner}/#{repo}" + lu = last_updated(url, etag) + debug "Repo #{owner}/#{repo} last updated: #{lu}, db_entry: #{db_entry[:updated_at]}" - if last_updated(url, etag).to_i > db_entry[:updated_at].to_i + if lu > db_entry[:updated_at] fresh_repo = retrieve_repo(owner, repo, true) unless fresh_repo.nil? db.from(:projects). where(:id => db_entry[:id]). - update(:etag => fresh_repo['etag']) + update(:etag => fresh_repo['etag'], + :updated_at => lu) + + info "Repo #{owner}/#{repo} updated at #{lu} (etag: #{fresh_repo['etag']})" end return db[:projects].first(:id => db_entry[:id]) @@ -27,4 +32,4 @@ db_entry end end -end+end
Set the update_at field to what GitHub reports ref: #74
diff --git a/lib/tugboat/middleware/authentication_middleware.rb b/lib/tugboat/middleware/authentication_middleware.rb index abc1234..def5678 100644 --- a/lib/tugboat/middleware/authentication_middleware.rb +++ b/lib/tugboat/middleware/authentication_middleware.rb @@ -24,7 +24,7 @@ if env[:body].is_a?(Hashie::Rash) puts "\n#{RED}#{env[:body].error_message}#{CLEAR}\n\n" end - puts "Double-check your parameters and configuration (in your ~/.tugboat file)" + puts "Double-check your parameters and configuration (in your ~/.tugboat file)" if env[:status] == 401 exit 1 end end
Add a 401 guard to asking someone to check creds No point asking a user to check credentials if it gives a 500 error
diff --git a/jiraSOAP.gemspec b/jiraSOAP.gemspec index abc1234..def5678 100644 --- a/jiraSOAP.gemspec +++ b/jiraSOAP.gemspec @@ -12,14 +12,12 @@ s.homepage = 'http://github.com/Marketcircle/jiraSOAP' s.license = 'MIT' - s.require_paths = ['lib'] - s.files = Dir.glob('lib/**/*.rb') - s.test_files = Dir.glob('test/**/*') + [ 'Rakefile' ] + s.files = Dir.glob('lib/**/*.rb') + ['.yardopts', 'Rakefile'] + s.test_files = Dir.glob('test/**/*') s.extra_rdoc_files = [ 'README.markdown', 'ChangeLog', 'LICENSE.txt', - '.yardopts', 'docs/GettingStarted.markdown', 'docs/Examples.markdown' ]
Put files in correct section of gemspec
diff --git a/lib/generics/type_checker.rb b/lib/generics/type_checker.rb index abc1234..def5678 100644 --- a/lib/generics/type_checker.rb +++ b/lib/generics/type_checker.rb @@ -3,6 +3,7 @@ # TypeChecker[String].valid?("3") # true # TypeChecker[String].valid?(3) # false # TypeChecker[String].valid!(3) # exception + # TypeChecker[:to_f].valid!(3) # true class TypeChecker class WrongTypeError < StandardError end @@ -16,7 +17,12 @@ end def valid?(value) - value.is_a?(@type) + case @type + when Class + value.is_a?(@type) + when Symbol + value.respond_to?(@type) + end end def valid!(value)
Add responds to type check ----------------------------------------------------------- On branch master - Tue 6 Sep 2016 21:55:09 PDT by matrinox <geoff.lee@lendesk.com>
diff --git a/lib/hirefire/macro/resque.rb b/lib/hirefire/macro/resque.rb index abc1234..def5678 100644 --- a/lib/hirefire/macro/resque.rb +++ b/lib/hirefire/macro/resque.rb @@ -19,13 +19,19 @@ queues = queues.flatten.map(&:to_s) queues = ::Resque.queues if queues.empty? - in_queues = queues.inject(0) do |memo, queue| - memo += ::Resque.size(queue) - memo - end + redis = ::Resque.redis + decoder = ::Resque::Worker.new(:noop) - in_progress = ::Resque::Worker.all.inject(0) do |memo, worker| - memo += 1 if queues.include?(worker.job["queue"]) + ids = Array(redis.smembers(:workers)).compact + raw_jobs = redis.pipelined { ids.map { |id| redis.get("worker:#{id}") } } + jobs = raw_jobs.map { |raw_job| decoder.decode(raw_job) || {} } + + in_queues = redis.pipelined do + queues.map { |queue| redis.llen("queue:#{queue}") } + end.map(&:to_i).inject(&:+) + + in_progress = jobs.inject(0) do |memo, job| + memo += 1 if queues.include?(job["queue"]) memo end @@ -34,4 +40,3 @@ end end end -
Access Resque data through Redis directly so that we can pipeline network operations. This makes network-bound operations scalable, and they will no longer suffer from the n+1 issue.
diff --git a/lib/phpcop/cli.rb b/lib/phpcop/cli.rb index abc1234..def5678 100644 --- a/lib/phpcop/cli.rb +++ b/lib/phpcop/cli.rb @@ -3,6 +3,8 @@ # logic class CLI attr_reader :options, :config_store + + MSG_END = '%s fichier traité. %s erreurs.'.freeze def initialize @options = {} @@ -12,8 +14,7 @@ # Run all files def run(_args = ARGV) runner = PhpCop::Runner.new - puts format('%s fichier traité. %s erreurs.', - runner.count_files, runner.count_errors) + puts format(MSG_END, runner.count_files, runner.count_errors) end end end
Use constant for final message
diff --git a/lib/import/import_samples.rb b/lib/import/import_samples.rb index abc1234..def5678 100644 --- a/lib/import/import_samples.rb +++ b/lib/import/import_samples.rb @@ -9,6 +9,11 @@ rows.map do |row| molfile = Chemotion::PubchemService.molfile_from_smiles URI::encode(row[:smiles], '[]/()+-.@#=\\') molecule = Molecule.find_or_create_by_molfile(molfile) + + if molecule.nil? + raise "Import of Sample #{row[:name]}: Molecule is nil." + end + sample = Sample.create(name: row[:name], description: row[:description], molecule: molecule) CollectionsSample.create(collection_id: collection_id, sample_id: sample.id) end
Add raise to avoid import of samples without molecules
diff --git a/lib/pairwise/input_file.rb b/lib/pairwise/input_file.rb index abc1234..def5678 100644 --- a/lib/pairwise/input_file.rb +++ b/lib/pairwise/input_file.rb @@ -34,8 +34,11 @@ module Yaml def load_and_parse require 'yaml' - - inputs = YAML.load_file(@filename) + begin + inputs = YAML.load_file(@filename) + rescue + nil + end end end
Deal with nasty yaml parsing on some rubies
diff --git a/lib/potatochop.rb b/lib/potatochop.rb index abc1234..def5678 100644 --- a/lib/potatochop.rb +++ b/lib/potatochop.rb @@ -1,10 +1,16 @@ require 'potatochop/version' require 'sinatra/base' +require 'haml' module Potatochop class Web < Sinatra::Base - get '/' do - "Hello worldz." + get '/*.html' do + file_path = File.join(settings.working_dir, "#{params[:splat][0]}.html.haml") + if File.exists? file_path + Haml::Engine.new(File.read(file_path)).render + else + 404 + end end end end
Add the first draft of the haml processor
diff --git a/lib/query_string_parser.rb b/lib/query_string_parser.rb index abc1234..def5678 100644 --- a/lib/query_string_parser.rb +++ b/lib/query_string_parser.rb @@ -1,9 +1,9 @@ class QueryStringParser def self.parse(query_string) result = {} - query_string.split('&').each do |pair| - key, value = pair.split('=') - unless value.nil? + URI.decode_www_form(query_string).each do |pair| + key, value = pair + unless value.nil? || value.empty? result[key] ||= [] result[key] << value end
3342: Refactor QueryStringParser to use URI.decode_www_form Authors: 2b40485fded67597eeee301cb96e815f61af979c@chrisholmes
diff --git a/spec/models/booking_template_spec.rb b/spec/models/booking_template_spec.rb index abc1234..def5678 100644 --- a/spec/models/booking_template_spec.rb +++ b/spec/models/booking_template_spec.rb @@ -8,7 +8,7 @@ end it 'should call build_booking on the matching template' do - template = stub_model(BookingTemplate) + template = double(BookingTemplate) allow(BookingTemplate).to receive(:find_by_code).with('code').and_return(template) expect(template).to receive(:build_booking).with({:test => 55}) BookingTemplate.build_booking 'code', {:test => 55}
Use double instead of stub_model.
diff --git a/spec/models/metrics/spelling_spec.rb b/spec/models/metrics/spelling_spec.rb index abc1234..def5678 100644 --- a/spec/models/metrics/spelling_spec.rb +++ b/spec/models/metrics/spelling_spec.rb @@ -0,0 +1,29 @@+require 'spec_helper' + +describe Metrics::Spelling do + + it "#detect_language" do + record = { notes: "This is a text." } + metric = Metrics::Spelling.new + expect(metric.detect_language(record)).to eq(:english) + end + + it "should determine the number of spelling mistakes" do + record = { notes: "Is this a aaaatext?" } + metric = Metrics::Spelling.new + score, analysis = metric.compute(record) + accessor = [:notes] + expect(score).to be(0.75) + expect(analysis[accessor]).to eq({ score: 0.75, misspelled: ['aaaatext'] }) + end + + it "should also work on nested records" do + record = { resources: { description: 'This is a text.' } } + metric = Metrics::Spelling.new + score, analysis = metric.compute(record) + accessor = [:resources, :description] + expect(score).to be(1.0) + expect(analysis[accessor]).to eq({ score: 1.0, misspelled: []}) + end + +end
Add unit test for the spelling metric I have added a unit test for the spelling metric in order to make sure the refactoring works as intended. Signed-off-by: Konrad Reiche <4ff0213f56e2082fcd8c882d04c546881c579ce4@gmail.com>
diff --git a/spec/rails_app/config/application.rb b/spec/rails_app/config/application.rb index abc1234..def5678 100644 --- a/spec/rails_app/config/application.rb +++ b/spec/rails_app/config/application.rb @@ -11,6 +11,7 @@ class Application < Rails::Application config.eager_load = true config.root = File.expand_path('../../.', __FILE__) + config.consider_all_requests_local = true end end
Simplify testing by returning full error messages from test app
diff --git a/lib/vmdb/config/activator.rb b/lib/vmdb/config/activator.rb index abc1234..def5678 100644 --- a/lib/vmdb/config/activator.rb +++ b/lib/vmdb/config/activator.rb @@ -44,6 +44,11 @@ def server(data) MiqServer.my_server.config_activated(data) unless MiqServer.my_server.nil? rescue nil end + + def workers(_data) + pgl = MiqPglogical.new + pgl.refresh_excludes if pgl.provider? + end end end end
Refresh the replication set when new worker config is saved Fixes #8190 This will become more targeted when we move replication settings out of the worker config, but for now the excludes will stay there while we still support rubyrep (and the replication worker)
diff --git a/lib/burrow/client.rb b/lib/burrow/client.rb index abc1234..def5678 100644 --- a/lib/burrow/client.rb +++ b/lib/burrow/client.rb @@ -1,21 +1,13 @@ class Burrow::Client - attr_reader :message, :connection + attr_reader :connection - def initialize(queue, method, params={}) + def initialize(queue) @connection = Burrow::Connection.new(queue) - @message = Burrow::Message.new(method, params) end - def self.call(queue, method, params) - new(queue, method, params).call - end + def publish(method, params={}) + message = Burrow::Message.new(method, params) - def call - publish - subscribe - end - - def publish connection.exchange.publish( JSON.generate(message.attributes), { correlation_id: message.id, @@ -23,9 +15,7 @@ routing_key: connection.queue.name } ) - end - def subscribe response = nil connection.return_queue.subscribe(block: true) do |delivery_info, properties, payload| if properties[:correlation_id] == message.id
Bring the Client api in line with the Server
diff --git a/test/models/notifiers/pushbullet_test.rb b/test/models/notifiers/pushbullet_test.rb index abc1234..def5678 100644 --- a/test/models/notifiers/pushbullet_test.rb +++ b/test/models/notifiers/pushbullet_test.rb @@ -0,0 +1,60 @@+require 'test_helper' + +class Notifiers::PushBulletTest < ActiveSupport::TestCase + def setup + @bullet = Notifiers::Pushbullet.new + end + + test '#initialize' do + refute_nil @bullet.instance_variable_get(:@config) + end + + test 'delegate' do + assert_respond_to @bullet, :access_token + assert_respond_to @bullet, :targets + end + + test '#perform' do + @bullet.define_singleton_method(:push_link) do |notification| + notification + end + @bullet.define_singleton_method(:push_note) do |notification| + notification + end + + assert_equal @bullet.send(:perform, :link, 'msg of link'), 'msg of link' + assert_equal @bullet.send(:perform, :note, 'msg of note'), 'msg of note' + end + + test '#client' do + assert_instance_of Washbullet::Client, @bullet.send(:client) + end + + test '#devices' do + devices = [Object.new] + mock = MiniTest::Mock.new.expect(:devices, devices) + @bullet.stub(:client, mock) do + assert_equal @bullet.send(:devices), devices + end + end + + test '#push_link' do + device = MiniTest::Mock.new + device.expect(:nickname, 'iPhone6') + @bullet.stub(:devices, [device]) do + @bullet.stub(:push_link, 'push_link called') do + assert_equal @bullet.send(:push_link, nil), 'push_link called' + end + end + end + + test '#push_note' do + device = MiniTest::Mock.new + device.expect(:nickname, 'iPhone6') + @bullet.stub(:devices, [device]) do + @bullet.stub(:push_note, 'push_note called') do + assert_equal @bullet.send(:push_note, nil), 'push_note called' + end + end + end +end
Create test for `Notifiers::Pushbullet` class
diff --git a/lib/cucumber/core.rb b/lib/cucumber/core.rb index abc1234..def5678 100644 --- a/lib/cucumber/core.rb +++ b/lib/cucumber/core.rb @@ -15,11 +15,11 @@ self end - def compile(gherkin_documents, receiver, filters = []) - filters.each do |filter_type, args| - receiver = filter_type.new(*args + [receiver]) + def compile(gherkin_documents, last_receiver, filters = []) + first_receiver = filters.reduce(last_receiver) do |receiver, (filter_type, args)| + filter_type.new(*args + [receiver]) end - compiler = Compiler.new(receiver) + compiler = Compiler.new(first_receiver) parse gherkin_documents, compiler self end
Use more functional style in building filter chain Thanks @dchelimsky
diff --git a/lib/tasks/data_import.rake b/lib/tasks/data_import.rake index abc1234..def5678 100644 --- a/lib/tasks/data_import.rake +++ b/lib/tasks/data_import.rake @@ -0,0 +1,7 @@+namespace :data_import do + desc "Migrate MS Access data from legacy database to new Postgres database" + task :import_csv_data, [:csv_filename] => [:environment] do |t, args| + puts "Importing CSV data from '#{args.csv_filename}'" + DataImportManager.new("args.csv_filename").import_data + end +end
Add data import task to import the MS Access data
diff --git a/lib/unique_id/generator.rb b/lib/unique_id/generator.rb index abc1234..def5678 100644 --- a/lib/unique_id/generator.rb +++ b/lib/unique_id/generator.rb @@ -22,7 +22,7 @@ end def next(opts) - _scope = opts[:scope] + _scope = opts[:scope].nil? ? nil : opts[:scope].to_s _type = opts[:type] table = Arel::Table.new(:unique_ids)
Fix typecast error on postgresql
diff --git a/lib/zuora/error_handler.rb b/lib/zuora/error_handler.rb index abc1234..def5678 100644 --- a/lib/zuora/error_handler.rb +++ b/lib/zuora/error_handler.rb @@ -1,8 +1,9 @@ module Zuora module ErrorHandler - class UnknownError < StandardError; end - class APIError < StandardError; end - class NotFound < StandardError; end - class BadRequest < StandardError; end + class BaseError < StandardError; end + class UnknownError < BaseError; end + class APIError < BaseError; end + class NotFound < BaseError; end + class BadRequest < BaseError; end end end
Create a Base Error class for easy exception rescuing
diff --git a/spec/bson/min_key_spec.rb b/spec/bson/min_key_spec.rb index abc1234..def5678 100644 --- a/spec/bson/min_key_spec.rb +++ b/spec/bson/min_key_spec.rb @@ -25,7 +25,7 @@ end it "encodes the field/min key pair to the buffer" do - expect(encoded.bytes).to eq("\xFFkey\x00") + expect(encoded.bytes).to eq("#{BSON::Types::MIN_KEY}key\x00") end end end
Fix ruby head encoding issue
diff --git a/db/migrate/24_cleanup_contents.rb b/db/migrate/24_cleanup_contents.rb index abc1234..def5678 100644 --- a/db/migrate/24_cleanup_contents.rb +++ b/db/migrate/24_cleanup_contents.rb @@ -0,0 +1,10 @@+class CleanupContents < ActiveRecord::Migration + def self.up + STDERR.puts "Updating all articles" + # This is needed when migrating from 2.5.x, because we skip GUID + # generation and tagging during earlier migrations. + Article.find(:all).each do |a| + a.save + end + end +end
Add cleanup migration; only needed when going straight from 2.5.x to current trunk, but safe for everyone git-svn-id: 70ab0960c3db1cbf656efd6df54a8f3de72dc710@681 820eb932-12ee-0310-9ca8-eeb645f39767
diff --git a/spec/github-pages_spec.rb b/spec/github-pages_spec.rb index abc1234..def5678 100644 --- a/spec/github-pages_spec.rb +++ b/spec/github-pages_spec.rb @@ -2,6 +2,6 @@ describe(GitHubPages) do it "exposes its version" do - expect(described_class::VERSION).to be_a(Fixnum) + expect(described_class::VERSION).to be_a(Integer) end end
Fix rubocop complaint about Fixnum vs Integer.
diff --git a/library/ripper/lex_spec.rb b/library/ripper/lex_spec.rb index abc1234..def5678 100644 --- a/library/ripper/lex_spec.rb +++ b/library/ripper/lex_spec.rb @@ -3,17 +3,21 @@ describe "Ripper.lex" do it "lexes a simple method declaration" do - expected = ['[[1, 0], :on_kw, "def", #<Ripper::Lexer::State: EXPR_FNAME>]', - '[[1, 3], :on_sp, " ", #<Ripper::Lexer::State: EXPR_FNAME>]', - '[[1, 4], :on_ident, "m", #<Ripper::Lexer::State: EXPR_ENDFN>]', - '[[1, 5], :on_lparen, "(", #<Ripper::Lexer::State: EXPR_BEG|EXPR_LABEL>]', - '[[1, 6], :on_ident, "a", #<Ripper::Lexer::State: EXPR_ARG>]', - '[[1, 7], :on_rparen, ")", #<Ripper::Lexer::State: EXPR_ENDFN>]', - '[[1, 8], :on_sp, " ", #<Ripper::Lexer::State: EXPR_BEG>]', - '[[1, 9], :on_kw, "nil", #<Ripper::Lexer::State: EXPR_END>]', - '[[1, 12], :on_sp, " ", #<Ripper::Lexer::State: EXPR_END>]', - '[[1, 13], :on_kw, "end", #<Ripper::Lexer::State: EXPR_END>]'] + expected = [ + [[1, 0], :on_kw, "def", 'FNAME'], + [[1, 3], :on_sp, " ", 'FNAME'], + [[1, 4], :on_ident, "m", 'ENDFN'], + [[1, 5], :on_lparen, "(", 'BEG|LABEL'], + [[1, 6], :on_ident, "a", 'ARG'], + [[1, 7], :on_rparen, ")", 'ENDFN'], + [[1, 8], :on_sp, " ", 'BEG'], + [[1, 9], :on_kw, "nil", 'END'], + [[1, 12], :on_sp, " ", 'END'], + [[1, 13], :on_kw, "end", 'END'] + ] lexed = Ripper.lex("def m(a) nil end") - lexed.map(&:inspect).should == expected + lexed.map { |e| + e[0...-1] + [e[-1].to_s.split('|').map { |s| s.sub(/^EXPR_/, '') }.join('|')] + }.should == expected end end
Generalize Ripper.lex spec so it works on both 2.6 and 2.7
diff --git a/lib/pogoplug/file.rb b/lib/pogoplug/file.rb index abc1234..def5678 100644 --- a/lib/pogoplug/file.rb +++ b/lib/pogoplug/file.rb @@ -1,6 +1,6 @@ module PogoPlug class File - attr_accessor :name, :id, :type, :size, :mimetype, :parent_id, :properties, :raw + attr_accessor :name, :id, :type, :size, :mimetype, :parent_id, :properties, :origin, :raw module Type FILE = 0 @@ -43,6 +43,7 @@ mimetype: json['mimetype'], parent_id: json['parentid'], size: json['size'].to_i, + origin: json['origin'], raw: json ) end
Set the origin field as well
diff --git a/Casks/unifi-controller-beta.rb b/Casks/unifi-controller-beta.rb index abc1234..def5678 100644 --- a/Casks/unifi-controller-beta.rb +++ b/Casks/unifi-controller-beta.rb @@ -0,0 +1,13 @@+cask :v1 => 'unifi-controller-beta' do + version '4.6.4-ade9eed' + sha256 'e2cc1bbef8419320a5a8a52a3fb3cff341746cb78e65ebe92aa03ea03a0fc120' + + url "http://dl.ubnt.com/unifi/#{version}/UniFi.pkg" + name 'Unifi Controller Beta' + homepage 'https://community.ubnt.com/t5/UniFi-Wireless-Beta/bd-p/UniFi_Beta' + license :commercial + + pkg 'Unifi.pkg' + + uninstall :pkgutil => 'com.ubnt.UniFi' +end
Add UniFi Controller Beta (version 4.6.4) This adds the UniFi Controller beta software to Cask Versions.
diff --git a/app/controllers/concerns/application_multitenancy_concern.rb b/app/controllers/concerns/application_multitenancy_concern.rb index abc1234..def5678 100644 --- a/app/controllers/concerns/application_multitenancy_concern.rb +++ b/app/controllers/concerns/application_multitenancy_concern.rb @@ -34,4 +34,14 @@ request.host end end + + module ClassMethods + # :nodoc: + def set_current_tenant_through_filter + super + class_eval do + private :set_current_tenant + end + end + end end
Make `set_current_tenant` private so that TraceRoute will not flag it as an unreachable action.
diff --git a/app/models/effective/effective_datatable/dsl/bulk_actions.rb b/app/models/effective/effective_datatable/dsl/bulk_actions.rb index abc1234..def5678 100644 --- a/app/models/effective/effective_datatable/dsl/bulk_actions.rb +++ b/app/models/effective/effective_datatable/dsl/bulk_actions.rb @@ -36,7 +36,7 @@ opts[:class] = [opts[:class], 'dropdown-item'].compact.join(' ') - link_to(title, url, opts) + link_to(title, url, **opts) end end
Handle opts as keyword arguments
diff --git a/app/scheduled_workers/decidim_initiatives_notify_progress.rb b/app/scheduled_workers/decidim_initiatives_notify_progress.rb index abc1234..def5678 100644 --- a/app/scheduled_workers/decidim_initiatives_notify_progress.rb +++ b/app/scheduled_workers/decidim_initiatives_notify_progress.rb @@ -4,6 +4,6 @@ include Sidekiq::Worker def perform - system("bundle exec rake decidim_initiatives:notify_progress") + system("bundle exec rake decidim_initiatives:notify_progress") if Rails.env.production? end end
Add production condition in notify task
diff --git a/japr.gemspec b/japr.gemspec index abc1234..def5678 100644 --- a/japr.gemspec +++ b/japr.gemspec @@ -20,7 +20,7 @@ s.email = 'japr@clicktrackheart.com' s.homepage = 'https://github.com/kitsched/japr' s.license = 'MIT' - s.required_ruby_version = '>= 2.1.0' + s.required_ruby_version = '>= 2.2.0' # Runtime dependencies s.add_runtime_dependency 'jekyll', '~> 3.5'
Update gemspec Ruby version requirement.
diff --git a/lib/generator.rb b/lib/generator.rb index abc1234..def5678 100644 --- a/lib/generator.rb +++ b/lib/generator.rb @@ -28,7 +28,7 @@ end def sha1 - `cd #{metadata_dir} && git log -1 --oneline` + `cd #{metadata_dir} && git log -1 --pretty=format:"%h"` end def test_cases
Remove commit message from git version indicator. Change git log format from oneline ("%h %s"), to abbreviated hash only ("%h") The code for generated tests often includes a comment giving the git version of the test data from which the test was generated, such as: `# deb225e Implement canonical dataset for scrabble-score problem (#255)` The same version string is used for all tests generated at that time and will often have no relevance to the test you are looking at and only adds confusion. "Why is it telling me about scrabble-score? This is the test file for hamming!" By including only the hash, anyone interested enough in the commit can easily look up the exact commit message and everybody else can just ignore what appears to be a random hexidecimal string.
diff --git a/lib/hanzo/cli.rb b/lib/hanzo/cli.rb index abc1234..def5678 100644 --- a/lib/hanzo/cli.rb +++ b/lib/hanzo/cli.rb @@ -25,8 +25,8 @@ Usage: hanzo action [options] Available actions: - deploy — Deploy a branch or a tag - install — Install Hanzo configuration + deploy - Deploy a branch or a tag + install - Install Hanzo configuration Options: BANNER
Fix issue with Ruby < 2.0 and non US-ASCII characters
diff --git a/db/migrate/20110504101336_add_reputation_values_to_person.rb b/db/migrate/20110504101336_add_reputation_values_to_person.rb index abc1234..def5678 100644 --- a/db/migrate/20110504101336_add_reputation_values_to_person.rb +++ b/db/migrate/20110504101336_add_reputation_values_to_person.rb @@ -0,0 +1,18 @@+class AddReputationValuesToPerson < ActiveRecord::Migration + #New table reputation is added, and now update those values for each person based on their history + def self.up + people = Person.all + people.each do | person | + gift_actions = ItemRequest.find(:all, :conditions => ["gifter_id=? and gifter_type=? and status=?", person.id, "Person", ItemRequest::STATUS_COMPLETED]).size + people_helped = ItemRequest.find(:all, :select => 'DISTINCT requester_id', :conditions => ["gifter_id=? and gifter_type=?", person.id, "Person"]).size + answered = ItemRequest.answered_gifter(person).size + requests_received = ItemRequest.involves_as_gifter(person).size + total = ItemRequest.involves(person).size + person.reputation_rating.update_attributes(:gift_actions => gift_actions, :distinct_people => people_helped, + :total_actions => total, :requests_received => requests_received, :requests_answered => answered) + end + end + + def self.down + end +end
Add reputation to current users in database
diff --git a/ci/travis.rb b/ci/travis.rb index abc1234..def5678 100644 --- a/ci/travis.rb +++ b/ci/travis.rb @@ -25,7 +25,7 @@ exit(true) else echo_failure "The build has failed." - echo_failure "Failed tasks: #{failed.join(', ')}" + echo_failure "Failed tasks: #{failed.keys.join(', ')}" exit(false) end end
Fix script for failure case
diff --git a/example/spec/views/project_assignments/show.html.erb_spec.rb b/example/spec/views/project_assignments/show.html.erb_spec.rb index abc1234..def5678 100644 --- a/example/spec/views/project_assignments/show.html.erb_spec.rb +++ b/example/spec/views/project_assignments/show.html.erb_spec.rb @@ -11,7 +11,7 @@ render expect(rendered).to match(/project1/) expect(rendered).to match(/user1@example.com/) - expect(rendered).to match(Regexp.new(Regexp.escape(localize(Time.zone.parse("2020-03-22 09:50:00"))))) - expect(rendered).to match(Regexp.new(Regexp.escape(localize(Time.zone.parse("2020-03-22 23:40:00"))))) + expect(rendered).to match(Regexp.new(Regexp.escape(localize(Time.zone.parse('2020-03-22 09:50:00'))))) + expect(rendered).to match(Regexp.new(Regexp.escape(localize(Time.zone.parse('2020-03-22 23:40:00'))))) end end
Use single quotations instead of double quotations
diff --git a/lib/remindice.rb b/lib/remindice.rb index abc1234..def5678 100644 --- a/lib/remindice.rb +++ b/lib/remindice.rb @@ -2,7 +2,7 @@ require "thor" module Remindice - TASK_FILENAME = "~/.reamindice_tasks" + TASK_FILENAME = File.expand_path("~/.reamindice_tasks") @@tasks = if File.exists?(TASK_FILENAME); File.readlines(TASK_FILENAME) else [] end class << self def tasks
Change filename to expand path
diff --git a/cmac.gemspec b/cmac.gemspec index abc1234..def5678 100644 --- a/cmac.gemspec +++ b/cmac.gemspec @@ -8,6 +8,7 @@ s.authors = ['John Downey'] s.email = ['jdowney@gmail.com'] s.homepage = 'https://github.com/jtdowney/cmac' + s.license = 'MIT' s.summary = %q{Cipher-based Message Authentication Code} s.description = %q{A ruby implementation of RFC4493, RFC4494, and RFC4615. CMAC is a message authentication code (MAC) built using AES-128.}
Add MIT license to gemspec
diff --git a/lib/repos/cli.rb b/lib/repos/cli.rb index abc1234..def5678 100644 --- a/lib/repos/cli.rb +++ b/lib/repos/cli.rb @@ -38,7 +38,7 @@ if options[:verbose] Dir.chdir repository do system 'git status' - system 'git stash --no-pager list' + system 'git --no-pager stash list' puts end end
Fix a git syntax issue with --no-pager
diff --git a/lib/fckeditor.rb b/lib/fckeditor.rb index abc1234..def5678 100644 --- a/lib/fckeditor.rb +++ b/lib/fckeditor.rb @@ -32,4 +32,4 @@ end end -require File.join(__FILE__, '../app/helper/application_helper.rb') +require File.join(File.dirname(__FILE__), '../app/helpers/application_helper.rb')
Correct path to application helpers. Fixed typo of 'helper' instead of 'helpers' in path Wrapped __FILE__ with File.dirname() Signed-off-by: Alexander Semyonov <2cc0c22c56db4b6d36fe7db16e451ab11afda27a@gmail.com>
diff --git a/lib/feed_sync.rb b/lib/feed_sync.rb index abc1234..def5678 100644 --- a/lib/feed_sync.rb +++ b/lib/feed_sync.rb @@ -23,7 +23,7 @@ def entries result = Feedzirra::Feed.fetch_and_parse(@feed.url) - result ? result.entries : [] + result.class.name =~ /Feedzirra/ ? result.entries : [] end def entry_content(entry)
Check feedzirra response class before running import
diff --git a/lib/filestore.rb b/lib/filestore.rb index abc1234..def5678 100644 --- a/lib/filestore.rb +++ b/lib/filestore.rb @@ -8,6 +8,10 @@ @db.type_translation = true @db.execute("create table if not exists sensor_reads (sensor string, date integer, value real)") + @db.execute("create index if not exists sensor_reads_sensor_index on + sensor_reads(sensor)") + @db.execute("create index if not exists sensor_reads_date_index on + sensor_reads(date)") @mutex = Mutex.new end
Add indexes to the database to try and speedup chart creation.
diff --git a/lib/oboe/util.rb b/lib/oboe/util.rb index abc1234..def5678 100644 --- a/lib/oboe/util.rb +++ b/lib/oboe/util.rb @@ -23,9 +23,14 @@ end if cls.method_defined? method.to_sym or cls.private_method_defined? method.to_sym + + # Strip '!' or '?' from method if present + safe_method_name = method.to_s.chop if method =~ /\?$|\!$/ + safe_method_name ||= method + cls.class_eval do - alias_method "#{method}_without_oboe", "#{method}" - alias_method "#{method}", "#{method}_with_oboe" + alias_method "#{safe_method_name}_without_oboe", "#{method}" + alias_method "#{method}", "#{safe_method_name}_with_oboe" end else Oboe.logger.warn "[oboe/loading] Couldn't properly instrument #{name}. Partial traces may occur." end
Update method_alias to handle method names with '!' or '?'
diff --git a/app/models/trackback.rb b/app/models/trackback.rb index abc1234..def5678 100644 --- a/app/models/trackback.rb +++ b/app/models/trackback.rb @@ -4,14 +4,6 @@ class Trackback < Feedback content_fields :excerpt validates :title, :excerpt, :url, presence: true - - # attr_accessible :url, :blog_name, :title, :excerpt, :ip, :published, :article_id - - def initialize(*args, &block) - super(*args, &block) - self.title ||= url - self.blog_name ||= '' - end before_create :process_trackback
Remove superfluous initializer from Trackback No new Trackback objects should be stored in the database, and also no tests fail when this code is removed.
diff --git a/lib/tufy/fields/contact_number/build_contact_number_field.rb b/lib/tufy/fields/contact_number/build_contact_number_field.rb index abc1234..def5678 100644 --- a/lib/tufy/fields/contact_number/build_contact_number_field.rb +++ b/lib/tufy/fields/contact_number/build_contact_number_field.rb @@ -2,6 +2,10 @@ module Fields module ContactNumber class BuildContactNumberField < BuildField + # When raw_data[:contact_number].blank? + # we use NULL_CONTACT_NUMBER instead + NULL_CONTACT_NUMBER = "0000000000" + expects :raw_data promises :transformed_data @@ -16,9 +20,15 @@ def self.transform(ctx) raw_data = ctx.raw_data + contact_number = if raw_data[:contact_number].empty? + NULL_CONTACT_NUMBER + else + raw_data[:contact_number] + end + BuildContactNumberSegment::Constants::CONTACT_NUMBER_TAG + - FormatStrings::F2TS % remove_special_characters(raw_data[:contact_number]).size + - remove_special_characters(raw_data[:contact_number]) + FormatStrings::F2TS % remove_special_characters(contact_number).size + + remove_special_characters(contact_number) end end end
Use ten zeros for blank contact numbers
diff --git a/nixos-x86_64.rb b/nixos-x86_64.rb index abc1234..def5678 100644 --- a/nixos-x86_64.rb +++ b/nixos-x86_64.rb @@ -3,7 +3,7 @@ gen_template( arch: "x86_64", - iso_url: "https://nixos.org/releases/nixos/15.09/nixos-15.09.1076.9220f03/nixos-minimal-15.09.1076.9220f03-x86_64-linux.iso", - iso_sha256: "77bd77859f937da23e9a45ccf50410ae32a41400e3b9ca3a8de212821b641c88", + iso_url: "https://nixos.org/releases/nixos/16.03/nixos-16.03.1271.546618c/nixos-minimal-16.03.1271.546618c-x86_64-linux.iso", + iso_sha256: "81c91427d7fd384097a8a811715f69379a81c3da02c7db39ec85f4a11f2d42f0", virtualbox_guest_os: "Linux_64", )
Update x86_64 template to 16.03
diff --git a/Library/Formula/android-ndk.rb b/Library/Formula/android-ndk.rb index abc1234..def5678 100644 --- a/Library/Formula/android-ndk.rb +++ b/Library/Formula/android-ndk.rb @@ -11,7 +11,17 @@ def install bin.mkpath prefix.install Dir['*'] - %w[ ndk-build ndk-gdb ndk-stack ].each { |app| ln_s prefix+app, bin+app } + + # Create a dummy script to launch the ndk apps + ndk_exec = prefix+'ndk-exec.sh' + (ndk_exec).write <<-EOS.undent + #!/bin/sh + BASENAME=`basename $0` + EXEC="#{prefix}/$BASENAME" + test -f "$EXEC" && exec "$EXEC" "$@" + EOS + (ndk_exec).chmod 0755 + %w[ ndk-build ndk-gdb ndk-stack ].each { |app| ln_s ndk_exec, bin+app } end def caveats; <<-EOS
Fix Android NDK packaging for execs Instead of symlinking the execs themselves, launch a script with the hard-coded path. This is similar to how adb works in the android-sdk. Signed-off-by: Adam Vandenberg <34c2b6407fd5a10249a15d699d40f9ed1782e98c@gmail.com>
diff --git a/lib/supido.rb b/lib/supido.rb index abc1234..def5678 100644 --- a/lib/supido.rb +++ b/lib/supido.rb @@ -7,6 +7,7 @@ module Supido; end # load Supido components +require 'supido/abstract_interface' require 'supido/abstract_benchmark_base' require 'supido/tools/apache_benchmark' require 'supido/config'
Include a better interface method to extentions
diff --git a/css_views.gemspec b/css_views.gemspec index abc1234..def5678 100644 --- a/css_views.gemspec +++ b/css_views.gemspec @@ -1,12 +1,12 @@ Gem::Specification.new do |s| s.name = 'css_views' - s.version = '0.5.2.pre' + s.version = '0.5.3' s.email = "michael@koziarski.com" s.author = "Michael Koziarski" s.description = %q{Allow you to create css.erb views, and use helpers and the like in them} s.summary = %q{Simple Controller support} - s.homepage = %q{http://www.radionz.co.nz/} + s.homepage = %q{http://https://github.com/rhulse/rails-css-views} s.add_dependency('actionpack', '>= 3.0.0')
Change gem homepage and version number
diff --git a/test/models/shadmin/admin_test.rb b/test/models/shadmin/admin_test.rb index abc1234..def5678 100644 --- a/test/models/shadmin/admin_test.rb +++ b/test/models/shadmin/admin_test.rb @@ -4,7 +4,7 @@ class AdminTest < ActiveSupport::TestCase def setup - @admin ||= build(:admin) + @admin ||= build(:admin_adam) end def test_validates_email @@ -31,5 +31,12 @@ @admin.email = new_admin.email assert_not @admin.valid? end + + # Test kaminari :page method + def test_page + create_list(:admin, 75) + admins = Shadmin::Admin.page(1) + assert_equal 20, admins.count + end end end
Test kaminari :page method in admin model
diff --git a/db_nazi.gemspec b/db_nazi.gemspec index abc1234..def5678 100644 --- a/db_nazi.gemspec +++ b/db_nazi.gemspec @@ -22,4 +22,5 @@ gem.add_development_dependency 'looksee', '~> 0.2.0' gem.add_development_dependency 'debugger', '~> 1.1.3' gem.add_development_dependency 'sqlite3', '~> 1.3.6' + gem.add_development_dependency 'mysql2', '~> 0.3.11' end
Add mysql2 as a development dependency.
diff --git a/json_world.gemspec b/json_world.gemspec index abc1234..def5678 100644 --- a/json_world.gemspec +++ b/json_world.gemspec @@ -15,7 +15,6 @@ spec.require_paths = ["lib"] spec.add_dependency "activesupport" - spec.add_dependency "json" spec.add_development_dependency "bundler", "~> 1.9" spec.add_development_dependency "rake", "~> 10.0" spec.add_development_dependency "rspec", "3.2.0"
Remove unnecessary dependency on json
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 @@ -6,6 +6,7 @@ require 'rails/test_help' require 'authlogic' require 'authlogic/test_case' +require 'pry' class User def nyuidn
Use Pry as the REPL in the tests
diff --git a/lib/generators/solidus/auth/install/install_generator.rb b/lib/generators/solidus/auth/install/install_generator.rb index abc1234..def5678 100644 --- a/lib/generators/solidus/auth/install/install_generator.rb +++ b/lib/generators/solidus/auth/install/install_generator.rb @@ -5,6 +5,7 @@ module Generators class InstallGenerator < Rails::Generators::Base class_option :auto_run_migrations, type: :boolean, default: false + class_option :skip_migrations, type: :boolean, default: false def self.source_paths paths = superclass.source_paths @@ -21,6 +22,8 @@ end def run_migrations + return if options[:skip_migrations] + run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask('Would you like to run the migrations now? [Y/n]')) if run_migrations run 'bundle exec rake db:migrate'
Add option to skip migrations In some cases (in particular, the solidus install) it makes sense to skip the entire migration block. With the current setup, it's impossible to not run migrations AND not be asked if you want to run migrations. This allows for a complete skip of the migrations + the question asking part, which will smooth out the Solidus installation.
diff --git a/db/migrate/20140411112914_add_vm_identifiers_to_virtual_machine_instances.rb b/db/migrate/20140411112914_add_vm_identifiers_to_virtual_machine_instances.rb index abc1234..def5678 100644 --- a/db/migrate/20140411112914_add_vm_identifiers_to_virtual_machine_instances.rb +++ b/db/migrate/20140411112914_add_vm_identifiers_to_virtual_machine_instances.rb @@ -0,0 +1,8 @@+class AddVmIdentifiersToVirtualMachineInstances < ActiveRecord::Migration + def change + add_column :virtual_machine_instances, :provider_name, :string + add_column :virtual_machine_instances, :provider_instance_id, :string + + add_index :virtual_machine_instances, [:provider_instance_id, :provider_name], name: 'index_vm_instances_on_provider_instance_id_and_provider_name' + end +end
Add virtual machine identifiers (missing migration required for vm identification)
diff --git a/lisp_test.rb b/lisp_test.rb index abc1234..def5678 100644 --- a/lisp_test.rb +++ b/lisp_test.rb @@ -7,4 +7,7 @@ puts eval(parse("(+ 3 5 8)")) == 16 puts eval(parse("(* 3 5 8)")) == 120 puts eval(parse("(- 3 5)")) == -2 -puts eval(parse("(/ 6 2)")) == 3+puts eval(parse("(/ 6 2)")) == 3 +eval(parse("(define pi 3.14)")) +eval(parse("(define circle-area (lambda (r) (* pi (* r r))))")) +puts eval(parse("(circle-area 10)")) == 314
Add test for lambda application
diff --git a/engines/dfc_provider/app/controllers/dfc_provider/api/products_controller.rb b/engines/dfc_provider/app/controllers/dfc_provider/api/products_controller.rb index abc1234..def5678 100644 --- a/engines/dfc_provider/app/controllers/dfc_provider/api/products_controller.rb +++ b/engines/dfc_provider/app/controllers/dfc_provider/api/products_controller.rb @@ -4,8 +4,13 @@ module DfcProvider module Api class ProductsController < ::ActionController::Metal - include Spree::Api::ControllerSetup - + include ActionController::Head + include AbstractController::Rendering + include ActionController::Rendering + include ActionController::Renderers::All + include ActionController::MimeResponds + include ActionController::ImplicitRender + include AbstractController::Callbacks # To access 'base_url' helper include ActionController::UrlFor include Rails.application.routes.url_helpers @@ -14,6 +19,8 @@ :check_enterprise, :check_user, :check_accessibility + + respond_to :json def index products = @enterprise.
Put back former lighter inclusions
diff --git a/test/integration/project_get_test.rb b/test/integration/project_get_test.rb index abc1234..def5678 100644 --- a/test/integration/project_get_test.rb +++ b/test/integration/project_get_test.rb @@ -0,0 +1,68 @@+# frozen_string_literal: true + +# Copyright 2015-2017, the Linux Foundation, IDA, and the +# CII Best Practices badge contributors +# SPDX-License-Identifier: MIT + +require 'test_helper' + +class ProjectGetTest < ActionDispatch::IntegrationTest + setup do + # @user = users(:test_user) + @project_one = projects(:one) + end + + # rubocop:disable Metrics/BlockLength + test 'ensure getting project has expected values (esp. security headers)' do + # Check project page values, primarily the various hardening headers + # (in particular the Content Security Policy (CSP) header). + # We want to make sure these headers maximally limit what browsers will + # do as an important hardening measure. + # The "projects" page is the page most at risk of malicious data + # from untrusted users, so we specifically test + # the headers for this most-at-risk page. + # We have to do this as an integration test, not as a controller test, + # because the secure_headers gem integrates at the Rack level + # (thus a controller test does not invoke it). + + get project_path(id: @project_one.id) + assert_response :success + + # Check some normal headers + assert_equal('text/html; charset=utf-8', @response.headers['Content-Type']) + assert_equal( + 'max-age=0, private, must-revalidate', + @response.headers['Cache-Control'] + ) + + # Check hardening headers + assert_equal( + "default-src 'self'; base-uri 'self'; block-all-mixed-content; " \ + "form-action 'self'; frame-ancestors 'none'; " \ + "img-src secure.gravatar.com avatars.githubusercontent.com 'self'; " \ + "object-src 'none'; style-src 'self'", + @response.headers['Content-Security-Policy'] + ) + assert_equal( + 'no-referrer-when-downgrade', + @response.headers['Referrer-Policy'] + ) + assert_equal( + 'nosniff', + @response.headers['X-Content-Type-Options'] + ) + assert_equal( + 'DENY', + @response.headers['X-Frame-Options'] + ) + assert_equal( + 'none', + @response.headers['X-Permitted-Cross-Domain-Policies'] + ) + assert_equal( + '1; mode=block', + @response.headers['X-XSS-Protection'] + ) + end + # rubocop:enable Metrics/BlockLength +end
Add new integration test: Check get project (esp. CSP values) This commit checks to make sure that the hardening headers added are at least what we expect. That way, when we update the secure_headers gem, we will detect reductions or unexpected changes to our hardening mechanisms. Signed-off-by: David A. Wheeler <9ae72d22d8b894b865a7a496af4fab6320e6abb2@dwheeler.com>
diff --git a/marc.gemspec b/marc.gemspec index abc1234..def5678 100644 --- a/marc.gemspec +++ b/marc.gemspec @@ -22,4 +22,5 @@ s.add_dependency "scrub_rb", ">= 1.0.1", "< 2" # backport for ruby 2.1 String#scrub s.add_dependency "unf" # unicode normalization + s.add_dependency "rexml" # rexml was unbundled from the stdlib in ruby 3 end
Add an explicit dependency rexml to the gemspec
diff --git a/lib/lib_network.rb b/lib/lib_network.rb index abc1234..def5678 100644 --- a/lib/lib_network.rb +++ b/lib/lib_network.rb @@ -5,7 +5,6 @@ # require 'thread' -require 'thwait' require_relative 'lib_config' @@ -18,14 +17,14 @@ # local arp cache # def self.ping_hosts(ip_base, ip_range) - threads = [] - - ip_range.each do |n| + children = ip_range.map do |n| address = ip_base + n.to_s - threads << (Thread.new { `#{LibConfig::PING} -q -c1 -W1 #{address}` }) + spawn("ping -q -W 1 -c 1 #{address} > /dev/null 2>&1") end - - ThreadsWait.all_waits(*threads) + children.each do |pid| + Process.wait(pid) + end + nil end # ----------------------------------------------------------------------------
Replace dependency on thwait class for stability
diff --git a/config/initializers/core.rb b/config/initializers/core.rb index abc1234..def5678 100644 --- a/config/initializers/core.rb +++ b/config/initializers/core.rb @@ -4,6 +4,7 @@ require 'core/repositories/action_plans/public_website' require 'core/repositories/articles/public_website' require 'core/repositories/categories/public_website' +require 'core/repositories/search/public_website' Core::Registries::Connection[:public_website] = Core::ConnectionFactory.build(ENV['MAS_PUBLIC_WEBSITE_URL']) @@ -16,3 +17,6 @@ Core::Registries::Repository[:category] = Core::Repositories::Categories::PublicWebsite.new + +Core::Registries::Repository[:search] = + Core::Repositories::Search::PublicWebsite.new
Add the search repository to the registry on load.
diff --git a/config/initializers/mail.rb b/config/initializers/mail.rb index abc1234..def5678 100644 --- a/config/initializers/mail.rb +++ b/config/initializers/mail.rb @@ -0,0 +1,22 @@+# -*- encoding : utf-8 -*- +require 'yaml' + +begin + options = YAML.load_file(Rails.root.join('config', 'mandrill.yml'))[Rails.env] + + ActionMailer::Base.smtp_settings = { + :address => "smtp.mandrillapp.com", + :port => 587, + :user_name => options['username'], + :password => options['password'], + :domain => 'heroku.com' + } + ActionMailer::Base.delivery_method = :smtp + + MandrillMailer.configure do |config| + config.api_key = options['api_key'] + end +rescue LoadError + puts "The Mandrill configuration (config/mandrill.yml) is missing or malformed" + exit(1) +end
Read mandrill api_key from mandrill.yml in all environments.
diff --git a/dyad.gemspec b/dyad.gemspec index abc1234..def5678 100644 --- a/dyad.gemspec +++ b/dyad.gemspec @@ -18,9 +18,10 @@ spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] + spec.add_dependency "ffi", "~> 1.9" + spec.add_dependency "ffi-compiler", "~> 0.1" + spec.add_development_dependency "bundler", "~> 1.6" - spec.add_development_dependency "ffi", "~> 1.9" - spec.add_development_dependency "ffi-compiler", "~> 0.1" spec.add_development_dependency "rake", "~> 10.1" spec.extensions << 'ext/Rakefile'
Fix gemspec file - ffi should be a dependency not a development dependency
diff --git a/Casks/itunes-volume-control.rb b/Casks/itunes-volume-control.rb index abc1234..def5678 100644 --- a/Casks/itunes-volume-control.rb +++ b/Casks/itunes-volume-control.rb @@ -1,13 +1,14 @@ cask 'itunes-volume-control' do - version '1.4.10' - sha256 '2217581e374c53853dfa5dac805214233f37b016ebed313edbb8499d2ff9f70f' + version '1.5.1' + sha256 '4af853571590f30457b015c2998881d0436643579eb2a67f6e6b3aa30731c200' - url 'https://github.com/alberti42/iTunes-Volume-Control/raw/master/iTunes%20Volume%20Control.dmg' - appcast 'https://github.com/alberti42/iTunes-Volume-Control/releases.atom', - checkpoint: '16c4f984043ff2321f6be00f0d7b06a5ce87a014747aedcdd5074d9e18e2b56a' + # uni-bonn.de/alberti/iTunesVolumeControl was verified as official when first introduced to the cask + url "http://quantum-technologies.iap.uni-bonn.de/alberti/iTunesVolumeControl/iTunesVolumeControl-v#{version}.zip" name 'iTunes Volume Control' homepage 'https://github.com/alberti42/iTunes-Volume-Control' license :oss + auto_updates true + app 'iTunes Volume Control.app' end
Upgrade iTunes Volume Control.app to 1.5.1
diff --git a/Casks/pinegrow-web-designer.rb b/Casks/pinegrow-web-designer.rb index abc1234..def5678 100644 --- a/Casks/pinegrow-web-designer.rb +++ b/Casks/pinegrow-web-designer.rb @@ -1,6 +1,6 @@ cask :v1 => 'pinegrow-web-designer' do - version '2.00' - sha256 '9cfaf6538e52d00022f928dd109f1bb064af7f4a42c01cce83c10ba18957a081' + version '2.01' + sha256 'f6811ca1cda6fcb370a5dbdc7742cc4aa7b2f26b7573d7ad75f83a5c10860782' # amazonaws.com is the official download host per the vendor homepage url "https://pinegrow.s3.amazonaws.com/PinegrowMac.#{version}.dmg"
Update Pinegrow Web Designer to 2.01
diff --git a/blimpy-cucumber.gemspec b/blimpy-cucumber.gemspec index abc1234..def5678 100644 --- a/blimpy-cucumber.gemspec +++ b/blimpy-cucumber.gemspec @@ -4,8 +4,8 @@ Gem::Specification.new do |gem| gem.authors = ["R. Tyler Croy"] gem.email = ["tyler@monkeypox.org"] - gem.description = %q{TODO: Write a gem description} - gem.summary = %q{TODO: Write a gem summary} + gem.description = "Cucumber steps for testing with Blimpy" + gem.summary = "This gem helps spin up and down VMs with Blimpy from within Cucumber tests" gem.homepage = "" gem.files = `git ls-files`.split($\)
Update the gemspec to include a basic description/etc
diff --git a/canonical-rails.gemspec b/canonical-rails.gemspec index abc1234..def5678 100644 --- a/canonical-rails.gemspec +++ b/canonical-rails.gemspec @@ -15,7 +15,7 @@ s.files = Dir["{app,config,db,lib}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.md"] - s.add_dependency 'rails', '>= 4.1', '< 5.2' + s.add_dependency 'rails', '>= 4.1', '< 5.3' s.add_development_dependency 'appraisal' s.add_development_dependency "sqlite3"
Allow Rails 5.2 in gemspec
diff --git a/lib/try_to.rb b/lib/try_to.rb index abc1234..def5678 100644 --- a/lib/try_to.rb +++ b/lib/try_to.rb @@ -9,13 +9,11 @@ attr_reader :exceptions, :handlers def add_handler(exception, handler) - @handlers[exception] = handler - @handlers + @handlers.tap { |h| h[exception] = handler } end def remove_handler!(exception) - @handlers.delete(exception) - @handlers + @handlers.tap { |h| h.delete(exception) } end def add_exception(exception)
Update code to use tap
diff --git a/content_manager.gemspec b/content_manager.gemspec index abc1234..def5678 100644 --- a/content_manager.gemspec +++ b/content_manager.gemspec @@ -9,7 +9,7 @@ s.version = ContentManager::VERSION s.authors = ["Jasper Lyons"] s.email = ["jasper.lyons@gmail.com"] - s.homepage = "TODO" + s.homepage = "content-manager.github.io" s.summary = "A super light weight, content manager for developers." s.description = "Define groups of content, views, and versions of that content that can be swapped out at runtime. The driving force behind this was allowing customers to be able to update the copy on their pages and for us to A/B test versions fo that copy for them." s.license = "MIT"
Add homepage for gem becuase bundler complains
diff --git a/acceptance/provider/network_forwarded_port_spec.rb b/acceptance/provider/network_forwarded_port_spec.rb index abc1234..def5678 100644 --- a/acceptance/provider/network_forwarded_port_spec.rb +++ b/acceptance/provider/network_forwarded_port_spec.rb @@ -20,6 +20,6 @@ it "properly configures forwarded ports" do status("Test: TCP forwarded port (default)") - assert_network("http://localhost:#{port}/", port) + assert_network("http://127.0.0.1:#{port}/", port) end end
Use address for forward check
diff --git a/Casks/latexit.rb b/Casks/latexit.rb index abc1234..def5678 100644 --- a/Casks/latexit.rb +++ b/Casks/latexit.rb @@ -1,6 +1,6 @@ cask :v1 => 'latexit' do - version '2.7.3' - sha256 '45efeeea0d7bde36ba08aa663d6dd10092ec66d7622bccccf73732257e1e82f0' + version '2.7.5' + sha256 '2faef9682f1450d2a4b240bcf602a84ae187e58bf62787e2185af0ee05161e6f' url "http://www.chachatelier.fr/latexit/downloads/LaTeXiT-#{version.gsub('.', '_')}.dmg" appcast 'http://pierre.chachatelier.fr/latexit/downloads/latexit-sparkle-en.rss',
Update LaTeXiT to version 2.7.5
diff --git a/app/controllers/pawoo/sitemap/status_indexes_controller.rb b/app/controllers/pawoo/sitemap/status_indexes_controller.rb index abc1234..def5678 100644 --- a/app/controllers/pawoo/sitemap/status_indexes_controller.rb +++ b/app/controllers/pawoo/sitemap/status_indexes_controller.rb @@ -15,11 +15,11 @@ def page_details read_from_slave do - StreamEntry.select('statuses.id') + StreamEntry.joins(:status).joins(status: :account) + .select('statuses.id') .select('statuses.updated_at') .select('accounts.username') .select('statuses.reblogs_count') - .joins(:status).joins(status: :account) .where('stream_entries.activity_type = \'Status\'') .where('stream_entries.id > ?', min_id) .where('stream_entries.id <= ?', max_id)
Move the method "joins" to the first line of activerecord chain.
diff --git a/spec/controllers/doorkeeper/openid_connect/userinfo_controller_spec.rb b/spec/controllers/doorkeeper/openid_connect/userinfo_controller_spec.rb index abc1234..def5678 100644 --- a/spec/controllers/doorkeeper/openid_connect/userinfo_controller_spec.rb +++ b/spec/controllers/doorkeeper/openid_connect/userinfo_controller_spec.rb @@ -2,7 +2,7 @@ describe Doorkeeper::OpenidConnect::UserinfoController, type: :controller do let(:client) { create :application } - let(:user) { User.create! name: 'Joe', password: 'sekret' } + let(:user) { create :user, name: 'Joe' } let(:token) { create :access_token, application: client, resource_owner_id: user.id } describe '#show' do
chore: Use user factory in spec
diff --git a/spec/models/volunteer_op_spec.rb b/spec/models/volunteer_op_spec.rb index abc1234..def5678 100644 --- a/spec/models/volunteer_op_spec.rb +++ b/spec/models/volunteer_op_spec.rb @@ -3,16 +3,19 @@ describe VolunteerOp do it 'must have a title' do v = VolunteerOp.new(title:'') - expect(v).to have(1).errors_on(:title) + v.valid? + expect(v.errors[:title].size).to eq(1) end it 'must have a description' do v = VolunteerOp.new(description:'') - expect(v).to have(1).errors_on(:description) + v.valid? + expect(v.errors[:description].size).to eq(1) end it 'must not be created without an organisation' do v = VolunteerOp.new(organisation_id:nil) - expect(v).to have(1).error_on(:organisation_id) + v.valid? + expect(v.errors[:organisation_id].size).to eq(1) end -end+end
Fix deprecation warnings about volop model spec
diff --git a/app/controllers/admin/base_controller_decorator.rb b/app/controllers/admin/base_controller_decorator.rb index abc1234..def5678 100644 --- a/app/controllers/admin/base_controller_decorator.rb +++ b/app/controllers/admin/base_controller_decorator.rb @@ -10,7 +10,7 @@ private def set_user_language - I18n.locale = Spree::Config[:default_locale].to_sym + I18n.locale = Rails.application.config.i18n.default_locale.to_sym end end
Remove ancient default_locale preference and depend on Rails.applicat… …ion.config.i18n.default_locale instead
diff --git a/spec/unit/apache_version_spec.rb b/spec/unit/apache_version_spec.rb index abc1234..def5678 100644 --- a/spec/unit/apache_version_spec.rb +++ b/spec/unit/apache_version_spec.rb @@ -17,4 +17,17 @@ end end end + + describe 'apache_version with empty OS' do + context 'with value' do + before :each do + Facter::Util::Resolution.stubs(:which).with('apachectl').returns(true) + Facter::Util::Resolution.stubs(:exec).with('apachectl -v 2>&1').returns('Server version: Apache/2.4.6 () + Server built: Nov 21 2015 05:34:59') + end + it do + expect(Facter.fact(:apache_version).value).to eq('2.4.6') + end + end + end end
Add spec test for apache_version with an empty OS
diff --git a/lib/xe_client.rb b/lib/xe_client.rb index abc1234..def5678 100644 --- a/lib/xe_client.rb +++ b/lib/xe_client.rb @@ -3,6 +3,8 @@ require "virtus" require "httparty" require "active_support/core_ext/hash/indifferent_access" +require "active_support/core_ext/date_time" +require "active_support/core_ext/string/conversions" require "xe_client/indifferent_hash" require "xe_client/models/quote" require "xe_client/client"
Add date time string extensions
diff --git a/libraries/ec2.rb b/libraries/ec2.rb index abc1234..def5678 100644 --- a/libraries/ec2.rb +++ b/libraries/ec2.rb @@ -29,10 +29,10 @@ Chef::Log.error("Missing gem 'fog'") end Fog::Compute.new( - :provider => 'AWS', - :aws_access_key_id => @current_resource.aws_access_key_id, - :aws_secret_access_key => @current_resource.aws_secret_access_key, - :region => @current_resource.region + provider: 'AWS', + aws_access_key_id: @current_resource.aws_access_key_id, + aws_secret_access_key: @current_resource.aws_secret_access_key, + region: @current_resource.region ) end end
Use Ruby 1.9 hash syntax
diff --git a/plugins/restart.rb b/plugins/restart.rb index abc1234..def5678 100644 --- a/plugins/restart.rb +++ b/plugins/restart.rb @@ -3,6 +3,7 @@ match /restart/, method: :restart match /update/, method: :update + match /updates/, method: :updates def restart(m) return if Time.now - STARTTIME < 10 @@ -20,6 +21,7 @@ end def update(m) + return if m.params[1][CONFIG['prefix'].length..CONFIG['prefix'].length + 7] == 'updates' return if Time.now - STARTTIME < 10 unless authenticate(m) && checkperm(m, m.user.name, 'restart') m.reply "You can't update! (If you are the owner of the bot, you did not configure properly! Otherwise, stop trying to update the bot!)" @@ -34,4 +36,18 @@ exec('ruby bot.rb') end end + + def updates(m) + unless authenticate(m) && checkperm(m, m.user.name, 'restart') + m.reply 'You are not allowed to check for updates!' + return + end + m.reply 'Checking for updates...' + response = `git fetch` + if response == '' + m.reply 'No new updates available.' + else + m.reply "New updates found! Run `#{CONFIG['prefix']}update` to update" + end + end end
Add updates command to check for new Chewbotcca updates
diff --git a/app/controllers/answers_controller.rb b/app/controllers/answers_controller.rb index abc1234..def5678 100644 --- a/app/controllers/answers_controller.rb +++ b/app/controllers/answers_controller.rb @@ -1,3 +1,8 @@+get '/answers/new' do + @potential_reply = PotentialReply.find_by(id: params[:potential_reply_id]) + erb :'/answers/new' +end + post '/answers' do question = Question.find_by(id: params[:answer][:question_id]) survey = question.survey
Add answers new route to answers controller:
diff --git a/app/controllers/picture_controller.rb b/app/controllers/picture_controller.rb index abc1234..def5678 100644 --- a/app/controllers/picture_controller.rb +++ b/app/controllers/picture_controller.rb @@ -4,20 +4,12 @@ def show # GET /pictures/:basename id, extension = params[:basename].split('.') - picture = Picture.find_by_id(id) - if picture && picture.extension == extension - render_picture_content(picture) - else - head :not_found - end - end - private + picture = Picture.where(:extension => extension).find_by(:id => id) + return head(:not_found) unless picture - def render_picture_content(picture) - response.headers['Cache-Control'] = "public" - response.headers['Content-Type'] = "image/#{picture.extension}" - response.headers['Content-Disposition'] = "inline" - render :body => picture.content + fresh_when(:etag => picture.md5, :public => true) + + send_data(picture.content, :type => "image/#{extension}", :disposition => 'inline') if stale? end end
Use standard rails methods to serve up photos - Don't fetch the photo from the db if it is the wrong extension - fresh_when could calculate the etags for us, but used our md5 instead
diff --git a/app/controllers/profile_controller.rb b/app/controllers/profile_controller.rb index abc1234..def5678 100644 --- a/app/controllers/profile_controller.rb +++ b/app/controllers/profile_controller.rb @@ -5,6 +5,7 @@ session['id'] = profile_data['id'] session['realm'] = profile_data['realm'] session['name'] = profile_data['displayName'] + render :json => data.to_json end
Create matches factory in services to hit back end to retrieve match history data
diff --git a/app/controllers/ratings_controller.rb b/app/controllers/ratings_controller.rb index abc1234..def5678 100644 --- a/app/controllers/ratings_controller.rb +++ b/app/controllers/ratings_controller.rb @@ -20,6 +20,12 @@ end def update + @sound_trek = SoundTrek.find(params[:sound_trek_id]) + if already_rated?(@sound_trek) + @rating = Rating.find_by(trekker_id: session[:user_id]) + @rating.update_attributes(stars: rating_params[:stars]) + redirect_to sound_trek_path(@sound_trek) + end end private
Add action to ratings controller so that user can change their rating for a soundtrek, logic to control access in controller and view
diff --git a/Library/Formula/kdebase-runtime.rb b/Library/Formula/kdebase-runtime.rb index abc1234..def5678 100644 --- a/Library/Formula/kdebase-runtime.rb +++ b/Library/Formula/kdebase-runtime.rb @@ -1,9 +1,9 @@ require 'formula' class KdebaseRuntime <Formula - url 'ftp://ftp.kde.org/pub/kde/stable/4.4.2/src/kdebase-runtime-4.4.2.tar.bz2' - homepage '' - md5 'd46fca58103624c28fcdf3fbd63262eb' + url 'ftp://ftp.kde.org/pub/kde/stable/4.5.2/src/kdebase-runtime-4.5.2.tar.bz2' + homepage 'http://www.kde.org/' + md5 '6503a445c52fc1055152d46fca56eb0a' depends_on 'cmake' => :build depends_on 'kde-phonon'
Update KDEBase Runtime to 1.4.0 and fix homepage.
diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index abc1234..def5678 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -10,7 +10,9 @@ end def login_dispatch - if current_user.role == "auditor" + if current_user.nil? + redirect_to :action => :index + elsif current_user.role == "auditor" redirect_to placeholder_path else redirect_to dashboard_index_path
Handle logged-out user in login_dispatch [story:496657]
diff --git a/sufia-models/app/models/concerns/sufia/works/generic_work.rb b/sufia-models/app/models/concerns/sufia/works/generic_work.rb index abc1234..def5678 100644 --- a/sufia-models/app/models/concerns/sufia/works/generic_work.rb +++ b/sufia-models/app/models/concerns/sufia/works/generic_work.rb @@ -5,7 +5,7 @@ include Hydra::Works::GenericWorkBehavior include Sufia::Works::Work include Sufia::Works::CurationConcern::WithBasicMetadata - include Sufia::Works::GenericWork::Metadata + include Sufia::Works::Metadata # TODO: Remove these items once the collection size(#1120) and # processing tickets(#1122) are closed. include Sufia::GenericFile::Batches
Include the correct Metadata namespace. The previous code references a non-existing namespace (but Rails masked the issue and loaded the correct one)
diff --git a/recipes/repo.rb b/recipes/repo.rb index abc1234..def5678 100644 --- a/recipes/repo.rb +++ b/recipes/repo.rb @@ -24,12 +24,14 @@ yum_key 'nginx' do url 'http://nginx.org/keys/nginx_signing.key' + key 'RPM-GPG-KEY-Nginx' action :add end yum_repository 'nginx' do description 'Nginx.org Repository' url node['nginx']['upstream_repository'] + key 'RPM-GPG-KEY-Nginx' end when 'debian' include_recipe 'apt::default'
[COOK-3733] Update key name and enable gpg checking - Change the key name to match the yum dist style - Pass the key name into the repository to enable gpg checking Signed-off-by: Seth Vargo <81550dbf04dfd8537ff7b3c014c6fbf86e0889dc@gmail.com>
diff --git a/CLPlacemark-StateAbbreviation.podspec b/CLPlacemark-StateAbbreviation.podspec index abc1234..def5678 100644 --- a/CLPlacemark-StateAbbreviation.podspec +++ b/CLPlacemark-StateAbbreviation.podspec @@ -3,7 +3,7 @@ s.version = '0.1.0' s.license = { :type => 'MIT', :file => 'LICENSE' } s.homepage = "https://github.com/jweyrich/#{s.name}" - s.author = 'Jardel Weyrich' => 'jweyrich@gmail.com' + s.author = { 'Jardel Weyrich' => 'jweyrich@gmail.com' } s.summary = '...' s.source = { :git => "https://github.com/jweyrich/#{s.name}.git", :tag => "v#{s.version}" } @@ -14,4 +14,4 @@ s.framework = 'CoreLocation' s.ios.deployment_target = '5.0' s.requires_arc = true -end+end
podspec: Fix error caught by lint.
diff --git a/activesupport/lib/active_support/locale/en.rb b/activesupport/lib/active_support/locale/en.rb index abc1234..def5678 100644 --- a/activesupport/lib/active_support/locale/en.rb +++ b/activesupport/lib/active_support/locale/en.rb @@ -5,16 +5,19 @@ number: { nth: { ordinals: lambda do |_key, number:, **_options| - abs_number = number.to_i.abs - - if (11..13).cover?(abs_number % 100) - "th" + case number + when 1; "st" + when 2; "nd" + when 3; "rd" + when 4, 5, 6, 7, 8, 9, 10, 11, 12, 13; "th" else - case abs_number % 10 - when 1 then "st" - when 2 then "nd" - when 3 then "rd" - else "th" + num_modulo = number.to_i.abs % 100 + num_modulo %= 10 if num_modulo > 13 + case num_modulo + when 1; "st" + when 2; "nd" + when 3; "rd" + else "th" end end end,
Improve the performance of `ActiveSupport::Inflector.ordinal` This improves the performance for the most ordinalized numbers (1st, 2nd, 3rd, etc). ``` require "benchmark/ips" def o1(number) abs_number = number.to_i.abs if (11..13).include?(abs_number % 100) "th" else case abs_number % 10 when 1; "st" when 2; "nd" when 3; "rd" else "th" end end end def o3(number) case number when 1; "st" when 2; "nd" when 3; "rd" when 4, 5, 6, 7, 8, 9, 10, 11, 12, 13; "th" else num_modulo = number.to_i.abs % 100 if 11 <= num_modulo && num_modulo <= 13 "th" else case num_modulo % 10 when 1; "st" when 2; "nd" when 3; "rd" else "th" end end end end def o4(number) case number when 1; "st" when 2; "nd" when 3; "rd" when 4, 5, 6, 7, 8, 9, 10, 11, 12, 13; "th" else num_modulo = number.to_i.abs % 100 num_modulo %= 10 if num_modulo > 13 case num_modulo when 1; "st" when 2; "nd" when 3; "rd" else "th" end end end puts RUBY_DESCRIPTION Benchmark.ips do |x| x.report("orig") { o1(1); o1(2); o1(3); o1(4); o1(11); o1(111); o1(1523) } x.report("ord3") { o3(1); o3(2); o3(3); o3(4); o3(11); o3(111); o3(1523) } x.report("ord4") { o4(1); o4(2); o4(3); o4(4); o4(11); o4(111); o4(1523) } x.compare! end ``` ``` ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin15] Warming up -------------------------------------- orig 25.305k i/100ms ord3 121.146k i/100ms ord4 124.944k i/100ms Calculating ------------------------------------- orig 275.496k (± 2.4%) i/s - 1.392M in 5.054720s ord3 1.649M (± 5.0%) i/s - 8.238M in 5.009801s ord4 1.700M (± 7.0%) i/s - 8.496M in 5.031646s Comparison: ord4: 1700059.6 i/s ord3: 1649154.9 i/s - same-ish: difference falls within error orig: 275496.3 i/s - 6.17x slower ``` Closes #25020. [lvl0nax, Jeremy Daer, Ryuta Kamizono]
diff --git a/Casks/adobe-photoshop-lightroom600.rb b/Casks/adobe-photoshop-lightroom600.rb index abc1234..def5678 100644 --- a/Casks/adobe-photoshop-lightroom600.rb +++ b/Casks/adobe-photoshop-lightroom600.rb @@ -0,0 +1,33 @@+cask :v1 => 'adobe-photoshop-lightroom600' do + version '6.0' + sha256 '5c36e5fa76b8676144c4bba9790fe4c597daf350b2195a2088346b097f46a95f' + + url "http://trials3.adobe.com/AdobeProducts/LTRM/#{version.to_i}/osx10/Lightroom_#{version.to_i}_LS11.dmg", + :user_agent => :fake, + :cookies => { 'MM_TRIALS' => '1234' } + name 'Adobe Photoshop Lightroom' + homepage 'https://www.adobe.com/products/photoshop-lightroom.html' + license :commercial + + uninstall :delete => "/Applications/Adobe Lightroom/Adobe Lightroom.app" + zap :delete => [ + '~/Library/Application Support/Adobe/Lightroom', + "~/Library/Preferences/com.adobe.Lightroom#{version.to_i}.plist", + ] + + # staged_path not available in Installer/Uninstall Stanza, workaround by nesting with preflight/postflight + # see https://github.com/caskroom/homebrew-cask/pull/8887 + # and https://github.com/caskroom/homebrew-versions/pull/296 + + preflight do + system '/usr/bin/killall', '-kill', 'SafariNotificationAgent' + system '/usr/bin/sudo', '-E', '--', "#{staged_path}/Install.app/Contents/MacOS/Install", '--mode=silent', "--deploymentFile=#{staged_path}/deploy/AdobeLightroom6.install.xml" + end + + uninstall_preflight do + system '/usr/bin/killall', '-kill', 'SafariNotificationAgent' + system '/usr/bin/sudo', '-E', '--', "#{staged_path}/Install.app/Contents/MacOS/Install", "--mode=silent", "--deploymentFile=#{staged_path}/deploy/AdobeLightroom6.remove.xml" + end + + caveats 'Installation or Uninstallation may fail with Exit Code 19 (Conflicting Processes running) if Browsers, Safari Notification Service or SIMBL Services are running or Adobe Creative Cloud or any other Adobe Products are already installed. See Logs in /Library/Logs/Adobe/Installers if Installation or Uninstallation fails, to identify the conflicting processes.' +end
Add Adobe Lightroom 6.0 base installer
diff --git a/Casks/intellij-idea-ce-bundled-jdk.rb b/Casks/intellij-idea-ce-bundled-jdk.rb index abc1234..def5678 100644 --- a/Casks/intellij-idea-ce-bundled-jdk.rb +++ b/Casks/intellij-idea-ce-bundled-jdk.rb @@ -1,17 +1,19 @@ cask :v1 => 'intellij-idea-ce-bundled-jdk' do - version '14' - sha256 '09bb078252e2f6af6b58605ad3a380a71c8cc53f8e697e31fe03fcadb2152b07' + version '14.1' + sha256 '62c8b150ff82c31f2b6355a6f43b8ef69913b8f387cef6ddb4659622abb59a52' - url "http://download.jetbrains.com/idea/ideaIC-#{version}-jdk-bundled.dmg" + url "https://download.jetbrains.com/idea/ideaIC-#{version}-custom-jdk-bundled.dmg" + name 'IntelliJ IDEA' homepage 'https://www.jetbrains.com/idea/' - license :oss + license :apache - app "IntelliJ IDEA #{version} CE.app" - + app 'IntelliJ IDEA 14 CE.app' + zap :delete => [ - "~/Library/Application Support/IdeaIC#{version}", - "~/Library/Preferences/IdeaIC#{version}", - "~/Library/Caches/IdeaIC#{version}", - "~/Library/Logs/IdeaIC#{version}", + '~/Library/Preferences/com.jetbrains.intellij.ce.plist', + '~/Library/Preferences/IdeaIC14', + '~/Library/Application Support/IdeaIC14', + '~/Library/Caches/IdeaIC14', + '~/Library/Logs/IdeaIC14', ] end
Upgrade IntelliJ Idea CE with bundled JDK to 14.1 - Unify with other IntelliJ-based formulas (see #879)
diff --git a/app/concerns/resources_controller/kaminari.rb b/app/concerns/resources_controller/kaminari.rb index abc1234..def5678 100644 --- a/app/concerns/resources_controller/kaminari.rb +++ b/app/concerns/resources_controller/kaminari.rb @@ -15,11 +15,18 @@ end def per_page - if [nil, 'all'].include?(params[:per_page]) + # Return page size from configuration if per_page is not present in params + unless params.has_key?(:per_page) + return Rails::AddOns::Configuration.pagination_per_page_default + end + + # Return count of all records or nil if no records present if + # params[:per_page] equals 'all'. Otherwise return params[:per_page] + if params[:per_page] == 'all' count = load_collection_scope.count count > 0 ? count : nil else - Rails::AddOns::Configuration.pagination_per_page_default + params[:per_page] end end end
Fix pagination not respecting params[:per_page].
diff --git a/app/models/project_score_calculation_batch.rb b/app/models/project_score_calculation_batch.rb index abc1234..def5678 100644 --- a/app/models/project_score_calculation_batch.rb +++ b/app/models/project_score_calculation_batch.rb @@ -31,7 +31,10 @@ private def projects_scope - Project.platform(@platform).includes(eager_loads).where(id: @project_ids) + Project.platform(@platform) + .includes(eager_loads) + .where(id: @project_ids) + .order('runtime_dependencies_count ASC NULLS LAST') end def eager_loads
Order projects by least dependencies first
diff --git a/app/controllers/ratings_controller.rb b/app/controllers/ratings_controller.rb index abc1234..def5678 100644 --- a/app/controllers/ratings_controller.rb +++ b/app/controllers/ratings_controller.rb @@ -5,7 +5,7 @@ def create page.add_rating(params[:rating], rating_user_token) respond_to do |format| - format.js {render :text => page.average_rating} + format.js {render :json => {:average => page.average_rating, :votes => page.ratings.count}}.to_json format.html {redirect_to page.url} end end
Use JSON to also return the votes.