diff
stringlengths
65
26.7k
message
stringlengths
7
9.92k
diff --git a/core/app/models/spree/stock_location.rb b/core/app/models/spree/stock_location.rb index abc1234..def5678 100644 --- a/core/app/models/spree/stock_location.rb +++ b/core/app/models/spree/stock_location.rb @@ -13,6 +13,8 @@ scope :active, where(active: true) + after_create :populate_stock_items + def stock_item(variant) stock_items.where(variant_id: variant).first end @@ -25,5 +27,11 @@ variant_stock_item = stock_item(variant) variant_stock_item.present? ? variant_stock_item : stock_items.create! end + + def populate_stock_items + Spree::Variant.all.each do |v| + self.stock_items.create!(:variant => v) + end + end end end
Create Stock Items when Stock Location is created
diff --git a/config/initializers/asset_sync.rb b/config/initializers/asset_sync.rb index abc1234..def5678 100644 --- a/config/initializers/asset_sync.rb +++ b/config/initializers/asset_sync.rb @@ -25,4 +25,14 @@ # # Fail silently. Useful for environments such as Heroku # config.fail_silently = true + + config.add_local_file_paths do + # Any code that returns paths of local asset files to be uploaded + # Like Webpacker + public_root = Rails.root.join("public") + Dir.chdir(public_root) do + packs_dir = Webpacker.config.public_output_path.relative_path_from(public_root) + Dir[File.join(packs_dir, '/**/**')] + end + end end
Add webpacker compiled scripts to asset sync
diff --git a/config/initializers/logstasher.rb b/config/initializers/logstasher.rb index abc1234..def5678 100644 --- a/config/initializers/logstasher.rb +++ b/config/initializers/logstasher.rb @@ -0,0 +1,8 @@+if Object.const_defined?('LogStasher') && LogStasher.enabled + LogStasher.add_custom_fields do |fields| + # Mirrors Nginx request logging, e.g GET /path/here HTTP/1.1 + fields[:request] = "#{request.request_method} #{request.fullpath} #{request.headers['SERVER_PROTOCOL']}" + # Pass X-Varnish to logging + fields[:varnish_id] = request.headers['X-Varnish'] + end +end
Configure custom fields for Logstash
diff --git a/gcra.gemspec b/gcra.gemspec index abc1234..def5678 100644 --- a/gcra.gemspec +++ b/gcra.gemspec @@ -5,12 +5,12 @@ Gem::Specification.new do |spec| spec.name = 'gcra' spec.version = GCRA::VERSION - spec.authors = ['Michael Frister'] - spec.email = ['michael.frister@barzahlen.de'] + spec.authors = ['Michael Frister', 'Tobias Schoknecht'] + spec.email = ['tobias.schoknecht@barzahlen.de'] spec.description = 'GCRA implementation for rate limiting' spec.summary = 'Ruby implementation of a generic cell rate algorithm (GCRA), ported from ' \ 'the Go implementation throttled.' - spec.homepage = 'https://github.com/Barzahlen/gcra' + spec.homepage = 'https://github.com/Barzahlen/gcra-ruby' spec.license = 'MIT' spec.files = Dir['lib/**/*.rb']
Fix gemspec homepage path for next release
diff --git a/lib/bundler/update_stdout.rb b/lib/bundler/update_stdout.rb index abc1234..def5678 100644 --- a/lib/bundler/update_stdout.rb +++ b/lib/bundler/update_stdout.rb @@ -1,5 +1,22 @@ require "bundler/update_stdout/version" require 'bundler/cli' + +# OVERRIDE +module Bundler + class Definition + def lock(file) + contents = to_lock + + # Convert to \r\n if the existing lock has them + # i.e., Windows with `git config core.autocrlf=true` + contents.gsub!(/\n/, "\r\n") if @lockfile_contents.match("\r\n") + + return if @lockfile_contents == contents + + $stdout.write(contents) + end + end +end module Bundler class CLI @@ -10,7 +27,36 @@ possible versions of the gems in the bundle. D def update_stdout(*gems) - puts 'bundle-update_stdout' + + sources = Array(options[:source]) + # OVERRIDE + Bundler.ui.level = "warn" + + if gems.empty? && sources.empty? + # We're doing a full update + Bundler.definition(true) + else + # cycle through the requested gems, just to make sure they exist + names = Bundler.locked_gems.specs.map{ |s| s.name } + gems.each do |g| + next if names.include?(g) + raise GemNotFound, not_found_message(g, names) + end + Bundler.definition(:gems => gems, :sources => sources) + end + + Bundler::Fetcher.disable_endpoint = options["full-index"] + + opts = {"update" => true, "local" => options[:local]} + # rubygems plugins sometimes hook into the gem install process + Gem.load_env_plugins if Gem.respond_to?(:load_env_plugins) + + Bundler.definition.validate_ruby! + Installer.install Bundler.root, Bundler.definition, opts + Bundler.load.cache if Bundler.root.join("vendor/cache").exist? + clean if Bundler.settings[:clean] && Bundler.settings[:path] + Bundler.ui.confirm "Your bundle is updated!" + Bundler.ui.confirm without_groups_message if Bundler.settings.without.any? end end end
Copy and paste from bunlder
diff --git a/spec/models/rating/strictness_spec.rb b/spec/models/rating/strictness_spec.rb index abc1234..def5678 100644 --- a/spec/models/rating/strictness_spec.rb +++ b/spec/models/rating/strictness_spec.rb @@ -0,0 +1,41 @@+require 'spec_helper' + +RSpec.describe Rating::Strictness do + + + describe '#adjusted_points_for_applications' do + subject { described_class.new.adjusted_points_for_applications } + + # This is not a realistic test scenarion (i.e. we will never ever + # have just one application), but it's an important mathematical + # requirement. + context "when there's only one application" do + let!(:application) { create :application, :in_current_season } + + let!(:rating1) { create :rating, rateable: application } + let!(:rating2) { create :rating, rateable: application } + + context 'when reviewers rate equally' do + before { allow_any_instance_of(Rating).to receive(:points) { 5.0 } } + + it 'reduces to arithmetic mean' do + expect(subject).to eql({ application.id => 5.0 }) + end + end + + context 'when one reviewer rates stricter than the other' do + # We still want to stub Rating#points, but we need different + # valus. Return `a` for the first rating, `b` else. + let(:points) { ->(rating) { rating == rating1 ? 4.0 : 8.0 } } + before { allow_any_instance_of(Rating).to receive(:points, &points) } + + it 'reduces to arithmetic mean' do + expect(subject).to eql({ application.id => 6.0 }) + end + end + + end + + end + +end
WIP: Test mathematical edge case where applications count == 1
diff --git a/lib/chamber/core_ext/hash.rb b/lib/chamber/core_ext/hash.rb index abc1234..def5678 100644 --- a/lib/chamber/core_ext/hash.rb +++ b/lib/chamber/core_ext/hash.rb @@ -0,0 +1,26 @@+class Hash + def symbolize_keys + dup.symbolize_keys! + end + + def symbolize_keys! + keys.each do |key| + self[(key.to_sym rescue key) || key] = delete(key) + end + + self + end + + def deep_merge(other_hash) + dup.deep_merge!(other_hash) + end + + def deep_merge!(other_hash) + other_hash.each_pair do |k,v| + tv = self[k] + self[k] = tv.is_a?(Hash) && v.is_a?(Hash) ? tv.deep_merge(v) : v + end + + self + end +end
Add core extensions for a couple Hash methods so we don't have to include an external library
diff --git a/lib/opic.rb b/lib/opic.rb index abc1234..def5678 100644 --- a/lib/opic.rb +++ b/lib/opic.rb @@ -6,7 +6,7 @@ include Singleton @endpoint = "https://opic.osu.edu/" singleton_class.class_eval do - attr_accessor :api_key, :endpoint + attr_accessor :api_key, :endpoint, :error end class << self @@ -33,6 +33,7 @@ r = RestClient.post("#{@endpoint}api/avatars", data, headers) return false unless r.code == 201 rescue => e + @error = e return false end return true
Store the last exception we got
diff --git a/lib/serp.rb b/lib/serp.rb index abc1234..def5678 100644 --- a/lib/serp.rb +++ b/lib/serp.rb @@ -5,13 +5,12 @@ module Serp - def self.search_engine=(val) @@search_engine = val end def self.search_engine - @@search_engine || "http://www.google.com" + @@search_engine ||= "http://www.google.com" end def self.rank(keywords, locale = 'en' , pages = 3)
Set default value for search_engine properly
diff --git a/plugins/supervisor/check-supervisor.rb b/plugins/supervisor/check-supervisor.rb index abc1234..def5678 100644 --- a/plugins/supervisor/check-supervisor.rb +++ b/plugins/supervisor/check-supervisor.rb @@ -1,4 +1,17 @@ #!/usr/bin/env ruby +# +# Check Supervisor +# === +# +# Check all supervisor processes are running +# +# Requires SNMP gem +# +# Author: Johan van den Dorpe +# Copyright (c) 2013 Double Negative Limited +# +# Released under the same terms as Sensu (the MIT license); see LICENSE +# for details. require 'rubygems' if RUBY_VERSION > "1.9" require 'sensu-plugin/check/cli'
Add comments and copyright assignment
diff --git a/lib/firering/instantiator.rb b/lib/firering/instantiator.rb index abc1234..def5678 100644 --- a/lib/firering/instantiator.rb +++ b/lib/firering/instantiator.rb @@ -10,8 +10,13 @@ attributes ||= Hash.new attributes.each do |key, val| + setter = "#{key}=" value = ( key.to_s =~ /(_at|_on)$/ ) ? (Time.parse(val) rescue val) : val - instance.send("#{key}=", value) + if instance.respond_to?(setter) + instance.send(setter, value) + else + Kernel.warn "WARNING: Tried to set #{setter} #{value.inspect} on a #{instance.class} instance but it didn't respond" + end end callback.call(instance) if callback
Handle extra API attributes with a warning. Rather than die with a NoMethodError, just #warn about trying to set a non-existent attribute instead.
diff --git a/lib/fluent/plugin/out_dbi.rb b/lib/fluent/plugin/out_dbi.rb index abc1234..def5678 100644 --- a/lib/fluent/plugin/out_dbi.rb +++ b/lib/fluent/plugin/out_dbi.rb @@ -4,7 +4,7 @@ Plugin.register_output('dbi', self) config_param :dsn, :string - config_param :keys, :string + config_param :keys, :array config_param :db_user, :string config_param :db_pass, :string, secret: true config_param :query, :string @@ -17,8 +17,6 @@ def configure(conf) super - - @keys = @keys.split(",") end def format(tag, time, record)
Use :array type for keys parameter
diff --git a/lib/yarr.rb b/lib/yarr.rb index abc1234..def5678 100644 --- a/lib/yarr.rb +++ b/lib/yarr.rb @@ -1,4 +1,5 @@ require "io/console" +require "readline" class YARR def call @@ -6,8 +7,7 @@ number = 0 loop do number += 1 - prompt(number) - expression = gets.chomp + expression = Readline.readline(prompt(number), true) break if expression == "exit" evaluate(expression) end @@ -21,7 +21,7 @@ end def prompt(n) - print "#{bold("ruby")}:#{"%03d" % n}#{bold(">")} " + "#{bold("ruby")}:#{"%03d" % n}#{bold(">")} " end def evaluate(expression)
Use Readline for history and autocompletation
diff --git a/lib/models/team/team_bnet.rb b/lib/models/team/team_bnet.rb index abc1234..def5678 100644 --- a/lib/models/team/team_bnet.rb +++ b/lib/models/team/team_bnet.rb @@ -7,22 +7,12 @@ RBattlenet.set_region(region: region, locale: "en_GB") $errors = { :tracking => 0, :role => 0 } if characters.any? - results = [] - characters.each do |character| - character.process_result(RBattlenet::Wow::Character.find( - name: character.name, - realm: character.realm_slug, - fields: BNET_FIELDS, - )) - results << ["", character] - end - - # result = RBattlenet::Wow::Character.find_all(characters, - # fields: BNET_FIELDS) + result = RBattlenet::Wow::Character.find_all(characters, + fields: BNET_FIELDS) Logger.t(INFO_TEAM_REFRESHED, id) - Writer.write(self, results, HeaderData.altered_header(self)) - Writer.update_db(results.map { |uri, character| character }, true) + Writer.write(self, result, HeaderData.altered_header(self)) + Writer.update_db(result.map { |uri, character| character }, true) else Logger.t(INFO_TEAM_EMPTY, id) end
Revert "Workaround to attempt and fix empty responses." This reverts commit 83366407f379f5ac1694d52422ceeeda54dd2c37.
diff --git a/lib/plenty_client/comment.rb b/lib/plenty_client/comment.rb index abc1234..def5678 100644 --- a/lib/plenty_client/comment.rb +++ b/lib/plenty_client/comment.rb @@ -22,11 +22,11 @@ end def create(body = {}) - post(CREATE_CATEGORY, body) + post(CREATE_COMMENT, body) end def destroy(cat_id, body = {}) - delete(build_endpoint(DELETE_CATEGORY, comment: cat_id), body) + delete(build_endpoint(DELETE_COMMENT, comment: cat_id), body) end end end
Fix incorrect endpoint in Comment
diff --git a/lib/rubocop/cop/lint/loop.rb b/lib/rubocop/cop/lint/loop.rb index abc1234..def5678 100644 --- a/lib/rubocop/cop/lint/loop.rb +++ b/lib/rubocop/cop/lint/loop.rb @@ -8,28 +8,20 @@ MSG = 'Use Kernel#loop with break rather than ' + 'begin/end/until(or while).' - def on_while(node) - check(node) - + def on_while_post(node) + register_offence(node) super end - def on_until(node) - check(node) - + def on_until_post(node) + register_offence(node) super end private - def check(node) - _cond, body = *node - type = node.type.to_s - - if body.type == :begin && - !node.loc.expression.source.start_with?(type) - add_offence(:warning, node.loc.keyword, MSG) - end + def register_offence(node) + add_offence(:warning, node.loc.keyword, MSG) end end end
Migrate Loop cop to Parser 2.0.0.beta8 Now Parser generates `while_post` and `until_post` nodes for `begin...end while/until` source. So we just need to catch them. https://github.com/whitequark/parser/commit/679b526
diff --git a/lib/stockboy/translations.rb b/lib/stockboy/translations.rb index abc1234..def5678 100644 --- a/lib/stockboy/translations.rb +++ b/lib/stockboy/translations.rb @@ -4,35 +4,35 @@ module Stockboy module Translations - @translators ||= {} + @registry ||= {} + def self.register(name, callable) + if callable.respond_to?(:call) or callable < Stockboy::Translator + @registry[name.to_sym] = callable + else + raise ArgumentError, "Registered translators must be callable" + end + end + + def self.translate(func_name, context) + translator_for(:value, func_name).call(context) + end + + def self.translator_for(attr, lookup) + if lookup.respond_to?(:call) + lookup + elsif tr = self[lookup] + tr.is_a?(Class) && tr < Stockboy::Translator ? tr.new(attr) : tr + else + ->(context) { context.public_send attr } # no-op + end + end + + def self.find(func_name) + @registry[func_name] + end class << self - def register(name, callable) - if callable.respond_to?(:call) or callable < Stockboy::Translator - @translators[name.to_sym] = callable - else - raise ArgumentError, "Registered translators must be callable" - end - end - - def translate(func_name, context) - translator_for(:value, func_name).call(context) - end - - def find(func_name) - @translators[func_name] - end alias_method :[], :find - - def translator_for(attr, lookup) - if lookup.respond_to?(:call) - lookup - elsif tr = self[lookup] - tr.is_a?(Class) && tr < Stockboy::Translator ? tr.new(attr) : tr - else - ->(context) { context.public_send attr } # no-op - end - end end end
Clean up code out of class << self Make translations more in line with other Registry modules.
diff --git a/app/controllers/api/agendas_controller.rb b/app/controllers/api/agendas_controller.rb index abc1234..def5678 100644 --- a/app/controllers/api/agendas_controller.rb +++ b/app/controllers/api/agendas_controller.rb @@ -1,14 +1,10 @@ class Api::AgendasController < ApiController def index committee_id = params[:committee_id] + @agendas = Agenda.all - @agendas = if @@query.empty? && committee_id == nil - Agenda.all - elsif @@query.empty? == false - Agenda.where("date = ?", Date.strptime(@@query.gsub("%",""), '%m-%d-%Y')) - else - Agenda.where("committee_id = ?", committee_id) - end + @agendas = Agenda.where("date = ?", Date.strptime(@@query.gsub("%",""), '%m-%d-%Y')) unless @@query.empty? + @agendas = Agenda.where("committee_id = ?", committee_id) if committee_id.present? paginate json: @agendas.order(change_query_order), per_page: change_per_page end
Change API Agendas Query To Use Multiple Criteria
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index abc1234..def5678 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -2,6 +2,8 @@ class ApplicationController < ActionController::Base protect_from_forgery + + helper_method :current_user private @@ -9,8 +11,6 @@ session[:auth_token] = cookies[:auth_token] if cookies[:auth_token] @current_user ||= User.find_by_auth_token(session[:auth_token]) if session[:auth_token] end - - helper_method :current_user def authentication_check redirect_to signin_path unless current_user
Move helpre_method to beginning of file
diff --git a/app/helpers/config_helper.rb b/app/helpers/config_helper.rb index abc1234..def5678 100644 --- a/app/helpers/config_helper.rb +++ b/app/helpers/config_helper.rb @@ -19,7 +19,7 @@ end def eoy_thermometer_config - start_date = Date.new(2019, 11, 0o1) + start_date = Date.new(2019, 11, 29) end_date = Date.new(2019, 12, 31) # end of year goal in cents eoy_goal = 60_000_000
Use EOY dates for the eoy thermometer data
diff --git a/app/helpers/events_helper.rb b/app/helpers/events_helper.rb index abc1234..def5678 100644 --- a/app/helpers/events_helper.rb +++ b/app/helpers/events_helper.rb @@ -10,4 +10,8 @@ def badge_for_event(event, user) 'badge-info' if event.user_opted_in?(user) end + + def format_description(description) + simple_format(auto_link description) + end end
Add helper method for formatting URLs as links
diff --git a/app/helpers/layout_helper.rb b/app/helpers/layout_helper.rb index abc1234..def5678 100644 --- a/app/helpers/layout_helper.rb +++ b/app/helpers/layout_helper.rb @@ -25,7 +25,7 @@ when :success 'alert-success' when :error - 'alert-error' + 'alert-danger' when :notice 'alert-info' end
Fix class for error alert
diff --git a/app/controllers/ember_tests_controller.rb b/app/controllers/ember_tests_controller.rb index abc1234..def5678 100644 --- a/app/controllers/ember_tests_controller.rb +++ b/app/controllers/ember_tests_controller.rb @@ -6,7 +6,7 @@ private def test_html_with_corrected_asset_urls - test_html.gsub(%r{assets/}i, "assets/#{app_name}/") + test_html.gsub(%r{assets/}i, "#{asset_prefix}/#{app_name}/") end def test_html @@ -24,4 +24,8 @@ def app_name params.fetch(:app_name) end + + def asset_prefix + Rails.configuration.assets.prefix + end end
Use Rails' configured asset prefix in tests Don't assume assets are served from `/assets`
diff --git a/app/models/topic_category.rb b/app/models/topic_category.rb index abc1234..def5678 100644 --- a/app/models/topic_category.rb +++ b/app/models/topic_category.rb @@ -20,9 +20,12 @@ t = topic.name.downcase.gsub(/\W/, "") options.each do |key, value| - values = [key.downcase.gsub(/\W/, ""), value.downcase.gsub(/\W/, "")] + values = [ + key.downcase.gsub(/\W/, ""), + value.try(:downcase).try(:gsub, /\W/, "") + ].compact - return value if values.include?(t) + return (value || key) if values.include?(t) end end
Allow options to be array of strings
diff --git a/app/models/spree/shipping/rate_builder.rb b/app/models/spree/shipping/rate_builder.rb index abc1234..def5678 100644 --- a/app/models/spree/shipping/rate_builder.rb +++ b/app/models/spree/shipping/rate_builder.rb @@ -19,7 +19,7 @@ private - attr_reader :package, :shipping_method, :ship_time, :calculator + attr_reader :package, :shipping_method, :ship_time def package_cost calculator.compute_package(package) @@ -40,7 +40,11 @@ def delivery_window @delivery_window ||= begin if calculator.respond_to?(:estimate_delivery_window) - calculator.estimate_delivery_window(package, ship_time) + range = calculator.estimate_delivery_window(package, ship_time) + if range.length == 1 + range.push(range[0]) + end + DeliveryWindow.new(range[0], range[1]) else DeliveryWindow.new(nil, nil) end
Fix rate builder to handle delivery window arrays with only one element
diff --git a/spec/_plugins/sitemap_generator_spec.rb b/spec/_plugins/sitemap_generator_spec.rb index abc1234..def5678 100644 --- a/spec/_plugins/sitemap_generator_spec.rb +++ b/spec/_plugins/sitemap_generator_spec.rb @@ -28,6 +28,15 @@ end end + it 'creates a sitemap file with no private page url' do + begin + file = File.open(@file, 'r') + file.read.include?(private_page_url).must_equal false + ensure + file.close + end + end + it 'creates a sitemap file with no private post url' do begin file = File.open(@file, 'r')
Add test for privpub page in site map.
diff --git a/spec/factories/ext_management_system.rb b/spec/factories/ext_management_system.rb index abc1234..def5678 100644 --- a/spec/factories/ext_management_system.rb +++ b/spec/factories/ext_management_system.rb @@ -12,8 +12,8 @@ zone end after(:create) do |ems| - client_id = Rails.application.secrets.amazon.try(:[], 'client_id') || 'AMAZON_CLIENT_ID' - client_key = Rails.application.secrets.amazon.try(:[], 'client_secret') || 'AMAZON_CLIENT_SECRET' + client_id = Rails.application.secrets.amazon.try(:[], :client_id) || 'AMAZON_CLIENT_ID' + client_key = Rails.application.secrets.amazon.try(:[], :client_secret) || 'AMAZON_CLIENT_SECRET' cred = { :userid => client_id,
Use symbols instead of strings for accessing secrets.
diff --git a/spec/services/markdown_renderer_spec.rb b/spec/services/markdown_renderer_spec.rb index abc1234..def5678 100644 --- a/spec/services/markdown_renderer_spec.rb +++ b/spec/services/markdown_renderer_spec.rb @@ -0,0 +1,13 @@+require 'rails_helper' + +describe MarkdownRenderer do + it 'renders a paragraph' do + html = MarkdownRenderer.new.paragraph 'Some text' + expect(html).to eq '<p>Some text</p>' + end + + it 'renders a note' do + html = MarkdownRenderer.new.paragraph 'NOTE: Some note' + expect(html).to eq '<p class="note">Some note</p>' + end +end
Add specs for markdown renderer
diff --git a/lib/tent-validator/validators/without_authentication/app_validator.rb b/lib/tent-validator/validators/without_authentication/app_validator.rb index abc1234..def5678 100644 --- a/lib/tent-validator/validators/without_authentication/app_validator.rb +++ b/lib/tent-validator/validators/without_authentication/app_validator.rb @@ -16,6 +16,7 @@ :read => %w( https://tent.io/types/status/v0# ), :write => %w( https://tent.io/types/status/v0# ) }, + :notification_post_types => %w( https://tent.io/types/status/v0# ), :scopes => %w( import_posts ) }, :permissions => {
Update app registration post validation: add notification_post_types to app content
diff --git a/sciencemag_latest_news.gemspec b/sciencemag_latest_news.gemspec index abc1234..def5678 100644 --- a/sciencemag_latest_news.gemspec +++ b/sciencemag_latest_news.gemspec @@ -6,8 +6,7 @@ Gem::Specification.new do |spec| spec.name = "sciencemag_latest_news" spec.version = SciencemagLatestNews::VERSION - spec.authors = ["'Carley Tripp'"] - spec.email = "carley.tripp@outlook.com" + spec.authors = ["'Jax05'"] spec.summary = %q{Read all the latest news from the Science Magazine website via CLI.} spec.homepage = "https://github.com/Jax05/sciencemag_latest_news"
Update author name and remove email
diff --git a/wateringServer/spec/routing/sessions_routing_spec.rb b/wateringServer/spec/routing/sessions_routing_spec.rb index abc1234..def5678 100644 --- a/wateringServer/spec/routing/sessions_routing_spec.rb +++ b/wateringServer/spec/routing/sessions_routing_spec.rb @@ -0,0 +1,15 @@+require 'rails_helper' + +describe SessionsController do + it 'routes GET /login to sessions#new' do + expect(get: '/login').to route_to('sessions#new') + end + + it 'routes POST /login to sessions#create' do + expect(post: '/login').to route_to('sessions#create') + end + + it 'routes DELETE /logout to sessions#destroy' do + expect(delete: '/logout').to route_to('sessions#destroy') + end +end
Add tests for sessions routing
diff --git a/app/controllers/spree/checkout_controller_decorator.rb b/app/controllers/spree/checkout_controller_decorator.rb index abc1234..def5678 100644 --- a/app/controllers/spree/checkout_controller_decorator.rb +++ b/app/controllers/spree/checkout_controller_decorator.rb @@ -1,6 +1,8 @@ Spree::CheckoutController.class_eval do def permitted_source_attributes super.push(permitted_komoju_konbini_attributes) + super.push(permitted_komoju_banktransfer_attributes) + super.flatten end private @@ -8,5 +10,9 @@ def permitted_komoju_konbini_attributes :convenience end + + def permitted_komoju_banktransfer_attributes + [:email, :phone, :family_name, :given_name, :family_name_kana, :given_name_kana] + end end
Add permitted params for bank transfer
diff --git a/test/helper.rb b/test/helper.rb index abc1234..def5678 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -6,6 +6,7 @@ require 'minitest/autorun' require 'usesthis' require 'json' +require 'yaml' def test_site @test_site ||= UsesThis::Site.new(test_configuration) @@ -27,15 +28,22 @@ end def test_interview - @test_interview ||= read_fixture('interview') + @test_interview ||= read_json_fixture('interview') +end + +def fixture_path(name) + File.join(__dir__, 'fixtures', name) +end + +def read_json_fixture(name) + JSON.parse(File.read(fixture_path("#{name}.json"))) +end + +def read_yaml_fixture(name) + YAML.load_file(fixture_path("#{name}.yml")) end def read_api_file(path = nil) path = File.join(test_site.output_paths[:site], 'api', path, 'index.json') JSON.parse(File.read(path)) end - -def read_fixture(name) - path = File.join(__dir__, 'fixtures', "#{name}.json") - JSON.parse(File.read(path)) -end
Split read_fixture into read_json_fixture and read_yaml_fixture.
diff --git a/test/helper.rb b/test/helper.rb index abc1234..def5678 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -14,8 +14,8 @@ def test_configuration @config ||= Dimples::Configuration.new( - 'source_path' => File.join(__dir__, 'build'), - 'destination_path' => File.join(__dir__, 'site'), + 'source_path' => File.join(__dir__, 'source'), + 'destination_path' => File.join(File::SEPARATOR, 'tmp', 'site', "dimples-#{Time.new.to_i}"), 'categories' => [{ 'slug' => 'a', 'name' => 'A' }] ) end
Update the source and destination paths.
diff --git a/app/controllers/stories_controller.rb b/app/controllers/stories_controller.rb index abc1234..def5678 100644 --- a/app/controllers/stories_controller.rb +++ b/app/controllers/stories_controller.rb @@ -30,10 +30,15 @@ end def update - if @story.update_attributes story_params - redirect_to story_path(@story) + @story = Story.find(params["id"]) + if @story.update(content: params["story"]["content"]) + if request.xhr? + render plain: "Autosaved on " + @story.updated_at.strftime("%m/%d/%Y at %I:%M:%S %p") + else + redirect_to story_path(@story) + end else - render :edit + redirect_to :back end end
Include ajax request for update
diff --git a/features/step_definitions/view_steps.rb b/features/step_definitions/view_steps.rb index abc1234..def5678 100644 --- a/features/step_definitions/view_steps.rb +++ b/features/step_definitions/view_steps.rb @@ -6,6 +6,7 @@ end def check_details(details_selector, title, description, table) + page.wait_until(5){ page.first details_selector } # CI tests fail randomly if we won't wait enough here details = page.find details_selector details.find("h2").should have_content title if not description.nil? and not table.nil?
Add some waiting for selector to be found to get rid off random fails
diff --git a/app/models/pull_request_downloader.rb b/app/models/pull_request_downloader.rb index abc1234..def5678 100644 --- a/app/models/pull_request_downloader.rb +++ b/app/models/pull_request_downloader.rb @@ -16,7 +16,7 @@ def download_pull_requests begin - events = Octokit.user_events(login) + events = github_client.user_events(login) events.select do |e| event_date = e['created_at'] e.type == 'PullRequestEvent' &&
Revert "Use Octokit client for now" This reverts commit af2cc66975bc81594484d31089d392bc52b84763.
diff --git a/app/serializers/v3/word_serializer.rb b/app/serializers/v3/word_serializer.rb index abc1234..def5678 100644 --- a/app/serializers/v3/word_serializer.rb +++ b/app/serializers/v3/word_serializer.rb @@ -19,9 +19,19 @@ # class V3::WordSerializer < V3::ApplicationSerializer - attributes :id, :position, :text_madani, :text_indopak, :text_simple, :verse_key, :class_name, :line_number, :code, :char_type + attributes :id, + :position, + :text_madani, + :text_indopak, + :text_simple, + :verse_key, + :class_name, + :line_number, + :page_number, + :code, + :char_type - has_one :audio, serializer: V3::AudioFileSerializer + has_one :audio, serializer: V3::AudioFileSerializer has_one :translation do object.translations.filter_by_language_or_default scope[:translations]
Add Page Number to Word Serializer
diff --git a/app/views/clients/index.json.jbuilder b/app/views/clients/index.json.jbuilder index abc1234..def5678 100644 --- a/app/views/clients/index.json.jbuilder +++ b/app/views/clients/index.json.jbuilder @@ -1,4 +1,4 @@ json.array!(@clients) do |client| - json.extract! client, :id, :first_name, :last_name, :phone, :address_line_1, :address_line_2, :city, :state, :country, :zipcode + json.extract! client, :id, :name, :phone, :address_line_1, :address_line_2, :city, :state, :country, :zipcode json.url client_url(client, format: :json) end
Add clients dropdown on Add Sale
diff --git a/Formula/kdepimlibs.rb b/Formula/kdepimlibs.rb index abc1234..def5678 100644 --- a/Formula/kdepimlibs.rb +++ b/Formula/kdepimlibs.rb @@ -0,0 +1,18 @@+require 'formula' + +class Kdepimlibs <Formula + url 'ftp://ftp.kde.org/pub/kde/stable/4.4.0/src/kdepimlibs-4.4.0.tar.bz2' + homepage 'http://www.kde.org/' + md5 '2eb04e5ae39a25009f036ec333eb118a' + + depends_on 'cmake' + depends_on 'gpgme' + depends_on 'akonadi' + depends_on 'libical' + depends_on 'kdelibs' + + def install + system "cmake . #{std_cmake_parameters}" + system "make install" + end +end
Add KDE PIM libraries version 4.4.0.
diff --git a/pkg/brew/watchexec.rb b/pkg/brew/watchexec.rb index abc1234..def5678 100644 --- a/pkg/brew/watchexec.rb +++ b/pkg/brew/watchexec.rb @@ -0,0 +1,17 @@+class Watchexec < Formula + desc "Execute commands when watched files change" + homepage "https://github.com/mattgreen/watchexec" + url "https://github.com/mattgreen/watchexec/releases/download/0.10.0/watchexec_osx_0.10.0.tar.gz" + version "0.10.0" + sha256 "0a2eae6fc0f88614bdc732b233b0084a3aa6208177c52c4d2ecb0a671f55d82b" + + bottle :unneeded + + def install + bin.install "watchexec" + end + + test do + system "#{bin}/watchexec", "--version" + end +end
Add Homebrew formula to this repo
diff --git a/examples/create_authorization.rb b/examples/create_authorization.rb index abc1234..def5678 100644 --- a/examples/create_authorization.rb +++ b/examples/create_authorization.rb @@ -5,7 +5,7 @@ card = client.cards.post(org, ::Io::Flow::V0::Models::CardForm.new( - :number => "378282246310005", + :number => "4012888888881881", :name => "Joe Smith", :expiration_month => 1, :expiration_year => Time.now.year + 1 @@ -16,7 +16,7 @@ auth = client.authorizations.post(org, ::Io::Flow::V0::Models::DirectAuthorizationForm.new( :token => card.token, - :amount => 3122, + :amount => 3110, :currency => "USD", :customer => { :name => {:first => "Joe", :last => "Smith"}
Update example w/ a test auth
diff --git a/metadata.rb b/metadata.rb index abc1234..def5678 100644 --- a/metadata.rb +++ b/metadata.rb @@ -2,7 +2,7 @@ maintainer 'Chef Software, Inc.' maintainer_email 'cookbooks@chef.io' license 'Apache 2.0' -description 'Installs/Configures tomcat' +description 'Installs and configures Apache Tomcat' long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) version '0.17.3' @@ -10,14 +10,9 @@ depends 'openssl' depends 'yum-epel' -supports 'debian' -supports 'ubuntu' -supports 'centos' -supports 'redhat' -supports 'amazon' -supports 'oracle' -supports 'scientific' -supports 'opensuse' +%w(ubuntu debian redhat centos suse opensuse scientific oracle amazon).each do |os| + supports os +end recipe 'tomcat::default', 'Installs and configures Tomcat' recipe 'tomcat::users', 'Setup users and roles for Tomcat'
Improve description and use array for supports
diff --git a/metadata.rb b/metadata.rb index abc1234..def5678 100644 --- a/metadata.rb +++ b/metadata.rb @@ -2,9 +2,9 @@ maintainer 'Continuuity, Inc.' maintainer_email 'ops@continuuity.com' license 'Apache 2.0' -description 'Installs/Configures hadoop' +description 'Installs/Configures Hadoop (HDFS/YARN/MRv2), HBase, Hive, Oozie, Pig, and ZooKeeper' long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version '0.1.2' +version '1.0.0' depends 'yum', '>= 3.0' depends 'apt'
Update description and version bump to 1.0.0 for release
diff --git a/metadata.rb b/metadata.rb index abc1234..def5678 100644 --- a/metadata.rb +++ b/metadata.rb @@ -18,5 +18,5 @@ depends 'apt', '>= 2.4' depends 'build-essential' depends 'chef-sugar' -depends 'yum', '>= 3.0', '< 4.1' +depends 'yum', '>= 3.0' depends 'yum-epel'
Remove upper bound on yum cookbook dependency
diff --git a/test/assert_raise.rb b/test/assert_raise.rb index abc1234..def5678 100644 --- a/test/assert_raise.rb +++ b/test/assert_raise.rb @@ -20,3 +20,8 @@ assert_equal "error", exception.message end +test "catches a custom exception" do + assert_raise do + raise Class.new(Exception) + end +end
Add test for custom exception
diff --git a/wobbly.gemspec b/wobbly.gemspec index abc1234..def5678 100644 --- a/wobbly.gemspec +++ b/wobbly.gemspec @@ -8,9 +8,9 @@ spec.version = Wobbly::VERSION spec.authors = ["Eric Roberts"] spec.email = ["ericroberts@gmail.com"] - spec.summary = %q{TODO: Write a short summary. Required.} - spec.description = %q{TODO: Write a longer description. Optional.} - spec.homepage = "" + spec.summary = "Why be constant when you can be wobbly?" + spec.description = "Ever wanted to just get or define a constant (or chain of constants)? Now you can." + spec.homepage = "https://github.com/ericroberts/wobbly" spec.license = "MIT" spec.files = `git ls-files -z`.split("\x0")
Add short and long description.
diff --git a/db/migrate/20131031175232_default_values_on_geocodings.rb b/db/migrate/20131031175232_default_values_on_geocodings.rb index abc1234..def5678 100644 --- a/db/migrate/20131031175232_default_values_on_geocodings.rb +++ b/db/migrate/20131031175232_default_values_on_geocodings.rb @@ -0,0 +1,15 @@+Sequel.migration do + up do + alter_table :geocodings do + set_column_default :processed_rows, 0 + set_column_default :total_rows, 0 + end + end + + down do + alter_table :geocodings do + set_column_default :processed_rows, nil + set_column_default :total_rows, nil + end + end +end
Add default values on geocodings table
diff --git a/db/migrate/20140627185148_add_timestamps_to_gift_cards.rb b/db/migrate/20140627185148_add_timestamps_to_gift_cards.rb index abc1234..def5678 100644 --- a/db/migrate/20140627185148_add_timestamps_to_gift_cards.rb +++ b/db/migrate/20140627185148_add_timestamps_to_gift_cards.rb @@ -0,0 +1,6 @@+class AddTimestampsToGiftCards < ActiveRecord::Migration + def change + add_column :spree_virtual_gift_cards, :created_at, :datetime + add_column :spree_virtual_gift_cards, :updated_at, :datetime + end +end
Add timestamps to virtual gift cards
diff --git a/spec/api_classes/track_spec.rb b/spec/api_classes/track_spec.rb index abc1234..def5678 100644 --- a/spec/api_classes/track_spec.rb +++ b/spec/api_classes/track_spec.rb @@ -2,10 +2,16 @@ describe LastFM::Track do it "should define unrestricted methods" do - LastFM::Track.unrestricted_methods.should == [:get_buy_links, :get_correction, :get_fingerprint_metadata, :get_info, :get_similar, :get_top_fans, :get_top_tags, :search] + LastFM::Track.should respond_to( + :get_buy_links, :get_correction, :get_fingerprint_metadata, :get_info, + :get_similar, :get_top_fans, :get_top_tags, :search + ) end it "should define restricted methods" do - LastFM::Track.restricted_methods.should == [:add_tags, :ban, :get_tags, :love, :remove_tag, :share, :unban, :unlove] + LastFM::Track.should respond_to( + :get_tags, :add_tags, :ban, :love, :remove_tag, :scrobble, :share, :unban, + :unlove, :update_now_playing + ) end end
Check method definitions for Track
diff --git a/spec/rails/rack/tracer_spec.rb b/spec/rails/rack/tracer_spec.rb index abc1234..def5678 100644 --- a/spec/rails/rack/tracer_spec.rb +++ b/spec/rails/rack/tracer_spec.rb @@ -17,7 +17,8 @@ it 'leaves the operation_name as it was' do respond_with { response } - expect(tracer.finished_spans.first.operation_name).to eq('GET') + expect(tracer).to have_spans(1) + expect(tracer).to have_span('GET').finished end end @@ -29,7 +30,8 @@ response end - expect(tracer.finished_spans.first.operation_name).to eq('Api::UsersController#index') + expect(tracer).to have_spans(1) + expect(tracer).to have_span('Api::UsersController#index').finished end end
Use tracing matchers in rack module tests
diff --git a/spec/redditkit/comment_spec.rb b/spec/redditkit/comment_spec.rb index abc1234..def5678 100644 --- a/spec/redditkit/comment_spec.rb +++ b/spec/redditkit/comment_spec.rb @@ -2,12 +2,12 @@ describe RedditKit::Comment, :vcr do - it "should return replies" do - comments = RedditKit.comments '1n002d' - comment = comments.first - - expect(comment.replies?).to be true - end + # it "should return replies" do + # comments = RedditKit.comments '1n002d' + # comment = comments.first + # + # expect(comment.replies?).to be true + # end it "should be deleted if both author and comment attributes are set to '[deleted]'" do attributes = { :data => { :author => '[deleted]', :body => '[deleted]' } }
Comment out the replies test while working on a fix.
diff --git a/lib/dot_grid/generator.rb b/lib/dot_grid/generator.rb index abc1234..def5678 100644 --- a/lib/dot_grid/generator.rb +++ b/lib/dot_grid/generator.rb @@ -14,12 +14,16 @@ def initialize(params) @file_name = params[:file_name] || "dotgrid.pdf" - @page_size = params[:page_size] || "LETTER" - @margin = params[:margin] || 0.5 + @page_size = params[:page_size] ? parse_page_size(params[:page_size]) : "LETTER" + @margin = params[:margin] || 0.5.mm @page_types = params[:page_types] ? params[:page_types].split(",") : ["planner"] @pdf = Prawn::Document.new(margin: margin, page_size: page_size, skip_page_creation: true) - params[:pdf] = pdf - @pages = create_pages(params) + @pages = create_pages(params.merge({pdf: pdf})) + end + + def parse_page_size(page_size) + return page_size unless p = /(?'w'\d+\.{0,1}\d*)x(?'h'\d+\.{0,1}\d*)(?'u'[a-z]{2})/.match(page_size) + return [p[:w].to_f.send(p[:u]), p[:h].to_f.send(p[:u])] end def create_pages(params)
Add Ability to Specify Page Size Added the ability to parse things like 13.3x5.4in in the page size.
diff --git a/lib/front_matter_ninja.rb b/lib/front_matter_ninja.rb index abc1234..def5678 100644 --- a/lib/front_matter_ninja.rb +++ b/lib/front_matter_ninja.rb @@ -5,17 +5,19 @@ class FrontMatterNinja attr_accessor :data, :content + DOCUMENT_MATCHER = /\A(---\s*\n.*?\n?)^((---|\.\.\.)\s*$\n?)(.*)/m + YAML_START_MATCHER = /\A---\s*/ + YAML_END_MATCHER = /\.\.\.\n\z/ + def initialize(string) - match = string.match(/\A(---\s*\n.*?\n?)^((---|\.\.\.)\s*$\n?)(.*)/m) + match = string.match DOCUMENT_MATCHER @data = SafeYAML.load(match[0]) || {} if match @content = match ? match[4] : string end def raw_data - @data.to_yaml - .sub(/\A---\s*/, '') - .sub(/\.\.\.\n\z/, '') + strip_yaml @data.to_yaml end def raw_data=(data) @@ -25,4 +27,10 @@ def to_s "---\n#{raw_data}---\n\n#{content}" end + + private + + def strip_yaml(string) + string.sub(YAML_START_MATCHER, '').sub(YAML_END_MATCHER, '') + end end
Move regular expressions to constants
diff --git a/config/initializers/abstract_adapter.rb b/config/initializers/abstract_adapter.rb index abc1234..def5678 100644 --- a/config/initializers/abstract_adapter.rb +++ b/config/initializers/abstract_adapter.rb @@ -1,4 +1,4 @@-if defined?(ActiveRecord::ConnectionAdaptors::AbstractAdaptor) +if defined?(ActiveRecord::ConnectionAdaptors::AbstractAdapter) module ActiveRecord module ConnectionAdapters class AbstractAdapter
Fix typo that stopped monkey patch working
diff --git a/spec/models/api_sampler/sample_spec.rb b/spec/models/api_sampler/sample_spec.rb index abc1234..def5678 100644 --- a/spec/models/api_sampler/sample_spec.rb +++ b/spec/models/api_sampler/sample_spec.rb @@ -5,6 +5,7 @@ RSpec.describe Sample, type: :model do subject { FactoryGirl.build(:sample) } + it { is_expected.to belong_to(:endpoint) } it { is_expected.to have_and_belong_to_many(:tags) } it { is_expected.to validate_presence_of(:endpoint_id) }
Add the missing association validation to ApiSampler::Sample
diff --git a/thrift-rack-middleware.gemspec b/thrift-rack-middleware.gemspec index abc1234..def5678 100644 --- a/thrift-rack-middleware.gemspec +++ b/thrift-rack-middleware.gemspec @@ -20,6 +20,7 @@ # specify any dependencies here; for example: s.add_development_dependency "rspec", "~> 2.14.0" + s.add_development_dependency "rake" s.add_runtime_dependency "rack", '>= 1.1.0' s.add_runtime_dependency "thrift", ">= 0.9.0" end
Add rake as development dependency
diff --git a/app/controllers/api/stateless/stateless_controller.rb b/app/controllers/api/stateless/stateless_controller.rb index abc1234..def5678 100644 --- a/app/controllers/api/stateless/stateless_controller.rb +++ b/app/controllers/api/stateless/stateless_controller.rb @@ -12,13 +12,13 @@ protected def authenticate_request! - @current_member = authenticate_user_from_token + @current_member = authenticate_member_from_token raise Exceptions::UnauthorizedError unless @current_member end private - def authenticate_user_from_token + def authenticate_member_from_token _, token = request.headers['authorization'].split payload = decode_jwt(token) Member.find(payload[:id])
Rename authenticate_user_ -> authenticate_member_ (semantics)
diff --git a/spec/unit/mutant/reporter/null_spec.rb b/spec/unit/mutant/reporter/null_spec.rb index abc1234..def5678 100644 --- a/spec/unit/mutant/reporter/null_spec.rb +++ b/spec/unit/mutant/reporter/null_spec.rb @@ -0,0 +1,11 @@+require 'spec_helper' + +describe Mutant::Reporter::Null do + let(:object) { described_class.new } + + describe '#report' do + subject { object.report(double('some input')) } + + it_should_behave_like 'a command method' + end +end
Add specs for null reporter
diff --git a/metadata.rb b/metadata.rb index abc1234..def5678 100644 --- a/metadata.rb +++ b/metadata.rb @@ -3,7 +3,7 @@ maintainer_email "k@treasure-data.com" license "Apache 2.0" description "Installs/Configures td-agent" -long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc')) +long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) version "0.0.1" recipe "td-agent", "td-agent configuration"
Use `README.md` as the `long_description` of the cookbook
diff --git a/metadata.rb b/metadata.rb index abc1234..def5678 100644 --- a/metadata.rb +++ b/metadata.rb @@ -19,3 +19,4 @@ depends 'bluepill', '~> 2.3' depends 'accumulator' depends 'ark' +depends 'golang'
Add dependency on golang for the ::source recipe.
diff --git a/lib/vagrant-parallels/guest_cap/linux/mount_parallels_shared_folder.rb b/lib/vagrant-parallels/guest_cap/linux/mount_parallels_shared_folder.rb index abc1234..def5678 100644 --- a/lib/vagrant-parallels/guest_cap/linux/mount_parallels_shared_folder.rb +++ b/lib/vagrant-parallels/guest_cap/linux/mount_parallels_shared_folder.rb @@ -4,25 +4,29 @@ class MountParallelsSharedFolder def self.mount_parallels_shared_folder(machine, name, guestpath, options) + # Expand the guest path so we can handle things like "~/vagrant" + expanded_guest_path = machine.guest.capability( + :shell_expand_guest_path, guestpath) + machine.communicate.tap do |comm| # clear prior symlink - if comm.test("test -L \"#{guestpath}\"", :sudo => true) - comm.sudo("rm \"#{guestpath}\"") + if comm.test("test -L \"#{expanded_guest_path}\"", :sudo => true) + comm.sudo("rm \"#{expanded_guest_path}\"") end # clear prior directory if exists - if comm.test("test -d \"#{guestpath}\"", :sudo => true) - comm.sudo("rm -Rf \"#{guestpath}\"") + if comm.test("test -d \"#{expanded_guest_path}\"", :sudo => true) + comm.sudo("rm -Rf \"#{expanded_guest_path}\"") end # create intermediate directories if needed - intermediate_dir = File.dirname(guestpath) + intermediate_dir = File.dirname(expanded_guest_path) if !comm.test("test -d \"#{intermediate_dir}\"", :sudo => true) comm.sudo("mkdir -p \"#{intermediate_dir}\"") end # finally make the symlink - comm.sudo("ln -s \"/media/psf/#{name}\" \"#{guestpath}\"") + comm.sudo("ln -s \"/media/psf/#{name}\" \"#{expanded_guest_path}\"") end end end
Use 'shell_expand_guest_path' guest capability to expand "~/" in shared folder mounts This was copied from the official NFS mount capability
diff --git a/app/models/concerns/gobierto_common/has_vocabulary.rb b/app/models/concerns/gobierto_common/has_vocabulary.rb index abc1234..def5678 100644 --- a/app/models/concerns/gobierto_common/has_vocabulary.rb +++ b/app/models/concerns/gobierto_common/has_vocabulary.rb @@ -26,7 +26,7 @@ define_singleton_method name do |site = nil| site ||= GobiertoCore::CurrentScope.current_site - return GobiertoCommon::Term.none unless site.settings_for_module(module_name) + return GobiertoCommon::Term.none unless site.settings_for_module(module_name)&.send(vocabulary_module_setting)&.present? site.vocabularies.find(site.settings_for_module(module_name).send(vocabulary_module_setting)).terms end
Return no vocabulary if configuration is blank
diff --git a/backend/app/helpers/spree/admin/adjustments_helper.rb b/backend/app/helpers/spree/admin/adjustments_helper.rb index abc1234..def5678 100644 --- a/backend/app/helpers/spree/admin/adjustments_helper.rb +++ b/backend/app/helpers/spree/admin/adjustments_helper.rb @@ -24,7 +24,7 @@ parts = [] parts << variant.product.name parts << "(#{variant.options_text})" if variant.options_text.present? - parts << line_item.display_total + parts << line_item.display_amount safe_join(parts, "<br />".html_safe) end
Update helper to use display_amount
diff --git a/ruby/referral-code.rb b/ruby/referral-code.rb index abc1234..def5678 100644 --- a/ruby/referral-code.rb +++ b/ruby/referral-code.rb @@ -0,0 +1,24 @@+# Testing referral code in chargify_api_ares gem + +gem 'chargify_api_ares', '=1.3.2' +require 'chargify_api_ares' + +Chargify.configure do |c| + c.subdomain = ENV['CHARGIFY_SUBDOMAIN'] + c.api_key = ENV['CHARGIFY_API_KEY'] +end + +# Create a subscription +new_sub = Chargify::Subscription.create( + :product_handle => 'free-product-with-trial-period', + :customer_attributes => { + :reference => "Test899", + :first_name => "Test899", + :last_name => "Customer899", + :email => "test@example.com" + }, + :components=>[{:component_id=>76623, :allocated_quantity=>7}], + :ref => "jj9pvw" +) + +puts new_sub.id
Add example of creating a subscription with a referral code
diff --git a/lib/pdf_generator/prince_pdf_generator.rb b/lib/pdf_generator/prince_pdf_generator.rb index abc1234..def5678 100644 --- a/lib/pdf_generator/prince_pdf_generator.rb +++ b/lib/pdf_generator/prince_pdf_generator.rb @@ -2,7 +2,7 @@ include Vmdb::Logging def self.executable return @executable if defined?(@executable) - @executable = `which prince`.chomp + @executable = `which prince 2> /dev/null`.chomp end def self.available?
Send 'which prince' failures to /dev/null.
diff --git a/lib/sanitize_email/custom_environments.rb b/lib/sanitize_email/custom_environments.rb index abc1234..def5678 100644 --- a/lib/sanitize_email/custom_environments.rb +++ b/lib/sanitize_email/custom_environments.rb @@ -16,10 +16,10 @@ module ClassMethods def consider_local? - local_environments.include?(Rails.env) + local_environments.include?(defined?(Rails) ? Rails.env : RAILS_ENV) end def consider_deployed? - deployed_environments.include?(Rails.env) + deployed_environments.include?(defined?(Rails) ? Rails.env : RAILS_ENV) end end
Use the oldschool RAILS_ENV constant to get the current environment, if the newfangled Rails.env isn't available.
diff --git a/lib/airbrake/rails.rb b/lib/airbrake/rails.rb index abc1234..def5678 100644 --- a/lib/airbrake/rails.rb +++ b/lib/airbrake/rails.rb @@ -6,16 +6,14 @@ # Rails namespace holds all Rails-related functionality. module Rails def self.logger + # Rails.logger is not set in some Rake tasks such as + # 'airbrake:deploy'. In this case we use a sensible fallback. + level = (::Rails.logger ? ::Rails.logger.level : Logger::ERROR) + if ENV['RAILS_LOG_TO_STDOUT'].present? - Logger.new(STDOUT, level: ::Rails.logger.level) + Logger.new(STDOUT, level: level) else - Logger.new( - ::Rails.root.join('log', 'airbrake.log'), - - # Rails.logger is not set in some Rake tasks such as - # 'airbrake:deploy'. In this case we use a sensible fallback. - level: (::Rails.logger ? ::Rails.logger.level : Logger::ERROR), - ) + Logger.new(::Rails.root.join('log', 'airbrake.log'), level: level) end end end
Fix crash when airbrake:deploy used with RAILS_LOG_TO_STDOUT
diff --git a/lib/chaindrive/api.rb b/lib/chaindrive/api.rb index abc1234..def5678 100644 --- a/lib/chaindrive/api.rb +++ b/lib/chaindrive/api.rb @@ -17,7 +17,7 @@ end get ':id' do - Gear.where(:name => params[:id], :status => true) + Gear.where(:name => params[:id], :status => true).order(:created_at).limit(1) end get ':id/version/:version' do
Order by the created_at field and limit to one. This will always get the latest version.
diff --git a/core/spec/integration/integration_spec.rb b/core/spec/integration/integration_spec.rb index abc1234..def5678 100644 --- a/core/spec/integration/integration_spec.rb +++ b/core/spec/integration/integration_spec.rb @@ -17,7 +17,7 @@ click_link "Add new" fill_in "channel_title", with: channel_title - click_button "Save" + click_button "Submit" within(:css, "h1") do page.should have_content(channel_title)
Test with the new confirm button
diff --git a/db/migrate/20190206235926_change_site_id_to_bigint.rb b/db/migrate/20190206235926_change_site_id_to_bigint.rb index abc1234..def5678 100644 --- a/db/migrate/20190206235926_change_site_id_to_bigint.rb +++ b/db/migrate/20190206235926_change_site_id_to_bigint.rb @@ -0,0 +1,13 @@+class ChangeSiteIdToBigint < ActiveRecord::Migration[6.0] + def up + change_column :sites, :id, :bigint + + change_column :members, :site_id, :bigint + end + + def down + change_column :sites, :id, :integer + + change_column :members, :site_id, :integer + end +end
Update site_id primary and foreign keys to bigint
diff --git a/web.rb b/web.rb index abc1234..def5678 100644 --- a/web.rb +++ b/web.rb @@ -30,6 +30,8 @@ MU_CORE = RDF::Vocabulary.new(MU.to_uri.to_s + 'core/') MU_EXT = RDF::Vocabulary.new(MU.to_uri.to_s + 'ext/') +SERVICE_RESOURCE_BASE = 'http://mu.semte.ch/services/' + ### # Helpers ###
Add service resource base URI
diff --git a/db/migrate/20130926133717_add_batch_number_to_push_sent_emails.rb b/db/migrate/20130926133717_add_batch_number_to_push_sent_emails.rb index abc1234..def5678 100644 --- a/db/migrate/20130926133717_add_batch_number_to_push_sent_emails.rb +++ b/db/migrate/20130926133717_add_batch_number_to_push_sent_emails.rb @@ -1,4 +1,4 @@-class AddBatchNumberToPushes < ActiveRecord::Migration +class AddBatchNumberToPushSentEmails < ActiveRecord::Migration def change add_column :push_sent_emails, :batch_number, :integer end
Correct class name of migration
diff --git a/lib/google_weather.rb b/lib/google_weather.rb index abc1234..def5678 100644 --- a/lib/google_weather.rb +++ b/lib/google_weather.rb @@ -12,7 +12,7 @@ end def weather - @weather ||= self.class.get("/ig/api", :query => {:weather => @zip}, :format => :xml)['xml_api_reply']['weather'] + @weather ||= self.class.get("/ig/api", :query => {:weather => @zip, :hl => I18n.locale.to_s, :oe => 'utf-8'}, :format => :xml)['xml_api_reply']['weather'] end def forecast_information
Use app locale to load weather, specify encoding
diff --git a/app/controllers/finders_controller.rb b/app/controllers/finders_controller.rb index abc1234..def5678 100644 --- a/app/controllers/finders_controller.rb +++ b/app/controllers/finders_controller.rb @@ -49,7 +49,6 @@ def finders_excluded_from_robots [ 'aaib-reports', - 'international-development-funding', 'drug-safety-update', ] end
Allow DFID finder to be crawled by robots
diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index abc1234..def5678 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -1,6 +1,6 @@ class WelcomeController < ApplicationController def index - @things = Thing.all.order(:name) + @things = Thing.all.includes(:check_outs).order(:name) respond_with @things end end
Fix n+1 query issue on home page
diff --git a/app/models/spree/product_decorator.rb b/app/models/spree/product_decorator.rb index abc1234..def5678 100644 --- a/app/models/spree/product_decorator.rb +++ b/app/models/spree/product_decorator.rb @@ -1,7 +1,7 @@ Spree::Product.class_eval do def option_values - @_option_values ||= Spree::OptionValue.for_product(self).order(:position).sort_by {|ov| ov.option_type.position } + @_option_values ||= Spree::OptionValue.find_by_sql(["SELECT ov.id FROM spree_option_values ov INNER JOIN spree_option_values_variants ovv ON ovv.option_value_id = ov.id INNER JOIN spree_variants v on ovv.variant_id = v.id WHERE v.product_id = ? ORDER BY v.position", self.id]) end def grouped_option_values
Order options by variant position
diff --git a/lib/mailbox_reader.rb b/lib/mailbox_reader.rb index abc1234..def5678 100644 --- a/lib/mailbox_reader.rb +++ b/lib/mailbox_reader.rb @@ -0,0 +1,15 @@+class MailboxReader + def self.run + mailboxes_config.each do |name, config| + retriever = Mail::IMAP.new(config) + retriever.find_and_delete(what: :first).each do |message| + mail = InboundMail.new_from_message(message) + mail.save! + end + end + end + + def self.mailboxes_config + @config ||= YAML::load(File.read(Rails.root + "config" + "mailboxes.yml")) + end +end
Add MailboxReader that fetches IMAP messages and saves them to InboundMail. Gets hosts from config/mailboxes.yml.
diff --git a/lib/monkey/patcher.rb b/lib/monkey/patcher.rb index abc1234..def5678 100644 --- a/lib/monkey/patcher.rb +++ b/lib/monkey/patcher.rb @@ -23,6 +23,10 @@ helper :release_logs end + + ApplicationHelper.class_eval do + include ReleaseLogsHelper + end end end end
Patch application helper to include our helper.
diff --git a/lib/puppet/type/s3.rb b/lib/puppet/type/s3.rb index abc1234..def5678 100644 --- a/lib/puppet/type/s3.rb +++ b/lib/puppet/type/s3.rb @@ -1,6 +1,6 @@ Puppet::Type.newtype(:s3) do - @@doc = %q{Get files from S3 + @doc = %q{Get files from S3 Example:
Remove doubled at sign for S3 doc block
diff --git a/lib/spreedly/model.rb b/lib/spreedly/model.rb index abc1234..def5678 100644 --- a/lib/spreedly/model.rb +++ b/lib/spreedly/model.rb @@ -8,7 +8,10 @@ field :token field :created_at, :updated_at, type: :date_time + attr_reader :xml_doc + def initialize(xml_doc) + @xml_doc = xml_doc initialize_fields(xml_doc) end
Add xml_doc accessor on base Model to expose access to the raw XML, because sometimes that's handy to see :)
diff --git a/lib/typedeploy/kit.rb b/lib/typedeploy/kit.rb index abc1234..def5678 100644 --- a/lib/typedeploy/kit.rb +++ b/lib/typedeploy/kit.rb @@ -6,14 +6,15 @@ def initialize(id, data) @kid = id @data = data + @api = Api.new end def publish - Api.publish(@kid) + @api.publish(@kid) end def create - Api.create(@data) + @api.create(self) end class Family
Make calls on Api instance, not class.
diff --git a/condensation.gemspec b/condensation.gemspec index abc1234..def5678 100644 --- a/condensation.gemspec +++ b/condensation.gemspec @@ -23,6 +23,6 @@ spec.add_development_dependency "timecop" spec.add_dependency "liquid", [">= 2.0", "<= 4.0"] - spec.add_dependency "tzinfo", "~> 0" + spec.add_dependency "tzinfo", "~> 1" spec.add_dependency "activesupport", ">= 3.0" end
Update tzinfo dependency to enable for rails 4.1
diff --git a/spec/controllers/main_controller_spec.rb b/spec/controllers/main_controller_spec.rb index abc1234..def5678 100644 --- a/spec/controllers/main_controller_spec.rb +++ b/spec/controllers/main_controller_spec.rb @@ -0,0 +1,33 @@+require 'spec_helper' + +describe TimecopConsole::MainController do + before(:each) do + request.env["HTTP_REFERER"] = "where_i_came_from" + end + + describe "POST to :update" do + let(:timecop_param) do + { + 'current_time(1i)' => 2012, + 'current_time(2i)' => 11, + 'current_time(3i)' => 30, + 'current_time(4i)' => 22, + 'current_time(5i)' => 01 + } + end + + it 'redirects back' do + post :update, :timecop => timecop_param, :use_route => :timecop_console + + response.should redirect_to("where_i_came_from") + end + end + + describe "GET to :reset" do + it 'redirects back' do + get :reset, :use_route => :timecop_console + + response.should redirect_to "where_i_came_from" + end + end +end
Add some basic controllers specs for MainController actions
diff --git a/spec/integration/building_module_spec.rb b/spec/integration/building_module_spec.rb index abc1234..def5678 100644 --- a/spec/integration/building_module_spec.rb +++ b/spec/integration/building_module_spec.rb @@ -33,13 +33,15 @@ specify 'including a custom module with coercion disabled' do user = Examples::NoncoercedUser.new(:name => 'Giorgio', :happy => 'yes') - user.name.should eql('Giorgio') - user.happy.should eql('yes') + + expect(user.name).to eql('Giorgio') + expect(user.happy).to eql('yes') end specify 'including a custom module with coercion enabled' do user = Examples::CoercedUser.new(:name => 'Paul', :happy => 'nope') - user.name.should eql('Paul') - user.happy.should eql(false) + + expect(user.name).to eql('Paul') + expect(user.happy).to be(false) end end
Update building module spec style
diff --git a/app/serializers/project_serializer.rb b/app/serializers/project_serializer.rb index abc1234..def5678 100644 --- a/app/serializers/project_serializer.rb +++ b/app/serializers/project_serializer.rb @@ -15,22 +15,8 @@ def build_commands <<-TEXT bundle install - mkdir -p config - echo '#{database_yml}' > config/database.yml - RAILS_ENV=test rake db:create RAILS_ENV=test rake db:reset TEXT end - - private - - def database_yml - "test: \n"\ - " adapter: postgresql\n"\ - " database: testributor_test\n"\ - " username: postgres\n"\ - " password: \n"\ - " host: db" - end end
Remove not needed database.yml from serializer We can now user the new model to create this file
diff --git a/test.rb b/test.rb index abc1234..def5678 100644 --- a/test.rb +++ b/test.rb @@ -13,7 +13,7 @@ puts "status: #{status}" -status = conn.send(0x0000112233440001, token, "dhello, from ruby land") +status = conn.send(0x0000112233440001, token, "hello, from ruby land") puts "status: #{status}"
Remove now-unneeded 'd' prefix from sent message
diff --git a/QRSwift.podspec b/QRSwift.podspec index abc1234..def5678 100644 --- a/QRSwift.podspec +++ b/QRSwift.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "QRSwift" - s.version = "0.4.0" + s.version = "0.4.1" s.summary = "Swift framework for generating QR codes" s.description = <<-DESC
Update podspec version to 0.4.1
diff --git a/ext/info_plist.rb b/ext/info_plist.rb index abc1234..def5678 100644 --- a/ext/info_plist.rb +++ b/ext/info_plist.rb @@ -0,0 +1,18 @@+# encoding: UTF-8 +require 'CFPropertyList' + +class InfoPList + attr_accessor :data + attr_reader :file + + def initialize(bundle_path) + @file = File.join(bundle_path, 'Contents', 'Info.plist') + @plist = CFPropertyList::List.new(file: @file) + @data = CFPropertyList.native_types(@plist.value) + end + + def write! + @plist.value = CFPropertyList.guess(@data, convert_unknown_to_string: true) + @plist.save(@file, CFPropertyList::List::FORMAT_BINARY) + end +end
Build system: factor out Info.plist manipulation Allows for more flexible, if slightly more verbose, Info.plist mainpulation.
diff --git a/test/shipping_materials/group_test.rb b/test/shipping_materials/group_test.rb index abc1234..def5678 100644 --- a/test/shipping_materials/group_test.rb +++ b/test/shipping_materials/group_test.rb @@ -26,4 +26,19 @@ assert_equal "3,Derek,Hello\n", @group.labels.first.to_csv, "The Group#label method is borked" end + + def test_sort_mixin + @group.filter { country == 'CA' } + + @group.sort { + rule { line_items.detect {|li| li.type == 'Vinyl' }} + rule { name == 'Miller' } + } + + @group.sort! + + assert_equal %w( Andrew J.M. Miller Riley ), + @group.objects.map {|o| o.name }, + "Sortable Mixin not working" + end end
Add Group sort DSL test
diff --git a/init.rb b/init.rb index abc1234..def5678 100644 --- a/init.rb +++ b/init.rb @@ -4,5 +4,5 @@ description 'Adds the pwauth authentication to Redmine. Requires `pwauth` to be installed.' version '1.0' url 'http://github.com/s3rvac/redmine_pwauth' - author_url 'http://www.linkedin.com/in/petrzemek' + author_url 'http://petrzemek.net/' end
Replace the original author_url to my new website.
diff --git a/test/worksheet/test_cond_format_21.rb b/test/worksheet/test_cond_format_21.rb index abc1234..def5678 100644 --- a/test/worksheet/test_cond_format_21.rb +++ b/test/worksheet/test_cond_format_21.rb @@ -0,0 +1,90 @@+# -*- coding: utf-8 -*- +require 'helper' +require 'write_xlsx' +require 'stringio' + +class TestCondFormat21 < Test::Unit::TestCase + def setup + @workbook = WriteXLSX.new(StringIO.new) + @worksheet = @workbook.add_worksheet('') + end + + ############################################################################### + # + # Tests for Excel::Writer::XLSX::Worksheet methods. + # + + ############################################################################### + # + # Test the _assemble_xml_file() method. + # + # Test conditional formats. + # + def test_conditional_formats + @worksheet.select + + # Start test code. + @worksheet.write('A1', 10) + @worksheet.write('A2', 20) + @worksheet.write('A3', 30) + @worksheet.write('A4', 40) + + @worksheet.conditional_formatting('A1', + { + :type => 'cell', + :format => nil, + :criteria => 'greater than', + :value => 5, + :stop_if_true => 1 + } + ) + # End test code. + + @worksheet.assemble_xml_file + result = got_to_array(@worksheet.instance_variable_get(:@writer).string) + + expected = expected_to_array(expected_xml) + assert_equal(expected, result) + end + + def expected_xml + <<EOS +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"> + <dimension ref="A1:A4"/> + <sheetViews> + <sheetView tabSelected="1" workbookViewId="0"/> + </sheetViews> + <sheetFormatPr defaultRowHeight="15"/> + <sheetData> + <row r="1" spans="1:1"> + <c r="A1"> + <v>10</v> + </c> + </row> + <row r="2" spans="1:1"> + <c r="A2"> + <v>20</v> + </c> + </row> + <row r="3" spans="1:1"> + <c r="A3"> + <v>30</v> + </c> + </row> + <row r="4" spans="1:1"> + <c r="A4"> + <v>40</v> + </c> + </row> + </sheetData> + <conditionalFormatting sqref="A1"> + <cfRule type="cellIs" priority="1" stopIfTrue="1" operator="greaterThan"> + <formula>5</formula> + </cfRule> + </conditionalFormatting> + <pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"/> +</worksheet> +EOS + end +end
Add unit test for "stop if true" conditional formatting feature.
diff --git a/mixlib-versioning.gemspec b/mixlib-versioning.gemspec index abc1234..def5678 100644 --- a/mixlib-versioning.gemspec +++ b/mixlib-versioning.gemspec @@ -15,4 +15,7 @@ spec.files = %w{LICENSE} + Dir.glob("lib/**/*") spec.require_paths = ["lib"] + + # we support EOL ruby because we use this in chef_client_updater cookbook with very old Chef / Ruby releases + spec.required_ruby_version = ">= 2.0" end
Support Ruby 2+ in the gemspec This serves mostly as a reminder that this is a dep on chef_client_updater and needs to support ancient Ruby releases until the time we decide to kill that upgrade path off. Signed-off-by: Tim Smith <764ef62106582a09ed09dfa0b6bff7c05fd7d1e4@chef.io>
diff --git a/lib/poke.rb b/lib/poke.rb index abc1234..def5678 100644 --- a/lib/poke.rb +++ b/lib/poke.rb @@ -1,11 +1,11 @@-require_relative "poke/modules" +require_relative 'poke/modules' require_relative 'poke/read_map' -require_relative "poke/window" -require_relative "poke/controls" -require_relative "poke/map" -require_relative "poke/grid" -require_relative "poke/user" -require_relative "poke/program" -require_relative "poke/program_map" -require_relative "poke/pausescreen" -require_relative "poke/coordinates" +require_relative 'poke/window' +require_relative 'poke/controls' +require_relative 'poke/map' +require_relative 'poke/grid' +require_relative 'poke/user' +require_relative 'poke/program' +require_relative 'poke/program_map' +require_relative 'poke/pausescreen' +require_relative 'poke/coordinates'
Change reqs to using single-quotes
diff --git a/html-pipeline-onebox.gemspec b/html-pipeline-onebox.gemspec index abc1234..def5678 100644 --- a/html-pipeline-onebox.gemspec +++ b/html-pipeline-onebox.gemspec @@ -21,7 +21,7 @@ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - spec.add_dependency "onebox", "~> 1.8.4" + spec.add_dependency "onebox", "~> 1.8" spec.add_dependency "html-pipeline", "~> 2.0" spec.add_development_dependency "bundler", "~> 1.14"
Change onebox gem version to less specific
diff --git a/ext/mkrf_conf.rb b/ext/mkrf_conf.rb index abc1234..def5678 100644 --- a/ext/mkrf_conf.rb +++ b/ext/mkrf_conf.rb @@ -13,8 +13,8 @@ # I don't *think* you can use Calatrava.platform == :mac here as it seems # RubyGems builds Ruby extensions without the dependencies declared in the gemspec. if RUBY_PLATFORM =~ /darwin/ - installer.install "xcodeproj", ">= 0.4.0" - installer.install "cocoapods", ">= 0.16.0" + installer.install "xcodeproj", ">= 0.11.0" + installer.install "cocoapods", ">= 0.25.0" end rescue Exception => ex
Update cocoapods and xcodeproj gem versions
diff --git a/filmbuff.gemspec b/filmbuff.gemspec index abc1234..def5678 100644 --- a/filmbuff.gemspec +++ b/filmbuff.gemspec @@ -18,6 +18,8 @@ s.add_dependency('faraday_middleware', '~> 0.8') s.add_development_dependency('minitest', '>= 1.4.0') + s.add_development_dependency('yard') + s.add_development_dependency('kramdown') s.files = `git ls-files`.split("\n") s.test_files = `git ls-files -- {test}/*`.split("\n")
Add dev dependencies for documentation tools (YARD)
diff --git a/lib/adiwg/mdtranslator/readers/fgdc/fgdc_reader.rb b/lib/adiwg/mdtranslator/readers/fgdc/fgdc_reader.rb index abc1234..def5678 100644 --- a/lib/adiwg/mdtranslator/readers/fgdc/fgdc_reader.rb +++ b/lib/adiwg/mdtranslator/readers/fgdc/fgdc_reader.rb @@ -20,7 +20,7 @@ # receive XML file if file.nil? || file == '' - hResponseObj[:readerStructureMessages] << 'XML file is missing' + hResponseObj[:readerStructureMessages] << 'ERROR: XML file is missing' hResponseObj[:readerStructurePass] = false return {} end @@ -29,8 +29,8 @@ begin xDoc = Nokogiri::XML(file) { |form| form.strict } rescue Nokogiri::XML::SyntaxError => err - hResponseObj[:readerStructureMessages] << 'XML file is not well formed' - hResponseObj[:readerStructureMessages] << err + hResponseObj[:readerStructureMessages] << 'ERROR: XML file is not well formed' + hResponseObj[:readerStructureMessages] << err.to_s hResponseObj[:readerStructurePass] = false return {} end @@ -38,7 +38,7 @@ # file must contain an fgdc <metadata> tag xMetadata = xDoc.xpath('/metadata') if xMetadata.empty? - hResponseObj[:readerValidationMessages] << 'FGDC file did not contain a <metadata> tag' + hResponseObj[:readerValidationMessages] << 'ERROR: FGDC file did not contain a <metadata> tag' hResponseObj[:readerValidationPass] = false return {} end
Format fgdc reader error messages
diff --git a/lib/scanny/checks/shell_expanding_methods_check.rb b/lib/scanny/checks/shell_expanding_methods_check.rb index abc1234..def5678 100644 --- a/lib/scanny/checks/shell_expanding_methods_check.rb +++ b/lib/scanny/checks/shell_expanding_methods_check.rb @@ -7,22 +7,20 @@ def pattern [ pattern_shell_expanding, - pattern_shell_execute, pattern_popen, pattern_execute_string ].join("|") end def check(node) - if Machete.matches?(node, pattern_shell_expanding) - # The command goes through shell expansion only if it is passed as one - # argument. - message = "The \"#{node.name}\" method passes the executed command through shell expansion." - else - message = "Execute system commands can lead the system to run dangerous code" - end + # The command goes through shell expansion only if it is passed as one + # argument. + issue :high, warning_message(node), :cwe => [88, 78] + end - issue :high, message, :cwe => [88, 78] + def warning_message(node = nil) + name = node.respond_to?(:name) ? node.name : "`" + "The \"#{name}\" method passes the executed command through shell expansion." end # system("rm -rf /") @@ -30,21 +28,21 @@ <<-EOT SendWithArguments< receiver = Self | ConstantAccess<name = :Kernel>, - name = :` | :exec | :system, + name = :` | :exec | :system | :spawn, arguments = ActualArguments<array = [any]> > EOT end - # Kernel.spawn("ls -lA") - def pattern_shell_execute - "SendWithArguments<name = :system | :spawn | :exec>" - end - # IO.popen # IO.popen3 def pattern_popen - "SendWithArguments<name ^= :popen>" + <<-EOT + SendWithArguments< + name ^= :popen, + arguments = ActualArguments<array = [any]> + > + EOT end # `system_command`
Check only method calls with one argument
diff --git a/lib/seek/research_objects/acts_as_snapshottable.rb b/lib/seek/research_objects/acts_as_snapshottable.rb index abc1234..def5678 100644 --- a/lib/seek/research_objects/acts_as_snapshottable.rb +++ b/lib/seek/research_objects/acts_as_snapshottable.rb @@ -1,6 +1,6 @@ module Seek #:nodoc: module ResearchObjects - module Snapshottable #:nodoc: + module ActsAsSnapshottable #:nodoc: def self.included(mod) mod.extend(ClassMethods) @@ -13,15 +13,15 @@ has_many :snapshots, as: :resource, foreign_key: :resource_id class_eval do - extend Seek::ResearchObjects::Snapshottable::SingletonMethods + extend Seek::ResearchObjects::ActsAsSnapshottable::SingletonMethods end - include Seek::ResearchObjects::Snapshottable::InstanceMethods + include Seek::ResearchObjects::ActsAsSnapshottable::InstanceMethods end def is_snapshottable? - include?(Seek::ResearchObjects::Snapshottable::InstanceMethods) + include?(Seek::ResearchObjects::ActsAsSnapshottable::InstanceMethods) end end @@ -55,5 +55,5 @@ end ActiveRecord::Base.class_eval do - include Seek::ResearchObjects::Snapshottable + include Seek::ResearchObjects::ActsAsSnapshottable end
Make module name match filename