diff
stringlengths
65
26.7k
message
stringlengths
7
9.92k
diff --git a/recipes/wp-database.rb b/recipes/wp-database.rb index abc1234..def5678 100644 --- a/recipes/wp-database.rb +++ b/recipes/wp-database.rb @@ -19,7 +19,6 @@ # include_recipe "mysql::client" unless platform_family?('windows') # No MySQL client on Windows -include_recipe "mysql::ruby" db = node['wordpress']['db']
Update for use with v5.0.0 of community coookbook
diff --git a/lib/tasks/maintenance.rake b/lib/tasks/maintenance.rake index abc1234..def5678 100644 --- a/lib/tasks/maintenance.rake +++ b/lib/tasks/maintenance.rake @@ -0,0 +1,42 @@+namespace :maintenance do + desc "Dump the current database, replace it with what's in production" + task export: :environment do + filename = File.join(Rails.root, "#{Rails.env}.sql.gz") + db_config = current_db_config(Rails.env) + system "#{mysqldump(db_config)} | gzip -c > #{filename}" + end + + desc "Import a database" + task import: :environment do + filename = ENV['FILE'] + raise "Need a FILE" unless file + raise "I refuse to blow away production" if Rails.env.production? + db_config = current_db_config(Rails.env) + system "gzip -d -c #{filename} | #{mysql(db_config)}" + end + + def current_db_config(env) + YAML::load(ERB.new(IO.read(File.join(Rails.root, 'config', 'database.yml'))).result)[env] + end + + def mysql(config) + sql_cmd("mysql", config) + end + + def mysqldump(config) + sql_cmd("mysqldump", config) + " --add-drop-table --extended-insert=TRUE --disable-keys --complete-insert=FALSE --triggers=FALSE" + end + + def sql_cmd(sql_command, config) + "".tap do |cmd| + cmd << sql_command + cmd << " " + cmd << "-u#{config["username"]} " if config["username"] + cmd << "-p#{config["password"]} " if config["password"] + cmd << "-h#{config["host"]} " if config["host"] + cmd << "-P#{config["port"]} " if config["port"] + cmd << "--default-character-set utf8 " + cmd << config["database"] if config["database"] + end + end +end
Make the filename more descriptive
diff --git a/lib/alf/sequel/unit_of_work/update.rb b/lib/alf/sequel/unit_of_work/update.rb index abc1234..def5678 100644 --- a/lib/alf/sequel/unit_of_work/update.rb +++ b/lib/alf/sequel/unit_of_work/update.rb @@ -6,9 +6,44 @@ def initialize(connection, relvar_name, updating, predicate) super(connection) - @relvar_name = relvar_name - @updating = updating - @predicate = predicate + @relvar_name = relvar_name + @updating = updating + @predicate = predicate + end + + def matching_relation + raise IllegalStateError, "Unit of work not ran" unless ran? + + # Check that updating is understandable + unless TupleLike===@updating + raise UnsupportedError, "Non-tuple update feedback is unsupported." + end + updating = @updating.to_hash + updating_keys = updating.keys + + # extract all keys, and pk in particular + keys = connection.keys(@relvar_name) + pk = keys.first + + # Strategy 1), @updating contains a key + if key = keys.to_a.find{|k| !(k & updating_keys).empty? } + return Relation(@updating.project(key).to_hash) + end + + raise UnsupportedError, "Unable to extract update matching relation" + end + + def pk_matching_relation + mr, pkey = matching_relation, connection.keys(@relvar_name).first + if mr.to_attr_list == pkey.to_attr_list + mr + else + filter = mr.tuple_extract.to_hash + tuples = connection.cog(@relvar_name) + .filter(filter) + .select(pkey.to_a) + Relation(tuples) + end end private
Add matching_relation and pk_matching_relation to UnitOfWork::Update
diff --git a/lib/protest/utils/backtrace_filter.rb b/lib/protest/utils/backtrace_filter.rb index abc1234..def5678 100644 --- a/lib/protest/utils/backtrace_filter.rb +++ b/lib/protest/utils/backtrace_filter.rb @@ -6,6 +6,9 @@ ESCAPE_PATHS = [ # Path to the library's 'lib' dir. /^#{Regexp.escape(File.dirname(File.dirname(File.dirname(File.expand_path(__FILE__)))))}/, + + # Users certainly don't care about what test loader is being used + %r[lib/rake/rake_test_loader.rb], %r[bin/testrb] ] # Convenience method to clean the API a bit
Clean the backtraces a bit more Ignore the test loaders from the backtrace, it's irrelevant to the test when it fails if it's loaded via rake, testrb, or whatever. And if it's not, then your problem isn't the backtrace :P
diff --git a/lib/kuroko2/configuration.rb b/lib/kuroko2/configuration.rb index abc1234..def5678 100644 --- a/lib/kuroko2/configuration.rb +++ b/lib/kuroko2/configuration.rb @@ -9,10 +9,10 @@ @config ||= build_config end + private + def build_config - filename = Rails.root.join('config', 'kuroko2.yml') - yaml = YAML::load(ERB.new(File.read(filename)).result) - Hashie::Mash.new(DEFAULT_CONFIG.merge(yaml[Rails.env])) + Hashie::Mash.new(DEFAULT_CONFIG.merge(Rails.application.config_for('kuroko2'))) end end end
Make use `config_for` method for loading config file Since Rails 4.2 YAML configuration files can be easily loaded with the new config_for
diff --git a/lib/mastermind/mastermind.rb b/lib/mastermind/mastermind.rb index abc1234..def5678 100644 --- a/lib/mastermind/mastermind.rb +++ b/lib/mastermind/mastermind.rb @@ -2,7 +2,12 @@ def initialize end + def clear + print "\e[2J\e[f" + end + def run + clear puts 'Welcome to MASTERMIND' puts 'Would you like to (p)lay, read the (i)nstructions, or (q)uit?' command = '' @@ -23,6 +28,7 @@ end end end + end mastermind = Mastermind.new
Add a clear screen function on game start
diff --git a/lib/monarchy/acts_as_role.rb b/lib/monarchy/acts_as_role.rb index abc1234..def5678 100644 --- a/lib/monarchy/acts_as_role.rb +++ b/lib/monarchy/acts_as_role.rb @@ -11,7 +11,7 @@ has_many :members_roles, dependent: :destroy, class_name: 'Monarchy::MembersRole' has_many :members, through: :members_roles, class_name: "::#{Monarchy.member_class}" - belongs_to :inherited_role, class_name: "::#{Monarchy.role_class}" + belongs_to :inherited_role, class_name: "::#{Monarchy.role_class}", optional: true after_create :default_inherited_role
Fix rails 5 belongs_to require validation
diff --git a/lib/multi_json/engines/oj.rb b/lib/multi_json/engines/oj.rb index abc1234..def5678 100644 --- a/lib/multi_json/engines/oj.rb +++ b/lib/multi_json/engines/oj.rb @@ -5,6 +5,8 @@ # Use the Oj library to encode/decode. class Oj ParseError = SyntaxError + + ::Oj.default_options = {:mode => :compat} def self.decode(string, options = {}) #:nodoc: ::Oj.load(string, options)
Set Oj to compat mode
diff --git a/lib/rake/loaders/makefile.rb b/lib/rake/loaders/makefile.rb index abc1234..def5678 100644 --- a/lib/rake/loaders/makefile.rb +++ b/lib/rake/loaders/makefile.rb @@ -4,18 +4,16 @@ class MakefileLoader include Rake::DSL - SPACE_MARK = "__&NBSP;__" + SPACE_MARK = "\0" # Load the makefile dependencies in +fn+. def load(fn) - open(fn) do |mf| - lines = mf.read - lines.gsub!(/\\ /, SPACE_MARK) - lines.gsub!(/#[^\n]*\n/m, "") - lines.gsub!(/\\\n/, ' ') - lines.split("\n").each do |line| - process_line(line) - end + lines = File.read fn + lines.gsub!(/\\ /, SPACE_MARK) + lines.gsub!(/#[^\n]*\n/m, "") + lines.gsub!(/\\\n/, ' ') + lines.each_line do |line| + process_line(line) end end @@ -23,17 +21,17 @@ # Process one logical line of makefile data. def process_line(line) - file_tasks, args = line.split(':') + file_tasks, args = line.split(':', 2) return if args.nil? dependents = args.split.map { |d| respace(d) } - file_tasks.strip.split.each do |file_task| + file_tasks.scan(/\S+/) do |file_task| file_task = respace(file_task) file file_task => dependents end end def respace(str) - str.gsub(/#{SPACE_MARK}/, ' ') + str.tr SPACE_MARK, ' ' end end
Deal with escaped spaces better. Ruby commit r22791
diff --git a/lib/realtime/view_helpers.rb b/lib/realtime/view_helpers.rb index abc1234..def5678 100644 --- a/lib/realtime/view_helpers.rb +++ b/lib/realtime/view_helpers.rb @@ -1,29 +1,26 @@ module Realtime - module ViewHelpers + module ViewHelpers - def realtime_support - return render(:template =>"realtime/realtime_support", - :layout => nil, - :locals => - { :realtime_token => @realtime_token, - :realtime_domain => @realtime_domain, - :realtime_server_url => @realtime_server_url, - :realtime_user_id => @realtime_user_id }).to_s - - end + def realtime_support + return render(template: "realtime/realtime_support", + layout: nil, + locals: + { realtime_token: @realtime_token, + realtime_domain: @realtime_domain, + realtime_server_url: @realtime_server_url, + realtime_user_id: @realtime_user_id }).to_s + end - def realtime_message_handler - return render(:template =>"realtime/realtime_message_handler", - :layout => nil, - :locals => {}).to_s - - end + def realtime_message_handler + return render(template: "realtime/realtime_message_handler", + layout: nil, + locals: {}).to_s + end - def realtime_message_console_logger - return render(:template =>"realtime/realtime_message_console_logger", - :layout => nil, - :locals => {}).to_s - - end - end -end+ def realtime_message_console_logger + return render(template: "realtime/realtime_message_console_logger", + layout: nil, + locals: {}).to_s + end + end +end
Switch the view helpers to the new Ruby hash notation
diff --git a/dummy/test/test_helper.rb b/dummy/test/test_helper.rb index abc1234..def5678 100644 --- a/dummy/test/test_helper.rb +++ b/dummy/test/test_helper.rb @@ -1,4 +1,4 @@-Rails.env = "test" +ENV['RAILS_ENV'] = 'test' require File.expand_path("../../config/environment", __FILE__) require "rails/test_help" require "minitest/rails"
Use ENV, fixes uninitialized constant Rails (NameError)
diff --git a/rumember.gemspec b/rumember.gemspec index abc1234..def5678 100644 --- a/rumember.gemspec +++ b/rumember.gemspec @@ -14,6 +14,13 @@ "rumember.gemspec", "bin/ru", "lib/rumember.rb", + "lib/rumember/abstract.rb", + "lib/rumember/account.rb", + "lib/rumember/list.rb", + "lib/rumember/location.rb", + "lib/rumember/task.rb", + "lib/rumember/timeline.rb", + "lib/rumember/transaction.rb", ] s.add_runtime_dependency("json", ["~> 1.4.0"]) s.add_runtime_dependency("launchy", ["~> 0.3.0"])
Add missing files to gemspec
diff --git a/spec/infrastructure/location_repository_spec.rb b/spec/infrastructure/location_repository_spec.rb index abc1234..def5678 100644 --- a/spec/infrastructure/location_repository_spec.rb +++ b/spec/infrastructure/location_repository_spec.rb @@ -15,4 +15,34 @@ found_location = location_repository.find(UnLocode.new('HKG')) found_location.should == location end + + it "Location can be stored and then found" do + + locations = { + 'USCHI' => 'Chicago', + 'USDAL' => 'Dallas', + # 'SEGOT' => 'Göteborg', + 'DEHAM' => 'Hamburg', + 'CNHGH' => 'Hangzhou', + 'FIHEL' => 'Helsinki', + 'CNHKG' => 'Hongkong', + 'AUMEL' => 'Melbourne', + 'USNYC' => 'New York', + 'NLRTM' => 'Rotterdam', + 'CNSHA' => 'Shanghai', + 'SESTO' => 'Stockholm', + 'JNTKO' => 'Tokyo' + } + location_repository = LocationRepository.new + + # TODO Replace this quick-and-dirty data teardown... + location_repository.nuke_all_locations + + locations.each do | code, name | + location_repository.store(Location.new(UnLocode.new(code), name)) + end + + found_locations = location_repository.find_all() + found_locations.size.should == 10 + end end
Initialize locations with hash list.
diff --git a/post_install.rb b/post_install.rb index abc1234..def5678 100644 --- a/post_install.rb +++ b/post_install.rb @@ -1,4 +1,4 @@ # This file is executed in the Rails environment by rails-post-install # Create any necessary global Censor rules -require 'censor_rules.rb' +require 'censor_rules'
Fix syntax of require statement.
diff --git a/paperclip-sftp.gemspec b/paperclip-sftp.gemspec index abc1234..def5678 100644 --- a/paperclip-sftp.gemspec +++ b/paperclip-sftp.gemspec @@ -20,7 +20,7 @@ gem.add_dependency "paperclip", "~> 3.2.0" gem.add_dependency "net-sftp", "~> 2.0.5" - gem.add_development_dependency "minitest", "~> 3.3.0" - gem.add_development_dependency "minitest_should", "~> 0.3.1" - gem.add_development_dependency "sqlite3", "~> 1.3.3" + gem.add_development_dependency "minitest" + gem.add_development_dependency "minitest_should" + gem.add_development_dependency "sqlite3" end
Remove versions from development dependencies.
diff --git a/lib/jimsy/cli.rb b/lib/jimsy/cli.rb index abc1234..def5678 100644 --- a/lib/jimsy/cli.rb +++ b/lib/jimsy/cli.rb @@ -24,6 +24,12 @@ end end + desc "password", "Generate a customer-friendly random password" + def password + words = File.read("/usr/share/dict/words").split("\n") + puts "#{words[rand(words.size)]}-#{words[rand(words.size)]}-#{rand(999)}" + end + desc "git SUBCOMMAND ...ARGS", "git stuff" subcommand :git, Git end
Add a friendly password generator.
diff --git a/lib/lightstep.rb b/lib/lightstep.rb index abc1234..def5678 100644 --- a/lib/lightstep.rb +++ b/lib/lightstep.rb @@ -26,9 +26,8 @@ # Returns a random guid. Note: this intentionally does not use SecureRandom, # which is slower and cryptographically secure randomness is not required here. def self.guid - # Re-seed the PRNG on a PID change - if @_lastpid != $$ - @_lastpid = $$ + if @_lastpid != Process.pid + @_lastpid = Process.pid @_rng = Random.new end @_rng.bytes(8).unpack('H*')[0]
Use Process.pid instead of $$ This is a bit clearer, and I think makes the comment for this block unnecessary.
diff --git a/lib/cuba/ron.rb b/lib/cuba/ron.rb index abc1234..def5678 100644 --- a/lib/cuba/ron.rb +++ b/lib/cuba/ron.rb @@ -7,9 +7,9 @@ Thread.current[:_cache] ||= Tilt::Cache.new end - def render(template, locals = {}) + def render(template, locals = {}, options = {}) _cache.fetch(template, locals) { - Tilt.new(template) + Tilt.new(template, 1, options) }.render(self, locals) end
Add the ability to pass in template options.
diff --git a/yubikey.gemspec b/yubikey.gemspec index abc1234..def5678 100644 --- a/yubikey.gemspec +++ b/yubikey.gemspec @@ -12,7 +12,7 @@ s.extra_rdoc_files = [ "LICENSE", - "README.rdoc" + "README.md" ] s.files = [ "examples/otp.rb",
Update gemspec - README.rdoc was renamed to .md
diff --git a/radriar.gemspec b/radriar.gemspec index abc1234..def5678 100644 --- a/radriar.gemspec +++ b/radriar.gemspec @@ -18,10 +18,16 @@ spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] + spec.required_ruby_version = "~> 2.0" + spec.add_dependency "activesupport", ">= 3.2" + spec.add_dependency "grape" spec.add_development_dependency "bundler", "~> 1.6" spec.add_development_dependency "rake" + spec.add_development_dependency "pry" spec.add_development_dependency "rspec", ">= 3.0.0.rc1" spec.add_development_dependency "webmock" spec.add_development_dependency "rr" + spec.add_development_dependency "grape-bugsnag" + spec.add_development_dependency "garner" end
Add required ruby 2 to gemfile and few deps
diff --git a/rails/routes.rb b/rails/routes.rb index abc1234..def5678 100644 --- a/rails/routes.rb +++ b/rails/routes.rb @@ -1,7 +1,7 @@ if defined?(Rails::Application) # Rails3 routes - Rails::Application.routes.draw do |map| + Rails.application.routes.draw do |map| match "/#{Jammit.package_path}/:package.:extension", :to => 'jammit#package', :as => :jammit end -end+end
Fix warning message in rails 3.0rc
diff --git a/lib/api/routes/exercises.rb b/lib/api/routes/exercises.rb index abc1234..def5678 100644 --- a/lib/api/routes/exercises.rb +++ b/lib/api/routes/exercises.rb @@ -21,7 +21,7 @@ end get '/exercises/:language/:slug' do |language, slug| - halt *Xapi.get("exercises", language, slug) + halt *Xapi.get("problems", language, slug) end end end
Call new endpoint on x-api
diff --git a/lib/get-fooda/restaurant.rb b/lib/get-fooda/restaurant.rb index abc1234..def5678 100644 --- a/lib/get-fooda/restaurant.rb +++ b/lib/get-fooda/restaurant.rb @@ -16,7 +16,7 @@ end def to_s - "#{name} (#{cuisine})" + "#{name} (#{cuisine}) - #{link}" end def slack_text
Add link to printed text
diff --git a/rails_template.rb b/rails_template.rb index abc1234..def5678 100644 --- a/rails_template.rb +++ b/rails_template.rb @@ -1,22 +1,22 @@ # Template engine -gem 'haml-rails' +gem "haml-rails" # Test framework -gem 'rspec-rails' +gem "rspec-rails" # Linters -gem 'rubocop' -gem 'haml-lint' -gem 'scss-lint' +gem "rubocop" +gem "haml-lint" +gem "scss-lint" # Haml application layout -generate('haml:application_layout', 'convert') -run('rm app/views/layouts/application.html.erb') +generate("haml:application_layout", "convert") +run("rm app/views/layouts/application.html.erb") # Rspec initial setup -generate('rspec:install') +generate("rspec:install") after_bundle do git :init - git add: '.' + git add: "." end
Use double quotes for Ruby stuff
diff --git a/lib/portal_configuration.rb b/lib/portal_configuration.rb index abc1234..def5678 100644 --- a/lib/portal_configuration.rb +++ b/lib/portal_configuration.rb @@ -1,5 +1,5 @@ # Add some investigation functionality to the User model -class User < ActiveRecord::Base +User.class_eval do has_many :investigations has_many :activities has_many :sections
Use class_eval so that our modifications actually get included.
diff --git a/rticles.gemspec b/rticles.gemspec index abc1234..def5678 100644 --- a/rticles.gemspec +++ b/rticles.gemspec @@ -16,7 +16,7 @@ s.files = `git ls-files`.split($\) - s.add_dependency "rails", "~> 3.2.8" + s.add_dependency "rails", "~> 3.2.8", '<4.1' s.add_dependency "acts_as_list", ">=0.1.8", "<0.3.0" s.add_dependency "roman-numerals", "~>0.3.0"
Expand dependencies to include Rails 4.0.
diff --git a/lib/capistrano/dsl/stages.rb b/lib/capistrano/dsl/stages.rb index abc1234..def5678 100644 --- a/lib/capistrano/dsl/stages.rb +++ b/lib/capistrano/dsl/stages.rb @@ -4,9 +4,6 @@ def stages Dir[stage_definitions].map { |f| File.basename(f, '.rb') } - end - - def infer_stages_from_stage_files end def stage_definitions
Remove unused and empty method definition
diff --git a/apps/base.rb b/apps/base.rb index abc1234..def5678 100644 --- a/apps/base.rb +++ b/apps/base.rb @@ -26,4 +26,26 @@ dep 'xquartz.cask' -dep 'zsh.bin' +dep 'zsh.bin' + +dep 'osx-core-all' do + requires 'osx-core-apps' + requires 'osx-core-apps-extended' +end + +dep 'osx-core-apps' do + requires 'homebrew-cask.lib' + requires 'dropbox.cask' + requires 'htop.bin' + requires 'iterm2.cask' + requires 'mvim.bin' + requires 'onepassword.cask' + requires 'vim.bin' + requires 'zsh.bin' +end + +dep 'osx-core-apps-extended' do + requires 'rescuetime.cask' + requires 'spectacle.cask' + requires 'xquartz.cask' +end
Add core dependency set tasks.
diff --git a/lib/kindle_manager/client.rb b/lib/kindle_manager/client.rb index abc1234..def5678 100644 --- a/lib/kindle_manager/client.rb +++ b/lib/kindle_manager/client.rb @@ -31,12 +31,12 @@ end def load_kindle_books - set_adapter(:books, @options) + set_adapter(:books, @options.except(:create)) adapter.load end def load_kindle_highlights - set_adapter(:highlights, @options) + set_adapter(:highlights, @options.except(:create)) adapter.load end
Fix a bug with 'create: true' option
diff --git a/lib/lifx/light_collection.rb b/lib/lifx/light_collection.rb index abc1234..def5678 100644 --- a/lib/lifx/light_collection.rb +++ b/lib/lifx/light_collection.rb @@ -21,11 +21,13 @@ tags_field = site.tag_manager.tags_field_for_tags(*tags) site.queue_write(params.merge(tagged: true, tags: tags_field)) end + self end - def with_tag(tag_label) - self.class.new(scope: scope, tags: [tag_label]) + def with_tags(*tag_labels) + self.class.new(scope: scope, tags: tag_labels) end + alias_method :with_tag, :with_tags def lights scope.sites.map do |site| @@ -41,7 +43,8 @@ def to_s %Q{#<#{self.class.name} lights=#{lights} tags=#{tags}>} end - - def_delegators :lights, :to_a, :[], :find, :each, :first, :last, :map + alias_method :inspect, :to_s + + def_delegators :lights, :length, :count, :to_a, :[], :find, :each, :first, :last, :map end end
Add with_tags method and delegate more array methods to lights
diff --git a/sidekiq-statsd.gemspec b/sidekiq-statsd.gemspec index abc1234..def5678 100644 --- a/sidekiq-statsd.gemspec +++ b/sidekiq-statsd.gemspec @@ -18,5 +18,7 @@ gem.require_paths = ["lib"] gem.add_dependency "activesupport" - gem.add_dependency "sidekiq", ">= 2.6" + gem.add_dependency "sidekiq", ">= 2.7" + + gem.required_ruby_version = '>= 2.4.0' end
Fix bad merge with master Address https://github.com/phstc/sidekiq-statsd/commit/b7c7998d36465b55b7f75475bf6b700d3a66096d#r36336711 and https://github.com/phstc/sidekiq-statsd/commit/b7c7998d36465b55b7f75475bf6b700d3a66096d#r36336689
diff --git a/lib/mailman-rails.rb b/lib/mailman-rails.rb index abc1234..def5678 100644 --- a/lib/mailman-rails.rb +++ b/lib/mailman-rails.rb @@ -1,5 +1,6 @@ require "mailman-rails/version" -require "mailman" +Gem.send :require, "mailman" # Force loading of the Gem, not my file +require 'mailman' require "mailman/rails" require "mailman/rails/railtie" require File.expand_path("../mailman", __FILE__)
Load the Mailman Gem instead of the file in this Gem
diff --git a/lib/pix_scale/pic.rb b/lib/pix_scale/pic.rb index abc1234..def5678 100644 --- a/lib/pix_scale/pic.rb +++ b/lib/pix_scale/pic.rb @@ -11,15 +11,15 @@ @path = path @dirname = File.dirname(path) @basename = File.basename(path, ".*") - @extname = File.extname(path).sub(/^\./, "") + @extname = File.extname(path) @pic = Gdk::Pixbuf.new(path) - @type = (/\A\.jpg\z/ =~ extname) ? "jpeg" : extname + @type = (/\A\.jpg\z/ =~ extname) ? "jpeg" : extname.sub(/^\./, "") end def scale_and_save(scale) scaled_pic = pic.scale(pic.width * scale, pic.height * scale) - output_path = "#{dirname}/#{basename}-#{scale.to_s}.#{extname}" + output_path = "#{dirname}/#{basename}-#{scale.to_s}#{extname}" scaled_pic.save(output_path, type) end end
Fix a extname format as File.extname png -> .png ^
diff --git a/lib/ditty/controllers/user_login_traits_controller.rb b/lib/ditty/controllers/user_login_traits_controller.rb index abc1234..def5678 100644 --- a/lib/ditty/controllers/user_login_traits_controller.rb +++ b/lib/ditty/controllers/user_login_traits_controller.rb @@ -36,5 +36,9 @@ policy_scope(::Ditty::UserLoginTrait).select(:browser).distinct.as_hash(:browser, :browser) end end + + def list + super.order(:updated_at).reverse + end end end
chore: Order login traits by updated_at, reversed
diff --git a/lib/sucker_punch/railtie.rb b/lib/sucker_punch/railtie.rb index abc1234..def5678 100644 --- a/lib/sucker_punch/railtie.rb +++ b/lib/sucker_punch/railtie.rb @@ -2,6 +2,10 @@ class Railtie < ::Rails::Railtie initializer "sucker_punch.logger" do SuckerPunch.logger = Rails.logger + + ActionDispatch::Reloader.to_prepare do + Celluloid::Actor.clear_registry + end end end end
Clear registry when Rails reloader is invoked
diff --git a/generic_api_rails.gemspec b/generic_api_rails.gemspec index abc1234..def5678 100644 --- a/generic_api_rails.gemspec +++ b/generic_api_rails.gemspec @@ -5,11 +5,11 @@ # Describe your gem and declare its dependencies: Gem::Specification.new do |s| - s.name = "generic_api_rails" + s.name = "generic-api-rails" s.version = GenericApiRails::VERSION - s.authors = ["Daniel Staudigel"] - s.email = ["dstaudigel@opuslogica.com"] - s.homepage = "http://opuslogica.com/" + s.authors = ["Daniel Staudigel", "Brian J. Fox", "Khrysle Rae-Dunn"] + s.email = ["dstaudigel@opuslogica.com", "bfox@opuslogica.com", "krae@opuslogica.com"] + s.homepage = "https://opuslogica.com/opus-source" s.summary = "Provides a simple API interface for dealing with the database." s.description = "Simple API server with easy configuratino for authentication mechanism & automagic RESTful api."
Change the name of the gem to match the rest of the world
diff --git a/lib/unisms/adapter/kotsms.rb b/lib/unisms/adapter/kotsms.rb index abc1234..def5678 100644 --- a/lib/unisms/adapter/kotsms.rb +++ b/lib/unisms/adapter/kotsms.rb @@ -9,8 +9,11 @@ end def deliver(message, to: nil, from: nil) - @kotsms.deliver to, message, @kotsms_options + raise ArgumentError.new("phone number should start with '+'") unless /\A\+.*\z/ === to + @kotsms.deliver to[1..-1], message, @kotsms_options true + rescue ArgumentError => e + Unisms.logger.error "ArgumentError: #{e}" rescue SocketError => e Unisms.logger.error "Failed to send message to #{to}" false
Fix bug of Kotsms adapter: Accept phone number in international format
diff --git a/lib/yard/rake/yardoc_task.rb b/lib/yard/rake/yardoc_task.rb index abc1234..def5678 100644 --- a/lib/yard/rake/yardoc_task.rb +++ b/lib/yard/rake/yardoc_task.rb @@ -12,7 +12,7 @@ def initialize(name = :yardoc) @name = name @options = [] - @files = ['lib/**/*.rb'] + @files = [] yield self if block_given? self.options += ENV['OPTS'].split(/[ ,]/) if ENV['OPTS']
Remove default files from rake task because they're specified in the CLI
diff --git a/perfecta.gemspec b/perfecta.gemspec index abc1234..def5678 100644 --- a/perfecta.gemspec +++ b/perfecta.gemspec @@ -19,5 +19,6 @@ gem.add_dependency "rest-client" gem.add_dependency "activesupport" + gem.add_dependency "rake" gem.add_development_dependency "mocha" end
Add rake as a dependency
diff --git a/server/lib/silently.rb b/server/lib/silently.rb index abc1234..def5678 100644 --- a/server/lib/silently.rb +++ b/server/lib/silently.rb @@ -0,0 +1,11 @@+# http://www.caliban.org/ruby/rubyguide.shtml#warnings +class Silently + def self.silently(&block) + warn_level = $VERBOSE + $VERBOSE = nil + result = block.call + $VERBOSE = warn_level + result + end +end +
Add library for silencing warnings from 3rd party modules
diff --git a/pharrell.gemspec b/pharrell.gemspec index abc1234..def5678 100644 --- a/pharrell.gemspec +++ b/pharrell.gemspec @@ -7,7 +7,7 @@ s.platform = Gem::Platform::RUBY s.authors = ["Callum Stott"] s.email = ["callum@seadowg.com"] - s.summary = "I'm a provider gurl." + s.summary = "I'm a provider gurl. Basic but powerful dependency injection for Ruby." s.license = 'MIT' s.require_paths = ['lib']
Make the description actually useful
diff --git a/Library/Contributions/examples/brew-audit.rb b/Library/Contributions/examples/brew-audit.rb index abc1234..def5678 100644 --- a/Library/Contributions/examples/brew-audit.rb +++ b/Library/Contributions/examples/brew-audit.rb @@ -26,6 +26,11 @@ problems << " * Remove 'use_mirror' from url." end + # 2 (or more, if in an if block) spaces before depends_on, please + if /^\ ?depends_on/ =~ text + problems << " * Check indentation of 'depends_on'." + end + if /(#\{\w+\s*\+\s*['"][^}]+\})/ =~ text problems << " * Try not to concatenate paths in string interpolation:\n #{$1}" end
Add depends_on spacing checks to brew_audit
diff --git a/plugins/emoji.rb b/plugins/emoji.rb index abc1234..def5678 100644 --- a/plugins/emoji.rb +++ b/plugins/emoji.rb @@ -12,6 +12,7 @@ match /breplace (.+)/, method: :breplace match /:b:replace (.+)/, method: :breplace match /🅱️replace (.+)/, method: :breplace + match /tm (.+)/, method: :tm def spread(m, args) m.reply args.split('').join(' ') @@ -37,4 +38,15 @@ end m.reply args.join(' ') end + + def tm(m, args) + args = args.split(' ') + amount = args.length + current = 0 + while current < amount + args[current] = "#{args[current]}™" + current += 1 + end + m.reply args.join(' ') + end end
Add !tm command. everything is trademarked
diff --git a/2019/puzzle.rb b/2019/puzzle.rb index abc1234..def5678 100644 --- a/2019/puzzle.rb +++ b/2019/puzzle.rb @@ -12,6 +12,11 @@ input = input.map(&:strip) if strip input = input.first if input.size == 1 # unwrap the array if it's still just one value input + end + + # defined in case I don't use any test cases on a day's solution + def test_cases + {} end # test the solution attempt against the test data sets
Define test_cases in the base to save dups
diff --git a/spec/backlog_kit/hash_extensions_spec.rb b/spec/backlog_kit/hash_extensions_spec.rb index abc1234..def5678 100644 --- a/spec/backlog_kit/hash_extensions_spec.rb +++ b/spec/backlog_kit/hash_extensions_spec.rb @@ -14,7 +14,7 @@ abcdEfgh_1234_ijklMnop: 'テスト', abcdEfgh_5678_ijklMnop: 'テスト', abcdEfgh_1234: 'テスト', - '1234_abcdEfgh_1234': { abcdEfgh_9012_ijklMnop: 'テスト' } + :'1234_abcdEfgh_1234' => { abcdEfgh_9012_ijklMnop: 'テスト' } } end
Fix SyntaxError on Ruby 2.0.0 and 2.1
diff --git a/spec/importers/rows/behavior_row_spec.rb b/spec/importers/rows/behavior_row_spec.rb index abc1234..def5678 100644 --- a/spec/importers/rows/behavior_row_spec.rb +++ b/spec/importers/rows/behavior_row_spec.rb @@ -17,10 +17,5 @@ it 'records a discipline incident' do expect { row.build.save! }.to change(DisciplineIncident, :count).by(1) end - - it 'creates the appropriate school year' do - expect { row.build }.to change(SchoolYear, :count).by(1) - expect(SchoolYear.last.name).to eq('1981-1982') - end end end
Remove extra behavior row spec
diff --git a/spec/models/spree/payment_method_spec.rb b/spec/models/spree/payment_method_spec.rb index abc1234..def5678 100644 --- a/spec/models/spree/payment_method_spec.rb +++ b/spec/models/spree/payment_method_spec.rb @@ -19,7 +19,6 @@ it "generates a clean name for known Payment Method types" do Spree::PaymentMethod::Check.clean_name.should == "Cash/EFT/etc. (payments for which automatic validation is not required)" Spree::Gateway::Migs.clean_name.should == "MasterCard Internet Gateway Service (MIGS)" - Spree::BillingIntegration::PaypalExpressUk.clean_name.should == "PayPal Express (UK)" Spree::BillingIntegration::PaypalExpress.clean_name.should == "PayPal Express" # Testing else condition
Remove test for PayPalExpress UK which does not exist anymore
diff --git a/AdjustIO.podspec b/AdjustIO.podspec index abc1234..def5678 100644 --- a/AdjustIO.podspec +++ b/AdjustIO.podspec @@ -7,7 +7,7 @@ s.author = { "Christian Wellenbrock" => "welle@adeven.com" } s.source = { :git => "https://github.com/adeven/adjust_ios_sdk.git", :tag => "v2.0.1" } s.platform = :ios, '4.3' - s.framework = 'AdSupport, SystemConfiguration' + s.framework = 'AdSupport', 'SystemConfiguration' s.source_files = 'AdjustIo/*.{h,m}', 'AdjustIo/AIAdditions/*.{h,m}' s.requires_arc = true end
Add missing quotes in podspec
diff --git a/db/migrate/20161017125927_add_unique_index_to_labels.rb b/db/migrate/20161017125927_add_unique_index_to_labels.rb index abc1234..def5678 100644 --- a/db/migrate/20161017125927_add_unique_index_to_labels.rb +++ b/db/migrate/20161017125927_add_unique_index_to_labels.rb @@ -7,9 +7,9 @@ disable_ddl_transaction! def up - select_all('SELECT title, COUNT(id) as cnt FROM labels GROUP BY project_id, title HAVING COUNT(id) > 1').each do |label| + select_all('SELECT title, project_id, COUNT(id) as cnt FROM labels GROUP BY project_id, title HAVING COUNT(id) > 1').each do |label| label_title = quote_string(label['title']) - duplicated_ids = select_all("SELECT id FROM labels WHERE title = '#{label_title}' ORDER BY id ASC").map{ |label| label['id'] } + duplicated_ids = select_all("SELECT id FROM labels WHERE project_id = #{label['project_id']} AND title = '#{label_title}' ORDER BY id ASC").map{ |label| label['id'] } label_id = duplicated_ids.first duplicated_ids.delete(label_id)
Fix broken label uniqueness label migration The previous implementation of the migration failed on staging because the migration was attempted to remove labels from projects that did not actually have duplicates. This occurred because the SQL query did not account for the project ID when selecting the labels. To replicate the problem: 1. Disable the uniqueness validation in app/models/label.rb. 2. Create a duplicate label "bug" in project A. 3. Create the same label in project B with label "bug". The migration will attempt to remove the label in B even if there are no duplicates. Closes #23609
diff --git a/frontend/config/routes.rb b/frontend/config/routes.rb index abc1234..def5678 100644 --- a/frontend/config/routes.rb +++ b/frontend/config/routes.rb @@ -6,6 +6,7 @@ resources :products, only: [:index, :show] get '/locale/set', to: 'locale#set' + post '/locale/set', to: 'locale#set', as: :select_locale # non-restful checkout stuff patch '/checkout/update/:state', to: 'checkout#update', as: :update_checkout
Copy set_locale route from solidus_i18n Our existing route to locale#set was a GET (which it shouldn't be), this adds it again as a POST. The existing get route is left for compatibility. The route is named "select_locale" instead of "set_locale" to avoid a conflict with the existing solidus_i18n route.
diff --git a/Fountain.podspec b/Fountain.podspec index abc1234..def5678 100644 --- a/Fountain.podspec +++ b/Fountain.podspec @@ -5,7 +5,7 @@ s.authors = { "Tobias Kräntzer" => "info@tobias-kraentzer.de" } s.license = { :type => 'BSD', :file => 'LICENSE.md' } s.homepage = 'https://github.com/anagromataf/Fountain' - s.source = {:git => 'https://github.com/anagromataf/Fountain.git', :tag => '0.1-alpha1'} + s.source = {:git => 'https://github.com/anagromataf/Fountain.git', :tag => "#{s.version}"} s.requires_arc = true s.ios.deployment_target = '7.0' s.source_files = 'Fountain/Fountain/**/*.{h,m,c}'
Set tag in the repository correctly.
diff --git a/Casks/easytag.rb b/Casks/easytag.rb index abc1234..def5678 100644 --- a/Casks/easytag.rb +++ b/Casks/easytag.rb @@ -0,0 +1,7 @@+class Easytag < Cask + url 'https://github.com/rfw/easytag-mac/releases/download/v2.1.8-mac-alpha-1/easytag-v2.1.8-mac-alpha-1.dmg' + homepage 'http://rfw.name/easytag-mac/' + version '2.1.8-mac-alpha-1' + sha256 'e637033759396911ed3988fd9349657a6db151821fb21759560ffa220fa3a877' + link 'EasyTAG.app' +end
Add EasyTAG 2.1.8-mac-alpha-1 This is not an official build.
diff --git a/Casks/filebot.rb b/Casks/filebot.rb index abc1234..def5678 100644 --- a/Casks/filebot.rb +++ b/Casks/filebot.rb @@ -0,0 +1,6 @@+class Filebot < Cask + url 'http://downloads.sourceforge.net/project/filebot/filebot/FileBot_3.6/FileBot_3.6.app.tar.gz' + homepage 'http://www.filebot.net/' + version '3.6' + sha1 'ad492132226c0f6eb019a5dc62e59449cd5d98cd' +end
Add Filebot starting with version 3.6
diff --git a/docx.gemspec b/docx.gemspec index abc1234..def5678 100644 --- a/docx.gemspec +++ b/docx.gemspec @@ -12,7 +12,7 @@ s.homepage = 'https://github.com/chrahunt/docx' s.files = Dir["README.md", "LICENSE.md", "lib/**/*.rb"] - s.add_dependency 'nokogiri', '~> 1.8', '>= 1.8.1' + s.add_dependency 'nokogiri', '> 1.8', '>= 1.8.1' s.add_dependency 'rubyzip', '~> 1.2', '>= 1.2.1' s.add_development_dependency 'rspec', '~> 3.7'
Support newer nokogiri as well To address security vulnerability only resolved in nokogiri 1.10.4
diff --git a/griddler-sendgrid.gemspec b/griddler-sendgrid.gemspec index abc1234..def5678 100644 --- a/griddler-sendgrid.gemspec +++ b/griddler-sendgrid.gemspec @@ -20,5 +20,6 @@ spec.add_development_dependency 'rake' spec.add_development_dependency 'rspec', '~> 3.5' - spec.add_dependency 'griddler' + spec.add_dependency 'griddler', '>= 1.5.2' + spec.add_dependency 'mail', '>= 2.7.0' end
Update gemspec for minimum griddler and mail versions
diff --git a/lib/acts_as_revisable/acts/deletable.rb b/lib/acts_as_revisable/acts/deletable.rb index abc1234..def5678 100644 --- a/lib/acts_as_revisable/acts/deletable.rb +++ b/lib/acts_as_revisable/acts/deletable.rb @@ -8,7 +8,7 @@ end def destroy - now = Time.now + now = Time.zone.now prev = self.revisions.first self.revisable_deleted_at = now
Use Time.zone.new for deleted_at timestamp. Signed-off-by: Rich Cavanaugh <5cb1f7e6d556f019dce85071c0a1f08204371cc3@mac.com>
diff --git a/spec/unshortme_spec.rb b/spec/unshortme_spec.rb index abc1234..def5678 100644 --- a/spec/unshortme_spec.rb +++ b/spec/unshortme_spec.rb @@ -1,15 +1,24 @@ require 'spec_helper' describe 'Unshortme' do - - it 'should not return the unshorted url' do + + it "should not return the unshorted url if the url isn't short" do unshorted = Unshortme.unshort("the url") unshorted.should_not == nil unshorted.should match /the url/ end it 'should return the unshorted url' do - unshorted = Unshortme.unshort("http://bit.ly/lathw5") + json = <<-JSON + { + "requestedURL":"http:\/\/bit.ly\/lathw6", + "success":"true", + "resolvedURL":"http:\/\/get2java.blogspot.com\/2011\/07\/whats-up-in-java-17.html" + } + JSON + json.stub(:code).and_return(200) + RestClient.stub(:get).and_return(json) + unshorted = Unshortme.unshort("http://bit.ly/lathw6") unshorted.should_not == nil unshorted.should == 'http://get2java.blogspot.com/2011/07/whats-up-in-java-17.html' end
Use stubs to avoid connecting to internet
diff --git a/app/models/section_edition.rb b/app/models/section_edition.rb index abc1234..def5678 100644 --- a/app/models/section_edition.rb +++ b/app/models/section_edition.rb @@ -39,9 +39,9 @@ scope :with_slug_prefix, ->(slug) { where(slug: /^#{slug}.*/) } - index "section_id" - index "state" - index "updated_at" + index section_id: 1 + index state: 1 + index updated_at: 1 def build_attachment(attributes) attachments.build(
Update indexes in SectionEdition for Mongoid 3 This avoids the following problem when running `rake`: Problem: Invalid index specification on SectionEdition: section_id, {} Summary: Indexes in Mongoid are defined as a hash of field name and direction/2d pairs, with a hash for any additional options. Resolution: Ensure that the index conforms to the correct syntax and has the correct options. The `index` method now takes a field name and direction where it previously took a name only. Although the `index` macro in Mongoid 2.8.1 only takes a `name` parameter, that was being converted to a name/direction pair in `Collection#parse_index_spec`[1] of the underlying mongo-ruby-driver Gem. The direction was being set to 1 (ascending) so I'm confident that we're retaining the same behaviour in this commit. This change to the `index` macros is mentioned in the Changelog for 3.0.0[2] > Indexing syntax has changed. The first parameter is now a hash of > name/direction pairs with an optional second hash parameter for > additional options. [1]: https://github.com/mongodb/mongo-ruby-driver/blob/1.x-stable/lib/mongo/collection.rb#L1121 [2]: https://github.com/mongodb/mongoid/blob/master/CHANGELOG.md#300
diff --git a/app/helpers/invoice_helper.rb b/app/helpers/invoice_helper.rb index abc1234..def5678 100644 --- a/app/helpers/invoice_helper.rb +++ b/app/helpers/invoice_helper.rb @@ -8,7 +8,8 @@ end def suggested_invoices_for_booking(booking) - invoices = Invoice.open_balance.where(:amount => booking.amount) + # Explicit loading (.all) as .uniq whould clear the added in booking.reference + invoices = Invoice.open_balance.where(:amount => booking.amount).all # Include currently referenced invoice invoices << booking.reference if booking.reference
Fix current referenced invoice not showing in select.
diff --git a/app/helpers/plugins_helper.rb b/app/helpers/plugins_helper.rb index abc1234..def5678 100644 --- a/app/helpers/plugins_helper.rb +++ b/app/helpers/plugins_helper.rb @@ -37,5 +37,11 @@ instance_exec(&content) end.join end + + def plugins_search_post_contents + @plugins.dispatch(:search_post_contents).map do |content| + instance_exec(&content) + end.join + end end
Allow plugins to add contents after search results
diff --git a/app/models/section_edition.rb b/app/models/section_edition.rb index abc1234..def5678 100644 --- a/app/models/section_edition.rb +++ b/app/models/section_edition.rb @@ -4,7 +4,7 @@ include Mongoid::Document include Mongoid::Timestamps - store_in "manual_section_editions" + store_in collection: "manual_section_editions" field :section_id, type: String field :version_number, type: Integer, default: 1
Update call to store_in for Mongoid 3 This addresses the following error message I was seeing when running `rake`: Problem: Invalid options passed to SectionEdition.store_in: manual_section_editions. Summary: The :store_in macro takes only a hash of parameters with the keys :database, :collection, or :session. Resolution: Change the options passed to store_in to match the documented API, and ensure all keys in the options hash are symbols. Note that we're already passing a hash to `store_in` in the User model. I'm fairly certain this wasn't working as expected prior to the upgrade to Mongoid 3 as the first param of the `store_in` method was a string containing the name of the collection. Passing a hash appears to have resulted in the users being stored in a collection named “{:collection=>:manuals_publisher_users}” in development. Note that this wouldn't have affected the production database as those users are stored in the single sign on app.
diff --git a/lib/google_directory_daemon/listener.rb b/lib/google_directory_daemon/listener.rb index abc1234..def5678 100644 --- a/lib/google_directory_daemon/listener.rb +++ b/lib/google_directory_daemon/listener.rb @@ -20,8 +20,8 @@ conn.start ch = conn.create_channel - x = ch.direct(@exchange_name) - q = ch.queue(@queue_name, :exclusive => true) + x = ch.topic(@exchange_name, :durable => true) + q = ch.queue(@queue_name, :durable => true) q.bind(@exchange_name, :routing_key => "request.gapps.create"); puts " [*] Waiting for messages in #{q.name}. To exit press CTRL+C"
Add topic to rabbitmq exchange and queue durability
diff --git a/lib/wakame/command/propagate_service.rb b/lib/wakame/command/propagate_service.rb index abc1234..def5678 100644 --- a/lib/wakame/command/propagate_service.rb +++ b/lib/wakame/command/propagate_service.rb @@ -1,32 +1,29 @@ class Wakame::Command::PropagateService include Wakame::Command + include Wakame - #command_name='launch_cluster' + command_name='propagate_service' - def parse(args) - @resource - end + def run(trigger) + refsvc = Service::ServiceInstance.find(@options["service_id"]) || raise("Unknown ServiceInstance: #{@options["service_id"]}") - def run(rule) - prop = nil - prop = rule.service_cluster.properties[@options["service"]] - if prop.nil? - raise "UnknownProperty: #{@options["service"]}" + host_id = @options["host_id"] + unless host_id.nil? + host = Service::Host.find(host_id) || raise("Specified host was not found: #{host_id}") + raise "Same resouce type is already assigned: #{refsvc.resource.class} on #{host_id}" if host.has_resource_type?(refsvc.resource) end - @num = nil - @num = @options["num"] || 1 + num = @options["number"] || 1 + raise "Invalid format of number: #{num}" unless /^(\d+)$/ =~ num.to_s + num = num.to_i - unless /^(\d){1,32}$/ =~ @num.to_s - raise "The number is not appropriate: #{@num}" + if num < 1 || refsvc.resource.max_instances < trigger.cluster.instance_count(refsvc.resource) + num + raise "The number must be between 1 and #{refsvc.resource.max_instances - trigger.cluster.instance_count(refsvc.resource)} (max limit: #{refsvc.resource.max_instances})" end - instance = rule.master.service_cluster.dump_status[:properties][@options["service"]] - if @num.to_i > (instance[:max_instances].to_i - instance[:instances].count.to_i) - raise "The number is not appropriate: #{@num}" - end - - rule.trigger_action(Wakame::Actions::PropagateInstances.new(prop, @num.to_i)) + num.times { + trigger.trigger_action(Wakame::Actions::PropagateService.new(refsvc)) + } end end
Update to recognize new propergate_service command options.
diff --git a/recipes/_ruby.rb b/recipes/_ruby.rb index abc1234..def5678 100644 --- a/recipes/_ruby.rb +++ b/recipes/_ruby.rb @@ -17,7 +17,10 @@ # Build and install Ruby version using chruby and ruby-build include_recipe "chruby::system" -# Prepend our Ruby version to PATH +# The chruby cookbook installs /etc/profile.d/chruby.sh which sets up the Ruby +# environment. Unfortunately, that file will only be sourced after the next +# login, causing the first converge to fail. We can fix this by prepending our +# Ruby version to PATH. ruby_block "add-ruby-to-path" do block do ENV["PATH"] = "/opt/rubies/#{ruby_version}/bin:#{ENV["PATH"]}"
Clarify why we modify PATH
diff --git a/spec/views/home/index.html.slim_spec.rb b/spec/views/home/index.html.slim_spec.rb index abc1234..def5678 100644 --- a/spec/views/home/index.html.slim_spec.rb +++ b/spec/views/home/index.html.slim_spec.rb @@ -4,11 +4,40 @@ include Devise::TestHelpers - let(:user) { FactoryGirl.create :user } + let(:user) { FactoryGirl.create :user } + let(:manager) { FactoryGirl.create :manager } + let(:admin) { FactoryGirl.create :admin_user } - it 'contain our dashboard header' do - sign_in user - render - expect(rendered).to include('eligible for benefits-based remission') + context 'public access' do + it 'shows a restriction message' do + render + expect(rendered).to have_xpath('//div', text: /This system is restricted/) + end + end + + context 'user access' do + it 'displays guidance' do + sign_in user + render + expect(rendered).to have_xpath('//span[@class="bold"]', text: /Check benefits/) + expect(rendered).to have_xpath('//p', text: /eligible for benefits-based remission/) + end + end + + context 'manager access' do + it 'displays a dwp checklist' do + sign_in manager + render + expect(rendered).to have_xpath('//h2', text: /Manager summary for/) + expect(rendered).to have_xpath('//th', text: 'Staff member') + end + end + + context 'admin access' do + it 'displays graphs' do + sign_in admin + render + expect(rendered).to have_xpath('//h2', text: 'Total') + end end end
Improve test coverage of index view
diff --git a/app/controllers/api/v1/credentials_controller.rb b/app/controllers/api/v1/credentials_controller.rb index abc1234..def5678 100644 --- a/app/controllers/api/v1/credentials_controller.rb +++ b/app/controllers/api/v1/credentials_controller.rb @@ -1,6 +1,5 @@ module Api::V1 class CredentialsController < ApiController - respond_to :json def show render json: credentials_serializer.call
Remove redundant respond_to :json class method
diff --git a/bosh_cli/lib/cli/deployment_manifest_compiler.rb b/bosh_cli/lib/cli/deployment_manifest_compiler.rb index abc1234..def5678 100644 --- a/bosh_cli/lib/cli/deployment_manifest_compiler.rb +++ b/bosh_cli/lib/cli/deployment_manifest_compiler.rb @@ -15,7 +15,7 @@ end def result - ERB.new(@raw_manifest, 4).result(binding.taint) + ERB.new(@raw_manifest).result(binding.taint) rescue SyntaxError => e raise MalformedManifest, "Deployment manifest contains a syntax error\n" + e.to_s
Remove $SAFE level for ERB parsing $SAFE=4 level was removed from ruby 2.1.1. In general, this SAFE level does not provide enough security. Signed-off-by: Maria Shaldibina <a39f51a90bfcf8ca23756ef12127e1cf20796cba@pivotallabs.com>
diff --git a/scripts/csv_to_yaml.rb b/scripts/csv_to_yaml.rb index abc1234..def5678 100644 --- a/scripts/csv_to_yaml.rb +++ b/scripts/csv_to_yaml.rb @@ -0,0 +1,94 @@+# +# This is a really fast and dirty script that I used to migrate photos out of +# Black Swan and Flickr and over to a Dropbox solution. I'm keeping it in the +# source tree for posterity and an example of using the Dropbox API even though +# I don't really expect to use it again. +# +# Postgres invocations to get a CSV: +# +# CREATE TEMP TABLE photographs (id BIGINT, occurred_at TIMESTAMPTZ, title TEXT, description TEXT); +# +# INSERT INTO photographs (SELECT slug::BIGINT, occurred_at, metadata -> 'title', metadata -> 'description' FROM events WHERE type = 'flickr' ORDER BY occurred_at); +# +# \COPY photographs TO './photographs.csv' +# +# + +require 'csv' +require 'excon' +require 'json' +require 'yaml' + +# Brandur Personal App +API_KEY = "..." + +csv_file = './photographs.csv' +yaml_file = './photographs.yaml' + +data = [] + +def get_link(slug) + dropbox_path = "/photo-archive/_lifestream/#{slug}.jpg" + p dropbox_path + + res = Excon.post("https://api.dropboxapi.com/2/sharing/list_shared_links", + headers: { + "Authorization" => "Bearer #{API_KEY}", + "Content-Type" => "application/json", + }, + body: JSON.generate({ + path: dropbox_path, + direct_only: true, + }), + expects: [200, 201] + ) + data = JSON.parse(res.body) + + link = data["links"].first + + unless link + res = Excon.post("https://api.dropboxapi.com/2/sharing/create_shared_link_with_settings", + headers: { + "Authorization" => "Bearer #{API_KEY}", + "Content-Type" => "application/json", + }, + body: JSON.generate({ + path: dropbox_path, + settings: { + requested_visibility: "public", + }, + }), + expects: [200, 201] + ) + link = JSON.parse(res.body) + end + + url = link["url"].gsub(/\?dl=0/, "?dl=1") + p url + url +end + +begin + CSV.foreach(csv_file, { col_sep: "\t", quote_char: "|" }) do |row| + + p row + data << { + slug: row[0], + occurred_at: DateTime.parse(row[1]).rfc3339, + title: row[2] || "", + description: row[3] || "", + original_image: get_link(row[0]), + } + + # hopefully avoid rate limiting + sleep(0.2) + end + + wrapper = {photographs: data} + + doc_yaml = YAML.dump(wrapper) + File.open(yaml_file, 'w') { |file| file.write(doc_yaml) } + +rescue Excon::Error::BadRequest, Excon::Error::Conflict => e + abort("#{e}: #{e.response.body}") +end
Add dirty script to get photos out of Black Swan/Flickr
diff --git a/vagrant-chefzero.gemspec b/vagrant-chefzero.gemspec index abc1234..def5678 100644 --- a/vagrant-chefzero.gemspec +++ b/vagrant-chefzero.gemspec @@ -18,6 +18,9 @@ spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] + spec.add_runtime_dependency 'chef', '~> 11.4' + spec.add_runtime_dependency 'berkshelf', '~> 1.4' + spec.add_development_dependency "bundler", "~> 1.3" spec.add_development_dependency "rake" end
Add chef and berkshelf dependencies
diff --git a/mongo_mapper.gemspec b/mongo_mapper.gemspec index abc1234..def5678 100644 --- a/mongo_mapper.gemspec +++ b/mongo_mapper.gemspec @@ -21,4 +21,6 @@ s.add_dependency 'activesupport', '>= 5.0' s.add_dependency 'activemodel', ">= 5.0" s.add_dependency 'activemodel-serializers-xml', "~> 1.0" + + s.add_dependency 'rexml' end
Add rexml to gemspec for Ruby 3.0 rexml is no longer default gem in Ruby 3.0. When we use activemodel 6.1.0 or greater, it includes rexml in its gemspec and we don't get errors on it. https://github.com/rails/rails/pull/40281 Otherwise, we can get a LoadError like the following: LoadError: cannot load such file -- rexml/document # ./lib/mongo_mapper/plugins/serialization.rb:92:in `from_xml'
diff --git a/box_clean.rb b/box_clean.rb index abc1234..def5678 100644 --- a/box_clean.rb +++ b/box_clean.rb @@ -0,0 +1,43 @@+# 'vagrant box list' display a list of the currently downloaded vagrant boxes +# This list is ordered by box name and then by version. I don't have multiple +# providers, so I don't know how those are handled. I am assuming they are +# group together as well. +# Example: +# chrisvire/precise32 (virtualbox, 0.4.0) +# chrisvire/precise32 (virtualbox, 0.5.0) +# chrisvire/precise64 (virtualbox, 0.4.0) +# chrisvire/precise64 (virtualbox, 0.5.0) +# chrisvire/saucy32 (virtualbox, 0.1.0) +# chrisvire/saucy32 (virtualbox, 0.2.0) +# chrisvire/saucy64 (virtualbox, 0.1.0) +# chrisvire/saucy64 (virtualbox, 0.2.0) +# chrisvire/trusty32 (virtualbox, 0.2.0) +# chrisvire/trusty32 (virtualbox, 0.3.0) +# chrisvire/trusty64 (virtualbox, 0.3.0) +# chrisvire/trusty64 (virtualbox, 0.4.0) +# chrisvire/wasta64-12 (virtualbox, 0.1.0) +# chrisvire/wasta64-12 (virtualbox, 0.3.0) +# chrisvire/wasta64-14 (virtualbox, 0.1.0) +# chrisvire/wasta64-14 (virtualbox, 0.2.0) +# +# The algorithm for the script is to push all the entries on a list (so that they +# are processed in reverse order). If a duplicate of box name and provider are +# found, then remove it. + +pipe = IO.popen("vagrant box list") +re = /(\S+)\s+\((\w+), ([0-9.]+)/ +boxes = [] +while (line = pipe.gets) + m = line.match(re) + boxes.unshift([ m[1], m[2], m[3] ]) +end + +last_box = nil +last_provider = nil +boxes.each do |box| + if box[0] == last_box && box[1] == last_provider + system "vagrant box remove #{box[0]} --provider #{box[1]} --box-version #{box[2]}" + end + last_box = box[0] + last_provider = box[1] +end
Add script to clean up outdated boxes. vagrant doesn't have a way to clean up outdated boxes. I have an open issue (https://github.com/mitchellh/vagrant/issues/4412). I will likely implement it once I get feedback from the maintainer as to how he would want it exposed in the command-line UI.
diff --git a/app/policies/collection_policy.rb b/app/policies/collection_policy.rb index abc1234..def5678 100644 --- a/app/policies/collection_policy.rb +++ b/app/policies/collection_policy.rb @@ -34,4 +34,8 @@ def linkable_user_collection_preferences policy_for(UserCollectionPreference).scope_for(:show) end + + def linkable_user_groups + policy_for(UserGroup).scope_for(:show) + end end
Add linkable user groups for Collection
diff --git a/Casks/xampp.rb b/Casks/xampp.rb index abc1234..def5678 100644 --- a/Casks/xampp.rb +++ b/Casks/xampp.rb @@ -5,7 +5,7 @@ # sourceforge.net is the official download host per the vendor homepage url "http://downloads.sourceforge.net/project/xampp/XAMPP%20Mac%20OS%20X/#{version.sub(%r{-\d+$},'')}/xampp-osx-#{version}-installer.dmg" name 'XAMPP' - homepage 'http://www.apachefriends.org/' + homepage 'https://www.apachefriends.org/' license :gpl installer :script => 'XAMPP.app/Contents/MacOS/osx-intel',
Fix homepage to use SSL in XAMPP Cask The HTTP URL is already getting redirected to HTTPS. Using the HTTPS URL directly makes it more secure and saves a HTTP round-trip.
diff --git a/lib/unimatrix/authorization/client_credentials_grant.rb b/lib/unimatrix/authorization/client_credentials_grant.rb index abc1234..def5678 100644 --- a/lib/unimatrix/authorization/client_credentials_grant.rb +++ b/lib/unimatrix/authorization/client_credentials_grant.rb @@ -13,13 +13,15 @@ params = { "grant_type" => "client_credentials" } http = Net::HTTP.new( uri.host, uri.port ) request = Net::HTTP::Post.new( uri.request_uri ) - + + http.use_ssl = true if uri.scheme == 'https' + request.basic_auth( @client_id, @client_secret ) request.set_form_data( params ) - + response = http.request( request ) rescue nil if response.code == '200' - + body = JSON.parse( response.body ) body = body[ 'token' ] if body[ 'token' ].present?
Fix request in ClientCredentialsGrant to use_ssl if applicable
diff --git a/JDSlider.podspec b/JDSlider.podspec index abc1234..def5678 100644 --- a/JDSlider.podspec +++ b/JDSlider.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "JDSlider" - s.version = "1.0.0" + s.version = "1.0.1" s.summary = "An iOS Slider written in swift." s.description = "A full customizable Slider of UIView."
[MODIFIED] Set PodSpec to release 1.0.1.
diff --git a/mutt.rb b/mutt.rb index abc1234..def5678 100644 --- a/mutt.rb +++ b/mutt.rb @@ -9,8 +9,10 @@ depends_on 'slang' def patches - # I only care about the trash patch - ['https://gist.github.com/raw/1361946/632541cf9ae54e3d1caed5c748149962f8972c28/mutt-trash-folder.patch'] + [ + 'http://patch-tracker.debian.org/patch/series/dl/mutt/1.5.21-6.2/features/trash-folder', + 'http://patch-tracker.debian.org/patch/series/dl/mutt/1.5.21-6.2/features/purge-message', + ] end def install
Add purge-message patch. Switch to Debian patch sources.
diff --git a/app/decorators/disk_decorator.rb b/app/decorators/disk_decorator.rb index abc1234..def5678 100644 --- a/app/decorators/disk_decorator.rb +++ b/app/decorators/disk_decorator.rb @@ -0,0 +1,12 @@+class DiskDecorator < MiqDecorator + def fonticon + case device_type + when 'floppy' + 'fa fa-floppy-o' + when 'cdrom' + 'ff ff-cdrom' + else + 'fa fa-hdd-o' + end + end +end
Add decorator for the Disk model with fonticons for various disktypes
diff --git a/db/migrate/20131004150321_remove_metadata_from_rooms.rb b/db/migrate/20131004150321_remove_metadata_from_rooms.rb index abc1234..def5678 100644 --- a/db/migrate/20131004150321_remove_metadata_from_rooms.rb +++ b/db/migrate/20131004150321_remove_metadata_from_rooms.rb @@ -1,9 +1,7 @@ class RemoveMetadataFromRooms < ActiveRecord::Migration def up - BigbluebuttonRoom.all.each do |room| - room.metadata.where(:name => 'mconfweb-title').destroy_all - room.metadata.where(:name => 'mconfweb-description').destroy_all - end + execute "DELETE FROM bigbluebutton_metadata WHERE owner_type='BigbluebuttonRoom' AND name='mconfweb-title';" + execute "DELETE FROM bigbluebutton_metadata WHERE owner_type='BigbluebuttonRoom' AND name='mconfweb-description';" # not worth removing from recordings, since the metadata is already in the web conference # servers and will be added again in the next sync end @@ -11,11 +9,6 @@ # Not exactly the inverse of up because we lose the values from the metadata destroyed. # But better than not allowing a rollback. def down - BigbluebuttonRoom.all.each do |room| - title = room.metadata.where(:name => 'mconfweb-title').first - room.metadata.create(:name => 'mconfweb-title') if title.nil? - description = room.metadata.where(:name => 'mconfweb-description').first - room.metadata.create(:name => 'mconfweb-description') if description.nil? - end + raise ActiveRecord::IrreversibleMigration end end
Make the migration RemoveMetadataFromRooms faster
diff --git a/db/migrate/20150615094200_add_color_to_organizations.rb b/db/migrate/20150615094200_add_color_to_organizations.rb index abc1234..def5678 100644 --- a/db/migrate/20150615094200_add_color_to_organizations.rb +++ b/db/migrate/20150615094200_add_color_to_organizations.rb @@ -8,7 +8,7 @@ end down do - drop_column :organizations, :text + drop_column :organizations, :color end end
Fix migration (delete column color instead of text)
diff --git a/app/models/setup/oauth2_scope.rb b/app/models/setup/oauth2_scope.rb index abc1234..def5678 100644 --- a/app/models/setup/oauth2_scope.rb +++ b/app/models/setup/oauth2_scope.rb @@ -19,7 +19,7 @@ validates_uniqueness_of :name, scope: :provider def scope_title - provider && provider.custom_title + provider&.custom_title end def key
Update | using safe operator
diff --git a/app/helpers/nivo_helper.rb b/app/helpers/nivo_helper.rb index abc1234..def5678 100644 --- a/app/helpers/nivo_helper.rb +++ b/app/helpers/nivo_helper.rb @@ -0,0 +1,24 @@+module NivoHelper + def slider(files, hash = {}) + options = { :theme => :default } + options.merge!(hash) + + content_tag(:div, :class => "slider-wrapper theme-#{options[:theme]}") do + content_tag(:div, :class => "nivoSlider #{options[:class]}", :id => "#{options[:id]}") + content = "" + + files.each do |file| + if file.kind_of?(String) + content += image_tag file, :data => { :thumb => file } + elsif file.kind_of?(Array) + content += image_tag file[0], :data => { :thumb => file[0] }, + :title => file[1] + end + end + + content + end + end + + end +end
Add a helper to easily generate sliders
diff --git a/app/helpers/user_helper.rb b/app/helpers/user_helper.rb index abc1234..def5678 100644 --- a/app/helpers/user_helper.rb +++ b/app/helpers/user_helper.rb @@ -1,9 +1,10 @@ module UserHelper def guider_options groups = Group.includes(:users) + { 'Groups': groups.map do |group| - [group.name, group.name, data: { icon: 'glyphicon-tag', children_to_select: group.users.pluck(:id) }] + [group.name, group.name, data: { icon: 'glyphicon-tag', children_to_select: group.user_ids }] end, 'Users': User.guiders.active.map do |guider| [guider.name, guider.id, data: { icon: 'glyphicon-user' }]
Reduce huge N+1 querying for associated user IDs This was causing a huge N+1 query through groups / assignments / users.
diff --git a/rom-sql.gemspec b/rom-sql.gemspec index abc1234..def5678 100644 --- a/rom-sql.gemspec +++ b/rom-sql.gemspec @@ -19,9 +19,9 @@ spec.add_runtime_dependency 'sequel', '>= 4.49' spec.add_runtime_dependency 'dry-equalizer', '~> 0.2' - spec.add_runtime_dependency 'dry-types', '~> 0.11', '>= 0.11.1' + spec.add_runtime_dependency 'dry-types', '~> 0.12' spec.add_runtime_dependency 'dry-core', '~> 0.3' - spec.add_runtime_dependency 'rom-core', '~> 4.0.0.beta' + spec.add_runtime_dependency 'rom-core', '~> 4.0.0.rc' spec.add_development_dependency 'bundler' spec.add_development_dependency 'rake', '~> 10.0'
Update rom and dry-types deps
diff --git a/spec/dummy/app/jobs/process_messenger_callback_job.rb b/spec/dummy/app/jobs/process_messenger_callback_job.rb index abc1234..def5678 100644 --- a/spec/dummy/app/jobs/process_messenger_callback_job.rb +++ b/spec/dummy/app/jobs/process_messenger_callback_job.rb @@ -0,0 +1,13 @@+class ProcessMessengerCallbackJob < ActiveJob::Base + + queue_as :messaging + + def perform(json) + MessengerPlatform::CallbackParser.new(json.deep_dup).parse do |event| + callback_handler = MessengerPlatform::CallbackRegistry.handler_for(event.webhook_name) + return unless callback_handler.present? + callback_handler.new.run(json.deep_dup) + end + end + +end
Copy ProcessMessegnerCallbackJob into spec/dummy/app/jobs folder for specs
diff --git a/spec/unit/coercible/coercer/class_methods/new_spec.rb b/spec/unit/coercible/coercer/class_methods/new_spec.rb index abc1234..def5678 100644 --- a/spec/unit/coercible/coercer/class_methods/new_spec.rb +++ b/spec/unit/coercible/coercer/class_methods/new_spec.rb @@ -7,7 +7,7 @@ it { should be_instance_of(Coercer) } - its(:config) { should be_instance_of(Configuration) } + its(:config) { should be_instance_of(Coercible::Configuration) } its(:config) { should respond_to(:string) } its(:config) { should respond_to(:string=) } end
Fix spec for ruby 1.9.2
diff --git a/app/models/jellyfish_aws/product_type/ec2.rb b/app/models/jellyfish_aws/product_type/ec2.rb index abc1234..def5678 100644 --- a/app/models/jellyfish_aws/product_type/ec2.rb +++ b/app/models/jellyfish_aws/product_type/ec2.rb @@ -33,7 +33,6 @@ def order_questions [ - { name: :zone_id, value_type: :string, field: :aws_zones, required: true } ] end
Remove availability zone order question
diff --git a/Formula/apr.rb b/Formula/apr.rb index abc1234..def5678 100644 --- a/Formula/apr.rb +++ b/Formula/apr.rb @@ -0,0 +1,28 @@+require 'brewkit' + +class AprUtil <Formula + @url='http://www.mirrorservice.org/sites/ftp.apache.org/apr/apr-util-1.3.9.tar.bz2' + @md5='29dd557f7bd891fc2bfdffcfa081db59' +end + +class Apr <Formula + @url='http://www.mirrorservice.org/sites/ftp.apache.org/apr/apr-1.3.8.tar.bz2' + @homepage='http://apr.apache.org' + @md5='3c7e3a39ae3d3573f49cb74e2dbf87a2' + + def install + ENV.j1 + system "./configure --prefix=#{prefix} --disable-debug --disable-dependency-tracking" + system "make install" + + AprUtil.new.brew do + system "./configure", "--prefix=#{prefix}", + "--disable-debug", + "--disable-dependency-tracking", + "--with-apr=#{bin}/apr-1-config" + system "make install" + end + + (prefix+'build-1').rmtree # wtf? + end +end
Remove MacPorts and Fink from the build environment Closes Homebrew/homebrew#13
diff --git a/web/db/seeds.rb b/web/db/seeds.rb index abc1234..def5678 100644 --- a/web/db/seeds.rb +++ b/web/db/seeds.rb @@ -1,7 +1,9 @@-# This file should contain all the record creation needed to seed the database with its default values. -# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). -# -# Examples: -# -# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) -# Mayor.create(name: 'Emanuel', city: cities.first) +[ + { title: "חוק הגנת הצרכן תיקון - פנייה מקדימה בעסקת מכר מרחוק", state: "עברה קריאה טרומית" }, + { title: "חוק המקרקעין (חיזוק בתים משותפים מפני רעידות אדמה) תיקון - סידור חלוף ארעי", state: "הוסבה לנושא לדיון" }, + { title: "חוק שכר מינימום תיקון - שכר מינימום לעובד שטרם מלאו לו 18 שנים", state: "הוסבה לנושא לדיון" }, + { title: "חוק הפסיכולוגים תיקון - הפרת חובת דיווח ופרסום החלטות ועדת המשמעת", state: "עברה קריאה טרומית" }, + { title: "חוק הביטוח הלאומי תיקון - שיעור ההטבה לפי הסכם בדבר גמלת ניידות", state: "נפלה בקריאה טרומית" } +].each do |params| + Bill.create!(params) +end
Add DB seed with mock bills
diff --git a/AmazeKit.podspec b/AmazeKit.podspec index abc1234..def5678 100644 --- a/AmazeKit.podspec +++ b/AmazeKit.podspec @@ -5,7 +5,7 @@ s.homepage = "https://github.com/detroit-labs/AmazeKit" s.license = "Apache" s.author = {"Jeff Kelley" => "SlaunchaMan@gmail.com"} - s.source = { :git => "git@github.com:detroit-labs/AmazeKit.git", :tag => "0.13.0" } + s.source = { :git => "https://github.com/detroit-labs/AmazeKit.git", :tag => "0.13.0" } s.source_files = "AmazeKit/AmazeKit/*.{h,m}" s.frameworks = 'Foundation', 'CoreGraphics', 'ImageIO', 'QuartzCore', 'UIKit' s.platform = :ios
Update podspec to pass validation.
diff --git a/spec/fixtures/movie.rb b/spec/fixtures/movie.rb index abc1234..def5678 100644 --- a/spec/fixtures/movie.rb +++ b/spec/fixtures/movie.rb @@ -1,5 +1,5 @@ class Movie - attr_accessor :title, :rating, :year, :country, :seen, :star_rating + attr_accessor :title, :rating, :year, :country, :seen, :star_rating, :home_formats def self.random_collection(count = 100) (1...count).map { |_| Movie.random } @@ -16,6 +16,7 @@ self.country = random_country self.seen = [true, false].sample self.star_rating = [1, 2, 3, 4, 5].sample + self.home_formats = %w(BD DVD Hulu Amazon Netflix).sample(2) end def seen?
Update fixture to give it a collection attribute home_formats will return an array of 2 of the available home formats
diff --git a/Casks/trailer.rb b/Casks/trailer.rb index abc1234..def5678 100644 --- a/Casks/trailer.rb +++ b/Casks/trailer.rb @@ -1,6 +1,6 @@ cask :v1 => 'trailer' do - version '1.3.0' - sha256 '1e546d9375e761e4d3ff3a74c218f39b89b9a0e0c4731108558249f0d1e1dc0f' + version '1.3.1' + sha256 '7be6fb7479d51d31ff535bc5c61a2a2532149a0caf866788014d5ee12938ed1e' url "http://ptsochantaris.github.io/trailer/trailer#{version.gsub('.','')}.zip" appcast 'http://ptsochantaris.github.io/trailer/appcast.xml',
Update Trailer version to 1.3.1 This commit updates the version and SHA
diff --git a/test/integration/upgrades/serverspec/default_spec.rb b/test/integration/upgrades/serverspec/default_spec.rb index abc1234..def5678 100644 --- a/test/integration/upgrades/serverspec/default_spec.rb +++ b/test/integration/upgrades/serverspec/default_spec.rb @@ -0,0 +1,40 @@+require 'serverspec' + +set :backend, :exec + +# Version to expect on install. Change this when we bump versions +current_version = '2.2.0' + +describe package('threatstack-agent') do + it { should be_installed } +end + +# Check version +describe 'package version' do + # How we can verify what is installed is what is defined to be installed + # + # IMPORTANT: Must set node.override['threatstack']['version'] in + # `test/cookbooks/install_old_agent/attributes/default.rb` for test to pass! + # + # See: http://www.hurryupandwait.io/blog/accessing-chef-node-attributes-from-kitchen-tests + let(:node) { JSON.parse(IO.read('/tmp/chef_node_for_tests.json')) } + let(:current_version) { node['threatstack'] } + + it 'is running the current version' do + if os[:family] == 'ubuntu' + expect(command("dpkg-query -f '${Status} ${Version}' -W threatstack-agent").stdout).to match("^(install|hold) ok installed #{current_version}.*$") + elsif os[:family] == 'redhat' + expect(command("repoquery --qf '%{version}' threatstack-agent").stdout.strip).to eq(current_version) # rubocop: disable Style/FormatStringToken + end + end +end + +describe service('threatstack') do + it { should be_running } + it { should be_enabled } +end + +describe command('tsagent status') do + # Sometimes due to other services, like auditd, the install would be successful, but then this service would get killed + its(:stdout) { should match /UP Threat Stack Audit Collection/ } # rubocop: disable Lint/AmbiguousRegexpLiteral +end
Add new test suite to test upgrading agent with cookbook * To properly run, the attributes in `test/cookbooks/install_old_agent/attributes/default.rb` need to be updated
diff --git a/spec/helpers.rb b/spec/helpers.rb index abc1234..def5678 100644 --- a/spec/helpers.rb +++ b/spec/helpers.rb @@ -1,7 +1,7 @@ require 'helpers/dummy_data' module Helpers - def self.included(base) - base.include Dummy_data + def self.included(_base) + include Dummy_data end end
Fix include grammer of ruby remove an unnecesary receiver
diff --git a/spec/helpers.rb b/spec/helpers.rb index abc1234..def5678 100644 --- a/spec/helpers.rb +++ b/spec/helpers.rb @@ -2,6 +2,6 @@ module Helpers def self.included(_base) - include DummyData + _base.include DummyData end end
Fix to include in itself It was not correctly included when rspec command is used to specify test file
diff --git a/spec/suby_spec.rb b/spec/suby_spec.rb index abc1234..def5678 100644 --- a/spec/suby_spec.rb +++ b/spec/suby_spec.rb @@ -11,7 +11,8 @@ suby = File.expand_path('../../bin/suby', __FILE__) Dir.chdir(dir) do system suby, file - Digest::MD5.hexdigest(File.read(srt)).should == 'd76d57eef776999f2b76c6dfb557b6b5' + subs = File.read(srt) + subs.should match(/yeah, this is gonna be the best slapsgiving ever./i) end end end
Fix too precise integration test
diff --git a/test/app/models/s3_upload/upload_test.rb b/test/app/models/s3_upload/upload_test.rb index abc1234..def5678 100644 --- a/test/app/models/s3_upload/upload_test.rb +++ b/test/app/models/s3_upload/upload_test.rb @@ -0,0 +1,121 @@+require "test_helper" + +describe S3Relay::Upload do + before do + @upload = S3Relay::Upload.new + end + + describe "associations" do + describe "parent" do + it do + S3Relay::Upload.reflect_on_association(:parent).macro + .must_equal :belongs_to + end + end + end + + describe "validations" do + describe "uuid" do + it "validates presence" do + @upload.valid? + @upload.errors[:uuid].must_include("can't be blank") + end + + it "validates uniqueness" do + S3Relay::Upload.new(uuid: @upload.uuid).save!(validate: false) + @upload.valid? + @upload.errors[:uuid].must_include("has already been taken") + end + end + + describe "filename" do + it "validates presence" do + @upload.valid? + @upload.errors[:filename].must_include("can't be blank") + end + end + + describe "content_type" do + it "validates presence" do + @upload.valid? + @upload.errors[:content_type].must_include("can't be blank") + end + end + + describe "pending_at" do + it "validates presence" do + @upload.pending_at = nil + @upload.valid? + @upload.errors[:pending_at].must_include("can't be blank") + end + end + end + + describe "scopes" do + before do + @pending = S3Relay::Upload.new + .tap { |u| u.save(validate: false) } + @imported = S3Relay::Upload.new(state: "imported") + .tap { |u| u.save(validate: false) } + end + + describe "pending" do + it do + results = S3Relay::Upload.pending.all + results.must_include @pending + results.wont_include @imported + end + end + + describe "imported" do + it do + results = S3Relay::Upload.imported.all + results.wont_include @pending + results.must_include @imported + end + end + end + + describe "upon finalization" do + it do + @upload.state.must_equal "pending" + @upload.pending_at.wont_equal nil + end + end + + describe "#pending?" do + it { @upload.pending?.must_equal true } + end + + describe "#imported" do + it do + @upload.state = "imported" + @upload.imported?.must_equal true + end + end + + describe "#mark_imported!" do + it do + @upload.mark_imported! + @upload.state.must_equal "imported" + @upload.imported_at.wont_equal nil + end + end + + describe "#private_url" do + it do + uuid = SecureRandom.uuid + filename = "cat.png" + @upload.uuid = uuid + @upload.filename = filename + + url = "url" + klass = stub + S3Relay::PrivateUrl.expects(:new).with(uuid, filename).returns(klass) + klass.expects(:generate).returns(url) + + @upload.private_url.must_equal url + end + end + +end
Add tests for upload model.
diff --git a/conductor.rb b/conductor.rb index abc1234..def5678 100644 --- a/conductor.rb +++ b/conductor.rb @@ -1,11 +1,12 @@-cask :v1 => 'conductor' do - version '1.2.2' - sha256 'a5f9ba34c258c7d6a902de86c4f14e36e0b6283ab3893d6c43a7ba95f3831e63' +cask :v1 => "conductor" do + version "1.2.2" + sha256 "a5f9ba34c258c7d6a902de86c4f14e36e0b6283ab3893d6c43a7ba95f3831e63" - url 'https://github.com/keith/conductor/releases/download/1.2.2/Conductor.app.zip' - name 'Conductor' - homepage 'https://github.com/keith/conductor' + url "https://github.com/keith/conductor/releases/download/#{version}/Conductor.app.zip" + appcast "https://github.com/keith/conductor/releases.atom" + name "Conductor" + homepage "https://github.com/keith/conductor" license :mit - app 'Conductor.app' + app "Conductor.app" end
Update brew cask formula from upstream
diff --git a/app/models/people_identifier.rb b/app/models/people_identifier.rb index abc1234..def5678 100644 --- a/app/models/people_identifier.rb +++ b/app/models/people_identifier.rb @@ -8,7 +8,7 @@ def people @people ||= if params[:email] # annoying that you can't do case insensitive without a regex - Person.where(email: /\A#{Regexp.escape(params[:email])}\z/i) + Person.where(email: regexp_for(params[:email])) elsif params[:twitter_id] people_from_twitter else @@ -17,10 +17,13 @@ end private + def regexp_for(string) + /\A#{Regexp.escape(string)}\z/i + end + def people_from_twitter # exact match only to return local results over twitter - regexp = /\A#{Regexp.escape(params[:twitter_id])}\z/i - people = Person.where(twitter_id: regexp) + people = Person.where(twitter_id: regexp_for(params[:twitter_id])) return people if people.count > 0 TwitterPersonService.new(params[:twitter_id]).people
Refactor common regexp to method
diff --git a/Casks/air-video-server.rb b/Casks/air-video-server.rb index abc1234..def5678 100644 --- a/Casks/air-video-server.rb +++ b/Casks/air-video-server.rb @@ -0,0 +1,6 @@+class AirVideoServer < Cask + url 'http://s3.amazonaws.com/AirVideo/Air+Video+Server+2.4.6-beta3u1.dmg' + homepage 'http://www.inmethod.com/air-video/' + version '2.4.6-beta3' + sha1 '2293b653fea6a939ab863a7bf918d601a504c9c8' +end
Add cask for Air Video Server
diff --git a/app/services/quality_control.rb b/app/services/quality_control.rb index abc1234..def5678 100644 --- a/app/services/quality_control.rb +++ b/app/services/quality_control.rb @@ -1,6 +1,6 @@ class QualityControl def self.dedupe(user) - readings = user.readings + readings = user.readings.order(created_at: :asc) dupes = [] (0...readings.length - 1).each do |i|
Sort readings for quality control dedupe