diff
stringlengths
65
26.7k
message
stringlengths
7
9.92k
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index abc1234..def5678 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -5,9 +5,7 @@ # Requires supporting ruby files with custom matchers and macros, etc, # in spec/support/ and its subdirectories. -Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} - -require 'spree/core/testing_support/factories' +Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |file| require file } RSpec.configure do |config| # == Mock Framework
Fix spec helper support file loader This line would work in a normal app, but the specs are run in the context of the dummy app, so Rails.root + spec is not going to find anything.
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index abc1234..def5678 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -14,3 +14,7 @@ def parse_stanza(xml) Nokogiri::XML.parse xml end + +def jruby? + RUBY_PLATFORM =~ /java/ +end
Fix checking for JRuby in the specs
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index abc1234..def5678 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -5,6 +5,15 @@ require 'paranoid' require 'yaml' require 'spec' + +$enabled = false + +ActiveSupport::Notifications.subscribe(/sql/i) do |*args| + if $enabled + event = ActiveSupport::Notifications::Event.new(*args) + puts "SQL #{event.duration}: #{event.payload[:sql]}" + end +end def connect(environment) conf = YAML::load(File.open(File.dirname(__FILE__) + '/database.yml'))
Allow logging of the sql output
diff --git a/yesand/spec/models/user_spec.rb b/yesand/spec/models/user_spec.rb index abc1234..def5678 100644 --- a/yesand/spec/models/user_spec.rb +++ b/yesand/spec/models/user_spec.rb @@ -17,4 +17,6 @@ it { should validate_uniqueness_of(:username) } + it { should allow_value('hello@hello.com').for(:email)} + end
Add email format validation test
diff --git a/gems/annoyance/lib/annoyance.rb b/gems/annoyance/lib/annoyance.rb index abc1234..def5678 100644 --- a/gems/annoyance/lib/annoyance.rb +++ b/gems/annoyance/lib/annoyance.rb @@ -1,4 +1,9 @@-require 'annoyance/engine' if defined?(Rails) +if defined?(Rails) + require 'annoyance/engine' +else + require_relative '../app/models/annoyance/levels' + require_relative '../app/models/annoyance/meter' +end module Annoyance end
Make gem work with and without rails
diff --git a/spec/unit/puppet/parser/functions/validate_bool_spec.rb b/spec/unit/puppet/parser/functions/validate_bool_spec.rb index abc1234..def5678 100644 --- a/spec/unit/puppet/parser/functions/validate_bool_spec.rb +++ b/spec/unit/puppet/parser/functions/validate_bool_spec.rb @@ -0,0 +1,68 @@+require 'puppet' + +# We don't need this for the basic tests we're doing +# require 'spec_helper' + +# Dan mentioned that Nick recommended the function method call +# to return the string value for the test description. +# this will not even try the test if the function cannot be +# loaded. +describe Puppet::Parser::Functions.function(:validate_bool) do + + # Pulled from Dan's create_resources function + def get_scope + @topscope = Puppet::Parser::Scope.new + # This is necessary so we don't try to use the compiler to discover our parent. + @topscope.parent = nil + @scope = Puppet::Parser::Scope.new + @scope.compiler = Puppet::Parser::Compiler.new(Puppet::Node.new("floppy", :environment => 'production')) + @scope.parent = @topscope + @compiler = @scope.compiler + end + + describe 'when calling validate_bool from puppet' do + it "should validate true and false as bare words" do + Puppet[:code] = 'validate_bool(true)' + get_scope + @scope.compiler.compile + end + it "should not compile when false is a string" do + Puppet[:code] = 'validate_bool("false")' + get_scope + expect { @scope.compiler.compile }.should raise_error(Puppet::ParseError, /is not a boolean/) + end + it "should not compile when an arbitrary string is passed" do + Puppet[:code] = 'validate_bool("jeff and dan are awesome")' + get_scope + expect { @scope.compiler.compile }.should raise_error(Puppet::ParseError, /is not a boolean/) + end + it "should not compile when no arguments are passed" do + Puppet[:code] = 'validate_bool()' + get_scope + expect { @scope.compiler.compile }.should raise_error(Puppet::ParseError, /wrong number of arguments/) + end + + it "should compile when multiple boolean arguments are passed" do + Puppet[:code] = <<-'ENDofPUPPETcode' + $foo = true + $bar = false + validate_bool($foo, $bar, true, false) + ENDofPUPPETcode + get_scope + @scope.compiler.compile + end + + it "should compile when multiple boolean arguments are passed" do + Puppet[:code] = <<-'ENDofPUPPETcode' + $foo = true + $bar = false + validate_bool($foo, $bar, true, false, 'jeff') + ENDofPUPPETcode + get_scope + expect { @scope.compiler.compile }.should raise_error(Puppet::ParseError, /is not a boolean/) + end + + end + +end +
Add spec test for validate_bool function This is an interesting spec test for module developers. It illustrates how to cause Puppet to test the function from the Puppet DSL rather than the Ruby DSL, fully exercising the system from the perspective of the end user. (Note how Puppet[:code] is set, then the scope reset, then the compile method called.) Paired-with: Dan Bode <2591e5f46f28d303f9dc027d475a5c60d8dea17a@puppetlabs.com>
diff --git a/pivotalcli.gemspec b/pivotalcli.gemspec index abc1234..def5678 100644 --- a/pivotalcli.gemspec +++ b/pivotalcli.gemspec @@ -21,7 +21,7 @@ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - spec.add_development_dependency "bundler", "~> 1.13" + spec.add_development_dependency "bundler", "~> 2.1" spec.add_development_dependency "rake", "~> 13.0" spec.add_development_dependency "rspec", "~> 3.0" spec.add_dependency "thor"
Update bundler requirement from ~> 1.13 to ~> 2.1 Updates the requirements on [bundler](https://github.com/bundler/bundler) to permit the latest version. - [Release notes](https://github.com/bundler/bundler/releases) - [Changelog](https://github.com/rubygems/bundler/blob/master/CHANGELOG.md) - [Commits](https://github.com/bundler/bundler/compare/v1.13.0...v2.1.4) Signed-off-by: dependabot-preview[bot] <5bdcd3c0d4d24ae3e71b3b452a024c6324c7e4bb@dependabot.com>
diff --git a/lib/fixbraces.rb b/lib/fixbraces.rb index abc1234..def5678 100644 --- a/lib/fixbraces.rb +++ b/lib/fixbraces.rb @@ -2,7 +2,7 @@ require "tempfile" module Fixbraces - def Fixbraces.fixbraces(text) + def self.fixbraces(text) text_changed = false # Move the opening brace to the same line as the opening clause @@ -19,7 +19,7 @@ text_changed ? text : nil end - def Fixbraces.process_file(file) + def self.process_file(file) corrected_text = "" # Read in the text and pass it to the method that corrects it. @@ -41,7 +41,7 @@ corrected_text ? file : nil end - def Fixbraces.dry_process_file(file) + def self.dry_process_file(file) corrected_text = "" # Read in the text and pass it to the method that corrects it.
Use self.method instead of Fixbraces.method
diff --git a/ContainerController.podspec b/ContainerController.podspec index abc1234..def5678 100644 --- a/ContainerController.podspec +++ b/ContainerController.podspec @@ -7,21 +7,21 @@ # Pod::Spec.new do |s| - s.name = 'HSContainerController' + s.name = 'ContainerController' s.version = File.read('VERSION') s.summary = 'Lightweight Swift Framework for iOS which let you replace UIViewController in UIContainerViews based on UIStoryboardSegues!' - s.homepage = 'https://github.com/tschob/HSContainerController.git' + s.homepage = 'https://github.com/tschob/ContainerController.git' # s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2' s.license = { :type => 'MIT', :file => 'LICENSE' } s.author = { 'Hans Seiffert' => 'hans.seiffert@gmail.com' } - s.source = { :git => 'https://github.com/tschob/HSContainerController.git', :tag => s.version.to_s } + s.source = { :git => 'https://github.com/tschob/ContainerController.git', :tag => s.version.to_s } s.platform = :ios s.ios.deployment_target = '8.0' - s.source_files = 'HSContainerController/**/*.{swift,h}' - s.public_header_files = 'HSContainerController/**/*.h' + s.source_files = 'ContainerController/**/*.{swift,h}' + s.public_header_files = 'ContainerController/**/*.h' s.frameworks = 'UIKit' end
Update podspec with new project name
diff --git a/lib/dimples/post.rb b/lib/dimples/post.rb index abc1234..def5678 100644 --- a/lib/dimples/post.rb +++ b/lib/dimples/post.rb @@ -25,6 +25,11 @@ @layout = @site.config['layouts']['post'] self.date = Time.mktime(parts[1], parts[2], parts[3]) + + @output_directory = File.join( + @date.strftime(@site.output_paths[:posts]), + @slug.to_s + ) end def date=(date) @@ -35,9 +40,8 @@ @day = @date.strftime('%d') end - def output_path(parent_path) - parent_path = @date.strftime(parent_path) if parent_path.match?(/%/) - File.join([parent_path, @slug.to_s, "#{@filename}.#{@extension}"]) + def inspect + "#<Dimples::Post @slug=#{@slug} @output_path=#{output_path}>" end end end
Set the output_directory on initialize, and add an inspect method.
diff --git a/lib/changeset_patch.rb b/lib/changeset_patch.rb index abc1234..def5678 100644 --- a/lib/changeset_patch.rb +++ b/lib/changeset_patch.rb @@ -12,7 +12,9 @@ def send_diff_emails logger.info "Sends called+++++++++++++++++++++++++++++++++++" if logger && logger.debug? # if repository.project.custom_value_for(CustomField.find_by_name("Send Diff Emails")) - DiffMailer.deliver_diff_notification(repository.diff("", previous.revision, revision), self) + if previous + DiffMailer.deliver_diff_notification(repository.diff("", previous.revision, revision), self) + end # end end end
Fix error when visit just created repository
diff --git a/lib/docomoru/client.rb b/lib/docomoru/client.rb index abc1234..def5678 100644 --- a/lib/docomoru/client.rb +++ b/lib/docomoru/client.rb @@ -1,5 +1,6 @@ require "docomoru/dialogue_methods" require "docomoru/response" +require "docomoru/version" require "active_support/core_ext/object/to_query" require "faraday" require "faraday_middleware"
Fix missing VERSION constant error
diff --git a/lib/needs_csv.rb b/lib/needs_csv.rb index abc1234..def5678 100644 --- a/lib/needs_csv.rb +++ b/lib/needs_csv.rb @@ -4,9 +4,10 @@ class NeedsCsv < CsvRenderer def to_csv CSV.generate do |csv| - csv << ["Id", "Title", "Context", "Tags", "Status", "Audiences", "Updated at"] + csv << ["Id", "Title", "Context", "Tags", "Status", "Audiences", "Updated at", "Statutory", "Search rank", "Pairwise rank", "Traffic", "Usage volume", "Interaction", "Related needs"] @data.each do |need| - csv << [need.id, need.title, need.description, need.tag_list, need.status, need.audiences.collect { |a| a.name }.join(", "), need.updated_at.to_formatted_s(:db)] + csv << [need.id, need.title, need.description, need.tag_list, need.status, need.audiences.collect { |a| a.name }.join(", "), need.updated_at.to_formatted_s(:db), + need.statutory, need.search_rank, need.pairwise_rank, need.traffic, need.usage_volume, need.interaction, need.related_needs] end end end
Include extra fields when exporting CSV
diff --git a/lib/micromachine.rb b/lib/micromachine.rb index abc1234..def5678 100644 --- a/lib/micromachine.rb +++ b/lib/micromachine.rb @@ -39,9 +39,7 @@ end def states - transitions_for.values.map do |transition| - [transition.keys, transition.values].flatten - end.flatten.uniq + events.map { |e| transitions_for[e].to_a }.flatten.uniq end def ==(some_state)
Convert to oneliner suggested by @sci-phi.
diff --git a/config/initializers/etsource.rb b/config/initializers/etsource.rb index abc1234..def5678 100644 --- a/config/initializers/etsource.rb +++ b/config/initializers/etsource.rb @@ -12,7 +12,11 @@ ETSOURCE_DIR = APP_CONFIG.fetch(:etsource_working_copy, 'etsource') ETSOURCE_EXPORT_DIR = ENV['ETSOURCE_DIR'] || APP_CONFIG.fetch(:etsource_export, 'etsource') -Atlas.data_dir = "#{ ETSOURCE_DIR }/data" +if ETSOURCE_DIR[0] == '/' + Atlas.data_dir = "#{ ETSOURCE_DIR }/data" +else + Atlas.data_dir = Rails.root.join(ETSOURCE_DIR).join('data') +end # On staging we might want to see the backtrace if Rails.env.production? && APP_CONFIG[:show_backtrace]
Fix using a relative ETSource directory Resolves test failures on Semaphore.
diff --git a/lib/tent-schemas.rb b/lib/tent-schemas.rb index abc1234..def5678 100644 --- a/lib/tent-schemas.rb +++ b/lib/tent-schemas.rb @@ -8,7 +8,7 @@ end def schemas - @schemas ||= schema_files.inject(Hash.new { |h,k| h[k.to_s] }) { |hash,schema| + @schemas ||= schema_files.inject(Hash.new { |h,k| h.has_key?(k.to_s) ? h[k.to_s] : nil }) { |hash,schema| schema_name = File.basename(schema, '.yaml') schema_directory = File.basename(File.dirname(schema)) schema_name = [schema_directory, schema_name].join('_') if schema_directory != 'schemas'
Fix TentSchemas.[](key): Stop SystemStackError from being raised when key doesn't exist
diff --git a/config/schedule.rb b/config/schedule.rb index abc1234..def5678 100644 --- a/config/schedule.rb +++ b/config/schedule.rb @@ -1,5 +1,5 @@ env :MAILTO, nil -every 3.hours do - runner "UpdateScheduler.perform_async" -end +# every 3.hours do +# runner "UpdateScheduler.perform_async" +# end
Disable auto updates for now
diff --git a/vendor/buildr/buildr-osgi-assembler/spec/spec_helper.rb b/vendor/buildr/buildr-osgi-assembler/spec/spec_helper.rb index abc1234..def5678 100644 --- a/vendor/buildr/buildr-osgi-assembler/spec/spec_helper.rb +++ b/vendor/buildr/buildr-osgi-assembler/spec/spec_helper.rb @@ -1,6 +1,6 @@ require 'spec' -DEFAULT_BUILDR_DIR=File.expand_path(File.dirname(__FILE__) + '/../../../../buildr') +DEFAULT_BUILDR_DIR=File.expand_path(File.dirname(__FILE__) + '/../../../../../buildr') BUILDR_DIR=ENV['BUILDR_DIR'] || DEFAULT_BUILDR_DIR unless File.exist?("#{BUILDR_DIR}/buildr.gemspec") @@ -19,7 +19,7 @@ def SandboxHook.included(spec_helpers) $LOAD_PATH.unshift(File.dirname(__FILE__)) $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) - require 'buildr_iidea' + require 'buildr_osgi_assembler' end end
Make sure helper works with current directory hierarchy
diff --git a/app/concerns/couriers/fusionable.rb b/app/concerns/couriers/fusionable.rb index abc1234..def5678 100644 --- a/app/concerns/couriers/fusionable.rb +++ b/app/concerns/couriers/fusionable.rb @@ -35,7 +35,6 @@ table.select("ROWID", "WHERE name='#{photo.key}'").map(&:values).map(&:first).map { |id| table.delete id } table.insert [photo.to_fusion] - sleep 1 end end end
Remove sleep from Fusion Tables
diff --git a/app/controllers/media_controller.rb b/app/controllers/media_controller.rb index abc1234..def5678 100644 --- a/app/controllers/media_controller.rb +++ b/app/controllers/media_controller.rb @@ -27,7 +27,7 @@ end def requested_via_private_vhost? - request.host == ENV['PRIVATE_ASSET_HOST'] + request.host == ENV['PRIVATE_ASSET_MANAGER_HOST'] end def asset_present_and_clean?
Change private host ENV VAR to be more explicit. This was driven by a need for clarity in the puppet config.
diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index abc1234..def5678 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -1,7 +1,7 @@ class PagesController < FrontendController def show if @page.nil? - not_found + raise ActiveRecord::RecordNotFound, "Record not found" else respond_to do |format| format.html
Fix bug with not_found method calling
diff --git a/app/controllers/track_controller.rb b/app/controllers/track_controller.rb index abc1234..def5678 100644 --- a/app/controllers/track_controller.rb +++ b/app/controllers/track_controller.rb @@ -1,6 +1,6 @@ class TrackController < ApplicationController def index - @upcoming_events = UpcomingEvents.find_all(:date => Date.new(2008, 6), :weeks => 6, :discipline => "Track") + @upcoming_events = UpcomingEvents.find_all(:weeks => 52, :discipline => "Track") end def schedule
Remove hard-coded date from track upcoming events, and default to entire year in advance
diff --git a/lib/gutentag/tag_validations.rb b/lib/gutentag/tag_validations.rb index abc1234..def5678 100644 --- a/lib/gutentag/tag_validations.rb +++ b/lib/gutentag/tag_validations.rb @@ -15,7 +15,7 @@ :uniqueness => {:case_sensitive => false} limit = klass.columns_hash["name"].limit - klass.validates_length_of :name, :maximum => limit if limit + klass.validates_length_of :name, :maximum => limit if limit.present? end private
Use limit.present? to make the condition more explicit
diff --git a/app/models/setup/collection_name.rb b/app/models/setup/collection_name.rb index abc1234..def5678 100644 --- a/app/models/setup/collection_name.rb +++ b/app/models/setup/collection_name.rb @@ -5,7 +5,7 @@ included do field :name, type: String - validates_format_of :name, with: /\A([a-z]|_)+\Z/ + validates_format_of :name, with: /\A([a-z]|_|\d)+\Z/ end end -end+end
Add number option into validates format
diff --git a/lib/mbsy/util/single_sign_on.rb b/lib/mbsy/util/single_sign_on.rb index abc1234..def5678 100644 --- a/lib/mbsy/util/single_sign_on.rb +++ b/lib/mbsy/util/single_sign_on.rb @@ -12,7 +12,8 @@ raise ArgumentError, "key :email is required" if options[:email].blank? raise ArgumentError, ":method must be either :login or :logout" unless %w(login logout).include?( options[:method].to_s ) signature = Digest::SHA1.hexdigest( options[:api_key] + options[:email] ) - %Q|<img src="https://#{Mbsy.user_name}.getambassador.com/sso/#{options[:method]}/?token=#{options[:token]}&email=#{CGI::escape(options[:email])}&signature=#{signature}" style="border: none; visibility: hidden" alt="" />| + domain = if options[:domain].blank? then "#{Mbsy.user_name}.getambassador.com" else options[:domain] end + %Q|<img src="https://#{domain}/sso/#{options[:method]}/?token=#{options[:token]}&email=#{CGI::escape(options[:email])}&signature=#{signature}" style="border: none; visibility: hidden" alt="" />| end
Add option for custom domain to single sign on - Adds `domain` argument to `Mbsy.SingleSignOn.embed_html` - Falls back to existing `username.getambassador.com` behavior
diff --git a/lib/perpetuity/attribute_set.rb b/lib/perpetuity/attribute_set.rb index abc1234..def5678 100644 --- a/lib/perpetuity/attribute_set.rb +++ b/lib/perpetuity/attribute_set.rb @@ -2,8 +2,11 @@ class AttributeSet include Enumerable - def initialize + def initialize *attributes @attributes = {} + attributes.each do |attribute| + self << attribute + end end def << attribute
Allow AttributeSet to be initialized w/ attributes
diff --git a/recipes/rsyslog.rb b/recipes/rsyslog.rb index abc1234..def5678 100644 --- a/recipes/rsyslog.rb +++ b/recipes/rsyslog.rb @@ -0,0 +1,26 @@+# +# extremly basic loghost setup +# + +if node[:rsyslog].has_key?('server_ip') + + loghost_line = "*.*\t@" + loghost_line =+ '@' if node['rsyslog']['protocol'] == 'tcp' + loghost_line =+ node[:rsyslog][:server_ip] + if node['rsyslog'].has_key?('port') + loghost_line =+ node['rsyslog']['port'] unless node['rsyslog']['port'] == 514 + end + + # forward everything to the loghost: + file '/etc/rsyslog.d/loghost.conf' do + content = "#{loghost_line}\n" + notifies :restart, "service[rsyslog]" + end + + service "rsyslog" do + supports :restart => true, :reload => true, :status => true + action [:enable, :start] + end + +end +
Add recipe for loghost config
diff --git a/lib/serverspec/commands/base.rb b/lib/serverspec/commands/base.rb index abc1234..def5678 100644 --- a/lib/serverspec/commands/base.rb +++ b/lib/serverspec/commands/base.rb @@ -57,7 +57,7 @@ def check_cron_entry user, entry entry_escaped = entry.gsub(/\*/, '\\*') - "crontab -u #{user} -l | grep '#{entry_escaped}'" + "crontab -u #{user} -l | grep \"#{entry_escaped}\"" end def check_link link, target
Change the quote character of argument string of grep, from single to double. Because single quote doesn't work correctly with escaped single quote in the argument string. (I don't know why)
diff --git a/OKObserver.podspec b/OKObserver.podspec index abc1234..def5678 100644 --- a/OKObserver.podspec +++ b/OKObserver.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "OKObserver" - s.version = "0.1.0" + s.version = "0.0.0" s.summary = "A lightweight framework which makes KVO easily to use." s.description = <<-DESC
Remove version field in podspec
diff --git a/adamantium.gemspec b/adamantium.gemspec index abc1234..def5678 100644 --- a/adamantium.gemspec +++ b/adamantium.gemspec @@ -5,15 +5,15 @@ Gem::Specification.new do |gem| gem.name = 'adamantium' gem.version = Adamantium::VERSION.dup - gem.authors = [ 'Dan Kubb', 'Markus Schirp' ] - gem.email = [ 'dan.kubb@gmail.com', 'mbj@seonic.net' ] + gem.authors = ['Dan Kubb', 'Markus Schirp'] + gem.email = %w[dan.kubb@gmail.com mbj@seonic.net] gem.description = 'Immutable extensions to objects' gem.summary = gem.description gem.homepage = 'https://github.com/dkubb/adamantium' - gem.require_paths = [ 'lib' ] - gem.files = `git ls-files`.split("\n") - gem.test_files = `git ls-files -- {spec}/*`.split("\n") + gem.require_paths = %w[lib] + gem.files = `git ls-files`.split($/) + gem.test_files = `git ls-files -- {spec}/*`.split($/) gem.extra_rdoc_files = %w[LICENSE README.md TODO] gem.add_runtime_dependency('backports', '~> 2.6.1')
Fix code formatting in gemspec
diff --git a/lib/spiderfw/controller/session/flash_hash.rb b/lib/spiderfw/controller/session/flash_hash.rb index abc1234..def5678 100644 --- a/lib/spiderfw/controller/session/flash_hash.rb +++ b/lib/spiderfw/controller/session/flash_hash.rb @@ -13,7 +13,13 @@ def reset @active = {} + @accessed = {} @sub_flashes.each{ |k, f| f.reset } + end + + def [](key) + @accessed[key] = true + super end def []=(key, val) @@ -39,7 +45,7 @@ end def purge - self.delete_if{ |k, v| !@active[k] } + self.delete_if{ |k, v| @accessed[k] && !@active[k] } @sub_flashes.each{ |k, f| f.purge } end
Remove variable from flash only when accessed
diff --git a/lib/sunspot/redis_index_queue/ordered_heap.rb b/lib/sunspot/redis_index_queue/ordered_heap.rb index abc1234..def5678 100644 --- a/lib/sunspot/redis_index_queue/ordered_heap.rb +++ b/lib/sunspot/redis_index_queue/ordered_heap.rb @@ -20,8 +20,8 @@ def range!(score_begin, score_end, limit = NO_LIMIT) redis.synchronize do result = redis.zrangebyscore(name, score_begin.to_i, score_end.to_i, :limit => [0, limit]) - if result.count > 0 - redis.zrem(name, result) + result.each do |item| + redis.zrem(name, item) end result.map {|item| unserialize(item) } end
Remove items from redis one by one instead of all in bulk (it's 2.4+ feature)
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index abc1234..def5678 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -3,6 +3,15 @@ unless defined?(SPEC_ROOT) SPEC_ROOT = File.expand_path("../", __FILE__) +end + +# The fixtures are UTF-8 encoded. +# Make sure Ruby uses the proper encoding. +if RUBY_VERSION < '1.9' + $KCODE='u' +else + Encoding.default_external = Encoding::UTF_8 + Encoding.default_internal = Encoding::UTF_8 end # Requires supporting ruby files with custom matchers and macros, etc,
Make sure Ruby uses the right encoding and doesn't rely on ENV settings.
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index abc1234..def5678 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -2,3 +2,12 @@ include SpecInfra::Helper::Exec +SPEC_TYPE = 'SpecInfra' + +module SpecInfra + module Commands + class Base + # dummy class for test + end + end +end
Add dummy commands::base class for testing
diff --git a/lib/buoys/link.rb b/lib/buoys/link.rb index abc1234..def5678 100644 --- a/lib/buoys/link.rb +++ b/lib/buoys/link.rb @@ -21,7 +21,7 @@ end def current? - !!@current + @current end def url
Fix `Avoid the use of double negation (!!).`
diff --git a/Casks/duet.rb b/Casks/duet.rb index abc1234..def5678 100644 --- a/Casks/duet.rb +++ b/Casks/duet.rb @@ -1,9 +1,9 @@ cask :v1 => 'duet' do - version '1.2.5' - sha256 'd3c178b6b07347fcacc62396706f4f6b9efbbc8d8eb7b0b5f003df0406d59143' + version '1.2.9' + sha256 'de45914dd00923e372a1d2aa205f4d14e27dd005c228af093a8e9a95d7516951' # devmate.com is the official download host per the vendor homepage - url "http://dl.devmate.com/com.kairos.duet/#{version}/1422514272/duet-#{version}.zip" + url 'http://dl.devmate.com/com.kairos.duet/1.2.9/1430518908/duet-1.2.9.zip' name 'Duet' homepage 'http://www.duetdisplay.com/' license :unknown
Upgrade Duet Display to v1.2.9 Updating Duet Display to version 1.2.9. URL change reflects the fact that it changes more than just the version number.
diff --git a/test/project_generator_test.rb b/test/project_generator_test.rb index abc1234..def5678 100644 --- a/test/project_generator_test.rb +++ b/test/project_generator_test.rb @@ -13,6 +13,7 @@ def test_generate_project Ichiban::ProjectGenerator.new(project_dest).generate + # Test that each of these files exists: %w( Capfile html/index.html
Test that project generator creates .gitignore in compiled dir
diff --git a/nomadize.gemspec b/nomadize.gemspec index abc1234..def5678 100644 --- a/nomadize.gemspec +++ b/nomadize.gemspec @@ -13,14 +13,6 @@ spec.homepage = "https://github.com/piisalie/nomadize" spec.license = "MIT" - # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or - # delete this section to allow pushing this gem to any host. - if spec.respond_to?(:metadata) - spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'" - else - raise "RubyGems 2.0 or newer is required to protect against public gem pushes." - end - spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } spec.bindir = "exe" spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } @@ -30,5 +22,5 @@ spec.add_development_dependency "rake", "~> 10.0" spec.add_development_dependency "minitest" - spec.add_dependency "pg" + spec.add_dependency "pg", "~> 0.18.1" end
Add version contraint for pg
diff --git a/app/controllers/spree/retail/shopify_hooks_controller.rb b/app/controllers/spree/retail/shopify_hooks_controller.rb index abc1234..def5678 100644 --- a/app/controllers/spree/retail/shopify_hooks_controller.rb +++ b/app/controllers/spree/retail/shopify_hooks_controller.rb @@ -0,0 +1,26 @@+module Spree + module Retail + class ShopifyHookController < ApplicationController + before_filter :verify_request_authenticity + + private + + def verify_request_authenticity + data = request.body.read + + head :unauthorized unless request_authentified?(data, Spree::Retail::Config.shopify_shared_secret) + end + + def request_authentified?(data, secret) + hmac_header = env['HTTP_X_SHOPIFY_HMAC_SHA256'] + digest = OpenSSL::Digest::Digest.new('sha256') + calculated_hmac = Base64.encode64(OpenSSL::HMAC.digest(digest, secret, data)).strip + calculated_hmac == hmac_header + end + + def json_body + @_json_body ||= JSON.parse(request.body.read) + end + end + end +end
Add the shopify webhook controller This will be used for all the webhook controllers that depends on Shopify. Less code duplication yay!
diff --git a/test/servers/sidekiq/worker.rb b/test/servers/sidekiq/worker.rb index abc1234..def5678 100644 --- a/test/servers/sidekiq/worker.rb +++ b/test/servers/sidekiq/worker.rb @@ -14,7 +14,13 @@ ::Instana.logger.warn "Booting background Sidekiq worker..." Thread.new do - system("INSTANA_GEM_TEST=true sidekiq #{cmd_line}") + begin + system("INSTANA_GEM_TEST=true sidekiq #{cmd_line}") + ensure + # Get and send a kill signal to the sidekiq process + s = File.read(Dir.pwd + "/test/tmp/sidekiq_#{Process.pid}.pid") + Process.kill("QUIT", s.chop.to_i) + end end -sleep 10 +sleep 7
Send SIGQUIT to sidekiq when exiting.
diff --git a/rspec_rake.gemspec b/rspec_rake.gemspec index abc1234..def5678 100644 --- a/rspec_rake.gemspec +++ b/rspec_rake.gemspec @@ -22,4 +22,5 @@ spec.add_development_dependency "bundler", "~> 1.11" spec.add_development_dependency "rake", "~> 10.0" spec.add_development_dependency "rspec", "~> 3.0" + spec.add_development_dependency "pry" end
Add pry to development dependency
diff --git a/ochibako-share.gemspec b/ochibako-share.gemspec index abc1234..def5678 100644 --- a/ochibako-share.gemspec +++ b/ochibako-share.gemspec @@ -0,0 +1,14 @@+Gem::Specification.new do |s| + s.name = 'ochibako-share' + s.version = '0.0.0' + s.date = '2015-03-02' + s.summary = "A CLI client for uploading and sharing files" + s.description = "A Ruby CLI client to upload files to your Dropbox and obtain URL to share them." + s.authors = ["zunda"] + s.email = 'zundan@gmail.com' + s.executables = %w(ochibako-share ochibako-share-auth) + s.homepage = 'https://github.com/zunda/ochibako-share#readme' + s.license = 'MIT' + s.add_dependency('dropbox-sdk') +end +
Create first version of gemspec
diff --git a/save_queue.gemspec b/save_queue.gemspec index abc1234..def5678 100644 --- a/save_queue.gemspec +++ b/save_queue.gemspec @@ -21,5 +21,5 @@ # specify any dependencies here; for example: s.add_development_dependency "rspec", ">= 2.6" s.add_development_dependency "rake" - s.add_runtime_dependency "active_support" + s.add_runtime_dependency "activesupport" end
Fix typo in activesupport gem
diff --git a/lib/health_monitor/providers/sidekiq.rb b/lib/health_monitor/providers/sidekiq.rb index abc1234..def5678 100644 --- a/lib/health_monitor/providers/sidekiq.rb +++ b/lib/health_monitor/providers/sidekiq.rb @@ -47,7 +47,11 @@ end def check_redis! - ::Sidekiq.redis(&:info) + if ::Sidekiq.respond_to?(:redis_info) + ::Sidekiq.redis_info + else + ::Sidekiq.redis(&:info) + end end end end
Fix deprecation warning when using Sidekiq with redis-namespace Passing 'info' command to redis as is; administrative commands cannot be effectively namespaced and should be called on the redis connection directly; passthrough has been deprecated and will be removed in redis-namespace 2.0
diff --git a/lib/post_publisher/twitter/publisher.rb b/lib/post_publisher/twitter/publisher.rb index abc1234..def5678 100644 --- a/lib/post_publisher/twitter/publisher.rb +++ b/lib/post_publisher/twitter/publisher.rb @@ -6,22 +6,18 @@ end def publish(args) - result = @client.update(args.tweet) - - { - content: args.tweet, - id: result.id - } - + @client.update(args.tweet) rescue => error - puts error + PostPublisher::Logger.error(error) + return false end def retweet(args) tweet = ::Twitter::Tweet.new(id: args.tweet_id) @client.retweet(tweet) rescue => error - puts error + PostPublisher::Logger.error(error) + return false end end end
Raise error when update or retweet failed
diff --git a/lib/proxy_rb/drivers/selenium_driver.rb b/lib/proxy_rb/drivers/selenium_driver.rb index abc1234..def5678 100644 --- a/lib/proxy_rb/drivers/selenium_driver.rb +++ b/lib/proxy_rb/drivers/selenium_driver.rb @@ -19,15 +19,12 @@ return end - options = { - proxy: { - http: proxy.url.to_s - } - } + profile = Selenium::WebDriver::Firefox::Profile.new + profile.proxy = Selenium::WebDriver::Proxy.new(http: format('%s:%s', proxy.host, proxy.port)) unless ::Capybara.drivers.key? proxy.to_ref ::Capybara.register_driver proxy.to_ref do |app| - ::Capybara::Selenium::Driver.new(app, options) + ::Capybara::Selenium::Driver.new(app, profile: profile) end end
Set the proxy via profile
diff --git a/lib/schema/schema/compare/comparison.rb b/lib/schema/schema/compare/comparison.rb index abc1234..def5678 100644 --- a/lib/schema/schema/compare/comparison.rb +++ b/lib/schema/schema/compare/comparison.rb @@ -14,20 +14,20 @@ attr_names ||= control_attributes.keys entries = attr_names.map do |attr_name| - build_entry(attr_name, control_attributes, compare_attributes) + build_entry(attr_name, control_attributes, attr_name, compare_attributes) end new(entries) end - def self.build_entry(attr_name, control_attributes, compare_attributes) - control_value = control_attributes[attr_name] - compare_value = compare_attributes[attr_name] + def self.build_entry(control_attr_name, control_attributes, compare_attr_name, compare_attributes) + control_value = control_attributes[control_attr_name] + compare_value = compare_attributes[compare_attr_name] entry = Entry.new( - attr_name, + control_attr_name, control_value, - attr_name, + compare_attr_name, compare_value )
Build entry receives both control and compare attribute names
diff --git a/capistrano-paratrooper-chef.gemspec b/capistrano-paratrooper-chef.gemspec index abc1234..def5678 100644 --- a/capistrano-paratrooper-chef.gemspec +++ b/capistrano-paratrooper-chef.gemspec @@ -15,5 +15,5 @@ gem.require_paths = ["lib"] gem.version = Capistrano::Paratrooper::Chef::VERSION - gem.add_dependency("capistrano") + gem.add_dependency("capistrano", "~> 2.14") end
Add version limitation; could not work with capistrano-3.x
diff --git a/messaging.gemspec b/messaging.gemspec index abc1234..def5678 100644 --- a/messaging.gemspec +++ b/messaging.gemspec @@ -1,7 +1,7 @@ # -*- encoding: utf-8 -*- Gem::Specification.new do |s| s.name = 'evt-messaging' - s.version = '0.8.0.0' + s.version = '0.8.0.1' s.summary = 'Messaging primitives for Eventide' s.description = ' '
Package version is increased from 0.8.0.0 to 0.8.0.1
diff --git a/messaging.gemspec b/messaging.gemspec index abc1234..def5678 100644 --- a/messaging.gemspec +++ b/messaging.gemspec @@ -1,7 +1,7 @@ # -*- encoding: utf-8 -*- Gem::Specification.new do |s| s.name = 'evt-messaging' - s.version = '0.25.1.0' + s.version = '0.26.0.0' s.summary = 'Common primitives for platform-specific messaging implementations for Eventide' s.description = ' '
Package version is increased from 0.25.1.0 to 0.26.0.0
diff --git a/messaging.gemspec b/messaging.gemspec index abc1234..def5678 100644 --- a/messaging.gemspec +++ b/messaging.gemspec @@ -1,7 +1,7 @@ # -*- encoding: utf-8 -*- Gem::Specification.new do |s| s.name = 'evt-messaging' - s.version = '0.29.0.10' + s.version = '0.29.0.11' s.summary = 'Common primitives for platform-specific messaging implementations for Eventide' s.description = ' '
Package version is increased from 0.29.0.10 to 0.29.0.11
diff --git a/db/migrate/20170224113808_remove_specialist_document_editions_with_non_manual_document_type.rb b/db/migrate/20170224113808_remove_specialist_document_editions_with_non_manual_document_type.rb index abc1234..def5678 100644 --- a/db/migrate/20170224113808_remove_specialist_document_editions_with_non_manual_document_type.rb +++ b/db/migrate/20170224113808_remove_specialist_document_editions_with_non_manual_document_type.rb @@ -0,0 +1,9 @@+class RemoveSpecialistDocumentEditionsWithNonManualDocumentType < Mongoid::Migration + def self.up + SpecialistDocumentEdition.where(:document_type.ne => 'manual').delete_all + end + + def self.down + raise IrreversibleMigration + end +end
Remove SpecialistDocumentEditions w/ non-manual document_type These should've been removed when the related specialist documents were moved to the newer Specialist Publisher application around the time of this large commit [1]. I've tested this migration against a dump of the production database taken on 2017-02-24. I ran the `document_types_report` script before and after running the migration to confirm that: * Only SpecialistDocumentEditions with a non-manual document_type were affected. * No ManualRecord::Editions were made childless nor ManualRecords made grand-childless. Since it's not currently possible to add non-manual SpecialistDocumentEditions via the user interface, it's safe to assume that this will continue to be the case in the production database until this migration is run. I've recorded the results of this test in a gist [2]. You can see that all 23018 SpecialistDocumentEditions with a non-manual document_type were deleted and 3688 with a manual document_type were left intact. [1]: 3162f0e72fd53bfd1cf87f5661bb198ff785940e [2]: https://gist.github.com/floehopper/93d519f75192c356e1b9a0b6151c951c
diff --git a/test/run.rb b/test/run.rb index abc1234..def5678 100644 --- a/test/run.rb +++ b/test/run.rb @@ -36,7 +36,7 @@ def self.run - Test::Unit::UI::Console::TestRunner.run( self ) + Test::Unit::UI::Console::TestRunner.run( self, output_level: Test::Unit::UI::Console::OutputLevel::VERBOSE ) end
Use verbose level of Test::Unit
diff --git a/spec/chore_spec.rb b/spec/chore_spec.rb index abc1234..def5678 100644 --- a/spec/chore_spec.rb +++ b/spec/chore_spec.rb @@ -21,6 +21,13 @@ expect { Chore.run_hooks_for(:before_perform) }.to_not raise_error end + it 'should pass args to the block if present' do + blk = proc {|*args| true } + blk.should_receive(:call).with('1','2',3) + Chore.add_hook(:an_event,&blk) + Chore.run_hooks_for(:an_event, '1','2',3) + end + it 'should support multiple hooks for an event' do blk = proc { true } blk.should_receive(:call).twice @@ -35,4 +42,5 @@ Chore.config.test_config_option.should == 'howdy' end + end
Add specs for the argument handling for global hooks
diff --git a/relative_date.rb b/relative_date.rb index abc1234..def5678 100644 --- a/relative_date.rb +++ b/relative_date.rb @@ -1,3 +1,4 @@+# adapted from http://stackoverflow.com/a/195894/391999 module RelativeDate def to_relative a = (Time.now-self).to_i
Add comment with source for RelativeDate
diff --git a/LYCategory.podspec b/LYCategory.podspec index abc1234..def5678 100644 --- a/LYCategory.podspec +++ b/LYCategory.podspec @@ -5,7 +5,7 @@ s.summary = 'The categories.' s.description = <<-DESC -The categories. +The categories for Objective-C. DESC s.homepage = 'https://github.com/blodely/LYCategory'
Modify : pod spec description
diff --git a/lib/capistrano/tasks/itamae.rake b/lib/capistrano/tasks/itamae.rake index abc1234..def5678 100644 --- a/lib/capistrano/tasks/itamae.rake +++ b/lib/capistrano/tasks/itamae.rake @@ -7,7 +7,7 @@ run_locally do with target_host: target, ssh_config: ssh_config do roles.each do |role| - execute :itamae, :ssh, "-F #{ssh_config}", "-h #{target}", "-y nodes/#{role}.yml", "roles/#{role}.rb" + execute :itamae, :ssh, "--ssh-config #{ssh_config}", "-h #{target}", "-y nodes/#{role}.yml", "roles/#{role}.rb" end end end
Use `--ssh-config` instead of `-F`
diff --git a/plugins/VMStatus.rb b/plugins/VMStatus.rb index abc1234..def5678 100644 --- a/plugins/VMStatus.rb +++ b/plugins/VMStatus.rb @@ -0,0 +1,79 @@+# -------------------------------------------------------------------------- # +# Copyright 2011-2012, Research In Motion Limited # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # +# +# This plugin checks the health of MySQL instances in an environment. It +# assumes all VMs in the envrionment will run MySQL server and uses the +# 'mysqladmin ping' command to check + +class VMStatus < Plugin + def initialize + @nummissing=0 + @numunknown=0 + @numfailed=0 + @numvms = 0 + @lastCheckTime = Hash.new + end + + def getVMStatus(envid) + now= Time.now + elapsedTime=0 + if @lastCheckTime[envid] != nil + elaspedTime = now - @lastCheckTime[envid] + return if elapsedTime < 30 + end + @lastCheckTime[envid]=now + + env = $envManager.getEnv(envid) + vmList = env.getVMList() + mastervmfailed=false + vmList.each { |vm| + @numvms += 1 + @nummissing += 1 if vm.status == "MISSING" + @numunknown += 1 if vm.status == "UNKNOWN" + @numfailed += 1 if vm.status == "FAILED" + } + end + + def numvms(envid) + getVMStatus(envid) + return @numvms + end + + def nummissing(envid) + getVMStatus(envid) +puts "nummissing=#{@nummissing}" + return @nummissing + end + + def numunknown(envid) + getVMStatus(envid) + return @numunknown + end + + def numfailed(envid) + getVMStatus(envid) + return @numfailed + end + + + def getMetrics + return ['numvms', 'nummissing', 'numunknown', 'numfailed'] + end + + def getMetrics + return ['numvms', 'nummissing', 'numunknown', 'numfailed'] + end +end
Support for custom metrics in availablity policies
diff --git a/lib/forem/default_permissions.rb b/lib/forem/default_permissions.rb index abc1234..def5678 100644 --- a/lib/forem/default_permissions.rb +++ b/lib/forem/default_permissions.rb @@ -19,7 +19,11 @@ unless method_defined?(:can_read_forem_forum?) def can_read_forem_forum?(forum) - true + return true if forum.allowed_viewers.empty? + + user = Forem.user_class.new + p forum.allowed_viewers + forum.allowed_viewers.include? user end end
Change default permissions for forem forum
diff --git a/lib/girl_friday/error_handler.rb b/lib/girl_friday/error_handler.rb index abc1234..def5678 100644 --- a/lib/girl_friday/error_handler.rb +++ b/lib/girl_friday/error_handler.rb @@ -15,7 +15,7 @@ class ErrorHandler class Hoptoad def handle(ex) - HoptoadNotifier.notify(ex) + HoptoadNotifier.notify_or_ignore(ex) end end end
Use notify_or_ignore so Hoptoad can ignore the exception based on local config
diff --git a/lib/libis/workflow/task_group.rb b/lib/libis/workflow/task_group.rb index abc1234..def5678 100644 --- a/lib/libis/workflow/task_group.rb +++ b/lib/libis/workflow/task_group.rb @@ -5,6 +5,9 @@ # noinspection RubyTooManyMethodsInspection class TaskGroup < Libis::Workflow::Task + + parameter abort_on_failure: true, + description: 'Stop processing tasks if one task fails.' attr_accessor :tasks @@ -38,6 +41,7 @@ debug 'Running subtask (%d/%d): %s', item, i+1, tasks.size, task.name task.run item status[item.status(task.namepath)] += 1 + break if parameter(:abort_on_failure) && item.status(task.namepath) != :DONE end substatus_check(status, item, 'task')
Make task group stop when subtask fails
diff --git a/lib/money-rails/mongoid/three.rb b/lib/money-rails/mongoid/three.rb index abc1234..def5678 100644 --- a/lib/money-rails/mongoid/three.rb +++ b/lib/money-rails/mongoid/three.rb @@ -13,9 +13,9 @@ # Get the object as it was stored in the database, and instantiate # this custom class from it. def demongoize(object) - if object.is_a?(Hash) && object.has_key?(:cents) + if object.is_a?(Hash) object = object.symbolize_keys - ::Money.new(object[:cents], object[:currency_iso]) + object.has_key?(:cents) ? ::Money.new(object[:cents], object[:currency_iso]) : nil else nil end
Fix error when the keys are not symbolized in mongoid
diff --git a/lib/spontaneous/prawn/context.rb b/lib/spontaneous/prawn/context.rb index abc1234..def5678 100644 --- a/lib/spontaneous/prawn/context.rb +++ b/lib/spontaneous/prawn/context.rb @@ -2,7 +2,7 @@ module Context def asset_path(path, options = {}) asset = _asset_environment.find_assets(path, options).first - asset.pathname.to_s + asset.pathname#.to_s end end end
Return a Pathname rather than a string for assets
diff --git a/lib/tasks/default_user_data.rake b/lib/tasks/default_user_data.rake index abc1234..def5678 100644 --- a/lib/tasks/default_user_data.rake +++ b/lib/tasks/default_user_data.rake @@ -3,9 +3,13 @@ task populate: :environment do Rhinoart::User.create!(name: "Admin", email: "admin@test.com", - roles: "ROLE_ADMIN", + name: "Admin User", + admin_role: "Super User", + approved: 1, password: "admin", - password_confirmation: "admin") + password_confirmation: "admin", + ) + # 99.times do |n| # name = Faker::Name.name # email = Faker::Internet.email
Change default data for install
diff --git a/recipes/build.rb b/recipes/build.rb index abc1234..def5678 100644 --- a/recipes/build.rb +++ b/recipes/build.rb @@ -24,8 +24,9 @@ # Set custom packages source folder if !node['package']['folder'].empty? cwd "#{node['package']['folder_path']}/#{node['package']['folder']}" + else + cwd "#{node['package']['folder_path']}/#{node['package']['name']}-#{node['package']['version']}" end - cwd "#{node['package']['folder_path']}/#{node['package']['name']}-#{node['package']['version']}" command 'dpkg-buildpackage -rfakeroot -uc -b' end end
Fix stupid issue with source folder.
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 @@ -4,6 +4,9 @@ ENV['RAILS_ENV'] ||= 'test' require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' + +ActiveRecord::Migration.maintain_test_schema! + require 'mocha/test_unit' require 'webmock/minitest' WebMock.disable_net_connect!(:allow => "codeclimate.com")
Test helper now handles preparing the test DB automatically rake db:test:prepare is deprected, and is replaced by this line.
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 @@ -1,7 +1,7 @@ require 'test/unit' require 'yaml' require 'fileutils' -require File.dirname(__FILE__)+'/../ownet.rb' +require File.dirname(__FILE__)+'/../lib/ownet.rb' class Test::Unit::TestCase def with_fake_owserver
Fix the require of ownet.
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,7 +6,7 @@ Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new -class Minitest::Spec +class ActiveSupport::TestCase include FactoryGirl::Syntax::Methods before :each do
Update test helper to better suit rails
diff --git a/test/app_helpers.rb b/test/app_helpers.rb index abc1234..def5678 100644 --- a/test/app_helpers.rb +++ b/test/app_helpers.rb @@ -0,0 +1,47 @@+require 'test_helper' +require 'camping' + +Camping.goes :Helpers + +module Helpers::Helpers + def frontpage + R(Index) + end + + def current_user + User.new + end +end + +module Helpers::Models + class User + def name + 'Bob' + end + end +end + +module Helpers::Controllers + class Index + def get + current_user.name + end + end + + class Users + def get + frontpage + end + end +end + +class Helpers::Test < TestCase + def test_inline + get '/' + assert_body "Bob" + + get '/users' + assert_body "/" + end +end +
Add failing test for controllers/models in helpers
diff --git a/softlayer-report-cli.gemspec b/softlayer-report-cli.gemspec index abc1234..def5678 100644 --- a/softlayer-report-cli.gemspec +++ b/softlayer-report-cli.gemspec @@ -22,8 +22,6 @@ spec.add_dependency 'thor', '~> 0.19.1' spec.add_dependency 'terminal-table', '~> 1.5.2' - spec.add_development_dependency 'bundler', '~> 1.10' spec.add_development_dependency 'rake', '~> 10.0' - spec.add_development_dependency 'pry', '~> 0.10.0' spec.add_development_dependency 'rspec' end
Remove excess baggage fro dev deps
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 @@ -1,7 +1,4 @@ $LOAD_PATH.unshift File.expand_path('../lib', __FILE__) - -require 'minitest/autorun' -require 'minitest/pride' unless ENV['CI'] require 'simplecov' @@ -15,5 +12,8 @@ end end +require 'minitest/autorun' +require 'minitest/pride' + # So we can be sure we have coverage on the whole lib directory: Dir.glob('lib/*.rb').each { |file| require file.gsub(%r{(^lib\/|\.rb$)}, '') }
Move simplecov code before minitest is required
diff --git a/spec/factories/line_items.rb b/spec/factories/line_items.rb index abc1234..def5678 100644 --- a/spec/factories/line_items.rb +++ b/spec/factories/line_items.rb @@ -6,6 +6,9 @@ price "0.99" title "Banana" description "Most delicious banana of all time!" + invoice + credit_account + debit_account end factory :vat do
Add associations to banana line item factory.
diff --git a/spec/raven/backtrace_spec.rb b/spec/raven/backtrace_spec.rb index abc1234..def5678 100644 --- a/spec/raven/backtrace_spec.rb +++ b/spec/raven/backtrace_spec.rb @@ -5,7 +5,20 @@ @backtrace = Raven::Backtrace.parse(Thread.current.backtrace) end + it "#lines" do + expect(@backtrace.lines.first).to be_a(Raven::Backtrace::Line) + end + it "#inspect" do expect(@backtrace.inspect).to match(/Backtrace: .*>$/) end + + it "#to_s" do + expect(@backtrace.to_s).to match(/backtrace_spec.rb:5/) + end + + it "==" do + @backtrace2 = Raven::Backtrace.new(@backtrace.lines) + expect(@backtrace).to be == @backtrace2 + end end
Add small amount of extra Backtrace test coverage
diff --git a/lib/leaflet-draw-rails.rb b/lib/leaflet-draw-rails.rb index abc1234..def5678 100644 --- a/lib/leaflet-draw-rails.rb +++ b/lib/leaflet-draw-rails.rb @@ -1,4 +1,11 @@ require "leaflet-draw-rails/version" +require "leaflet-draw-rails/testing" + +if defined? RSpec + RSpec.configure do |spec| + spec.include Leaflet::Draw::Rails::Testing + end +end module Leaflet module Draw
RSpec: Include Testing module, that will contain helpers for tests.
diff --git a/uninhibited.gemspec b/uninhibited.gemspec index abc1234..def5678 100644 --- a/uninhibited.gemspec +++ b/uninhibited.gemspec @@ -12,11 +12,12 @@ s.homepage = "http://bernerdschaefer.github.com/uninhibited" s.summary = "" s.description = s.summary + s.files = Dir.glob("lib/**/*.rb") + %w(README.md MIT_LICENSE) s.required_rubygems_version = ">= 1.3.6" s.rubyforge_project = "uninhibited" s.add_runtime_dependency "rspec", "~> 2.0.0.beta.19" - - s.files = Dir.glob("lib/**/*.rb") + %w(README.md MIT_LICENSE) + s.add_development_dependency "yard" + s.add_development_dependency "bluecloth" end
Use yard for generating documentation
diff --git a/lib/dense.rb b/lib/dense.rb index abc1234..def5678 100644 --- a/lib/dense.rb +++ b/lib/dense.rb @@ -8,6 +8,5 @@ require 'dense/path' require 'dense/parser' -require 'dense/errors' require 'dense/methods'
Drop useless IndexableError (take 2)
diff --git a/Casks/balsamiq-mockups.rb b/Casks/balsamiq-mockups.rb index abc1234..def5678 100644 --- a/Casks/balsamiq-mockups.rb +++ b/Casks/balsamiq-mockups.rb @@ -1,6 +1,6 @@ cask 'balsamiq-mockups' do - version '3.5.4' - sha256 'ef2ae819ffee8d7fe1641a260c8fa695caaa8719274b8c733baea5f83f953ae1' + version '3.5.5' + sha256 'b08819effb63fa3361e2286d4e580bc67edf30c16962c34453e191ccbcfc482e' url "https://builds.balsamiq.com/mockups-desktop/Balsamiq_Mockups_#{version}.dmg" name 'Balsamiq Mockups'
Update Balsamiq Mockups to 3.5.5
diff --git a/app/models/call.rb b/app/models/call.rb index abc1234..def5678 100644 --- a/app/models/call.rb +++ b/app/models/call.rb @@ -1,4 +1,7 @@ class Call < ActiveRecord::Base + belongs_to :player + belongs_to :round + def bid return nil if bs? Bid.new number, face_value
Create associations in Call model
diff --git a/app/models/page.rb b/app/models/page.rb index abc1234..def5678 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -15,8 +15,8 @@ enum status: %i(draft published blocked) - validates :name, presence: true - + validates :title, presence: true + validates :main, uniqueness: true # triggered unless page is not itself and is not selected as the main page before_save :drop_other_main, on: %i(create update destroy), if: ->(o) { o.main? } @@ -33,6 +33,6 @@ private def drop_other_main - self.class.where('id != ? AND main', self.id).update_all("main = 'false'") + self.class.where(main: true).where.not(id: self.id).update_all(main: false) end end
Update Page to drop other main boolean flags
diff --git a/app/models/user.rb b/app/models/user.rb index abc1234..def5678 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,6 +1,10 @@ class User < ActiveRecord::Base def self.from_omniauth(auth) - where(provider: auth['provider'], uid: auth['uid']).first || create_from_omniauth(auth) + user = where(provider: auth['provider'], uid: auth['uid']).first || create_from_omniauth(auth) + user.token = auth['credentials']['token'] + user.secret = auth['credentials']['secret'] + user.save! + user end def self.create_from_omniauth(auth) @@ -8,8 +12,6 @@ user.provider = auth['provider'] user.uid = auth['uid'] user.username = auth['info']['username'] - user.token = auth['credentials']['token'] - user.secret = auth['credentials']['secret'] end end end
Set the token and secret every time in case they've changed
diff --git a/gemfiles/travis.rb b/gemfiles/travis.rb index abc1234..def5678 100644 --- a/gemfiles/travis.rb +++ b/gemfiles/travis.rb @@ -1,6 +1,6 @@ source "https://rubygems.org".freeze -gem "codeclimate-test-reporter".freeze +gem "codeclimate-test-reporter".freeze if RUBY_VERSION >= "1.9".freeze gem "json".freeze, "~> 1.8.3".freeze gem "rake".freeze, "~> 10.5.0".freeze gem "rspec".freeze
Install `codeclimate-test-reporter` only in Ruby 1.9+ versions.
diff --git a/gen_idl_history.rb b/gen_idl_history.rb index abc1234..def5678 100644 --- a/gen_idl_history.rb +++ b/gen_idl_history.rb @@ -10,9 +10,11 @@ def read_hist_from_file(file) res = [] - open(File.expand_path(file)) do |f| - while l = f.gets - res << extract_idl_command(l.chomp) + if File.exist?(File.expand_path(file)) then + open(File.expand_path(file)) do |f| + while l = f.gets + res << extract_idl_command(l.chomp) + end end end res.reverse
Add check if file exists
diff --git a/gitmethere.gemspec b/gitmethere.gemspec index abc1234..def5678 100644 --- a/gitmethere.gemspec +++ b/gitmethere.gemspec @@ -20,6 +20,7 @@ spec.add_development_dependency "bundler", "~> 1.6" spec.add_development_dependency "rake", "~> 10.0" + spec.add_development_dependency "rspec", "~> 3.0" spec.add_runtime_dependency "git", "~> 1.2"
Add rspec as development dependency
diff --git a/lib/PDB/secondary_structure.rb b/lib/PDB/secondary_structure.rb index abc1234..def5678 100644 --- a/lib/PDB/secondary_structure.rb +++ b/lib/PDB/secondary_structure.rb @@ -2,6 +2,13 @@ module PDB + # From Stride Documentation + # H alpha helix + # G 3-10 + # I PI helix + # Extended conformation + # T turn - many types + # C coil class SecondaryStructure attr_reader :structure, :subtype_index @@ -12,4 +19,6 @@ end end + + end
Add some annotation of secondary structure from STRIDE documentation
diff --git a/guard-less.gemspec b/guard-less.gemspec index abc1234..def5678 100644 --- a/guard-less.gemspec +++ b/guard-less.gemspec @@ -16,7 +16,7 @@ # s.rubyforge_project = 'guard-less' s.add_dependency 'guard', '>= 0.2.2' - s.add_dependency 'less', '~> 2.1.0' + s.add_dependency 'less', '~> 2.3' s.add_development_dependency 'bundler', '~> 1.0' s.add_development_dependency 'fakefs', '~> 0.3'
Update less dependency to current version 2.3.x
diff --git a/uberspacify.gemspec b/uberspacify.gemspec index abc1234..def5678 100644 --- a/uberspacify.gemspec +++ b/uberspacify.gemspec @@ -25,7 +25,7 @@ gem.add_dependency 'rack' , '>=1.4.1' gem.add_dependency 'daemon_controller', '>=1.0.0' - # dependencies for mysql on Uberspace + # dependency for mysql on Uberspace gem.add_dependency 'mysql2' - gem.add_dependency 'activerecord-mysql2-adapter' + end
Revert "needs activerecord-mysql2-adapter as well" ...because it doesn't This reverts commit 0ed01cd0cf0a4c941c15090efd126f4b0a92cee7.
diff --git a/lib/happy-helpers/templates.rb b/lib/happy-helpers/templates.rb index abc1234..def5678 100644 --- a/lib/happy-helpers/templates.rb +++ b/lib/happy-helpers/templates.rb @@ -3,10 +3,12 @@ module HappyHelpers module Templates def self.render(name, scope = nil, variables = {}, &block) - load("views/%s" % name).render(scope, variables, &block) + load(name).render(scope, variables, &block) end def self.load(name) + name = File.expand_path(name) + if false # Freddie.env.production? @templates ||= {} @templates[name] ||= Tilt.new(name, :default_encoding => 'utf-8')
Remove hardcoded "views/" view path.
diff --git a/lib/thinking_sphinx/railtie.rb b/lib/thinking_sphinx/railtie.rb index abc1234..def5678 100644 --- a/lib/thinking_sphinx/railtie.rb +++ b/lib/thinking_sphinx/railtie.rb @@ -1,6 +1,10 @@ # frozen_string_literal: true class ThinkingSphinx::Railtie < Rails::Railtie + config.to_prepare do + ThinkingSphinx::Configuration.reset + end + initializer 'thinking_sphinx.initialisation' do ActiveSupport.on_load(:active_record) do ActiveRecord::Base.send :include, ThinkingSphinx::ActiveRecord::Base
Reset configuration when Rails reloads. I feel like I've hit this problem before, and I thought I'd restructured things in v3 onwards to avoid it, but I guess not. It's reared its head again in #1125 - the cached configuration's indices kept onto their old references to models, whereas models returned from ActiveRecord search calls were using the new references, and thus not quite matching. It wasn't a problem if all models were using the default primary key of 'id', but otherwise with alternative primary keys things would break.
diff --git a/lib/media_master_client/base.rb b/lib/media_master_client/base.rb index abc1234..def5678 100644 --- a/lib/media_master_client/base.rb +++ b/lib/media_master_client/base.rb @@ -10,22 +10,41 @@ @@app_uid = app_uid end + def self.app_uid + @@app_uid + end + def self.app_secret=(app_secret) @@app_secret = app_secret + end + + def self.app_secret + @@app_secret end def self.host=(host) @@host = host end + def self.host + @@host + end + def self.username=(username) @@username = username + end + + def self.username + @@username end def self.password=(password) @@password = password end + def self.password + @@password + end
Add getter methods for configuration attributes
diff --git a/lib/rom/support/class_macros.rb b/lib/rom/support/class_macros.rb index abc1234..def5678 100644 --- a/lib/rom/support/class_macros.rb +++ b/lib/rom/support/class_macros.rb @@ -27,28 +27,23 @@ # # @api private def defines(*args) - mod = Module.new - - args.each do |name| - mod.module_eval <<-RUBY, __FILE__, __LINE__ + 1 - def #{name}(value = Undefined) + mod = Module.new do + args.each do |name| + define_method(name) do |value = Undefined| + ivar = "@#{name}" if value == Undefined - defined?(@#{name}) && @#{name} + defined?(ivar) && instance_variable_get(ivar) else - @#{name} = value + instance_variable_set(ivar, value) end end - RUBY + end + + define_method(:inherited) do |klass| + superclass.send(:inherited, klass) + args.each { |name| klass.send(name, send(name)) } + end end - - delegates = args.map { |name| "klass.#{name}(#{name})" }.join("\n") - - mod.module_eval <<-RUBY, __FILE__, __LINE__ + 1 - def inherited(klass) - super - #{delegates} - end - RUBY extend(mod) end
Modify ClassMacros to use define_method Using define_method in favor of module_eval should perform better. See: https://tenderlovemaking.com/2013/03/03/dynamic_method_definitions.html
diff --git a/app/models/forem/topic.rb b/app/models/forem/topic.rb index abc1234..def5678 100644 --- a/app/models/forem/topic.rb +++ b/app/models/forem/topic.rb @@ -4,7 +4,7 @@ belongs_to :forum belongs_to :user - has_many :posts, :dependent => :destroy + has_many :posts, :dependent => :destroy, :order => "created_at ASC" accepts_nested_attributes_for :posts validates :subject, :presence => true
Order posts by created_at ASC
diff --git a/app/services/feed_info.rb b/app/services/feed_info.rb index abc1234..def5678 100644 --- a/app/services/feed_info.rb +++ b/app/services/feed_info.rb @@ -29,13 +29,18 @@ def parse_feed_and_operators # feed feed = Feed.from_gtfs(@gtfs, url: @url) + feed = Feed.find_by_onestop_id(feed.onestop_id) || feed # operators operators = [] @gtfs.agencies.each do |agency| next if agency.stops.size == 0 operator = Operator.from_gtfs(agency) + operator = Operator.find_by_onestop_id(operator.onestop_id) || operator operators << operator - feed.operators_in_feed.new(gtfs_agency_id: agency.id, operator: operator, id: nil) + feed.operators_in_feed.find_or_initialize_by( + gtfs_agency_id: agency.id, + operator: operator + ) end # done return [feed, operators]
Check for existing Feed and Operator
diff --git a/app/models/player.rb b/app/models/player.rb index abc1234..def5678 100644 --- a/app/models/player.rb +++ b/app/models/player.rb @@ -17,10 +17,10 @@ end def pickup!(card) - actions.create!(effect: Action::PICKUP, card: card) + actions.pickup.create!(card: card) end def play!(card) - actions.create!(effect: Action::PLAY, card: card) + actions.play.create!(card: card) end end
Refactor action creation method to use play and pickup scopes
diff --git a/app/contexts/events_filtering.rb b/app/contexts/events_filtering.rb index abc1234..def5678 100644 --- a/app/contexts/events_filtering.rb +++ b/app/contexts/events_filtering.rb @@ -1,5 +1,5 @@ require 'role_playing' -require 'refinements/method_chain' +require 'core_ext/then_if' require 'paginated_dataset' require 'date_filtered_dataset' @@ -20,8 +20,12 @@ [DateFilteredDataset, PaginatedDataset].played_by(@dataset) do |dataset| dataset .filter_by_date(from: params[:from], to: params[:to]) - .then(-> { format != :ical }) { |d| d.paginate(offset: params[:offset], limit: params[:limit]) } + .then_if(paginate?) { |d| d.paginate(offset: params[:offset], limit: params[:limit]) } end end + private + def paginate? + format != :ical + end end
Use then_if in events filtering
diff --git a/app/helpers/topologies_helper.rb b/app/helpers/topologies_helper.rb index abc1234..def5678 100644 --- a/app/helpers/topologies_helper.rb +++ b/app/helpers/topologies_helper.rb @@ -3,7 +3,7 @@ if topology.new_record? && topology.graph.blank? TopologyTemplate::DEFAULT_GRAPH elsif topology.graph.is_a?(String) - topology.graph + topology.graph.to_json else JSON.dump(topology.graph.to_hash) end
Convert topology graph as string to json Fixes: #1552
diff --git a/app/helpers/transcribe_helper.rb b/app/helpers/transcribe_helper.rb index abc1234..def5678 100644 --- a/app/helpers/transcribe_helper.rb +++ b/app/helpers/transcribe_helper.rb @@ -12,7 +12,7 @@ pivot, end_index = match.offset(0) # Generate a list of \n indexes - linebreaks = [0] + linebreaks = [0, text.length] text.to_enum(:scan,/\n/).each {|m,| linebreaks.push $`.size} ## Sensible index defaults @@ -20,7 +20,7 @@ post = text.length - 1 # Separate the \n before and after the main match (ignore \n in the title) - left, right = linebreaks.reject{|idx| idx > pivot && idx < end_index } + left, right = linebreaks.uniq.reject{|idx| idx > pivot && idx < end_index } .partition {|idx| idx < pivot } # Set new pre/post indexes based on line radius
Fix for 1-line documents (no \n)
diff --git a/spec/facade_spec.rb b/spec/facade_spec.rb index abc1234..def5678 100644 --- a/spec/facade_spec.rb +++ b/spec/facade_spec.rb @@ -0,0 +1,57 @@+require 'fileutils' +require 'spec_helper' +require 'tmpdir' + +module Vim + module Flavor + describe Facade do + describe '#create_vim_script_for_bootstrap' do + around :each do |example| + Dir.mktmpdir do |tmp_path| + @tmp_path = tmp_path + example.run + end + end + + it 'creates a bootstrap script to configure runtimepath for flavors' do + vimfiles_path = @tmp_path.to_vimfiles_path + Facade.new().create_vim_script_for_bootstrap(vimfiles_path) + + File.should exist(vimfiles_path.to_flavors_path.to_bootstrap_path) + + _rtp = %x{ + for plugin_name in 'foo' 'bar' 'baz' + do + mkdir -p "#{vimfiles_path.to_flavors_path}/$plugin_name" + done + HOME='#{@tmp_path}' vim -u NONE -i NONE -n -N -e -s -c ' + set verbose=1 + let vimfiles_path = split(&runtimepath, ",")[0] + runtime flavors/bootstrap.vim + for path in split(&runtimepath, ",") + if stridx(path, vimfiles_path) == 0 + echo substitute(path, vimfiles_path, "!", "") + endif + endfor + qall! + ' 2>&1 + } + rtps = + _rtp. + split(/[\r\n]/). + select {|p| p != ''} + rtps.should == [ + '!', + '!/flavors/bar', + '!/flavors/baz', + '!/flavors/foo', + '!/flavors/foo/after', + '!/flavors/baz/after', + '!/flavors/bar/after', + '!/after', + ] + end + end + end + end +end
Add a spec for bootstrap script
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index abc1234..def5678 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -8,6 +8,8 @@ require 'rubygems' require 'bundler/setup' +MINIMUM_COVERAGE = 57 + if ENV['COVERAGE'] require 'simplecov' require 'simplecov-rcov' @@ -16,6 +18,14 @@ add_filter '/vendor/' add_filter '/spec/' add_group 'lib', 'lib' + end + SimpleCov.at_exit do + SimpleCov.result.format! + percent = SimpleCov.result.covered_percent + unless percent >= MINIMUM_COVERAGE + puts "Coverage must be above #{MINIMUM_COVERAGE}%. It is #{"%.2f" % percent}%" + Kernel.exit(1) + end end end
Add coverage requirements (57% is current coverage)
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index abc1234..def5678 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -2,7 +2,8 @@ require 'simplecov' if ENV['COVERAGE'] SimpleCov.start do - add_filter "/spec/" + add_filter '/spec/' + add_filter '/vendor/' end end rescue LoadError
Add simplecov filter for vendor directory
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index abc1234..def5678 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -26,5 +26,5 @@ RSpec.configure do |config| config.platform = 'centos' - config.version = '6.5' + config.version = '6.6' end
Set centos 6.6 as the os version