diff
stringlengths
65
26.7k
message
stringlengths
7
9.92k
diff --git a/config.ru b/config.ru index abc1234..def5678 100644 --- a/config.ru +++ b/config.ru @@ -1,5 +1,5 @@ require 'rubygems' -require './lookup_service.rb' +require "#{File.expand_path(File.dirname(__FILE__))}/lookup_service.rb" CgLookupService::App.set :run, false # disable built-in sinatra web server CgLookupService::App.set :environment, :development
Fix the require path for lookup_service.rb when running from a different directory. git-svn-id: fef28697fff9bc4bae060bf37c18ee74cae4f475@1673 bc291798-7d79-44a5-a816-fbf4f7d05ffa
diff --git a/era_ja.gemspec b/era_ja.gemspec index abc1234..def5678 100644 --- a/era_ja.gemspec +++ b/era_ja.gemspec @@ -4,9 +4,9 @@ Gem::Specification.new do |gem| gem.authors = ["tomi"] gem.email = ["tomiacannondale@gmail.com"] - gem.description = %q{TODO: Write a gem description} - gem.summary = %q{TODO: Write a gem summary} - gem.homepage = "" + gem.description = %q{Convert to Japanese era.} + gem.summary = %q{Convert Date or Time instance to String of Japanese era.} + gem.homepage = "https://github.com/tomiacannondale/era_ja" gem.files = `git ls-files`.split($\) gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
Fix gem description, gem summary, gem homepage
diff --git a/konjak.gemspec b/konjak.gemspec index abc1234..def5678 100644 --- a/konjak.gemspec +++ b/konjak.gemspec @@ -18,6 +18,7 @@ spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] + spec.add_dependency "activesupport" spec.add_dependency "mem" spec.add_dependency "nokogiri" spec.add_development_dependency "bundler"
Add activesupport to gem dependency
diff --git a/tiny_http_parser.gemspec b/tiny_http_parser.gemspec index abc1234..def5678 100644 --- a/tiny_http_parser.gemspec +++ b/tiny_http_parser.gemspec @@ -21,5 +21,5 @@ spec.add_development_dependency "bundler", "~> 1.6" spec.add_development_dependency "rake" spec.add_development_dependency "rspec" - spec.add_dependency "httpclient" + spec.add_dependency "faraday" end
Change http client to faraday
diff --git a/country_select.gemspec b/country_select.gemspec index abc1234..def5678 100644 --- a/country_select.gemspec +++ b/country_select.gemspec @@ -21,5 +21,5 @@ # specify any dependencies here; for example: s.add_development_dependency 'rspec' s.add_development_dependency 'actionpack' - s.add_runtime_dependency 'appraisal' + s.add_development_dependency 'appraisal' end
Make appraisal a development dependency rather than runtime
diff --git a/omniauth-oauth2.gemspec b/omniauth-oauth2.gemspec index abc1234..def5678 100644 --- a/omniauth-oauth2.gemspec +++ b/omniauth-oauth2.gemspec @@ -1,5 +1,6 @@-# -*- encoding: utf-8 -*- -require File.expand_path('../lib/omniauth-oauth2/version', __FILE__) +lib = File.expand_path('../lib', __FILE__) +$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) +require 'omniauth-oauth2/version' Gem::Specification.new do |gem| gem.add_dependency 'omniauth', '~> 1.0' @@ -10,7 +11,7 @@ gem.authors = ['Michael Bleigh', 'Erik Michaels-Ober'] gem.email = ['michael@intridea.com', 'sferik@gmail.com'] gem.description = %q{An abstract OAuth2 strategy for OmniAuth.} - gem.summary = %q{An abstract OAuth2 strategy for OmniAuth.} + gem.summary = gem.description gem.homepage = 'https://github.com/intridea/omniauth-oauth2' gem.license = 'MIT'
Fix loading of version file from gemspec
diff --git a/test/controllers/accounts_controller_test.rb b/test/controllers/accounts_controller_test.rb index abc1234..def5678 100644 --- a/test/controllers/accounts_controller_test.rb +++ b/test/controllers/accounts_controller_test.rb @@ -4,6 +4,9 @@ test "should get index" do get :index assert_response :success + assert_not_nil assigns(:accounts) + assert_template :index + assert_template layout: "layouts/application" end test "should create account" do
Enforce test case for index action in account controller.
diff --git a/faye/config.ru b/faye/config.ru index abc1234..def5678 100644 --- a/faye/config.ru +++ b/faye/config.ru @@ -1,8 +1,28 @@ require 'faye' Faye::WebSocket.load_adapter('thin') - bayeux = Faye::RackAdapter.new(:mount => 'faye', :timeout => 50) +class ServerAuth + def incoming(message, callback) + unless message["channel"] == '/meta/subcribe' + return callback.call(message) + end + + subscription = message["subscription"] + msg_token = message["ext"] && message["ext"]["authToken"] + + config = YAML.load_file("../config/config.yml") + FAYE_TOKEN = config["faye_token"] + + if msg_token != FAYE_TOKEN + message["error"] = 'Invalid subscription auth token.' + end + + callback.call(message) + end +end + +bayeux.add_extenstion(ServerAuth.new) run bayeux
Add the extension for faye.
diff --git a/test/lib/gday/version_test.rb b/test/lib/gday/version_test.rb index abc1234..def5678 100644 --- a/test/lib/gday/version_test.rb +++ b/test/lib/gday/version_test.rb @@ -1,6 +1,6 @@ require_relative '../../test_helper' -describe Gday do +describe Gday, 'VERSION' do it "must be defined" do Gday::VERSION.wont_be_nil
Add 'VERSION' to describe for VERSION tests
diff --git a/week-6/nested_data_solution.rb b/week-6/nested_data_solution.rb index abc1234..def5678 100644 --- a/week-6/nested_data_solution.rb +++ b/week-6/nested_data_solution.rb @@ -0,0 +1,47 @@+# RELEASE 2: NESTED STRUCTURE GOLF +# Hole 1 +# Target element: "FORE" + +array = [[1,2], ["inner", ["eagle", "par", ["FORE", "hook"]]]] + +# attempts: +# ============================================================ + + + +# ============================================================ + +# Hole 2 +# Target element: "congrats!" + +hash = {outer: {inner: {"almost" => {3 => "congrats!"}}}} + +# attempts: +# ============================================================ + + + +# ============================================================ + + +# Hole 3 +# Target element: "finished" + +nested_data = {array: ["array", {hash: "finished"}]} + +# attempts: +# ============================================================ + + + +# ============================================================ + +# RELEASE 3: ITERATE OVER NESTED STRUCTURES + +number_array = [5, [10, 15], [20,25,30], 35] + + + +# Bonus: + +startup_names = ["bit", ["find", "fast", ["optimize", "scope"]]]
Create files for 6.5 Nested Data Structures
diff --git a/examples/multi/basic_top_level.rb b/examples/multi/basic_top_level.rb index abc1234..def5678 100644 --- a/examples/multi/basic_top_level.rb +++ b/examples/multi/basic_top_level.rb @@ -2,13 +2,11 @@ require 'tty-spinner' -spinners = TTY::Spinner::Multi.new "[:spinner] main" +spinners = TTY::Spinner::Multi.new "[:spinner] main", format: :pulse -spinners.auto_spin - -sp1 = spinners.register "[:spinner] one" -sp2 = spinners.register "[:spinner] two" -sp3 = spinners.register "[:spinner] three" +sp1 = spinners.register "[:spinner] one", format: :classic +sp2 = spinners.register "[:spinner] two", format: :classic +sp3 = spinners.register "[:spinner] three", format: :classic th1 = Thread.new { 20.times { sleep(0.2); sp1.spin }} th2 = Thread.new { 30.times { sleep(0.1); sp2.spin }}
Change to use different formatting and remove auto spin
diff --git a/cloud_conductor_utils.gemspec b/cloud_conductor_utils.gemspec index abc1234..def5678 100644 --- a/cloud_conductor_utils.gemspec +++ b/cloud_conductor_utils.gemspec @@ -24,6 +24,5 @@ spec.add_dependency "rest-client" spec.add_dependency "json" - spec.add_dependency "yaml" end
Fix gemspec to remove unnecessary dependency.
diff --git a/lib/kosmos/packages/enhanced_navball.rb b/lib/kosmos/packages/enhanced_navball.rb index abc1234..def5678 100644 --- a/lib/kosmos/packages/enhanced_navball.rb +++ b/lib/kosmos/packages/enhanced_navball.rb @@ -0,0 +1,8 @@+class EnhancedNavball < Kosmos::Package + title 'Enhanced Navball' + url 'http://kerbalspaceport.com/wp/wp-content/themes/kerbal/inc/download.php?f=uploads/2013/09/EnhancedNavBall_1_2.zip' + + def install + merge_directory 'EnhancedNavBall/Plugins' + end +end
Add a package for Enhanced Navball.
diff --git a/lib/lobster.rb b/lib/lobster.rb index abc1234..def5678 100644 --- a/lib/lobster.rb +++ b/lib/lobster.rb @@ -1,12 +1,12 @@ module Lobster end -require 'lobster/version' +require_relative 'lobster/version' -require 'lobster/error_codes' -require 'lobster/error' -require 'lobster/result' -require 'lobster/uuid' -require 'lobster/identifiable' +require_relative 'lobster/error_codes' +require_relative 'lobster/error' +require_relative 'lobster/result' +require_relative 'lobster/uuid' +require_relative 'lobster/identifiable' -require 'lobster/users' +require_relative 'lobster/users'
Use require_relative instead of require
diff --git a/lib/tasks/change_organisation_slug.rake b/lib/tasks/change_organisation_slug.rake index abc1234..def5678 100644 --- a/lib/tasks/change_organisation_slug.rake +++ b/lib/tasks/change_organisation_slug.rake @@ -0,0 +1,26 @@+desc "Change an organisation slug (DANGER!).\n + +This rake task changes an organisation slug in whitehall. + +It performs the following steps: +- changes org slug +- changes organisation_slug of users +- re-registers org with search +- re-registers any related editions with search + +It is one part of an inter-related set of steps which must be carefully +coordinated. + +For reference: + +https://github.com/alphagov/wiki/wiki/Changing-GOV.UK-URLs#changing-an-organisations-slug" + +task :change_organisation_slug, [:old_slug, :new_slug] => :environment do |_task, args| + logger = Logger.new(STDOUT) + organisation = Organisation.find_by_slug(args[:old_slug]) + if organisation + Whitehall::OrganisationSlugChanger.new(organisation, args[:new_slug], logger: logger).call + else + logger.error("Organisation with slug '#{args[:old_slug]}' not found") + end +end
Add rake task and usage notes.
diff --git a/lib/weather_reporter/console_printer.rb b/lib/weather_reporter/console_printer.rb index abc1234..def5678 100644 --- a/lib/weather_reporter/console_printer.rb +++ b/lib/weather_reporter/console_printer.rb @@ -1,11 +1,30 @@ module WeatherReporter + include OutputFormatter + class ConsolePrinter def initialize(weather_obj) @weather_obj = weather_obj end def print_to_console - @weather_reporter + puts(condition_map[:"#{weather_condition}"]) end + + def weather_condition + @weather_obj.current.condition.text + end + + def condition_map + { + "Sunny": sunny, + "Overcast": cloudy, + "Mist": mist, + "Partly cloudy": partly_cloudy, + "Light rain": light_rain, + "Light rain shower": light_rain, + 'Patchy rain possible': light_rain + } + end + end end
Print current weather condition gets weather codtion from weather_obj form the map weather condition to the relevent terminal icon
diff --git a/postgresql-connector.gemspec b/postgresql-connector.gemspec index abc1234..def5678 100644 --- a/postgresql-connector.gemspec +++ b/postgresql-connector.gemspec @@ -2,7 +2,7 @@ Gem::Specification.new do |s| s.name = 'postgresql-connector' s.summary = 'PostgreSQL Connector for Sequel' - s.version = '0.1.0.1' + s.version = '0.1.0.2' s.authors = [''] s.require_paths = ['lib'] s.files = Dir.glob('{lib}/**/*')
Package version is increased from 0.1.0.1 to 0.1.0.2
diff --git a/depend.rb b/depend.rb index abc1234..def5678 100644 --- a/depend.rb +++ b/depend.rb @@ -31,8 +31,12 @@ @gems = [] - weighted_results.sort {|(k1, v1), (k2, v2)| v2 <=> v1 }.first(50).each_with_index do |(k, v), i| - @gems << { name: k, count: v } + sorted_by_download_count = weighted_results.sort do |(name1, count1), (name2, count2)| + count2 <=> count1 + end + + sorted_by_download_count.first(50).each do |(name, count)| + @gems << { name: name, downloads: count } end erb :gem
Clarify gem sorting logic by download count
diff --git a/tidings.gemspec b/tidings.gemspec index abc1234..def5678 100644 --- a/tidings.gemspec +++ b/tidings.gemspec @@ -13,11 +13,10 @@ spec.email = ['manfred@fngtpspec.com'] spec.extensions << 'ext/extconf.rb' - spec.files = Dir[ + spec.files = Dir.glob('{bin,lib,ext}/**/*') + [ 'README.rdoc', 'COPYING' ] - spec.extra_rdoc_files = %w( README.rdoc COPYING
Include ext and bin in the gemspec.
diff --git a/config/initializers/abingo.rb b/config/initializers/abingo.rb index abc1234..def5678 100644 --- a/config/initializers/abingo.rb +++ b/config/initializers/abingo.rb @@ -0,0 +1,8 @@+require 'abingo' +Abingo.cache = ActiveSupport::Cache::MemCacheStore.new('localhost', { :namespace => "wheelmap/#{Rails.env}/", + :c_threshold => 10_000, + :compression => true, + :debug => Rails.env.staging?, + :readonly => false, + :urlencode => false + })
Use memcache for Abingo caching.
diff --git a/config/initializers/resque.rb b/config/initializers/resque.rb index abc1234..def5678 100644 --- a/config/initializers/resque.rb +++ b/config/initializers/resque.rb @@ -1,2 +1,7 @@ Resque.redis.namespace = "resque:Cyclescape" Resque.inline = true if Rails.env.test? + +# This seems to be required so that prepared statements don't fail due to +# attempting to be created on the second run of a job. +# https://github.com/defunkt/resque/issues/306#issuecomment-1421034 +Resque.before_fork = Proc.new { ActiveRecord::Base.establish_connection }
Fix AR error in Resque workers.
diff --git a/Casks/iterm2-beta.rb b/Casks/iterm2-beta.rb index abc1234..def5678 100644 --- a/Casks/iterm2-beta.rb +++ b/Casks/iterm2-beta.rb @@ -1,12 +1,13 @@ cask :v1 => 'iterm2-beta' do - version '2.9.20150830' - sha256 '3248adc0281c03d5d367e042bcc373ae673bf5eea55fe181169e5824c8379e42' + version '2.9.20151001' + sha256 '0bfb7fa52a69103f2d1779b3c0af9f443dbd5a249ea83f522a452d84dd605b23' - url 'https://iterm2.com/downloads/beta/iTerm2-2_9_20150830.zip' + url 'https://iterm2.com/downloads/beta/iTerm2-2_9_20151001.zip' + name 'iTerm2' homepage 'https://www.iterm2.com/' license :gpl app 'iTerm.app' - + zap :delete => '~/Library/Preferences/com.googlecode.iterm2.plist' end
Upgrade iTerm2 Beta to v2.9.20151001
diff --git a/providers/common.rb b/providers/common.rb index abc1234..def5678 100644 --- a/providers/common.rb +++ b/providers/common.rb @@ -24,17 +24,16 @@ # Install the application requirements. # If a requirements file has been specified, use pip. # otherwise use the setup.py - # FIXME: Should we use something other than the bash resource? if new_resource.requirements_file - bash 'pip install' do + execute 'pip install' do action :run - code "pip install -r \ - #{new_resource.path}/#{new_resource.requirements_file}" + cwd new_resource.path + command "pip install -r #{new_resource.requirements_file}" end else - bash 'python setup.py' do + execute 'python setup.py install' do action :run - code "python #{new_resource.path}/setup.py install" + cwd new_resource.path end end new_resource.updated_by_last_action(true)
Replace bash resource with execute resource
diff --git a/app/views/results_table_view.rb b/app/views/results_table_view.rb index abc1234..def5678 100644 --- a/app/views/results_table_view.rb +++ b/app/views/results_table_view.rb @@ -3,24 +3,22 @@ NSColor.secondarySelectedControlColor end - def acceptsFirstResponder - false - end - def control(control, textView:textView, doCommandBySelector:commandSelector) - case commandSelector - when :moveUp + case commandSelector.to_s + when 'moveUp:' scrollToRow(selectedRow - 1) - when :moveDown + when 'moveDown:' scrollToRow(selectedRow + 1) - when :insertNewline + when 'insertNewline:' target.rowDoubleClicked(self) if !numberOfRows.zero? - end + else + return false + end; true end def scrollToRow(row, select = true) unless row < 0 or row == numberOfRows - selectColumnIndexes(NSIndexSet.indexSetWithIndex(row), byExtendingSelection:false) if select + selectRowIndexes(NSIndexSet.indexSetWithIndex(row), byExtendingSelection:false) if select scrollRowToVisible(row) end end
Make keyboard navigation in the result view work again.
diff --git a/trends.rb b/trends.rb index abc1234..def5678 100644 --- a/trends.rb +++ b/trends.rb @@ -13,10 +13,8 @@ trends << ["year","total paintings","topic paintings"] - -step = 1800 # Enter the year to begin (default to 1800, as this is when SAAM collections begin to get interesting) - ######### Check each year ######### +step = 1750 # Enter the year to begin (default to 1750, as this is when SAAM collections begin to get interesting) puts "Checking all years since #{step} for `#{TARGET}`" while step < 2012
Revert "Start step at 1800" This reverts commit acfecb6380864fc3df2c96409ee9ccd82e4a3765. Conflicts: trends.rb
diff --git a/qa/qa/support/waiter.rb b/qa/qa/support/waiter.rb index abc1234..def5678 100644 --- a/qa/qa/support/waiter.rb +++ b/qa/qa/support/waiter.rb @@ -3,9 +3,11 @@ module QA module Support module Waiter + DEFAULT_MAX_WAIT_TIME = 60 + module_function - def wait(max: 60, interval: 0.1) + def wait(max: DEFAULT_MAX_WAIT_TIME, interval: 0.1) QA::Runtime::Logger.debug("with wait: max #{max}; interval #{interval}") start = Time.now
Make max wait time a constant So it can be used elsewhere in the code
diff --git a/Casks/colorpicker-skalacolor.rb b/Casks/colorpicker-skalacolor.rb index abc1234..def5678 100644 --- a/Casks/colorpicker-skalacolor.rb +++ b/Casks/colorpicker-skalacolor.rb @@ -1,7 +1,7 @@ class ColorpickerSkalacolor < Cask - url 'http://s3.amazonaws.com/bjango/files/skalacolor/skalacolor1.0.zip' + url 'http://download.bjango.com/skalacolor/' homepage 'http://bjango.com/mac/skalacolor/' - version '1.0' - sha256 '211c32672318f137c4f70835507347eac16e81408440e0e95a85c11a7ac29fc6' + version 'latest' + no_checksum colorpicker 'Skala Color Installer.app/Contents/Resources/SkalaColor.colorPicker' end
Update to use the latest version of Skala Color.
diff --git a/ContentfulManagementAPI.podspec b/ContentfulManagementAPI.podspec index abc1234..def5678 100644 --- a/ContentfulManagementAPI.podspec +++ b/ContentfulManagementAPI.podspec @@ -20,5 +20,5 @@ s.source_files = 'Pod/**/*.{h,m}' s.public_header_files = 'Pod/Headers/*.h' - s.dependency 'ContentfulDeliveryAPI', '~> 1.7.3' + s.dependency 'ContentfulDeliveryAPI', '~> 1.9.3' end
Update required version of the CDA SDK
diff --git a/ruby-gem/crudecumber.gemspec b/ruby-gem/crudecumber.gemspec index abc1234..def5678 100644 --- a/ruby-gem/crudecumber.gemspec +++ b/ruby-gem/crudecumber.gemspec @@ -1,8 +1,8 @@ Gem::Specification.new do |s| s.name = 'crudecumber' - s.version = '0.3.0' + s.version = '0.3.1' s.date = Date.today.to_s - s.summary = 'Crudecumber 0.3.0' + s.summary = "Crudecumber #{s.version}" s.description = "Manually run through your Cucumber scenarios.\n Run exactly as you would run Cucumber but instead use \'crudecumber\' followed by your usual arguments."
Increment gem version to 0.3.1
diff --git a/db/migrate/20180402153329_educator_labels_foreign_key.rb b/db/migrate/20180402153329_educator_labels_foreign_key.rb index abc1234..def5678 100644 --- a/db/migrate/20180402153329_educator_labels_foreign_key.rb +++ b/db/migrate/20180402153329_educator_labels_foreign_key.rb @@ -0,0 +1,5 @@+class EducatorLabelsForeignKey < ActiveRecord::Migration[5.1] + def change + add_foreign_key "educator_labels", "educators", name: "educator_labels_educator_id_fk" + end +end
Add migration for foreign key constraint
diff --git a/spec/bastet/base_spec.rb b/spec/bastet/base_spec.rb index abc1234..def5678 100644 --- a/spec/bastet/base_spec.rb +++ b/spec/bastet/base_spec.rb @@ -13,6 +13,23 @@ @bastet.activate(:banana, group) @bastet.active?(:banana, user).should be_true end + + describe "complex criteria" do + before do + @group = Bastet::Group.new("20_percent") { |entity| (entity.id % 10) < (20 / 10) } + @bastet.activate(:secret_feature, @group) + end + + it "should be true for the user" do + user = mock('user', id: 20) + @bastet.active?(:secret_feature, user).should be_true + end + + it "should be false for the user" do + user = mock('user', id: 19) + @bastet.active?(:secret_feature, user).should be_false + end + end end describe "deactivate" do @@ -27,4 +44,11 @@ @bastet.inactive?(:banana, user).should be_true end end + + describe "default to inactive" do + it "should default to inactive for new features" do + user = mock('user') + @bastet.active?(:unknown_feature, user).should be_false + end + end end
Add test coverage for complex criteria in groups as well as the default behavior
diff --git a/spec/models/task_spec.rb b/spec/models/task_spec.rb index abc1234..def5678 100644 --- a/spec/models/task_spec.rb +++ b/spec/models/task_spec.rb @@ -3,7 +3,46 @@ RSpec.describe Task do let(:task) { build(:task) } + it { should belong_to(:story) } + it { should belong_to(:owner).class_name("User") } + it { should belong_to(:assignment).class_name("User") } + it { should belong_to(:completer).class_name("User") } + + it { should validate_presence_of(:label) } + it { should validate_presence_of(:story_id) } + it "must be valid" do expect(task).to be_valid end + + describe "#assignment_name" do + context "when unassigned" do + it "returns unassigned" do + task = build(:task, assignment: nil) + + expect(task.assignment_name).to eq("unassigned") + end + end + + context "when assigned" do + it "returns the assignees username" do + user = build(:user, username: "harry2003") + task = build(:task, assignment: user) + + expect(task.assignment_name).to eq("harry2003") + end + end + end + + describe "#update_completion_status" do + it "sets a task as completed" do + task = create(:task) + + task.update_completion_status(true, create(:user, username: "harry2006")) + + expect(task.completer.username).to eq("harry2006") + expect(task.completed?).to be(true) + expect(task.completed_on).to be_within(10.seconds).of(Time.zone.now) + end + end end
Add more specs for Tasks
diff --git a/spec/centos/grub_spec.rb b/spec/centos/grub_spec.rb index abc1234..def5678 100644 --- a/spec/centos/grub_spec.rb +++ b/spec/centos/grub_spec.rb @@ -4,6 +4,7 @@ it { should be_file } it { should contain "tsc=reliable" } it { should contain "divider=10" } + it { should contain "GRUB_TIMEOUT=5" } end
Test to ensure 5 second grub timout. IMAGE-543
diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb index abc1234..def5678 100644 --- a/spec/models/post_spec.rb +++ b/spec/models/post_spec.rb @@ -2,9 +2,34 @@ describe Post do + before(:each) do + @post = Post.create!(title: "test", body: "this is a test", author_id: 1) + end -#METHOD TESTS WILL LIVE HERE! + after(:each) do + Post.destroy_all + end + describe "#posted_date" do + it "returns the date of the post in month day year format" do + expect(@post.posted_date).to eq(DateTime.now.strftime("%m-%d-%y")) + end + end + + describe "#search" do + it "returns a post with the same or similiar title" do + expect(Post.search("tes")).to include(@post) + end + + it "returns a post that has something similiar in its body" do + expect(Post.search("this")).to include(@post) + end + + it "does NOT return a post with a non similiar title and non similiar body" do + expect(Post.search("bop")).to_not include(@post) + end + + end describe "validations" do @@ -33,9 +58,6 @@ expect(post.errors).to be_empty end - - end - end
Add post model rspec tests
diff --git a/Library/Contributions/examples/brew-bottle.rb b/Library/Contributions/examples/brew-bottle.rb index abc1234..def5678 100644 --- a/Library/Contributions/examples/brew-bottle.rb +++ b/Library/Contributions/examples/brew-bottle.rb @@ -13,8 +13,8 @@ filename = formula + '-' + version + '.tar.gz' ohai "Bottling #{formula} #{version}..." HOMEBREW_CELLAR.cd do - # Use gzip, much faster than bzip2 and hardly any file size difference - # when compressing binaries. + # Use gzip, faster to compress than bzip2, faster to uncompress than bzip2 + # or an uncompressed tarball (and more bandwidth friendly). safe_system 'tar', 'czf', "#{destination}/#{filename}", "#{formula}/#{version}" end ohai "Bottled #{filename}"
Improve reasoning in brew bottle for using gzip.
diff --git a/lib/active_interaction/attr.rb b/lib/active_interaction/attr.rb index abc1234..def5678 100644 --- a/lib/active_interaction/attr.rb +++ b/lib/active_interaction/attr.rb @@ -5,7 +5,7 @@ raise NoMethodError unless ActiveInteraction.const_defined?(klass) - "ActiveInteraction::#{klass}".constantize + ActiveInteraction.const_get(klass) end def return_nil(allow_nil)
Use const_get instead of constantize
diff --git a/lib/batch/helpers/date_time.rb b/lib/batch/helpers/date_time.rb index abc1234..def5678 100644 --- a/lib/batch/helpers/date_time.rb +++ b/lib/batch/helpers/date_time.rb @@ -0,0 +1,52 @@+ +class Batch + + module Helpers + + # Methods for displaying times/durations + module DateTime + + # Converts the elapsed time in seconds to a string showing days, hours, + # minutes and seconds. + def display_duration(elapsed) + return nil unless elapsed + elapsed = elapsed.round + display = '' + [['days', 86400], ['h', 3600], ['m', 60], ['s', 1]].each do |int, seg| + if elapsed >= seg + count, elapsed = elapsed.divmod(seg) + display << "#{count}#{int.length > 1 && count == 1 ? int[0..-2] : int} " + elsif display.length > 0 + display << "0#{int}" + end + end + display = "0s" if display == '' + display.strip + end + + + # Displays a date/time in abbreviated format, suppressing elements of + # the format string for more recent dates/times. + # + # @param ts [Time, Date, DateTime] The date/time object to be displayed + # @return [String] A formatted representation of the date/time. + def display_timestamp(ts) + return unless ts + ts_date = ts.to_date + today = Date.today + if today - ts_date < 7 + # Date is within the last week + ts.strftime('%a %H:%M:%S') + elsif today.year != ts.year + # Data is from a different year + ts.strftime('%a %b %d %Y %H:%M:%S') + else + ts.strftime('%a %b %d %H:%M:%S') + end + end + + end + + end + +end
Add helper for displaying timestamps and durations
diff --git a/lib/ionic_notification/status_service.rb b/lib/ionic_notification/status_service.rb index abc1234..def5678 100644 --- a/lib/ionic_notification/status_service.rb +++ b/lib/ionic_notification/status_service.rb @@ -26,7 +26,7 @@ private def headers - { 'Content-Type' => 'application/json', 'Authorization' => IonicNotification.ionic_application_api_token } + { 'Content-Type' => 'application/json', 'Authorization' => "Bearer #{IonicNotification.ionic_application_api_token}" } end end end
Update status check to use new Ionic header Fixes "Authorization header is malformed; JWT could not be extracted."
diff --git a/lib/action_cable/channel/redis.rb b/lib/action_cable/channel/redis.rb index abc1234..def5678 100644 --- a/lib/action_cable/channel/redis.rb +++ b/lib/action_cable/channel/redis.rb @@ -9,9 +9,10 @@ end def subscribe_to(redis_channel, callback = nil) - @_redis_channels ||= [] + raise "`ActionCable::Server.pubsub` class method is not defined" unless connection.class.respond_to?(:pubsub) callback ||= -> (message) { broadcast ActiveSupport::JSON.decode(message) } + @_redis_channels ||= [] @_redis_channels << [ redis_channel, callback ] pubsub.subscribe(redis_channel, &callback) @@ -25,7 +26,7 @@ end def pubsub - @connection.class.pubsub + connection.class.pubsub end end
Raise an exception when Server.pubsub class method is not defined
diff --git a/server/config/application.rb b/server/config/application.rb index abc1234..def5678 100644 --- a/server/config/application.rb +++ b/server/config/application.rb @@ -29,8 +29,5 @@ # Do not swallow errors in after_commit/after_rollback callbacks. config.active_record.raise_in_transactional_callbacks = true - - config.api_only = false - config.session_store = :cookie end end
Disable session store and reenable api_only now that Omniauth is gone
diff --git a/test/minitest_helper.rb b/test/minitest_helper.rb index abc1234..def5678 100644 --- a/test/minitest_helper.rb +++ b/test/minitest_helper.rb @@ -1,7 +1,7 @@+require 'coveralls' +Coveralls.wear! + $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__) require 'rubic' require 'minitest/autorun' -require 'coveralls' - -Coveralls.wear!
Fix position of activating coveralls
diff --git a/server.rb b/server.rb index abc1234..def5678 100644 --- a/server.rb +++ b/server.rb @@ -1,5 +1,8 @@ require "sinatra" require "twilio-ruby" + +# Allows this app to be embedded in an iframe. Feel free to remove it. +set :protection, :except => :frame_options get "/" do capability = Twilio::Util::Capability.new ENV["ACCOUNT_SID"], ENV["ACCOUNT_TOKEN"]
Allow to embed this app in an iframe
diff --git a/morandi.gemspec b/morandi.gemspec index abc1234..def5678 100644 --- a/morandi.gemspec +++ b/morandi.gemspec @@ -19,7 +19,7 @@ spec.require_paths = ["lib"] spec.add_dependency "gtk2" - spec.add_dependency "gdk_pixbuf2" + spec.add_dependency "gdk_pixbuf2", "~> 3.4.0" spec.add_dependency "cairo" spec.add_dependency "pixbufutils" spec.add_dependency "redeye"
Add dependency on gdk_pixbuff2 ~> 3.4.0
diff --git a/capitomcat.gemspec b/capitomcat.gemspec index abc1234..def5678 100644 --- a/capitomcat.gemspec +++ b/capitomcat.gemspec @@ -13,7 +13,7 @@ s.authors = ['Sunggun Yu'] s.email = ['sunggun.dev@gmail.com'] s.licenses = ['Apache 2.0'] - s.date = %q{2014-01-11} + s.date = %q{2014-01-24} s.homepage = 'http://sunggun-yu.github.io/capitomcat/' s.summary = %q{Capistrano 3 recipe for Tomcat web application deployment} s.description = %q{Capitomcat is the Capistrano 3 recipe for Tomcat web application deployment.} @@ -21,5 +21,5 @@ s.files = `git ls-files`.split("\n") s.require_paths = ["lib"] - s.add_dependency 'capistrano', '~> 3.0', '>= 3.0.1' + s.add_dependency 'capistrano', '>= 3.1.0' end
Update Capistrano dependency to v3.1.0
diff --git a/test/angular_rails_csrf_test.rb b/test/angular_rails_csrf_test.rb index abc1234..def5678 100644 --- a/test/angular_rails_csrf_test.rb +++ b/test/angular_rails_csrf_test.rb @@ -3,14 +3,9 @@ class AngularRailsCsrfTest < ActionController::TestCase tests ApplicationController - setup do - @controller.allow_forgery_protection = true - @correct_token = @controller.send(:form_authenticity_token) - end - test "a get sets the XSRF-TOKEN cookie but does not require the X-XSRF-TOKEN header" do get :index - assert_equal @correct_token, cookies['XSRF-TOKEN'] + assert_valid_cookie assert_response :success end @@ -28,13 +23,26 @@ end test "a post is accepted if X-XSRF-TOKEN is set properly" do - set_header_to @correct_token + set_header_to @controller.send(:form_authenticity_token) post :create + assert_valid_cookie assert_response :success end + + private + + # Helpers def set_header_to(value) # Rails 3 uses `env` and Rails 4 uses `headers` @request.env['X-XSRF-TOKEN'] = @request.headers['X-XSRF-TOKEN'] = value end + + def assert_valid_cookie + if @controller.respond_to?(:valid_authenticity_token?, true) + assert @controller.send(:valid_authenticity_token?, session, cookies['XSRF-TOKEN']) + else + assert_equal @controller.send(:form_authenticity_token), cookies['XSRF-TOKEN'] + end + end end
Fix tests for Rails 4.2
diff --git a/onkcop.gemspec b/onkcop.gemspec index abc1234..def5678 100644 --- a/onkcop.gemspec +++ b/onkcop.gemspec @@ -19,8 +19,8 @@ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - spec.add_dependency "rubocop", "~> 0.50.0" - spec.add_dependency "rubocop-rspec", ">= 1.18.0" + spec.add_dependency "rubocop", "~> 0.51.0" + spec.add_dependency "rubocop-rspec", ">= 1.19.0" spec.add_development_dependency "bundler" spec.add_development_dependency "rake" end
Update rubocop v0.51.0 and rubocop-rspec v1.19.0
diff --git a/lib/active_admin/sortable/engine.rb b/lib/active_admin/sortable/engine.rb index abc1234..def5678 100644 --- a/lib/active_admin/sortable/engine.rb +++ b/lib/active_admin/sortable/engine.rb @@ -5,7 +5,7 @@ class Engine < ::Rails::Engine engine_name 'activeadmin_sortable_tree' - initializer "Rails precompile hook", group: :assets do |app| + initializer "Rails precompile hook", group: :all do |app| app.config.assets.precompile += [ "active_admin/sortable.css", "active_admin/sortable.js" ] end
Fix assets precompile with config.assets.initialize_on_precompile = true
diff --git a/lib/delayed/serialization/sequel.rb b/lib/delayed/serialization/sequel.rb index abc1234..def5678 100644 --- a/lib/delayed/serialization/sequel.rb +++ b/lib/delayed/serialization/sequel.rb @@ -33,7 +33,7 @@ def init_with(coder) @values = coder["values"] reload - rescue Sequel::Error + rescue ::Sequel::Error raise Delayed::DeserializationError, "Sequel Record not found, class: #{self.class.name} , primary key: #{pk}" end end
Use fully qualified name when rescuing Sequel::Error
diff --git a/core/range/clone_spec.rb b/core/range/clone_spec.rb index abc1234..def5678 100644 --- a/core/range/clone_spec.rb +++ b/core/range/clone_spec.rb @@ -7,14 +7,14 @@ copy.begin.should == 1 copy.end.should == 3 copy.should_not.exclude_end? - copy.object_id.should_not == original.object_id + copy.should_not.equal? original original = ("a"..."z") copy = original.clone copy.begin.should == "a" copy.end.should == "z" copy.should.exclude_end? - copy.object_id.should_not == original.object_id + copy.should_not.equal? original end it "maintains the frozen state" do
Use .should_not.equal? instead of comparing object_id
diff --git a/lib/thinking_sphinx/active_record/sql_source/template.rb b/lib/thinking_sphinx/active_record/sql_source/template.rb index abc1234..def5678 100644 --- a/lib/thinking_sphinx/active_record/sql_source/template.rb +++ b/lib/thinking_sphinx/active_record/sql_source/template.rb @@ -48,6 +48,6 @@ end def primary_key - source.model.primary_key.to_sym + source.options[:primary_key].to_sym end end
Use more general specification of primary key rather than model's primary key.
diff --git a/lib/georgia.rb b/lib/georgia.rb index abc1234..def5678 100644 --- a/lib/georgia.rb +++ b/lib/georgia.rb @@ -24,6 +24,9 @@ mattr_accessor :permissions @@permissions = Georgia::Permissions::DEFAULT_PERMISSIONS + mattr_accessor :roles + @@roles = %w(admin editor contributor guest) + def self.setup yield self end
Add Georgia.roles with default roles
diff --git a/lib/migrate.rb b/lib/migrate.rb index abc1234..def5678 100644 --- a/lib/migrate.rb +++ b/lib/migrate.rb @@ -12,7 +12,7 @@ t.text :error_backtrace t.string :employee_host - t.string :employee_pid + t.integer :employee_pid t.timestamps end
Store employee_pid as an Integer
diff --git a/lib/api_recipes/settings.rb b/lib/api_recipes/settings.rb index abc1234..def5678 100644 --- a/lib/api_recipes/settings.rb +++ b/lib/api_recipes/settings.rb @@ -15,8 +15,7 @@ } DEFAULT_ROUTE_ATTRIBUTES = { - method: :get, - encode_params_as: :json + method: :get } AVAILABLE_PARAMS_ENCODINGS = %w(form params json body)
Fix stupid bug setting json as default params encoding method
diff --git a/config/initializers/omni_auth.rb b/config/initializers/omni_auth.rb index abc1234..def5678 100644 --- a/config/initializers/omni_auth.rb +++ b/config/initializers/omni_auth.rb @@ -4,4 +4,3 @@ require "openid/fetchers" OpenID.fetcher.ca_file = "/etc/ssl/certs/ca-certificates.crt" -OmniAuth.config.full_host = SITE_URL
Revert "try forcing omniauth return url" This reverts commit 7590e0481b65ab4acb4a588315627fe272016098.
diff --git a/config/initializers/recaptcha.rb b/config/initializers/recaptcha.rb index abc1234..def5678 100644 --- a/config/initializers/recaptcha.rb +++ b/config/initializers/recaptcha.rb @@ -0,0 +1,6 @@+Recaptcha.configuration.hostname = ->(hostname) do + ( + Rails.application.config.action_mailer.default_url_options[:host].gsub(/:\d+\z/, '') == hostname || + Convention.where(domain: hostname).any? + ) +end
Add server-side reCAPTCHA hostname validation based on known convention domains + default host
diff --git a/config/initializers/slack_api.rb b/config/initializers/slack_api.rb index abc1234..def5678 100644 --- a/config/initializers/slack_api.rb +++ b/config/initializers/slack_api.rb @@ -7,11 +7,11 @@ client = Slack.realtime client.on :team_join do |data| - puts 'New User Joined' + puts "New User, #{data['user']['name']}, Joined" welcome = "Welcome to slashrocket, <@#{data['user']['id']}>! Type `/rocket` for a quick tour of our channels. :simple_smile:" options = { channel: '#general', text: welcome, as_user: true } Slack.chat_postMessage(options) - puts 'Posted Welcome Message' + puts "Welcomed #{data['user']['name']}" end Thread.new do
Add descriptive console messages for join events
diff --git a/groonga/init.rb b/groonga/init.rb index abc1234..def5678 100644 --- a/groonga/init.rb +++ b/groonga/init.rb @@ -3,13 +3,12 @@ require "feedcellar" resources = YAML.load_file("resources.yaml") +puts "Resources: #{resources}" command = Feedcellar::Command.new -resources.each do |resource| - puts "Registering #{resource}" - command.register(resource) -end +puts "Registering..." +command.register(*resources) puts "Collecting..." command.collect
Reduce number of opening database
diff --git a/lib/takosan.rb b/lib/takosan.rb index abc1234..def5678 100644 --- a/lib/takosan.rb +++ b/lib/takosan.rb @@ -36,6 +36,11 @@ end def logger - @@_logger ||= Rails.logger + @@_logger ||= + if defined?(Rails.logger) + Rails.logger + else + Logger.new($stderr) + end end end
Write logs to stderr if used in non-Rails application
diff --git a/lib/pavlov/alpha_compatibility.rb b/lib/pavlov/alpha_compatibility.rb index abc1234..def5678 100644 --- a/lib/pavlov/alpha_compatibility.rb +++ b/lib/pavlov/alpha_compatibility.rb @@ -37,7 +37,7 @@ end # Add attribute for pavlov_options - attribute :pavlov_options, Hash + attribute :pavlov_options, Hash, default: {} end end end
Set default value for pavlov_options
diff --git a/lib/pipedrive_api/organization.rb b/lib/pipedrive_api/organization.rb index abc1234..def5678 100644 --- a/lib/pipedrive_api/organization.rb +++ b/lib/pipedrive_api/organization.rb @@ -3,7 +3,10 @@ class << self - + def deals(id, **params) + response = get "#{resource_path}/#{id}/deals", query: params + handle response + end end
Add deals method to Organization
diff --git a/lib/special_route_publisher.rb b/lib/special_route_publisher.rb index abc1234..def5678 100644 --- a/lib/special_route_publisher.rb +++ b/lib/special_route_publisher.rb @@ -24,7 +24,7 @@ def self.routes { - prefix: [ + exact: [ { document_type: "answer", content_id: "bb986a97-3b8c-4b1a-89bf-2a9f46be9747",
Change /eubusiness to an exact route [We're getting errors](https://sentry.io/organizations/govuk/issues/1884114207/?environment=production&project=202213&referrer=slack) because router is sending sub paths of /eubusiness to collections. We only have the /eubusiness page right now, so an exact route is the way to go. I'll check about removing the prefix route once this is republished.
diff --git a/robot_name/robot_name.rb b/robot_name/robot_name.rb index abc1234..def5678 100644 --- a/robot_name/robot_name.rb +++ b/robot_name/robot_name.rb @@ -47,6 +47,17 @@ puts "My pet robot's name is #{robot.name}, but we usually call him sparky." # Errors! -# generator = -> { 'AA111' } -# Robot.new(name_generator: generator) -# Robot.new(name_generator: generator) +begin +generator = -> { 'AA111' } +Robot.new(name_generator: generator) +Robot.new(name_generator: generator) +rescue => e + puts "Failed with: #{e.class}: #{e.message}" +end + +begin +generator = -> { 'AA11' } +Robot.new(name_generator: generator) +rescue => e + puts "Failed with: #{e.class}: #{e.message}" +end
Check both errors at once using begin/end This is a bit smelly because this code really belongs in a test instead of at the bottom of the file. However, I want to focus more on the main class itself right now and not so much creating a test. How dare that be typed from my fingers!!!
diff --git a/app/controllers/api/atomic_docs_controller.rb b/app/controllers/api/atomic_docs_controller.rb index abc1234..def5678 100644 --- a/app/controllers/api/atomic_docs_controller.rb +++ b/app/controllers/api/atomic_docs_controller.rb @@ -5,11 +5,12 @@ before_action :validate_api_key, only: %i[documents sessions] def documents - render json: { id: 1234, status: "queued" } + atomic_doc = AtomicDoc.find_or_create_by(url: params[:url], status: "queued") + # render json: { id: atomic_doc.id, status: atomic_doc.status } end def sessions - render json: { id: "CFAmd3Qjm_2ehBI7HyndnXKsDrQXJ7jHCuzcRv" } + # render json: { id: "CFAmd3Qjm_2ehBI7HyndnXKsDrQXJ7jHCuzcRv" } end def view
Add AtomicDoc to the controller
diff --git a/spec/adapter/faraday_spec.rb b/spec/adapter/faraday_spec.rb index abc1234..def5678 100644 --- a/spec/adapter/faraday_spec.rb +++ b/spec/adapter/faraday_spec.rb @@ -3,7 +3,7 @@ describe Faraday::Adapter::RackClient do - let(:url) { URI.join(@base_url, '/faraday') } + let(:url) { @base_url } let(:conn) do Faraday.new(:url => url) do |faraday| @@ -12,7 +12,7 @@ faraday.adapter(:rack_client) do |builder| builder.use Rack::Lint - builder.run Rack::Client::Handler::NetHTTP.new + builder.run LiveServer end end end @@ -39,8 +39,6 @@ end it 'with body' do - pending "Faraday tests a GET request with a POST body, which rack-client forbids." - response = conn.get('echo') do |req| req.body = {'bodyrock' => true} end
Switch the Faraday specs to use the faraday test app directly.
diff --git a/spec/unit/rom/global_spec.rb b/spec/unit/rom/global_spec.rb index abc1234..def5678 100644 --- a/spec/unit/rom/global_spec.rb +++ b/spec/unit/rom/global_spec.rb @@ -2,8 +2,8 @@ describe ROM do describe '.setup' do - it 'allows passing in repository instances' do - klass = Class.new(ROM::Repository) + it 'allows passing in gateway instances' do + klass = Class.new(ROM::Gateway) repo = klass.new setup = ROM.setup(test: repo) @@ -11,4 +11,5 @@ expect(setup.repositories[:test]).to be(repo) end end + end
Remove Repository reference in spec
diff --git a/lib/ruboty/dmm/actions/messenger.rb b/lib/ruboty/dmm/actions/messenger.rb index abc1234..def5678 100644 --- a/lib/ruboty/dmm/actions/messenger.rb +++ b/lib/ruboty/dmm/actions/messenger.rb @@ -5,7 +5,7 @@ def call attachments = Ruboty::DMM::Ranking.new(submedia: message.match_data[:submedia], term: message.match_data[:term]).call term = term_converter(message.match_data[:term]) - message.reply("#{term}の本日のランキングです。", attachments: attachments) + message.reply("#{term}のランキングです。", attachments: attachments) rescue => exception message.reply("Failed by #{exception.class}") end
Remove 'Today's' in the action
diff --git a/Casks/air-video-server.rb b/Casks/air-video-server.rb index abc1234..def5678 100644 --- a/Casks/air-video-server.rb +++ b/Casks/air-video-server.rb @@ -2,9 +2,11 @@ version '2.4.6-beta3u2' sha256 '479af913987a4cc8414969a8d4a4c164a4bd0a22d156829a983b4c58e9dd3f6e' + # amazonaws.com is the official download host per the vendor homepage url "https://s3.amazonaws.com/AirVideo/Air+Video+Server+#{version}.dmg" + name 'Air Video Server' homepage 'http://www.inmethod.com/air-video/' - license :unknown # todo: change license and remove this comment; ':unknown' is a machine-generated placeholder + license :gratis app 'Air Video Server.app' end
AirVideoServer: Update license, add name stanza
diff --git a/typeahead-rails.gemspec b/typeahead-rails.gemspec index abc1234..def5678 100644 --- a/typeahead-rails.gemspec +++ b/typeahead-rails.gemspec @@ -6,8 +6,8 @@ Gem::Specification.new do |spec| spec.name = 'typeahead-rails' spec.version = Typeahead::Rails::VERSION - spec.authors = ['Maksim Berjoza'] - spec.email = ['torbjon@gmail.com'] + spec.authors = ['Maksim Berjoza', 'Luc Donnet'] + spec.email = ['torbjon@gmail.com', 'luc.donnet@free.fr'] spec.description = 'Twitter Typeahead.js with Rails asset pipeline' spec.homepage = 'https://github.com/torbjon/typeahead-rails' spec.summary = 'Twitter Typeahead.js with Rails asset pipeline'
Add author and contact for this gem
diff --git a/Casks/thunderbird-beta.rb b/Casks/thunderbird-beta.rb index abc1234..def5678 100644 --- a/Casks/thunderbird-beta.rb +++ b/Casks/thunderbird-beta.rb @@ -1,8 +1,8 @@ class ThunderbirdBeta < Cask - version '32.0b1' - sha256 '0f66e9cb452293e248d92c9a156c0b81c50e81ba1107922ab6f8b555934e83d3' + version '33.0b1' + sha256 '96db91d29cf5ec4e01e1c877eb804c9894e699e57c0d6d55219b1f53cbdb0dab' - url 'https://download-installer.cdn.mozilla.net/pub/thunderbird/releases/32.0b1/mac/en-US/Thunderbird%2032.0b1.dmg' + url 'https://download-installer.cdn.mozilla.net/pub/thunderbird/releases/33.0b1/mac/en-US/Thunderbird%2033.0b1.dmg' homepage 'https://www.mozilla.org/en-US/thunderbird/all-beta.html' app 'Thunderbird.app'
Update Thunderbird Beta to 33.0b1
diff --git a/app/controllers/admin/article_categories_controller.rb b/app/controllers/admin/article_categories_controller.rb index abc1234..def5678 100644 --- a/app/controllers/admin/article_categories_controller.rb +++ b/app/controllers/admin/article_categories_controller.rb @@ -35,7 +35,7 @@ if @article_category.update_attributes(params[:article_category]) flash[:notice] = 'ArticleCategory was successfully updated.' - format.html redirect_to(admin_article_categories_url) + redirect_to(admin_article_categories_url) else render :edit end
Fix article category edit redirect.
diff --git a/app/controllers/second_level_browse_page_controller.rb b/app/controllers/second_level_browse_page_controller.rb index abc1234..def5678 100644 --- a/app/controllers/second_level_browse_page_controller.rb +++ b/app/controllers/second_level_browse_page_controller.rb @@ -33,7 +33,7 @@ end def page - MainstreamBrowsePage.find( + @page ||= MainstreamBrowsePage.find( "/browse/#{params[:top_level_slug]}/#{params[:second_level_slug]}" ) end
Reduce content store requests for 2nd level browse This reduces the number of content store requests made to render an HTML page in second level browse from 3 to 1, and for a json response from 4 to 1. Example URL: https://www.gov.uk/browse/births-deaths-marriages/death
diff --git a/app/services/organisational_manual_service_registry.rb b/app/services/organisational_manual_service_registry.rb index abc1234..def5678 100644 --- a/app/services/organisational_manual_service_registry.rb +++ b/app/services/organisational_manual_service_registry.rb @@ -1,6 +1,6 @@ class OrganisationalManualServiceRegistry < AbstractManualServiceRegistry - def initialize(dependencies) - @organisation_slug = dependencies.fetch(:organisation_slug) + def initialize(organisation_slug:) + @organisation_slug = organisation_slug end private
Use Ruby keyword args in OrganisationalManualServiceRegistry I think that using language features instead of custom code makes this easier to understand.
diff --git a/lib/pwwka/error_handlers.rb b/lib/pwwka/error_handlers.rb index abc1234..def5678 100644 --- a/lib/pwwka/error_handlers.rb +++ b/lib/pwwka/error_handlers.rb @@ -1,3 +1,8 @@+module Pwwka + module ErrorHandlers + end +end + require_relative "error_handlers/chain" require_relative "error_handlers/base_error_handler" require_relative "error_handlers/crash"
Define Pwwka::ErrorHandlers module to make it requirable
diff --git a/app/helpers/georgia/internationalization_helper.rb b/app/helpers/georgia/internationalization_helper.rb index abc1234..def5678 100644 --- a/app/helpers/georgia/internationalization_helper.rb +++ b/app/helpers/georgia/internationalization_helper.rb @@ -1,7 +1,7 @@ # encoding: UTF-8 module Georgia module InternationalizationHelper - + LOCALES_HASH = {en: "English", fr: "Français"} def locale_name(locale) @@ -17,16 +17,17 @@ current_locale? :en end - def link_to_locale options={}, html_options={} + def link_to_locale options={}, html_options={} options[:text] ||= english? ? "Français" : "English" + options[:text] = sanitize(options[:text]) if options[:sanitize] options[:locale] ||= english? ? :fr : :en html_options[:hreflang] ||= english? ? :fr : :en - + link_to(options[:text], {locale: options[:locale]}, html_options) end - + private - + def current_locale?(locale) I18n.locale == locale end
Add option sanitize to link_to_locale
diff --git a/lib/quick_travel/payment.rb b/lib/quick_travel/payment.rb index abc1234..def5678 100644 --- a/lib/quick_travel/payment.rb +++ b/lib/quick_travel/payment.rb @@ -5,10 +5,6 @@ class Payment < Adapter def payment_type QuickTravel::PaymentType.find(@payment_type_id) - end - - def self.create(options = {}) - post_and_validate("/front_office/bookings/#{options[:booking_id]}/payments.json", options) end def self.get_redirect_url(options)
Remove unused method (URL doesnt exist in QT) Was used by CC-CMS a while ago
diff --git a/web.rb b/web.rb index abc1234..def5678 100644 --- a/web.rb +++ b/web.rb @@ -5,5 +5,9 @@ end post '/' do - puts request.body + request.body.rewind + request_payload = JSON.parse request.body.read + + #do something with request_payload + puts "Text from groupme: "request_payload['text'] end
Add in puts for groupme text
diff --git a/lib/signal_api/short_url.rb b/lib/signal_api/short_url.rb index abc1234..def5678 100644 --- a/lib/signal_api/short_url.rb +++ b/lib/signal_api/short_url.rb @@ -19,7 +19,8 @@ response = post('/api/short_urls.xml', :body => body, - :headers => {'api_token' => SignalApi.api_key, 'Content-Type' => 'application/xml'}) + :format => :xml, + :headers => {'api_token' => SignalApi.api_key}) if response.code == 201 data = response.parsed_response['short_url']
Use the :format option to specify the format
diff --git a/lib/smart_api/controller.rb b/lib/smart_api/controller.rb index abc1234..def5678 100644 --- a/lib/smart_api/controller.rb +++ b/lib/smart_api/controller.rb @@ -2,17 +2,21 @@ module Controller extend ActiveSupport::Concern + include AbstractController::Callbacks include ActionController::ConditionalGet include ActionController::Head include ActionController::Instrumentation include ActionController::MimeResponds include ActionController::Redirecting + include ActionController::Renderers::All include ActionController::Rendering include ActionController::Rescue include ActionController::UrlFor include Rails.application.routes.url_helpers included do + append_view_path Rails.root.join("app", "views") + self.responder = SmartApi::Responder class_attribute :_endpoint_descriptors
Add common modules and allow view rendering
diff --git a/hideable.gemspec b/hideable.gemspec index abc1234..def5678 100644 --- a/hideable.gemspec +++ b/hideable.gemspec @@ -7,7 +7,7 @@ s.platform = Gem::Platform::RUBY s.authors = ['Joe Corcoran'] s.email = ['joecorcoran@gmail.com'] - s.homepage = 'http://github.com/joecorcoran/judge' + s.homepage = 'http://github.com/joecorcoran/hideable' s.summary = "Don't want to destroy your records? Hide them" s.description = 'Enables soft-deletion in ActiveRecord by marking records as hidden'
Remove bad homepage ref in gemspec
diff --git a/lib/hairballs.rb b/lib/hairballs.rb index abc1234..def5678 100644 --- a/lib/hairballs.rb +++ b/lib/hairballs.rb @@ -1,8 +1,10 @@ require_relative 'hairballs/version' +require_relative 'hairballs/helpers' require_relative 'hairballs/theme' +class Hairballs + extend Helpers -class Hairballs def self.themes @themes ||= [] end @@ -17,7 +19,7 @@ def self.use_theme(theme_name) switch_to = themes.find { |theme| theme.name == theme_name } - fail 'meow' unless switch_to + fail "Theme not found: :#{theme_name}." unless switch_to puts "found theme: #{switch_to.name}" switch_to.use!
Use helpers in base class
diff --git a/lib/intrinsic.rb b/lib/intrinsic.rb index abc1234..def5678 100644 --- a/lib/intrinsic.rb +++ b/lib/intrinsic.rb @@ -12,6 +12,7 @@ def initialize(values = {}) @properties = {}.merge self.class.defaults check_properties_of values + values.each { |property, value| send property.to_sym, value } end def to_s
Set each key value as property and value
diff --git a/lib/pig_latin.rb b/lib/pig_latin.rb index abc1234..def5678 100644 --- a/lib/pig_latin.rb +++ b/lib/pig_latin.rb @@ -3,9 +3,10 @@ module PigLatin def PigLatin.translate(text) + if text.nil? then return "Translation will appear here." end pig_arr = text.split(" ") pig_trans_arr = [] - if text.nil? then return "Please enter a stream." end + puts text pig_arr.each do |x| pig_string="" @@ -28,4 +29,3 @@ return pig_trans_arr.join(" ") end end -
Fix nil logic to exit method
diff --git a/lib/transproc.rb b/lib/transproc.rb index abc1234..def5678 100644 --- a/lib/transproc.rb +++ b/lib/transproc.rb @@ -3,23 +3,25 @@ require 'transproc/composer' module Transproc - def self.register(*args, &block) + module_function + + def register(*args, &block) name, fn = *args functions[name] = fn || block end - def self.register_from(mod) + def register_from(mod) (mod.public_methods - Module.public_methods).each do |meth| Transproc.register(meth, mod.method(meth)) end end - def self.functions - @_functions ||= {} + def [](name) + functions.fetch(name) end - def self.[](name) - functions.fetch(name) + def functions + @_functions ||= {} end end
Use module_function in Transproc module
diff --git a/lib/tasks/load_legacy_mappings.rake b/lib/tasks/load_legacy_mappings.rake index abc1234..def5678 100644 --- a/lib/tasks/load_legacy_mappings.rake +++ b/lib/tasks/load_legacy_mappings.rake @@ -13,18 +13,15 @@ begin topic_taxon_id = api.lookup_content_id(base_path: topic_taxon) raise "Lookup failed for #{topic_taxon}" unless topic_taxon_id - topic_taxon_links = api.get_links(topic_taxon_id) legacy_taxon_ids = api.lookup_content_ids(base_paths: legacy_taxons) missing_legacy_taxons = legacy_taxons - legacy_taxon_ids.keys raise "Lookup failed for #{missing_legacy_taxons}" if missing_legacy_taxons.any? - topic_taxon_links["legacy_taxons"] = legacy_taxon_ids.values puts "Adding #{legacy_taxons.count} legacy taxons for #{topic_taxon}" api.patch_links(topic_taxon_id, - links: topic_taxon_links["links"], - bulk_publishing: true, - previous_version: topic_taxon_links["version"]) + links: { legacy_taxons: legacy_taxon_ids.values }, + bulk_publishing: true) rescue StandardError => e puts "Failed to patch #{topic_taxon}: #{e.message}" end
Replace optimistic locking or legacy taxon with specific patch. The patch API for links allows you to specify the specific link set to patch. As the legacy_taxon links are new, there's no possibility of overwriting previous versions.
diff --git a/lib/travis/sidekiq/build_request.rb b/lib/travis/sidekiq/build_request.rb index abc1234..def5678 100644 --- a/lib/travis/sidekiq/build_request.rb +++ b/lib/travis/sidekiq/build_request.rb @@ -21,7 +21,7 @@ def service raise(ProcessingError, "the #{type} payload was empty and could not be processed") unless data - @service ||= Travis::Services::Requests::Receive.new(@user, payload: data, event_type: type, token: credentials['token']) + @service ||= Travis::Service.service(:request, :receive, @user, payload: data, event_type: type, token: credentials['token']) end def type
Use the service force, Luke!
diff --git a/rspec-image.gemspec b/rspec-image.gemspec index abc1234..def5678 100644 --- a/rspec-image.gemspec +++ b/rspec-image.gemspec @@ -18,9 +18,8 @@ spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] - spec.add_dependency "rmagick" - spec.add_dependency "rspec" + spec.add_runtime_dependency "rmagick" + spec.add_runtime_dependency "rspec" spec.add_development_dependency "bundler", "~> 1.6" spec.add_development_dependency "rake" - spec.add_development_dependency "rspec" end
Use add_runtime_dependency instead of add_dependency
diff --git a/lib/dimples.rb b/lib/dimples.rb index abc1234..def5678 100644 --- a/lib/dimples.rb +++ b/lib/dimples.rb @@ -12,7 +12,6 @@ require 'dimples/logger' require 'dimples/frontable' -require 'dimples/writeable' require 'dimples/renderable' require 'dimples/category'
Remove the writeable require statement.
diff --git a/config/initializers/simple_form_foundation.rb b/config/initializers/simple_form_foundation.rb index abc1234..def5678 100644 --- a/config/initializers/simple_form_foundation.rb +++ b/config/initializers/simple_form_foundation.rb @@ -8,7 +8,7 @@ b.optional :min_max b.optional :readonly b.use :label_input - b.use :error, wrap_with: { tag: :small } + b.use :error, wrap_with: { tag: :small, class: 'error' } # Uncomment the following line to enable hints. The line is commented out by default since Foundation # does't provide styles for hints. You will need to provide your own CSS styles for hints.
Configure simple_form to use error class for inputs with error
diff --git a/lib/handler.rb b/lib/handler.rb index abc1234..def5678 100644 --- a/lib/handler.rb +++ b/lib/handler.rb @@ -6,7 +6,6 @@ def self.included(base) base.extend ClassMethods end - module ClassMethods @@ -25,15 +24,16 @@ # Generate a URL-friendly name. # define_method :generate_handle do + str = send(attribute) return nil unless str.is_a?(String) - returning send(attribute) do |str| - str.downcase! - str.strip! - str.gsub!('&', ' and ') # add space for, e.g., "Y&T" - str.delete!('.\'"') # no space - str.gsub!(/\W/, ' ') # space - str.gsub!(/ +/, options[:separator]) - end + #str = ActiveSupport::Inflector.transliterate(str).to_s + str = str.downcase + str = str.strip + str = str.gsub('&', ' and ') # add space for, e.g., "Y&T" + str = str.delete('.\'"') # no space + str = str.gsub(/\W/, ' ') # space + str = str.gsub(/ +/, options[:separator]) + str end ##
Clean up generate_handle implementation and attempt to transliterate.
diff --git a/rummageable.gemspec b/rummageable.gemspec index abc1234..def5678 100644 --- a/rummageable.gemspec +++ b/rummageable.gemspec @@ -13,11 +13,11 @@ s.require_paths = ["lib"] s.summary = "Mediator for apps that want their content to be in the search index" s.test_files = Dir["test/**/*_test.rb"] - s.add_dependency "yajl-ruby" s.add_dependency "multi_json" s.add_dependency "rest-client" s.add_dependency "plek", '>= 0.5.0' s.add_development_dependency "rake" s.add_development_dependency "webmock" s.add_development_dependency "gem_publisher", "1.0.0" + s.add_development_dependency "yajl-ruby", "1.1.0" end
Make yajl-ruby just a development_dependency
diff --git a/db/migrate/20190522180629_add_raw_contents.rb b/db/migrate/20190522180629_add_raw_contents.rb index abc1234..def5678 100644 --- a/db/migrate/20190522180629_add_raw_contents.rb +++ b/db/migrate/20190522180629_add_raw_contents.rb @@ -14,15 +14,8 @@ # Apply HTML cleansing / munging to existing content attributes klass.find_each do |instance| - # if the case was annotated, use the HTMLUtils version that was in place at the point - # that the first annotation was created, maxing out at V3 because V4 onward was only used - # when formatting HTML for exports. If it's not annotated, use the newest HTMLUtils - date = instance.annotated? ? - [instance.annotations.order(created_at: :asc).limit(1).pluck(:created_at)[0], - HTMLUtils::V3::EFFECTIVE_DATE].min : - Date.today # use update_column to avoid touching the timestamps - instance.update_column :content, HTMLUtils.at(date).sanitize(instance.content) + instance.update_column :content, HTMLUtils.sanitize(instance.content) end end end
Use most recent HTMLUtils for all contents in migration The older HTMLUtils versions were proving to be problematic in the way they handled HTML, which is why we iterated on and replaced them, but utilizing them here in order to preserve quirks on which annotations might be dependent is bring with it bigger problems.
diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb index abc1234..def5678 100644 --- a/config/initializers/sidekiq.rb +++ b/config/initializers/sidekiq.rb @@ -1,13 +1,11 @@ Sidekiq.configure_server do |config| config.redis = { - url: ENV['REDIS_PROVIDER'], namespace: "tahi_#{Rails.env}" } end Sidekiq.configure_client do |config| config.redis = { - url: ENV['REDIS_PROVIDER'], namespace: "tahi_#{Rails.env}" } end
Remove `url` key from Sidekiq configuration This way, Sidekiq uses its own conventions to work it out.
diff --git a/plugins/ssh/check-ssh.rb b/plugins/ssh/check-ssh.rb index abc1234..def5678 100644 --- a/plugins/ssh/check-ssh.rb +++ b/plugins/ssh/check-ssh.rb @@ -0,0 +1,56 @@+#! /usr/bin/env ruby +# +# check-ssh +# +# DESCRIPTION: +# Check the status and version of SSH +# +# OUTPUT: +# plain-text +# +# PLATFORMS: +# all +# +# DEPENDENCIES: +# gem: socket +# gem: sensu-plugin +# +# EXAMPLES: +# check-ssh.rb -h <hostname> -p port +# +# NOTES: +# +# LICENSE: +# Copyright 2014 Yieldbot, Inc <devops@yieldbot.com> +# Released under the same terms as Sensu (the MIT license); see LICENSE +# for details. +# + +require 'rubygems' if RUBY_VERSION < '1.9.0' +require 'sensu-plugin/check/cli' +require 'socket' + +class CheckSSH < Sensu::Plugin::Check::CLI + + option :hostname, + description: 'The host you wish to connect to', + short: '-h HOSTNAME', + long: '--hostname HOSTNAME', + default: 'localhost' + + option :port, + description: 'The port you wish to connect to', + short: '-p PORT', + long: '--PORT PORT', + default: '22' + + def socket_output + s = TCPSocket(hostname, port) + data = s.gets.chop + end + + def run + d = socket_output + critical unless d.include('SSH') + end +end
Add new check for ssh
diff --git a/app/controllers/api/timeslots_controller.rb b/app/controllers/api/timeslots_controller.rb index abc1234..def5678 100644 --- a/app/controllers/api/timeslots_controller.rb +++ b/app/controllers/api/timeslots_controller.rb @@ -13,9 +13,11 @@ end def update - @timeslot = Timeslot.find_by(id: safe_params[:id]) - @timeslot.student_id = current_user.id - if @timeslot.save + timeslot = Timeslot.find_by(id: safe_params[:id]) + timeslot.student_id = current_user.id + if timeslot.save + timeslot.send_tutor_scheduling_email + timeslot.send_student_scheduling_email render plain: { message: 'success' } else render plain: { message: 'fail' }
Add Damian's scheduling_email back into api timeslots controller
diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index abc1234..def5678 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -21,4 +21,8 @@ def after_inactive_sign_up_path_for(resource) registration_notify_path end + + def after_update_path_for(resource) + edit_user_registration_path + end end
Update Devise Registrations Update Redirect Update the Devise Registrations controller 'update' action to redirect to the User registration edit path on successful update so that the User is not redirected away from the current page they are viewing.
diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index abc1234..def5678 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -3,14 +3,14 @@ def new # Building the resource with information that MAY BE available from omniauth! - build_resource(:first_name => session[:omniauth] && session[:omniauth]['user_info'] && session[:omniauth]['user_info']['first_name'], + build_resource(:first_name => session[:omniauth] && session[:omniauth]['user_info'] && session[:omniauth]['user_info']['first_name'], :last_name => session[:omniauth] && session[:omniauth]['user_info'] && session[:omniauth]['user_info']['last_name'], :email => session[:omniauth_email] ) - render_with_scope :new + render :new end def create - build_resource + build_resource if session[:omniauth] && @user.errors[:email][0] =~ /has already been taken/ user = User.find_by_email(@user.email) @@ -22,7 +22,7 @@ super session[:omniauth] = nil unless @user.new_record? end - + def build_resource(*args) super
Fix bug with sign_up on registration controller
diff --git a/app/controllers/user_sessions_controller.rb b/app/controllers/user_sessions_controller.rb index abc1234..def5678 100644 --- a/app/controllers/user_sessions_controller.rb +++ b/app/controllers/user_sessions_controller.rb @@ -5,7 +5,7 @@ end def create - @user_session = UserSession.new(params[:user_session]) + @user_session = UserSession.new(session_params) if @user_session.save redirect_to root_path else @@ -17,4 +17,10 @@ current_user_session.destroy redirect_to new_user_session_url end + + private + + def session_params + params.require(:user_session).permit(:email, :password) + end end
Use strong parameters. Required for Authlogic.
diff --git a/app/decorators/billing/account_decorator.rb b/app/decorators/billing/account_decorator.rb index abc1234..def5678 100644 --- a/app/decorators/billing/account_decorator.rb +++ b/app/decorators/billing/account_decorator.rb @@ -15,7 +15,7 @@ def credit_limit_or_none if credit_limit? num = h.number_to_currency(credit_limit) - credit_exceeded? ? content_tag(:span, num, class: "exceeded") : num + credit_exceeded? ? h.content_tag(:span, num, class: "exceeded") : num else "None" end
Fix bug with account page
diff --git a/lib/riemann.rb b/lib/riemann.rb index abc1234..def5678 100644 --- a/lib/riemann.rb +++ b/lib/riemann.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true module Riemann - $LOAD_PATH.unshift __dir__ - require 'rubygems' require 'beefcake' require 'timeout' @@ -12,5 +10,4 @@ require 'riemann/event' require 'riemann/query' require 'riemann/message' - require 'riemann/client' end
Fix warning: circular require considered harmful Running the riemann-tools test suite emit this warning: lib/riemann.rb:15: warning: lib/riemann.rb:15: warning: loading in progress, circular require considered harmful - lib/riemann/client.rb The README.md says one should require 'riemann/client', so let 'riemann/client' load 'riemann', and stop loading 'riemann/client' from 'riemann'. Fix the warning.
diff --git a/lib/ui.rb b/lib/ui.rb index abc1234..def5678 100644 --- a/lib/ui.rb +++ b/lib/ui.rb @@ -23,8 +23,8 @@ io.get_user_input end - def display_winner_message(game_being_played) - io.display_winner_message(game_being_played) + def display_winner_message(rules, game_being_played) + io.display_winner_message(rules, game_being_played) end def display_invalid_input
Add correct paramters so test will pass