diff
stringlengths
65
26.7k
message
stringlengths
7
9.92k
diff --git a/nagios_parser.gemspec b/nagios_parser.gemspec index abc1234..def5678 100644 --- a/nagios_parser.gemspec +++ b/nagios_parser.gemspec @@ -22,6 +22,7 @@ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } s.require_paths = ["lib"] + s.add_development_dependency "rake" s.add_development_dependency "racc" s.add_development_dependency "rspec" end
Add rake to development dependencies.
diff --git a/lib/telebot/bot.rb b/lib/telebot/bot.rb index abc1234..def5678 100644 --- a/lib/telebot/bot.rb +++ b/lib/telebot/bot.rb @@ -13,7 +13,10 @@ def run(&block) loop do - updates = @client.get_updates(offset: @processed_update_ids.last) + # Note: https://core.telegram.org/bots/api#getupdates + # To mark an update as confirmed need to use offset+1 + offset = @processed_update_ids.last && @processed_update_ids.last + 1 + updates = @client.get_updates(offset: offset) updates.each do |update| next if @processed_update_ids.include?(update.update_id)
Mark updates as confirmed using offset + 1 as described in Bot API
diff --git a/lib/tent-client.rb b/lib/tent-client.rb index abc1234..def5678 100644 --- a/lib/tent-client.rb +++ b/lib/tent-client.rb @@ -1,5 +1,6 @@ require 'tent-client/version' require 'faraday' +require 'tent-client/middleware/content_type_header' require 'tent-client/middleware/encode_json' require 'tent-client/cycle_http' require 'tent-client/discovery'
Fix last commit: require content type header middleware
diff --git a/test/helper.rb b/test/helper.rb index abc1234..def5678 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -21,4 +21,4 @@ include Rack::Test::Methods end -Protest.report_with(:turn) +ENV["PROTEST_REPORT"] ||= "turn"
Allow change protest report type by enviroment.
diff --git a/logstash-client.gemspec b/logstash-client.gemspec index abc1234..def5678 100644 --- a/logstash-client.gemspec +++ b/logstash-client.gemspec @@ -17,7 +17,7 @@ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] - spec.add_runtime_dependency "faraday", "~> 0.9.1" + spec.add_runtime_dependency "faraday", "~> 0.9.0" spec.add_development_dependency 'rspec', "~>3.0" spec.add_development_dependency 'vcr', '~> 2.9', '>= 2.9.3'
Fix Faraday version to 0.9.0 or later
diff --git a/lib/game.rb b/lib/game.rb index abc1234..def5678 100644 --- a/lib/game.rb +++ b/lib/game.rb @@ -1,5 +1,4 @@ require_relative 'tic_tac_toe' -# decisions vs dependency class Game
Remove comments from Game class
diff --git a/lib/game.rb b/lib/game.rb index abc1234..def5678 100644 --- a/lib/game.rb +++ b/lib/game.rb @@ -9,19 +9,6 @@ @gametype = args.fetch(:gametype, nil) end - def user_move - index_position = get_user_input - if gametype.valid_move?(index_position) - @gametype = gametype.move(index_position) - else - puts "Invalid input try again" - end - end - - def get_user_input - gets.chomp.to_i - end - def comp_move if !gametype.valid_slots.empty? @gametype = gametype.move(gametype.optimal_move) @@ -29,10 +16,15 @@ end def alternate_move - user_move - comp_move - ui.show_board(gametype.board) - ui.display_winner_message(gametype) + index_position = ui.get_user_input + if @gametype.valid_slots.include?(index_position) + @gametype = gametype.move(index_position) + comp_move + ui.show_board(gametype.board) + ui.display_winner_message(gametype) + else + ui.display_invalid_input + end end def play @@ -44,4 +36,4 @@ end end -end +end
Fix bug where invalid inputs were accepted by the Game, the issue was that after taking in user input the program will continue to let the computer move instead of asking the user for input again
diff --git a/lib/game.rb b/lib/game.rb index abc1234..def5678 100644 --- a/lib/game.rb +++ b/lib/game.rb @@ -7,29 +7,6 @@ def initialize(gametype = nil, ui = nil) @ui = ui @gametype = gametype - end - - # def display_intro_msg - # puts "Welcome to #{gametype.desc[:name]} \n#{gametype.desc[:instructions]}" - # ui.show_board(gametype.board) - # end - - def prompt_user_for_input - "Enter a number #{@gametype.valid_slots.join(", ")} to place an X" - end - - # def get_user_input - # user_input = gets.chomp.to_i - # end - - def winner - if gametype.won?("X") - "You won!" - elsif gametype.won?("O") - "Computer won!" - elsif gametype.draw? - "It's a draw!" - end end def user_move(index_position) @@ -50,15 +27,15 @@ user_move(user_input) comp_move ui.show_board(gametype.board) - winner + ui.display_winner_message(gametype) end def play ui.display_intro_msg(gametype) ui.show_board(gametype.board) while !gametype.game_over? - puts prompt_user_for_input - puts alternate_move(ui.get_user_input) + ui.prompt_user_for_input(gametype) + alternate_move(ui.get_user_input) end end
Remove method that relates to stdin and stdout
diff --git a/lib/gday.rb b/lib/gday.rb index abc1234..def5678 100644 --- a/lib/gday.rb +++ b/lib/gday.rb @@ -3,11 +3,11 @@ module Gday class Greeting def hi - puts "G'day!" + "G'day!" end def bye - puts "Cheerio" + "Cheerio" end end end
Remove puts from methods in Gday class to return string instead of nil.
diff --git a/minitest-around.gemspec b/minitest-around.gemspec index abc1234..def5678 100644 --- a/minitest-around.gemspec +++ b/minitest-around.gemspec @@ -14,5 +14,4 @@ s.add_development_dependency 'rdoc' s.add_development_dependency 'rake' s.add_development_dependency 'cucumber' - s.add_development_dependency 'minitest', '~> 5.6' end
Drop duplicate dependency on minitest
diff --git a/lib/shiv.rb b/lib/shiv.rb index abc1234..def5678 100644 --- a/lib/shiv.rb +++ b/lib/shiv.rb @@ -14,7 +14,7 @@ end def self.nodes - Chef::Node.list.keys + Chef::Node.list.keys.sort.reverse end def self.hostname_from(node)
Sort node names in reverse alphabetical order so nodes that are substrings of each other dont get replaced first
diff --git a/memcached_store.gemspec b/memcached_store.gemspec index abc1234..def5678 100644 --- a/memcached_store.gemspec +++ b/memcached_store.gemspec @@ -17,10 +17,10 @@ gem.version = MemcachedStore::VERSION gem.add_runtime_dependency "activesupport", ">= 3.2" gem.add_runtime_dependency "snappy", "0.0.4" + gem.add_runtime_dependency "memcached" + gem.add_development_dependency "rake" gem.add_development_dependency "minitest" gem.add_development_dependency "mocha" gem.add_development_dependency "timecop" - gem.add_development_dependency "memcached" - gem.add_development_dependency "memcache-client" end
Remove memcache-client as we dont need it anymore
diff --git a/trasto.gemspec b/trasto.gemspec index abc1234..def5678 100644 --- a/trasto.gemspec +++ b/trasto.gemspec @@ -12,6 +12,7 @@ gem.description = 'Translatable columns for Rails 4, directly stored in a Postgres hstore in the model table.' gem.summary = 'Use PostgreSQL hstore to keep column translations in the model table without adding lots of tables/columns.' gem.homepage = 'https://github.com/yabawock/trasto' + gem.licenses = ['MIT'] gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR) gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
[TASK] Add license information to gemspec
diff --git a/middleman-title.gemspec b/middleman-title.gemspec index abc1234..def5678 100644 --- a/middleman-title.gemspec +++ b/middleman-title.gemspec @@ -13,9 +13,9 @@ s.email = 'jcypret@gmail.com' s.homepage = 'https://github.com/jcypret/middleman-title' - spec.files = `git ls-files`.split($/) - # spec.test_files = `git ls-files -- {features,fixtures}/*`.split($/) - spec.require_paths = ['lib'] + s.files = `git ls-files`.split($/) + # s.test_files = `git ls-files -- {features,fixtures}/*`.split($/) + s.require_paths = ['lib'] - spec.add_dependency 'middleman-core', '~> 3.2' + s.add_dependency 'middleman-core', '~> 3.2' end
Fix gemset passed in block variable name
diff --git a/freckles.gemspec b/freckles.gemspec index abc1234..def5678 100644 --- a/freckles.gemspec +++ b/freckles.gemspec @@ -10,7 +10,7 @@ s.summary = 'Ruby client for Version 2 of the Freckle API' s.files = Dir.glob('{lib,test}/**/*') + %w(LICENSE.txt README.md freckles.gemspec) s.required_ruby_version = '>= 1.9.3' - s.add_development_dependency('rake', '>= 12') + s.add_development_dependency('rake', '~> 12') s.add_development_dependency('webmock', '~> 3.0') s.add_development_dependency('minitest', '~> 5.0') s.require_path = 'lib'
Fix open-ended dependency on rake warning from gemspec
diff --git a/Library/Formula/asterisk.rb b/Library/Formula/asterisk.rb index abc1234..def5678 100644 --- a/Library/Formula/asterisk.rb +++ b/Library/Formula/asterisk.rb @@ -1,40 +1,20 @@ require 'formula' class Asterisk < Formula - url 'http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-1.6.1.6.tar.gz' + url 'http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-1.8.3.2.tar.gz' homepage 'http://www.asterisk.org/' - md5 '63a928373e741524aac09d8c078df7d5' + md5 '0bee03f4498a6081146a579b51130633' skip_clean :all # Or modules won't load - # Use cURL instead of wget - def patches; DATA; end + def options + [['--with-sample-config', "Install the sample config files. NOTE. Without this, you won't have any config file."]] + end def install - configure_flags = [ "--prefix=#{prefix}", "--localstatedir=#{var}", "--sysconfdir=#{etc}" ] - # Avoid "src/add.c:1: error: CPU you selected does not support x86-64 instruction set" - configure_flags << "--host=x86_64-darwin" if MacOS.prefer_64_bit? - system "./configure", *configure_flags + system "./configure", "--prefix=#{prefix}", "--localstatedir=#{var}", "--sysconfdir=#{etc}" system "make" system "make install" - (etc+"asterisk").mkpath + system "make samples" if ARGV.include? '--with-sample-config' end end - - -__END__ ---- a/sounds/Makefile 2009-10-13 02:12:08.000000000 +0300 -+++ b/sounds/Makefile 2009-10-13 02:15:11.000000000 +0300 -@@ -53,10 +53,8 @@ - MM:=$(subst -SLN16,-sln16,$(MM)) - MOH:=$(MM:MOH-%=asterisk-moh-%.tar.gz) - MOH_TAGS:=$(MM:MOH-%=$(MOH_DIR)/.asterisk-moh-%) --# If "fetch" is used, --continue is not a valid option. --ifeq ($(WGET),wget) --WGET_ARGS:=--continue --endif -+DOWNLOAD:=curl -+WGET_ARGS:=-O - - all: $(CORE_SOUNDS) $(EXTRA_SOUNDS) $(MOH) -
Update Asterisk from 1.6.1.6 to 1.8.3.2. * Added the '--with-sample-config' option. This will generate the sample Asterisk config files in /usr/local/etc/asterisk. It creates backups of any existing files first. * Removed the patch that used curl instead of wget to download the sound files. This doesn't appear to be required any longer (at least, the sound files download correctly without it, where they didn't previously). * Removed the '--host=x86_64-darwin' configure switch. Supplying this switch to configure results in the warning, 'configure: WARNING: If you wanted to set the --build type, don't use --host. If a cross compiler is detected then cross compile mode will be used.', and building without the switch appears to result in the correct architecture being targeted. * Removed the manual creation of /usr/local/etc/asterisk. This directory is created automatically. Signed-off-by: Adam Vandenberg <34c2b6407fd5a10249a15d699d40f9ed1782e98c@gmail.com>
diff --git a/gherkin3.gemspec b/gherkin3.gemspec index abc1234..def5678 100644 --- a/gherkin3.gemspec +++ b/gherkin3.gemspec @@ -16,7 +16,7 @@ s.add_development_dependency 'rspec', '~> 3.3' # For coverage reports - s.add_development_dependency 'coveralls', '~> 0.8' + s.add_development_dependency 'coveralls', '~> 0.8', '< 0.8.8' s.rubygems_version = ">= 1.6.1" s.files = `git ls-files`.split("\n").reject {|path| path =~ /\.gitignore$/ }
Set an upper limit on the coveralls version in the gemspec coveralls 0.8.8 have the dependency tins ~> 1.6.0, and tins 1.7.0 required Ruby version >= 2.0. Fixes #127.
diff --git a/spec/controllers/rules_controller_spec.rb b/spec/controllers/rules_controller_spec.rb index abc1234..def5678 100644 --- a/spec/controllers/rules_controller_spec.rb +++ b/spec/controllers/rules_controller_spec.rb @@ -0,0 +1,35 @@+require 'rails_helper' + +module Toritsugi + describe RulesController do + routes { Engine.routes } + + describe "#after_redirection_callback" do + let!(:rule) { create(:rule, destination: "/advice") } + let!(:callback) { -> (request, params, rule) { throw :called } } + + context "after redirection callback is not set in config" do + it "doesn't calls the after redirection callback" do + expect { + get :show, id: 'advice' + }.not_to throw_symbol :called + end + end + + context "after redirection callback is set" do + before do + allow(Toritsugi.config).to( + receive(:after_redirection_callback) + .and_return(callback) + ) + end + + it "calls the after redirection callback" do + expect { + get :show, id: 'advice' + }.to throw_symbol :called + end + end + end + end +end
Add specs to ensure the given after redirection call is called
diff --git a/spec/uniara_virtual_parser/client_spec.rb b/spec/uniara_virtual_parser/client_spec.rb index abc1234..def5678 100644 --- a/spec/uniara_virtual_parser/client_spec.rb +++ b/spec/uniara_virtual_parser/client_spec.rb @@ -2,7 +2,7 @@ module UniaraVirtualParser describe Client do - before :each do + after :each do described_class.instance_variable_set :@client, nil end
Fix the reset Client status in client
diff --git a/spec/unit/nutrella/developer_keys_spec.rb b/spec/unit/nutrella/developer_keys_spec.rb index abc1234..def5678 100644 --- a/spec/unit/nutrella/developer_keys_spec.rb +++ b/spec/unit/nutrella/developer_keys_spec.rb @@ -0,0 +1,29 @@+module Nutrella + extend DeveloperKeys + + RSpec.describe DeveloperKeys do + let(:nutrella) { Nutrella.new { extend DeveloperKeys } } + + describe "#open_public_key_url" do + it "show Nutrella as the application requesting access in the Trello oauth page" do + expect(Trello).to receive(:open_public_key_url) + + Nutrella.open_public_key_url + end + end + + describe "#open_authorization_url" do + it "show Nutrella as the application requesting access in the Trello oauth page" do + expect(Trello).to receive(:open_authorization_url).with(name: "Nutrella") + + Nutrella.open_authorization_url + end + + it "merge application name into existing options" do + expect(Trello).to receive(:open_authorization_url).with(expiration: "1day", name: "Nutrella") + + Nutrella.open_authorization_url(expiration: "1day") + end + end + end +end
Add a specification for the DeveloperKeys module. Note: reduces the mutations that survive.
diff --git a/spec/lib/wiki_edits_spec.rb b/spec/lib/wiki_edits_spec.rb index abc1234..def5678 100644 --- a/spec/lib/wiki_edits_spec.rb +++ b/spec/lib/wiki_edits_spec.rb @@ -2,27 +2,35 @@ require "#{Rails.root}/lib/wiki_edits" describe WikiEdits do + # We're not testing any of the network stuff, nor whether the requests are + # well-formatted, but at least this verifies that the flow is parsing tokens + # in the expected way. describe '.notify_untrained' do - pending 'should post messages to Wikipedia talk pages' - end - - describe '.tokens' do - it 'should get edit tokens using OAuth credentials' do - user = create(:user, - wiki_token: 'foo', - wiki_secret: 'bar') - + it 'should post talk page messages on Wikipedia' do + create(:course, + id: 1) + create(:user, + id: 1, + wiki_token: 'foo', + wiki_secret: 'bar') + create(:user, + id: 2, + wiki_token: 'foo', + wiki_secret: 'bar') + create(:courses_user, + course_id: 1, + user_id: 1) + create(:courses_user, + course_id: 1, + user_id: 2) # rubocop:disable Metrics/LineLength fake_tokens = "{\"query\":{\"tokens\":{\"csrftoken\":\"myfaketoken+\\\\\"}}}" # rubocop:enable Metrics/LineLength - stub_request(:get, /.*/) + stub_request(:get, /.*wikipedia.*/) .to_return(status: 200, body: fake_tokens, headers: {}) - response = WikiEdits.tokens(user) - expect(response).to be + stub_request(:post, /.*wikipedia.*/) + .to_return(status: 200, body: 'success', headers: {}) + WikiEdits.notify_untrained(1, User.first) end end - - describe '.api_get' do - pending 'should send data and tokens to Wikipedia' - end end
Extend WikiEdits test to superficially cover the entire class.
diff --git a/Parse-RACExtensions.podspec b/Parse-RACExtensions.podspec index abc1234..def5678 100644 --- a/Parse-RACExtensions.podspec +++ b/Parse-RACExtensions.podspec @@ -6,10 +6,10 @@ s.license = { :type => 'MIT', :file => 'LICENSE.txt' } s.author = { "Dave Lee" => "dave@kastiglione.com" } s.source = { :git => "https://github.com/kastiglione/Parse-RACExtensions.git", :tag => "v#{s.version}" } - s.platform = :ios, '5.0' + s.platform = :ios, '6.0' s.source_files = 'Parse-RACExtensions' s.requires_arc = true - s.dependency 'Parse', '~> 1.2.15' + s.dependency 'Parse', '~> 1.3.0' s.dependency 'ReactiveCocoa', '~> 2.1' s.xcconfig = { 'FRAMEWORK_SEARCH_PATHS' => '"${PODS_ROOT}/Parse"' } end
Update Parse version to 1.3.0.1.
diff --git a/serverspec/spec/all/all_configure_spec.rb b/serverspec/spec/all/all_configure_spec.rb index abc1234..def5678 100644 --- a/serverspec/spec/all/all_configure_spec.rb +++ b/serverspec/spec/all/all_configure_spec.rb @@ -10,8 +10,8 @@ describe 'connect jmx_server' do servers = property[:servers] - svr['roles'].each do |var| - case var + servers.each do |var, server| + case var[:roles] when "ap" then if File.exist?('/etc/sysconfig/tomcat7') describe "#{svr_name} access check" do
Modify logic of spec test files.
diff --git a/acts_as_paranoid.gemspec b/acts_as_paranoid.gemspec index abc1234..def5678 100644 --- a/acts_as_paranoid.gemspec +++ b/acts_as_paranoid.gemspec @@ -25,5 +25,5 @@ spec.add_development_dependency "bundler", "~> 1.5" spec.add_development_dependency "rake" spec.add_development_dependency "rdoc" - spec.add_development_dependency "minitest", "~> 5.4" + spec.add_development_dependency "minitest", ">= 4.0", "<= 6.0" end
Allow broad range of minitest versions This is to avoid conflict with minitest versions required by the different versions of Rails.
diff --git a/spec/lint_trappings/document_spec.rb b/spec/lint_trappings/document_spec.rb index abc1234..def5678 100644 --- a/spec/lint_trappings/document_spec.rb +++ b/spec/lint_trappings/document_spec.rb @@ -2,17 +2,17 @@ RSpec.describe LintTrappings::Document do let(:config) { double } + let(:options) { {} } + let(:document_class) { described_class } + + let(:source) { normalize_indent(<<-SRC) } + This is some source code + It is beautiful source code + SRC + + subject { document_class.new(source, config, options) } describe '#initialize' do - let(:source) { normalize_indent(<<-SRC) } - This is some source code - It is beautiful source code - SRC - - let(:options) { {} } - - subject { described_class.new(source, config, options) } - before do allow_any_instance_of(described_class).to receive(:process_source) end @@ -44,4 +44,14 @@ end end end + + describe '#process_source' do + context 'when process_source has not been implemented' do + let(:document_class) { Class.new(LintTrappings::Document) } + + it 'raises' do + expect { subject }.to raise_error NotImplementedError, 'Must implement #process_source' + end + end + end end
Increase Document test coverage to 100%
diff --git a/spec/process_watcher/monitor_spec.rb b/spec/process_watcher/monitor_spec.rb index abc1234..def5678 100644 --- a/spec/process_watcher/monitor_spec.rb +++ b/spec/process_watcher/monitor_spec.rb @@ -0,0 +1,59 @@+#-- +# Copyright: Copyright (c) 2010 RightScale, Inc. +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# 'Software'), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#++ + +require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) + +describe ProcessWatcher::ProcessMonitor do + + before(:each) do + @monitor = ProcessWatcher::ProcessMonitor.new + end + + after(:each) do + @monitor.cleanup + end + + it 'should launch and watch well-behaved processes' do + ruby = "puts 42; exit 42" + times = 0 + pid = @monitor.spawn('ruby', '-e', ruby) do |hash| + case times + when 0 then hash.should == {:output => "42\n"} + when 1 then hash[:exit_code].should == 42 + hash[:exit_status].should_not be_nil + else fail "Shouldn't see more than two ticks" + end + times += 1 + end + @monitor.cleanup + lambda { Process.kill(0, pid) }.should raise_exception(Errno::ESRCH) + end + + it 'should launch processes where we don\'t care about output' do + ruby = "puts 42; exit 42" + times = 0 + pid = @monitor.spawn('ruby', '-e', ruby) + @monitor.cleanup + lambda { Process.kill(0, pid) }.should raise_exception(Errno::ESRCH) + end +end
Add test cases for ProcessWatcher::ProcessMonitor.
diff --git a/app/controllers/adhoq/current_tables_controller.rb b/app/controllers/adhoq/current_tables_controller.rb index abc1234..def5678 100644 --- a/app/controllers/adhoq/current_tables_controller.rb +++ b/app/controllers/adhoq/current_tables_controller.rb @@ -8,7 +8,7 @@ hidden_model_names << 'ApplicationRecord' @ar_classes = ActiveRecord::Base.descendants. - reject {|klass| klass.abstract_class? || hidden_model_names.include?(klass.name) }. + reject {|klass| klass.abstract_class? || hidden_model_names.include?(klass.name) || klass.name.nil? }. sort_by(&:name) render layout: false
Fix show table feature error(a case where there is an anonymous class inherited ActiveRecord::Base) If there is an anonymous class inherited ActiveRecord::Base(e.g. SwitchPoint), the show table feature fails. Because the name is nil in anonymous classes, it fails sorting by table name. So I excluded anonymous classes.
diff --git a/db/migrate/20170413195527_follow_all_creators_rpc.rb b/db/migrate/20170413195527_follow_all_creators_rpc.rb index abc1234..def5678 100644 --- a/db/migrate/20170413195527_follow_all_creators_rpc.rb +++ b/db/migrate/20170413195527_follow_all_creators_rpc.rb @@ -0,0 +1,40 @@+class FollowAllCreatorsRpc < ActiveRecord::Migration + def up + execute <<-SQL + create or replace function "1".follow_all_creators() RETURNS void + LANGUAGE SQL + AS $$ + INSERT INTO public.user_follows (user_id, follow_id) + ( + SELECT + distinct + current_user_id() as user_id, + p.user_id as follow_id + FROM ( + projects p + JOIN contributions c ON (c.project_id = p.id) + JOIN payments pa ON (pa.contribution_id = c.id) + ) + WHERE ( + c.user_id = current_user_id() + and pa.state = 'paid' + and p.state = 'successful' + ) + AND NOT EXISTS( + SELECT TRUE + FROM public.user_follows ufo + WHERE ufo.user_id = current_user_id() + AND ufo.follow_id = p.user_id + ) + ); + $$; + + grant execute on function "1".follow_all_creators() to admin, web_user; + SQL + end + def down + execute %Q{ + DROP FUNCTION "1".follow_all_creators(); + } + end +end
Add follow all creators rpc
diff --git a/app/validators/francis_cms/webmention_validator.rb b/app/validators/francis_cms/webmention_validator.rb index abc1234..def5678 100644 --- a/app/validators/francis_cms/webmention_validator.rb +++ b/app/validators/francis_cms/webmention_validator.rb @@ -1,13 +1,9 @@ module FrancisCms class WebmentionValidator < ActiveModel::Validator def validate(record) - return record.errors[:base] << 'Webmention source and target must be different.' if source_is_target? - end - - private - - def source_is_target? - record.source.sub(%r{^https?://}, '') == record.target.sub(%r{^https?://}, '') + if record.source.sub(/^https?:\/\//, '') == record.target.sub(/^https?:\/\//, '') + record.errors[:base] << 'Webmention source and target must be different.' + end end end end
Revert conditional logic bug introduced in 0d5ee8c
diff --git a/app/controllers/api/application_controller.rb b/app/controllers/api/application_controller.rb index abc1234..def5678 100644 --- a/app/controllers/api/application_controller.rb +++ b/app/controllers/api/application_controller.rb @@ -1,5 +1,7 @@ class Api::ApplicationController < ActionController::Base protect_from_forgery with: :null_session + + private def serialization_scope view_context
Add missing `private` specification to internal method
diff --git a/app/helpers/textual_mixins/textual_os_info.rb b/app/helpers/textual_mixins/textual_os_info.rb index abc1234..def5678 100644 --- a/app/helpers/textual_mixins/textual_os_info.rb +++ b/app/helpers/textual_mixins/textual_os_info.rb @@ -9,7 +9,7 @@ h[:value] = os h[:title] = _("Show OS container information") h[:explorer] = true - h[:link] = url_for(:action => 'show', :id => @record, :display => 'os_info') + h[:link] = url_for(:action => 'show', :id => @record, :display => 'os_info') end h end
Address rubocop comments for TextualMixins::TextualOsInfo
diff --git a/app/services/projects/participants_service.rb b/app/services/projects/participants_service.rb index abc1234..def5678 100644 --- a/app/services/projects/participants_service.rb +++ b/app/services/projects/participants_service.rb @@ -4,7 +4,7 @@ @target = get_target(note_type, note_id) participating = if note_type && note_id - participants_in(note_type, note_id) + participants_in_target else [] end @@ -31,7 +31,7 @@ }] end - def participants_in(type, id) + def participants_in_target return [] unless @target users = @target.participants(current_user)
Update method name and remove unneeded params
diff --git a/log.gemspec b/log.gemspec index abc1234..def5678 100644 --- a/log.gemspec +++ b/log.gemspec @@ -1,7 +1,7 @@ # -*- encoding: utf-8 -*- Gem::Specification.new do |s| s.name = 'log' - s.version = '0.4.0.0' + s.version = '0.4.0.1' s.summary = 'Logging to STD IO with levels, tagging, and coloring' s.description = ' '
Package version is increased from 0.4.0.0 to 0.4.0.1
diff --git a/test/lib/fixtures_test.rb b/test/lib/fixtures_test.rb index abc1234..def5678 100644 --- a/test/lib/fixtures_test.rb +++ b/test/lib/fixtures_test.rb @@ -32,7 +32,7 @@ FileUtils.rm_rf(host_path) end - def test_import_all_with_no_site + def test_export_all_with_no_site comfy_cms_sites(:default).destroy assert_exception_raised ActiveRecord::RecordNotFound do @@ -40,4 +40,4 @@ end end -end+end
Rename test to unique and correct name
diff --git a/test/integration/default/activemq_spec.rb b/test/integration/default/activemq_spec.rb index abc1234..def5678 100644 --- a/test/integration/default/activemq_spec.rb +++ b/test/integration/default/activemq_spec.rb @@ -1,6 +1,3 @@-describe 'ActiveMQ server' do - it 'should be running the activemq server' do - expect(service('activemq')).to be_running - expect(service('activemq')).to be_enabled - end +describe command('ps ax | grep activem[q]') do + its('exit_status') { should eq 0 } end
Check process vs. service check Signed-off-by: Tim Smith <764ef62106582a09ed09dfa0b6bff7c05fd7d1e4@chef.io>
diff --git a/config/initializers/delayed_job_config.rb b/config/initializers/delayed_job_config.rb index abc1234..def5678 100644 --- a/config/initializers/delayed_job_config.rb +++ b/config/initializers/delayed_job_config.rb @@ -1,2 +1,22 @@ Delayed::Worker.max_attempts = 100 Delayed::Worker.max_run_time = 1.week + +require 'active_job/queue_adapters/delayed_job_adapter' + +# We patch in the display_name method to the Delayed Job queue adapter +# so that all the jobs aren't aggregated under one name in AppSignal. +module ActiveJob + module QueueAdapters + class DelayedJobAdapter + class JobWrapper + def display_name + if job_data['job_class'] == 'ActionMailer::DeliveryJob' + "#{job_data['arguments'][0]}##{job_data['arguments'][1]}" + else + "#{job_data['job_class']}#perform" + end + end + end + end + end +end
Patch queue adapter for better reporting in AppSignal Currently all the jobs are reported under the same name in AppSignal. This is a dirty way to fix it but there is no other option as adding a `appsignal_name` method to the job class doesn't work since that's not the object that gets passed to AppSignal's Delayed Job plugin.
diff --git a/app/models/dump_importer.rb b/app/models/dump_importer.rb index abc1234..def5678 100644 --- a/app/models/dump_importer.rb +++ b/app/models/dump_importer.rb @@ -35,7 +35,7 @@ location: row['Address'], coordinates: row['Geo'].split(",") source_url: row['Source of Picture'], - captured_at: Date.new(row['Date'].to_i), + captured_at: Date.new(*row['Date'].split("/").map(&:to_i).reverse), approximate_date: (row['Circa'].to_s.downcase.strip == 'y') } item.save!
ADD ALL OF THE THINGS
diff --git a/app/models/event_history.rb b/app/models/event_history.rb index abc1234..def5678 100644 --- a/app/models/event_history.rb +++ b/app/models/event_history.rb @@ -0,0 +1,11 @@+class EventHistory < ApplicationRecord + belongs_to :dojo + + validates :dojo_name, presence: true + validates :service_name, presence: true, uniqueness: { scope: :event_id } + validates :service_group_id, presence: true + validates :event_id, presence: true + validates :event_url, presence: true, uniqueness: true, allow_nil: true + validates :participants, presence: true + validates :evented_at, presence: true +end
Create a model named `EventHistory`
diff --git a/app/models/page_template.rb b/app/models/page_template.rb index abc1234..def5678 100644 --- a/app/models/page_template.rb +++ b/app/models/page_template.rb @@ -25,7 +25,7 @@ def render_terms_of_service_template(site) template = File.read('lib/assets/terms_template.json.erb') - hosting_organization = SiteSetting.hosting_organization(site.id).value || + hosting_organization = SiteSetting.hosting_organization(site.id).try(:value) || '[HOSTING ORGANIZATION]' result = TemplateRenderer.render( template,
Fix for running the sample task on an empty database
diff --git a/app/views/projects/index.rb b/app/views/projects/index.rb index abc1234..def5678 100644 --- a/app/views/projects/index.rb +++ b/app/views/projects/index.rb @@ -15,7 +15,7 @@ :description => project.description(:en_US), :project_dom_id => project_dom_id(project), :github_url => project.github_url, - :fork_count => fork_count(project) + :fork_count => fork_count(project), } end end
Add a comma to the last entry in the Hash * This is more a case of preference. Including the comma on the last entry makes it so you can more easily reorder the entries. It also allows you to add new entries without worrying about modifying any further code, aside from the lines being added.
diff --git a/app/views/api/v1/commodity_merchandising/contracts/index.json.jbuilder b/app/views/api/v1/commodity_merchandising/contracts/index.json.jbuilder index abc1234..def5678 100644 --- a/app/views/api/v1/commodity_merchandising/contracts/index.json.jbuilder +++ b/app/views/api/v1/commodity_merchandising/contracts/index.json.jbuilder @@ -2,6 +2,8 @@ json.contract_id contract.ContractId json.customer_id contract.CustomerId.to_i json.commodity_id contract.CommodityId.to_i + json.inv_contract_id contract.Inv_ContractId + json.location_id contract.LocationId.to_i json.contract_number contract.CONT_ContractNumber json.price contract.CONT_Price.to_f json.freight_adjustment contract.CONT_FreightAdjustment.to_f @@ -15,7 +17,7 @@ json.description contract.unit_of_measure.CommUOMDescription.strip end json.contract_date contract.CONT_ContractDate - json.contract_type contract.CONT_ContractType + json.contract_type contract.contract_type json.quantity contract.CONT_Quantity.to_f json.delivered_quantity contract.CONT_DeliveredBushels.to_f json.from_date contract.CONT_FromDate
Implement the missing fields in the contract reponse
diff --git a/db/migrate/20130328151958_add_status_string_indices.rb b/db/migrate/20130328151958_add_status_string_indices.rb index abc1234..def5678 100644 --- a/db/migrate/20130328151958_add_status_string_indices.rb +++ b/db/migrate/20130328151958_add_status_string_indices.rb @@ -0,0 +1,8 @@+class AddStatusStringIndices < ActiveRecord::Migration + def change + add_index :exports, :status + add_index :subjects, :status + add_index :users, :status + add_index :variables, :variable_type + end +end
Make sure active record filters that are often used are indexed
diff --git a/Bugsnag.podspec b/Bugsnag.podspec index abc1234..def5678 100644 --- a/Bugsnag.podspec +++ b/Bugsnag.podspec @@ -5,30 +5,15 @@ s.summary = "Cocoa notifier for SDK for bugsnag.com" s.homepage = "https://bugsnag.com" s.license = 'MIT' - s.author = { "Bugsnag" => "notifiers@bugsnag.com" } - - s.source = { :git => "https://github.com/bugsnag/bugsnag-cocoa.git", :tag=>"v#{s.version}", :submodules => true } + s.author = {"Bugsnag" => "notifiers@bugsnag.com" } + s.source = {:git => "https://github.com/bugsnag/bugsnag-cocoa.git", + :tag=>"v#{s.version}"} s.frameworks = 'Foundation' - s.libraries = 'c++' - s.xcconfig = { 'GCC_ENABLE_CPP_EXCEPTIONS' => 'YES' } - s.platforms = {:ios => "5.0", :osx => "10.7"} - - s.source_files = ["KSCrash/Source/KSCrash/Recording/**/*.{m,h,mm,c,cpp}", - "KSCrash/Source/KSCrash/Reporting/Filters/KSCrashReportFilter.h", - "Source/Bugsnag/**/*.{m,h,mm,c,cpp}"] - - s.exclude_files = ["KSCrash/Source/KSCrash/Recording/Tools/KSZombie.{h,m}"] - + s.source_files = ["Source/Bugsnag/**/*.{m,h,mm,c,cpp}"] s.requires_arc = true - s.public_header_files = ["Source/Bugsnag/*.h", - "KSCrash/Source/KSCrash/Reporting/Filters/KSCrashReportFilter.h", - "KSCrash/Source/KSCrash/Recording/KKSCrashReportWriter.h", - ] - - s.subspec 'no-arc' do |sp| - sp.source_files = ["KSCrash/Source/KSCrash/Recording/Tools/KSZombie.{h,m}"] - sp.requires_arc = false - end + s.public_header_files = ["Source/Bugsnag/*.h"] + s.dependency "KSCrash/Recording", "~> 0.0.8" + s.dependency "KSCrash/Reporting", "~> 0.0.8" end
Remove KSCrash source, settings from podspec
diff --git a/app/concerns/viewable.rb b/app/concerns/viewable.rb index abc1234..def5678 100644 --- a/app/concerns/viewable.rb +++ b/app/concerns/viewable.rb @@ -42,6 +42,7 @@ private def view_for(user) + raise("view_for(#{user.id}) but @view.user_id is #{@view.user_id}") if @view && user.id != @view.user_id @view ||= views.where(user_id: user.id).first_or_initialize end end
Throw in a sanity check for Viewable's view_for caching
diff --git a/lib/cdc_migration_testing/fixtures/web_conference.rb b/lib/cdc_migration_testing/fixtures/web_conference.rb index abc1234..def5678 100644 --- a/lib/cdc_migration_testing/fixtures/web_conference.rb +++ b/lib/cdc_migration_testing/fixtures/web_conference.rb @@ -19,6 +19,7 @@ module CdcFixtures def self.create_web_conference ps = PluginSetting.find_or_create_by(name: 'adobe_connect') + ps.settings = {} ps.disabled = false ps.save!
spec: Set empty settings hash when creating a PluginSetting Plugin.enabled? will return false if the PluginSetting has an empty settings hash, even if PluginSetting.disabled is false. A conference-type plugin needs to be enabled before a WebConference can be created. And a WebConference needs to be created to test the web_conferences table in the CDC build. test plan: - RAILS_ENV=test bundle exec rake db:test:fill_tables does not error refs PLAT-5394 Change-Id: Ia4d1b762a3f1427e3c2378cadd4d4d1a9d0899cd Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/229736 Tested-by: Service Cloud Jenkins <9144042a601061f88f1e1d7a1753ea3e2972119d@instructure.com> Reviewed-by: Evan Battaglia <e557ffdfc4b80aab44858030b0ae5370b86cb7b1@instructure.com> Reviewed-by: Tucker Mcknight <4b51b98c1d84aa97854d216bd061ce5d3eda8a28@instructure.com> QA-Review: Tucker Mcknight <4b51b98c1d84aa97854d216bd061ce5d3eda8a28@instructure.com> Product-Review: Tucker Mcknight <4b51b98c1d84aa97854d216bd061ce5d3eda8a28@instructure.com>
diff --git a/lib/maskable_attribute/acts_as_maskable_attribute.rb b/lib/maskable_attribute/acts_as_maskable_attribute.rb index abc1234..def5678 100644 --- a/lib/maskable_attribute/acts_as_maskable_attribute.rb +++ b/lib/maskable_attribute/acts_as_maskable_attribute.rb @@ -6,6 +6,14 @@ end module ClassMethods + ## + # Specifices an attribute to be masked, followed by masks to be made available to the attribute. + # + # ==== Examples + # + # class Foo < ActiveRecord::Base + # maskable_attrribute :some_attribute, :some_method_be_used_as_a_mask, :another_attribute_mask + # end def maskable_attribute(masked_attribute, *masks) cattr_accessor :masked_attributes, :masks self.masked_attributes ||= Hash.new
Add Rdoc Comment to maskable_attribute Method
diff --git a/FeedKit.podspec b/FeedKit.podspec index abc1234..def5678 100644 --- a/FeedKit.podspec +++ b/FeedKit.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'FeedKit' - s.version = '9.0.1' + s.version = '9.1.0' s.license = 'MIT' s.summary = 'An RSS, Atom and JSON Feed parser written in Swift' s.homepage = 'https://github.com/nmdias/FeedKit'
Fix podspec version to 9.1.0
diff --git a/spec/rspec/expectations/minitest_integration_spec.rb b/spec/rspec/expectations/minitest_integration_spec.rb index abc1234..def5678 100644 --- a/spec/rspec/expectations/minitest_integration_spec.rb +++ b/spec/rspec/expectations/minitest_integration_spec.rb @@ -10,12 +10,12 @@ context "once required", :slow do include MinitestIntegration - it "includes itself in Minitest::Test" do + it "includes itself in Minitest::Test, and sets up our exceptions to be counted as assertion failures" do with_minitest_loaded do minitest_case = MiniTest::Test.allocate - sample_matchers.each do |sample_matcher| - expect(minitest_case).to respond_to(sample_matcher) - end + expect(minitest_case).to respond_to(*sample_matchers) + + expect(RSpec::Expectations::ExpectationNotMetError).to be ::Minitest::Assertion end end
Improve our spec for minitest integration.
diff --git a/modules/auxiliary/scanner/http/wordpress/wp_ninja_forms_xss_scanner.rb b/modules/auxiliary/scanner/http/wordpress/wp_ninja_forms_xss_scanner.rb index abc1234..def5678 100644 --- a/modules/auxiliary/scanner/http/wordpress/wp_ninja_forms_xss_scanner.rb +++ b/modules/auxiliary/scanner/http/wordpress/wp_ninja_forms_xss_scanner.rb @@ -0,0 +1,92 @@+## +# This module requires Metasploit: http://metasploit.com/download +# Current source: https://github.com/rapid7/metasploit-framework +## + +require 'msf/core' + +class Metasploit4 < Msf::Auxiliary + + include Msf::HTTP::Wordpress + include Msf::Auxiliary::Scanner + include Msf::Auxiliary::Report + + def initialize(info = {}) + super(update_info(info, + 'Name' => 'WordPress Ninja Forms XSS Scanner', + 'Description' => %q{ + This module attempts to exploit an Authenticated Cross-Site Scripting in Ninja + Forms Plugin for Wordpress, version 2.9.21 and likely prior in order if the + instance is vulnerable. + }, + 'Author' => + [ + 'Morten Nørtoft, Kenneth Jepsen, Mikkel Vej', # Vulnerability Discovery + 'Roberto Soares Espreto <robertoespreto[at]gmail.com>' # Metasploit Module + ], + 'License' => MSF_LICENSE, + 'References' => + [ + ['WPVDB', '8128'], + ['URL', 'https://packetstormsecurity.com/files/132913/'] + ], + 'DisclosureDate' => 'Jul 14 2015' + )) + + register_options( + [ + OptString.new('WP_USER', [true, 'A valid username', nil]), + OptString.new('WP_PASS', [true, 'A valid password', nil]) + ], self.class) + end + + def check + check_plugin_version_from_readme('ninja-forms', '2.9.22') + end + + def user + datastore['WP_USER'] + end + + def password + datastore['WP_PASS'] + end + + def run_host(ip) + vprint_status("#{peer} - Trying to login as: #{user}") + cookie = wordpress_login(user, password) + if cookie.nil? + print_error("#{peer} - Unable to login as: #{user}") + return + end + + xss = "<script>alert(#{Rex::Text.rand_text_numeric(8)})</script>" + + res = send_request_cgi( + 'uri' => normalize_uri(wordpress_url_backend, 'admin.php'), + 'vars_get' => { + 'page' => 'nf-processing', + 'title' => "#{xss}" + }, + 'cookie' => cookie + ) + + unless res && res.body + print_error("#{peer} - Server did not respond in an expected way") + return + end + + if res.code == 200 && res.body.include?("#{xss}") + print_good("#{peer} - Vulnerable to Cross-Site Scripting the Ninja Forms 2.9.21 plugin for Wordpress") + p = store_local( + 'ninjaforms.http', + 'text/html', + res.body, + "#{xss}" + ) + print_good("Save in: #{p}") + else + print_error("#{peer} - Failed, maybe the target isn't vulnerable.") + end + end +end
Add WP Ninja Forms XSS Vulnerability Module
diff --git a/lib/engineyard-serverside-adapter/version.rb b/lib/engineyard-serverside-adapter/version.rb index abc1234..def5678 100644 --- a/lib/engineyard-serverside-adapter/version.rb +++ b/lib/engineyard-serverside-adapter/version.rb @@ -1,7 +1,7 @@ module EY module Serverside class Adapter - VERSION = "2.0.2" + VERSION = "2.0.3.pre" # For backwards compatibility, the serverside version default will be maintained until 2.1 # It is recommended that you supply a serverside_version to engineyard-serverside-adapter # rather than relying on the default version here. This default will go away soon.
Add .pre for next release
diff --git a/lib/html/pipeline/syntax_highlight_filter.rb b/lib/html/pipeline/syntax_highlight_filter.rb index abc1234..def5678 100644 --- a/lib/html/pipeline/syntax_highlight_filter.rb +++ b/lib/html/pipeline/syntax_highlight_filter.rb @@ -1,8 +1,7 @@ begin require 'linguist' rescue LoadError - $stderr.puts "You need to install linguist before using the SyntaxHighlightFilter. See README.md for details" - exit 1 + raise LoadError, "You need to install linguist before using the SyntaxHighlightFilter. See README.md for details" end module HTML
Raise the roof---I mean, error
diff --git a/lib/generators/knock/token_controller_generator.rb b/lib/generators/knock/token_controller_generator.rb index abc1234..def5678 100644 --- a/lib/generators/knock/token_controller_generator.rb +++ b/lib/generators/knock/token_controller_generator.rb @@ -13,7 +13,7 @@ end def add_route - route "post '#{name.underscore}_token' => '#{name.underscore}_token#create" + route "post '#{name.underscore}_token' => '#{name.underscore}_token#create'" end private
Add missing quote in generated route
diff --git a/lib/local_transaction_location_identifier.rb b/lib/local_transaction_location_identifier.rb index abc1234..def5678 100644 --- a/lib/local_transaction_location_identifier.rb +++ b/lib/local_transaction_location_identifier.rb @@ -40,7 +40,7 @@ case type when 'DIS' then 'district' when 'CTY' then 'county' - when 'LBO', 'MTD', 'UTA', 'COI' then 'unitary' + when 'LBO', 'LGD', 'MTD', 'UTA', 'COI' then 'unitary' end end
Add LGD to the area types that we support We support Northern Ireland councils now, but we need to allow them to be found. This area type is already supported in [find-local-council](https://github.com/alphagov/frontend/blob/master/app/controllers/find_local_council_controller.rb#L8) and by adding it to the list here, will be activated in local transactions as well. We should have done this a while ago; it seems to have been an oversight.
diff --git a/lib/metacrunch/job/dsl/dependency_support.rb b/lib/metacrunch/job/dsl/dependency_support.rb index abc1234..def5678 100644 --- a/lib/metacrunch/job/dsl/dependency_support.rb +++ b/lib/metacrunch/job/dsl/dependency_support.rb @@ -1,3 +1,5 @@+require "rubygems/dependency_installer" + module Metacrunch class Job::Dsl::DependencySupport @@ -6,13 +8,11 @@ proxy.instance_eval(&block) if install + installer = Gem::DependencyInstaller.new puts "Installing dependencies..." proxy.each do |name, options| - if options[:version] - `gem install #{name} -v "#{options[:version]}"` - else - `gem install #{name}` - end + args = [name, options[:version]].compact + installer.install(*args) end exit(0) @@ -26,7 +26,7 @@ gem(name) end rescue Gem::LoadError => e - puts "#{e.message}. Use 'metacrunch run --install FILE' to install the missing dependencies." + puts "'#{e.name}' (#{e.requirement}) is not installed. Use 'metacrunch run JOB_FILE --install' to install required dependencies." exit(1) end
Use Gem::DependecyInstaller to install gems.
diff --git a/lib/metal_archives/concerns/initializable.rb b/lib/metal_archives/concerns/initializable.rb index abc1234..def5678 100644 --- a/lib/metal_archives/concerns/initializable.rb +++ b/lib/metal_archives/concerns/initializable.rb @@ -19,7 +19,7 @@ # Set properties # def set(**attributes) - attributes.each { |key, value| instance_variable_set(:"@#{key}", value) } + attributes.each { |key, value| send("#{key}=", value) } end ##
Use setter instead of instance_variable_set
diff --git a/lib/netsuite/records/deposit_payment_list.rb b/lib/netsuite/records/deposit_payment_list.rb index abc1234..def5678 100644 --- a/lib/netsuite/records/deposit_payment_list.rb +++ b/lib/netsuite/records/deposit_payment_list.rb @@ -1,35 +1,15 @@ module NetSuite module Records - class DepositPaymentList - include Support::Fields + class DepositPaymentList < Support::Sublist include Namespaces::TranBank - attr_accessor :replace_all + sublist :deposit_payment, DepositPayment - fields :deposit_payment - - def initialize(attributes = {}) - initialize_from_attributes_hash(attributes) + # legacy support + def payments + self.deposit_payment end - def payment=(payments) - case payments - when Hash - self.payments << DepositPayment.new(payments) - when Array - payments.each { |p| self.payments << DepositPayment.new(p) } - end - end - - def payments - @payments ||= [] - end - - def to_record - rec = { "#{record_namespace}:depositPayment" => payments.map(&:to_record) } - rec[:@replaceAll] = @replace_all unless @replace_all.nil? - rec - end end end end
Use sublist on deposit payment sublist This may be a breaking change for some people!
diff --git a/app/models/paper_role.rb b/app/models/paper_role.rb index abc1234..def5678 100644 --- a/app/models/paper_role.rb +++ b/app/models/paper_role.rb @@ -6,6 +6,8 @@ validates :paper, presence: true after_save :assign_tasks_to_editor, if: -> { user_id_changed? && role == 'editor' } + + validates_uniqueness_of :role, scope: [:user_id, :paper_id] def self.admins where(role: 'admin')
Validate uniqueness of collaborator paper roles.
diff --git a/app/models/repository.rb b/app/models/repository.rb index abc1234..def5678 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -37,13 +37,14 @@ end def best_record(metric) - sort_metric_scores(metric, 'desc').first + sort_metric_scores(metric, 'desc').first.to_hash end def worst_record(metric) - sort_metric_scores(metric, 'asc').first + sort_metric_scores(metric, 'asc').first.to_hash end + private def sort_metric_scores(metric, sorting_order) name = @name search = Tire.search 'metadata' do
Add to_hash to best and worst record methods Similar to the previous commit I have added the to_hash conversion to the methods for retrieving the best and worst record with respect to a certain metric. Signed-off-by: Konrad Reiche <4ff0213f56e2082fcd8c882d04c546881c579ce4@gmail.com>
diff --git a/lib/game.rb b/lib/game.rb index abc1234..def5678 100644 --- a/lib/game.rb +++ b/lib/game.rb @@ -3,12 +3,17 @@ class Game + attr_accessor :ttt + def initialize(tictactoe = nil) @ttt = tictactoe end + def prompt_user_for_input + return "Enter a number #{@ttt.valid_slots.join(", ")} to place an X" + end + def get_user_input - puts "Enter a number #{@ttt.valid_slots.join(", ")} to place an X" user_input = gets.chomp.to_i end @@ -16,6 +21,7 @@ puts "Welcome to Tic Tac toe" @ttt.show_board while !@ttt.game_over? + puts prompt_user_for_input input = get_user_input if @ttt.valid_slots.include?(input) @ttt = @ttt.move(input)
Refactor for single responsibility of methods for get_user_input
diff --git a/lib/checks/check_response_splitting.rb b/lib/checks/check_response_splitting.rb index abc1234..def5678 100644 --- a/lib/checks/check_response_splitting.rb +++ b/lib/checks/check_response_splitting.rb @@ -0,0 +1,18 @@+require 'checks/base_check' +require 'processors/lib/find_call' + +#Warn about response splitting in Rails versions before 2.3.13 +#http://groups.google.com/group/rubyonrails-security/browse_thread/thread/6ffc93bde0298768 +class CheckResponseSplitting < BaseCheck + Checks.add self + + def run_check + if version_between?('2.3.0', '2.3.13') + + warn :warning_type => "Response Splitting", + :message => "Versions before 2.3.14 have a vulnerability content type handling allowing injection of headers. Upgrade or apply patches as needed.", + :confidence => CONFIDENCE[:med] + + end + end +end
Check for response splitting vulnerability http://groups.google.com/group/rubyonrails-security/t/6ffc93bde0298768
diff --git a/metadata.rb b/metadata.rb index abc1234..def5678 100644 --- a/metadata.rb +++ b/metadata.rb @@ -4,11 +4,11 @@ license "Apache 2.0" description "Sets up a shared admin user to manage the system" long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version "1.1.0" +version "1.1.1" supports 'ubuntu', ">= 10.04" supports 'centos', ">= 5.8" -depends "sudo", "~> 2.0.4" +depends "sudo" attribute "admin-user/user", :display_name => "User",
Remove version constraint on sudo cookbook
diff --git a/lib/hyper_admin/resource_controller.rb b/lib/hyper_admin/resource_controller.rb index abc1234..def5678 100644 --- a/lib/hyper_admin/resource_controller.rb +++ b/lib/hyper_admin/resource_controller.rb @@ -1,6 +1,7 @@ module HyperAdmin class ResourceController < ActionController::Base before_action :set_resource_class + before_action :permit_params, only: [ :create, :update ] def index @resources = resource_class.all @@ -23,6 +24,13 @@ end def create + @resource = @resource_class.new params[@resource_class.model_name.param_key] + + if @resource.save + redirect_to [ :admin, @resource ] + else + render "admin/resources/new", layout: layout + end end def update @@ -45,6 +53,10 @@ @resource_class = resource_class end + def permit_params + params.permit! + end + def layout 'hyper_admin/application' end
Create resources when submitted through new view
diff --git a/lib/pier.rb b/lib/pier.rb index abc1234..def5678 100644 --- a/lib/pier.rb +++ b/lib/pier.rb @@ -1,3 +1,4 @@+require 'English' require 'pier/moor' require 'pier/pier' require 'pier/version'
Fix undefined CHILD_STATUS variable error ``` lib/pier.rb:16: warning: global variable `$CHILD_STATUS' not initialized ```
diff --git a/app/models/project.rb b/app/models/project.rb index abc1234..def5678 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -14,7 +14,7 @@ acts_as_followable acts_as_taggable # Alias for acts_as_taggable_on :tags - scope :with_github_url, -> { where( "github_url <> ''" ) } + scope :with_github_url, -> { where.not(github_url: '') } def self.search(search, page) order('LOWER(title)')
Make scope in Project model clearer
diff --git a/app/models/section.rb b/app/models/section.rb index abc1234..def5678 100644 --- a/app/models/section.rb +++ b/app/models/section.rb @@ -6,4 +6,7 @@ field :sort, type: Integer, default: 0 has_many :nodes, dependent: :destroy + + default_scope { desc(:sort) } + end
Use the default_scope macro to set a default scope for all operations on the model.
diff --git a/lib/rlrw.rb b/lib/rlrw.rb index abc1234..def5678 100644 --- a/lib/rlrw.rb +++ b/lib/rlrw.rb @@ -7,9 +7,9 @@ def self.all(key, nodes) res = [] nodes.each do |node| - res << [node, self.phash(key, node)] + res << { node: node, weight: self.phash(key, node) } end - res.sort_by { |_, val| -val } + res.sort_by { |res| -res[:weight] } end def self.top(key, nodes, len)
Return a list of results, where each result is a hash with node and weight.
diff --git a/lib/metacrunch/ubpb/record/zählung.rb b/lib/metacrunch/ubpb/record/zählung.rb index abc1234..def5678 100644 --- a/lib/metacrunch/ubpb/record/zählung.rb +++ b/lib/metacrunch/ubpb/record/zählung.rb @@ -1,4 +1,45 @@ require_relative "./generisches_element" class Metacrunch::UBPB::Record::Zählung < Metacrunch::UBPB::Record::GenerischesElement + + SUBFIELDS = { + a: { "Zusammenfassung" => :NW }, # Non-RDA + b: { "Band" => :NW }, # RDA + h: { "Heft" => :NW }, # RDA + j: { "Jahr" => :NW }, # RDA + s: { "Seiten" => :NW } # RDA + } + + def get(property = nil, options = {}) + zusammenfassung = @properties["Zusammenfassung"] + + if zusammenfassung.present? + zusammenfassung + else + # Beispiel: Heft 19 (1964), Seite 39-45 : Illustrationen + result = join("", @properties["Band"], prepend_always: "Band ") + result = join(result, @properties["Heft"], separator: ", ", prepend_always: "Heft ") + result = join(result, @properties["Jahr"], separator: " ", wrap: "(@)") + result = join(result, @properties["Seiten"], separator: ", ", prepend_always: "Seite ") + result + end + end + +private + + def join(memo, string, separator: "", wrap: "", prepend_always: "") + if string.blank? + memo + else + string = prepend_always + string + + if memo.present? + string = wrap.gsub("@", string) if wrap.present? + memo + separator + string + else + string + end + end + end + end
Add RDA Support for field 596
diff --git a/lib/modules/adapters/simple_adapter.rb b/lib/modules/adapters/simple_adapter.rb index abc1234..def5678 100644 --- a/lib/modules/adapters/simple_adapter.rb +++ b/lib/modules/adapters/simple_adapter.rb @@ -1,5 +1,14 @@ class Adapters::SimpleAdapter < Adapters::Base + #Example on how to invoke the adapter + # + # selected_country = 'Simple' + # adapter = Country.find_by_name(selected_country).adapter + # if adapter.is_available + # @res = adapter.name.constantize.run(adapter) + # else + # #Return unavailable message + # end def initialize(adapter) @params = { request_type: 'soap_request',
Comment about how to invoke the adapter
diff --git a/lib/sastrawi/stemmer/cached_stemmer.rb b/lib/sastrawi/stemmer/cached_stemmer.rb index abc1234..def5678 100644 --- a/lib/sastrawi/stemmer/cached_stemmer.rb +++ b/lib/sastrawi/stemmer/cached_stemmer.rb @@ -1,3 +1,5 @@+require 'filter/text_normalizer' + module Sastrawi module Stemmer class CachedStemmer @@ -9,8 +11,7 @@ end def stem(text) - # TODO: call TextNormalizer class - # normalized_text = + normalized_text = TextNormalizer.normalize_text(text) words = normalized_text.split(' ') stems = []
Call "TextNormalizer" to normalize text
diff --git a/lib/toy_robot_simulator/application.rb b/lib/toy_robot_simulator/application.rb index abc1234..def5678 100644 --- a/lib/toy_robot_simulator/application.rb +++ b/lib/toy_robot_simulator/application.rb @@ -1,4 +1,3 @@-require 'pry' require_relative 'factory' require_relative 'command/matcher/matcher' @@ -28,21 +27,10 @@ case raw_input when /\AR(EPORT_DEBUG)*\z/ puts controller.instance_variable_get(:@robot).inspect - when /\AD(EBUG)*\z/ - console when /\AE(XIT)*\z/ puts 'Have a nice day, bye :)' puts '...' exit(false) end end - - def console - # Application debug session - # - # Call `self` to see - # state. - - binding.pry - end end
Remove production dependancy on 'pry'
diff --git a/crack.gemspec b/crack.gemspec index abc1234..def5678 100644 --- a/crack.gemspec +++ b/crack.gemspec @@ -9,8 +9,7 @@ gem.homepage = "http://github.com/jnunemaker/crack" gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } - gem.files = `git ls-files`.split("\n") - gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") + gem.files = `git ls-files -- lib/*`.split("\n") gem.name = "crack" gem.require_paths = ["lib"] gem.version = Crack::VERSION
Exclude tests (and fixtures) from bundled gem
diff --git a/lib/metasploit_data_models/active_record_models/ref.rb b/lib/metasploit_data_models/active_record_models/ref.rb index abc1234..def5678 100644 --- a/lib/metasploit_data_models/active_record_models/ref.rb +++ b/lib/metasploit_data_models/active_record_models/ref.rb @@ -2,6 +2,7 @@ def self.included(base) base.class_eval{ has_many :vulns, :through => :vulns_refs, :class_name => "Mdm::Vuln" + has_many :vulns_refs, :class_name => "Mdm::VulnRef" } end end
Add missing has_many back to the model
diff --git a/metadata.rb b/metadata.rb index abc1234..def5678 100644 --- a/metadata.rb +++ b/metadata.rb @@ -9,7 +9,7 @@ supports 'ubuntu' # Compat resource is required for 12.5+ as resource API changed between 12.4 and 12.5 -supports 'compat_resource' +depends 'compat_resource' depends 'java' depends 'authbind'
Move to Chef 12 support
diff --git a/proxy/recipes/deploy.rb b/proxy/recipes/deploy.rb index abc1234..def5678 100644 --- a/proxy/recipes/deploy.rb +++ b/proxy/recipes/deploy.rb @@ -10,16 +10,5 @@ command "/usr/sbin/proxy2ensite #{application} #{deploy[:deploy_to]} #{deploy[:domains].join(',')}" notifies :reload, "service[nginx]" end - - Chef::Log.info("Restart NodeJS Application #{application}.") - Chef::Log.info("Restart Current PAth #{application}.") - execute "Restart NodeJS Application #{application}." do - cwd deploy[:current_path] - command "sleep #{deploy[:sleep_before_restart]} && #{deploy[:restart_command]}" - action :run - only_if do - File.exists?(deploy[:current_path]) - end - end end
Remove automatically restart nodeJs App
diff --git a/lib/action_controller/parents.rb b/lib/action_controller/parents.rb index abc1234..def5678 100644 --- a/lib/action_controller/parents.rb +++ b/lib/action_controller/parents.rb @@ -1,7 +1,4 @@ require 'active_support/core_ext/string/conversions' -require 'action_controller/parents/finder' -require 'action_controller/parents/methods' -require 'action_controller/parents/version' module ActionController # To be included in a controller. @@ -45,3 +42,7 @@ end end # Parents end + +require 'action_controller/parents/finder' +require 'action_controller/parents/methods' +require 'action_controller/parents/version'
Fix 'superclass mismatch for class Parents' error
diff --git a/metadata.rb b/metadata.rb index abc1234..def5678 100644 --- a/metadata.rb +++ b/metadata.rb @@ -4,7 +4,7 @@ source_url 'https://github.com/osuosl-cookbooks/resource_from_hash' issues_url 'https://github.com/osuosl-cookbooks/resource_from_hash/issues' license 'Apache-2.0' -chef_version '>= 14.0' +chef_version '>= 16.0' description 'Installs/Configures resource_from_hash' version '1.3.0'
Update Chef dependency to >= 16
diff --git a/metadata.rb b/metadata.rb index abc1234..def5678 100644 --- a/metadata.rb +++ b/metadata.rb @@ -16,7 +16,7 @@ depends '7-zip', '~> 1.0' depends 'build-essential', '~> 2.0' -depends 'chef-sugar', '~> 1.1' +depends 'chef-sugar', '~> 2.0' depends 'homebrew', '~> 1.5' depends 'windows', '~> 1.30' depends 'wix', '~> 1.1'
Update Chef Sugar to v2.0.0 to fix an installation bug
diff --git a/metadata.rb b/metadata.rb index abc1234..def5678 100644 --- a/metadata.rb +++ b/metadata.rb @@ -7,6 +7,8 @@ %w{ debian ubuntu + centos + redhat }.each do |os| supports os end
Add centos and redhat to supported platforms
diff --git a/neighborly-balanced-creditcard.gemspec b/neighborly-balanced-creditcard.gemspec index abc1234..def5678 100644 --- a/neighborly-balanced-creditcard.gemspec +++ b/neighborly-balanced-creditcard.gemspec @@ -22,4 +22,5 @@ spec.add_dependency 'rails' spec.add_development_dependency 'rspec-rails' + spec.add_development_dependency "sqlite3" end
Add sqlite3 as dependency to development
diff --git a/lib/mail_room/mailbox_watcher.rb b/lib/mail_room/mailbox_watcher.rb index abc1234..def5678 100644 --- a/lib/mail_room/mailbox_watcher.rb +++ b/lib/mail_room/mailbox_watcher.rb @@ -60,10 +60,10 @@ def connection @connection ||= - if @mailbox.imap? + if @mailbox.microsoft_graph? + ::MailRoom::MicrosoftGraph::Connection.new(@mailbox) + else ::MailRoom::IMAP::Connection.new(@mailbox) - else - ::MailRoom::MicrosoftGraph::Connection.new(@mailbox) end end end
Swap connection to check for Microsoft Graph first
diff --git a/lib/puppet/type/file_fragment.rb b/lib/puppet/type/file_fragment.rb index abc1234..def5678 100644 --- a/lib/puppet/type/file_fragment.rb +++ b/lib/puppet/type/file_fragment.rb @@ -9,8 +9,16 @@ desc "TODO" end + newparam(:target) do + desc "Deprecated. Use *path* instead." + end + newparam(:path) do desc "TODO" + + defaultto do + resource.value(:target) + end end newparam(:content) do
Support target parameter as an alias for path "path" defaults to "target" for easier transition from R.I.Pienaar's concat module: https://github.com/ripienaar/puppet-concat
diff --git a/lib/nehm.rb b/lib/nehm.rb index abc1234..def5678 100644 --- a/lib/nehm.rb +++ b/lib/nehm.rb @@ -43,7 +43,7 @@ end def initialized? - File.exist?(Cfg::FILE_PATH) + Cfg.exist? end end
Use Cfg method for check of existence of Cfg file
diff --git a/lib/dap/input.rb b/lib/dap/input.rb index abc1234..def5678 100644 --- a/lib/dap/input.rb +++ b/lib/dap/input.rb @@ -64,8 +64,7 @@ begin json = Oj.load(line.strip, mode: :strict) rescue - $stderr.puts "\nRecord is not valid JSON and will be skipped." - $stderr.puts line + $stderr.puts "Record is not valid JSON and will be skipped: '#{line}'" return Error::InvalidFormat end return Error::Empty unless json @@ -78,4 +77,4 @@ end require 'dap/input/warc' -require 'dap/input/csv'+require 'dap/input/csv'
Improve logging for invalid JSON
diff --git a/lib/likes/set.rb b/lib/likes/set.rb index abc1234..def5678 100644 --- a/lib/likes/set.rb +++ b/lib/likes/set.rb @@ -1,7 +1,7 @@ module Likes # Job: Understands patterns in people likings class Set - # Default engine - simplest one + # Default engine - a fast one # # @see Engines::FastJaccardSimilarity DEFAULT_ENGINE = Engines::FastJaccardSimilarity
Update default engine constant description
diff --git a/lib/rapns/app.rb b/lib/rapns/app.rb index abc1234..def5678 100644 --- a/lib/rapns/app.rb +++ b/lib/rapns/app.rb @@ -4,7 +4,7 @@ attr_accessible :name, :environment, :certificate, :password, :connections, :auth_key - has_many :notifications + has_many :notifications, :class_name => 'Rapns::Notification' validates :name, :presence => true, :uniqueness => { :scope => [:type, :environment] } validates_numericality_of :connections, :greater_than => 0, :only_integer => true
Add explicit class_name to properly handle introspection.
diff --git a/lib/sg_mailer.rb b/lib/sg_mailer.rb index abc1234..def5678 100644 --- a/lib/sg_mailer.rb +++ b/lib/sg_mailer.rb @@ -11,7 +11,7 @@ def configure(delivery_processor: default_delivery_processor, test_client: false, **client_options) - self.client = test_client ? TestClient.new : Client.new(**options) + self.client = test_client ? TestClient.new : Client.new(**client_options) self.delivery_processor = delivery_processor end
Fix the clients options typo
diff --git a/lib/syoboemon.rb b/lib/syoboemon.rb index abc1234..def5678 100644 --- a/lib/syoboemon.rb +++ b/lib/syoboemon.rb @@ -4,6 +4,7 @@ require 'rubygems' require 'faraday' require 'happymapper' +require "json" # syoboemon ruby files # version file
Add gem to require rubygems list
diff --git a/mrbgem.rake b/mrbgem.rake index abc1234..def5678 100644 --- a/mrbgem.rake +++ b/mrbgem.rake @@ -1,4 +1,6 @@ MRuby::Gem::Specification.new('mruby-singleton') do |spec| spec.license = 'MIT' spec.author = 'ksss <co000ri@gmail.com>' + + spec.add_test_dependency 'mruby-metaprog', core: 'mruby-metaprog' end
Fix test failure on mruby-2.0.0.
diff --git a/metadata.rb b/metadata.rb index abc1234..def5678 100644 --- a/metadata.rb +++ b/metadata.rb @@ -4,7 +4,7 @@ license "Apache 2.0" description "Installs/Configures td-agent" long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version "2.0.3" +version "2.1.0" recipe "td-agent", "td-agent configuration" %w{redhat centos debian ubuntu}.each do |os|
Fix version to be released as 2.1.0
diff --git a/metadata.rb b/metadata.rb index abc1234..def5678 100644 --- a/metadata.rb +++ b/metadata.rb @@ -4,7 +4,7 @@ license 'Apache-2.0' description 'Manages unbound DNS resolver' long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version '0.1.0' +version '0.1.1' issues_url 'https://github.com/sous-chefs/unbound/issues' source_url 'https://github.com/sous-chefs/unbound' chef_version '>= 12.5' if respond_to?(:chef_version)
Move to Sous Chefs organistaion Release 0.1.1 - see changelog.md for more information
diff --git a/lib/spdx.rb b/lib/spdx.rb index abc1234..def5678 100644 --- a/lib/spdx.rb +++ b/lib/spdx.rb @@ -8,6 +8,7 @@ end def self.closest(name) + name.gsub!(/software|license/i, '') match = names.sort_by do |key| Text::Levenshtein.distance(name, key) end.first
Remove a couple stop words before searching
diff --git a/lib/booking_locations/location.rb b/lib/booking_locations/location.rb index abc1234..def5678 100644 --- a/lib/booking_locations/location.rb +++ b/lib/booking_locations/location.rb @@ -52,11 +52,7 @@ end def name_for(location_id) - if id == location_id - name - else - locations.find { |location| location.id == location_id }.name - end + location_for(location_id).name end end end
Refactor to use newly introduced helper
diff --git a/lib/gitlab/tasks/purge_cache.rake b/lib/gitlab/tasks/purge_cache.rake index abc1234..def5678 100644 --- a/lib/gitlab/tasks/purge_cache.rake +++ b/lib/gitlab/tasks/purge_cache.rake @@ -11,10 +11,6 @@ "/var/cache/omnibus/src/gitlab-shell", "/var/cache/omnibus/src/gitlab-workhorse", - # Force a new download of Curl's certificate bundle because it gets updated - # upstream silently once every while - "/var/cache/omnibus/cache/cacert.pem", - # Clear out old packages to prevent uploading them a second time to S3 "/var/cache/omnibus/pkg" ].each do |path|
Remove cacerts.pem from list of files to be purged
diff --git a/lib/helios/static_color_effect.rb b/lib/helios/static_color_effect.rb index abc1234..def5678 100644 --- a/lib/helios/static_color_effect.rb +++ b/lib/helios/static_color_effect.rb @@ -10,13 +10,9 @@ def change! @lights = Array(@lights) - t = [] @lights.each do |light| - t << Thread.new do - Lights[light] = [@red, @green, @blue] - end + Lights[light] = [@red, @green, @blue] end - t.map(&:join) end end end
Remove threads because it makes the lights jittery
diff --git a/recipes/spark_worker.rb b/recipes/spark_worker.rb index abc1234..def5678 100644 --- a/recipes/spark_worker.rb +++ b/recipes/spark_worker.rb @@ -24,14 +24,14 @@ action :install end -if node['spark'].key? 'spark_env' and node['spark']['spark_env'].key? 'spark_worker_dir' +if node['spark'].key?('spark_env') && node['spark']['spark_env'].key?('spark_worker_dir') directory node['spark']['spark_env']['spark_worker_dir'] do mode '0755' owner 'spark' group 'spark' action :create recursive true - only_if { node['spark']['spark_env'].key? 'spark_worker_dir' } + only_if { node['spark']['spark_env'].key?('spark_worker_dir') } end end
Use && instead of and
diff --git a/lib/middleman-deploy/extension.rb b/lib/middleman-deploy/extension.rb index abc1234..def5678 100644 --- a/lib/middleman-deploy/extension.rb +++ b/lib/middleman-deploy/extension.rb @@ -17,8 +17,11 @@ options = Options.new(options_hash) yield options if block_given? + # Default options for the rsync method. options.port ||= 22 options.clean ||= false + + # Default options for the git method. options.remote ||= "origin" options.branch ||= "gh-pages"
Comment and separate default options.
diff --git a/lib/quesadilla/core_ext/string.rb b/lib/quesadilla/core_ext/string.rb index abc1234..def5678 100644 --- a/lib/quesadilla/core_ext/string.rb +++ b/lib/quesadilla/core_ext/string.rb @@ -9,15 +9,20 @@ def q_truncate(truncate_at, options = {}) return dup unless length > truncate_at + # Default omission to '...' options[:omission] ||= '...' - length_with_room_for_omission = truncate_at - options[:omission].length - stop = \ - if options[:separator] - rindex(options[:separator], length_with_room_for_omission) || length_with_room_for_omission - else - length_with_room_for_omission - end + # Account for the omission string in the truncated length + truncate_at -= options[:omission].length + + # Calculate end index + stop = if options[:separator] + rindex(options[:separator], truncate_at) || truncate_at + else + truncate_at + end + + # Return the trucnated string plus the omission string self[0...stop] + options[:omission] end end
Clean up truncate a bit
diff --git a/lib/rake/ruby182_test_unit_fix.rb b/lib/rake/ruby182_test_unit_fix.rb index abc1234..def5678 100644 --- a/lib/rake/ruby182_test_unit_fix.rb +++ b/lib/rake/ruby182_test_unit_fix.rb @@ -1,3 +1,5 @@+# TODO: Remove in rake 11 + # Local Rake override to fix bug in Ruby 0.8.2 module Test # :nodoc: # Local Rake override to fix bug in Ruby 0.8.2
Mark the 1.8.2 test/unit fix for removal in Rake 11
diff --git a/lib/rspec/requestable-examples.rb b/lib/rspec/requestable-examples.rb index abc1234..def5678 100644 --- a/lib/rspec/requestable-examples.rb +++ b/lib/rspec/requestable-examples.rb @@ -31,15 +31,11 @@ end def requestable_describe(description, options={}, &blk) - requestable_describes << description - describe description, &blk if requested_examples.include?(options[:as] || description) + label = options[:as] || description + requestable_examples << label + describe description, &blk if requested_examples.run?(label) end alias_method :requestable_context, :requestable_describe - - def requestable_describes - @requestable_describes ||= [] - end - alias_method :requestable_contexts, :requestable_describes end end
Use proper describe label text when doing requestable_describe.
diff --git a/test/spec/configured.rb b/test/spec/configured.rb index abc1234..def5678 100644 --- a/test/spec/configured.rb +++ b/test/spec/configured.rb @@ -1,22 +1,43 @@ require_relative 'spec_init' -module ConfiguredRandomUUID - class Example - attr_accessor :uuid +module Configured + module UUID + class Example + attr_accessor :uuid + end + end + + module Identifier + class Example + attr_accessor :identifier + end end end -describe ConfiguredRandomUUID::Example do - context "Configured" do - let(:subject) { ConfiguredRandomUUID::Example.new } - let(:uuid) { subject.uuid } +describe "Configured Receiver" do + context "Receiver attribute named uuid" do + let(:receiver) { Configured::UUID::Example.new } + let(:uuid) { receiver.uuid } before do - Identifier::UUID::Random.configure subject + Identifier::UUID::Random.configure receiver end specify "Receiver has a random UUID generator" do assert(uuid.instance_of? Identifier::UUID::Random) end end + + context "Receiver attribute named identifier" do + let(:receiver) { Configured::Identifier::Example.new } + let(:identifier) { receiver.identifier } + + before do + Identifier::UUID::Random.configure receiver + end + + specify "Receiver has a random UUID generator" do + assert(identifier.instance_of? Identifier::UUID::Random) + end + end end
Test coverage for configuration is improved