diff stringlengths 65 26.7k | message stringlengths 7 9.92k |
|---|---|
diff --git a/app/mailers/tip_mailer.rb b/app/mailers/tip_mailer.rb
index abc1234..def5678 100644
--- a/app/mailers/tip_mailer.rb
+++ b/app/mailers/tip_mailer.rb
@@ -6,7 +6,7 @@ @tip = Tip.find(tip_id)
@user = @tip.to
mail to: @user.email_address,
- subject: "#{@tip.from.username} tipped you #{@tip.cents} coins"
+ subject: "#{@tip.from.username} tipped you #{pluralize(@tip.cents / 100, 'coins')}"
end
end
| Fix subject lines on Tip Emails.
|
diff --git a/spec/dummy/config/routes.rb b/spec/dummy/config/routes.rb
index abc1234..def5678 100644
--- a/spec/dummy/config/routes.rb
+++ b/spec/dummy/config/routes.rb
@@ -19,6 +19,4 @@ end
get '*a' => 'errors#not_found'
-
- get 'index' => 'simplified_format#index'
end
| Remove meaningless line that was leftover.
|
diff --git a/test/integration/default/serverspec/default_spec.rb b/test/integration/default/serverspec/default_spec.rb
index abc1234..def5678 100644
--- a/test/integration/default/serverspec/default_spec.rb
+++ b/test/integration/default/serverspec/default_spec.rb
@@ -25,10 +25,6 @@ it { is_expected.to be_listening }
end
- describe process('rackup') do
- it { is_expected.to be_running }
- end
-
describe 'HTTP response' do
subject { Net::HTTP.new('localhost', 8000).get('/').body }
it { is_expected.to eq 'Hello world' }
| Remove the process check because rackup isn't run directly anymore.
The important thing is that the app works anyway :) |
diff --git a/spec/cask/artifact/binary_spec.rb b/spec/cask/artifact/binary_spec.rb
index abc1234..def5678 100644
--- a/spec/cask/artifact/binary_spec.rb
+++ b/spec/cask/artifact/binary_spec.rb
@@ -55,4 +55,14 @@
Hbc.no_binaries = false
end
+
+ it "creates parent directory if it doesn't exist" do
+ FileUtils.rmdir Hbc.binarydir
+
+ shutup do
+ Hbc::Artifact::Binary.new(cask).install_phase
+ end
+
+ expect(expected_path.exist?).to be true
+ end
end
| Add test for creating binarydir if it doesn't exist
|
diff --git a/spec/ci/reporter/cucumber_spec.rb b/spec/ci/reporter/cucumber_spec.rb
index abc1234..def5678 100644
--- a/spec/ci/reporter/cucumber_spec.rb
+++ b/spec/ci/reporter/cucumber_spec.rb
@@ -0,0 +1,10 @@+# (c) Copyright 2006-2008 Nick Sieger <nicksieger@gmail.com>
+# See the file LICENSE.txt included with the distribution for
+# software license details.
+
+require File.dirname(__FILE__) + "/../../spec_helper.rb"
+require 'stringio'
+
+describe "The Cucumber reporter" do
+ it "should work"
+end
| Add in a place to stick specs for the Cucumber integration.
|
diff --git a/spec/output_context_spec.rb b/spec/output_context_spec.rb
index abc1234..def5678 100644
--- a/spec/output_context_spec.rb
+++ b/spec/output_context_spec.rb
@@ -0,0 +1,26 @@+require "spec_helper"
+
+describe Yarrow::Output::Context do
+ let(:context_hash) do
+ Yarrow::Output::Context.new(number: 99, text: "plain value")
+ end
+
+ class Value
+ def text
+ "nested value"
+ end
+ end
+
+ let(:object_hash) do
+ Yarrow::Output::Context.new(value: Value.new)
+ end
+
+ it 'generates dynamic accessors for hash values on initialization' do
+ expect(context_hash.number).to eq(99)
+ expect(context_hash.text).to eq("plain value")
+ end
+
+ it 'generates dynamic accessors for value objects on initialization' do
+ expect(object_hash.value.text).to eq("nested value")
+ end
+end
| Test dynamic accessor generation for output context class
|
diff --git a/spec/rspec_matchers_spec.rb b/spec/rspec_matchers_spec.rb
index abc1234..def5678 100644
--- a/spec/rspec_matchers_spec.rb
+++ b/spec/rspec_matchers_spec.rb
@@ -0,0 +1,28 @@+require 'spec_helper'
+require 'govuk-content-schema-test-helpers/rspec_matchers'
+
+describe GovukContentSchemaTestHelpers::RSpecMatchers do
+ include GovukContentSchemaTestHelpers::RSpecMatchers
+
+ before do
+ ENV['GOVUK_CONTENT_SCHEMAS_PATH'] = fixture_path
+
+ GovukContentSchemaTestHelpers.configure do |c|
+ c.schema_type = 'publisher'
+ end
+ end
+
+ describe "#be_valid_against_schema" do
+ it "correctly tests valid schemas" do
+ expect(
+ format: "minidisc"
+ ).to be_valid_against_schema('minidisc')
+ end
+
+ it "fails for invalid schemas" do
+ expect(
+ not_format: "not minidisc"
+ ).to_not be_valid_against_schema('minidisc')
+ end
+ end
+end
| Add test for RSpec matcher
Our custom matcher doesn't have a test. This commit fixes that so we
can confidently work on it.
|
diff --git a/lib/sequelizer/connection_maker.rb b/lib/sequelizer/connection_maker.rb
index abc1234..def5678 100644
--- a/lib/sequelizer/connection_maker.rb
+++ b/lib/sequelizer/connection_maker.rb
@@ -22,7 +22,12 @@
# Returns a Sequel connection to the database
def connection
- Sequel.connect(options.to_hash)
+ opts = options.to_hash
+ if url = (opts.delete(:uri) || opts.delete(:url))
+ Sequel.connect(url, opts)
+ else
+ Sequel.connect(options.to_hash)
+ end
end
end
end
| Use URI/URL as a string in Sequel.connect
|
diff --git a/spec/support/bad_tests.rb b/spec/support/bad_tests.rb
index abc1234..def5678 100644
--- a/spec/support/bad_tests.rb
+++ b/spec/support/bad_tests.rb
@@ -27,7 +27,7 @@ duration = Time.zone.now - config.start_time
average = duration / examples
- if duration > 2.minutes || average > 0.25
+ if duration > 2.minutes || average > 0.26
fail "Tests took too long: total=#{duration.to_i}s average=#{average.round(5)}s"
end
end
| Increase test memory limit to stop random failures
|
diff --git a/spec/xml/encoding_spec.rb b/spec/xml/encoding_spec.rb
index abc1234..def5678 100644
--- a/spec/xml/encoding_spec.rb
+++ b/spec/xml/encoding_spec.rb
@@ -10,12 +10,24 @@ it "should output those characters as input via methods" do
res = TestResult.new
res.message = "sadfk одловыа jjklsd " #random russian and english charecters
- res.to_xml.at('message').inner_text.should == "sadfk одловыа jjklsd "
+ doc = ROXML::XML::Document.new
+ doc.root = res.to_xml
+ if defined?(Nokogiri)
+ doc.at('message').inner_text
+ else
+ doc.find_first('message').inner_xml
+ end.should == "sadfk одловыа jjklsd "
end
it "should output those characters as input via xml" do
res = TestResult.from_xml("<test_result><message>sadfk одловыа jjklsd </message></test_result>")
- res.to_xml.at('message').inner_text.should == "sadfk одловыа jjklsd "
+ doc = ROXML::XML::Document.new
+ doc.root = res.to_xml
+ if defined?(Nokogiri)
+ doc.at('message').inner_text
+ else
+ doc.find_first('message').inner_xml
+ end.should == "sadfk одловыа jjklsd "
end
end
end
| Expand on encoding spec a bit to accomodate libxml idosyncracies
|
diff --git a/app/jobs/update_cocoa_pod_from_github_job.rb b/app/jobs/update_cocoa_pod_from_github_job.rb
index abc1234..def5678 100644
--- a/app/jobs/update_cocoa_pod_from_github_job.rb
+++ b/app/jobs/update_cocoa_pod_from_github_job.rb
@@ -1,7 +1,7 @@ class UpdateCocoaPodFromGithubJob
def run
github_updater = GithubUpdater.new
- CocoaPod.all.each do |cocoa_pod|
+ CocoaPod.all.find_each do |cocoa_pod|
puts "sync github #{cocoa_pod.name}"
github_updater.update cocoa_pod
end
| Use batch find in job.
|
diff --git a/app/models/concerns/setup/namespace_named.rb b/app/models/concerns/setup/namespace_named.rb
index abc1234..def5678 100644
--- a/app/models/concerns/setup/namespace_named.rb
+++ b/app/models/concerns/setup/namespace_named.rb
@@ -6,6 +6,9 @@ include CustomTitle
included do
+
+ build_in_data_type.and_polymorphic(label: '{{namespace}} | {{name}}')
+
field :namespace, type: String
field :name, type: String
| Update | Default namespace label for build-in types
|
diff --git a/app/models/renalware/patients/worry_query.rb b/app/models/renalware/patients/worry_query.rb
index abc1234..def5678 100644
--- a/app/models/renalware/patients/worry_query.rb
+++ b/app/models/renalware/patients/worry_query.rb
@@ -13,7 +13,7 @@ def call
search
.result
- .includes(patient: { current_modality: [:description] })
+ .includes(:created_by, patient: { current_modality: [:description] })
.order(created_at: :asc)
.page(query_params[:page])
.per(query_params[:per_page])
| Resolve Worryboard list N+1 issues
|
diff --git a/lib/cms/hippo_importer/about_us.rb b/lib/cms/hippo_importer/about_us.rb
index abc1234..def5678 100644
--- a/lib/cms/hippo_importer/about_us.rb
+++ b/lib/cms/hippo_importer/about_us.rb
@@ -2,7 +2,7 @@ module HippoImporter
class AboutUs < CorporatePage
def hippo_type
- 'contentauthoringwebsite:Static'
+ 'contentauthoringwebsite:StaticPage'
end
end
end
| Fix hippo type name on about us class
|
diff --git a/lib/amistad/config.rb b/lib/amistad/config.rb
index abc1234..def5678 100644
--- a/lib/amistad/config.rb
+++ b/lib/amistad/config.rb
@@ -11,11 +11,11 @@ end
def friendship_model
- "#{self.friend_model}Friendship"
+ "Friendship"
end
def friendship_class
- Amistad::Friendships.const_get(self.friendship_model)
+ Amistad::Friendships::Friendship
end
end
end
| Add support to namespaced friend model
This commit only removes the unecessary dependency of model naming.
It's uneeded to have a friendship_model dependent on friend_model's
name, since it brings problems with namespaced models (e.g.
'User::Profile').
|
diff --git a/lib/ansible/runner.rb b/lib/ansible/runner.rb
index abc1234..def5678 100644
--- a/lib/ansible/runner.rb
+++ b/lib/ansible/runner.rb
@@ -3,6 +3,22 @@ class << self
def run(env_vars, extra_vars, playbook_path)
run_via_cli(env_vars, extra_vars, playbook_path)
+ end
+
+ def run_queue(env_vars, extra_vars, playbook_path, user_id, queue_opts)
+ queue_opts = {
+ :args => [env_vars, extra_vars, playbook_path],
+ :queue_name => "generic",
+ :class_name => name,
+ :method_name => "run",
+ }.merge(queue_opts)
+
+ task_opts = {
+ :action => "Run Ansible Playbook",
+ :userid => user_id,
+ }
+
+ MiqTask.generic_action_with_callback(task_opts, queue_opts)
end
private
| Add a method to queue an Ansible::Runner.run
This adds a way to queue an Ansible::Runner.run and wraps it in a task
so that it can be invoked asynchronously from automate.
|
diff --git a/lib/healthcheck/s3.rb b/lib/healthcheck/s3.rb
index abc1234..def5678 100644
--- a/lib/healthcheck/s3.rb
+++ b/lib/healthcheck/s3.rb
@@ -0,0 +1,16 @@+module Healthcheck
+ class S3
+ def name
+ :s3
+ end
+
+ def status
+ connection = S3FileUploader.connection
+ connection.directories.get(ENV["AWS_S3_BUCKET_NAME"])
+
+ GovukHealthcheck::OK
+ rescue StandardError
+ GovukHealthcheck::CRITICAL
+ end
+ end
+end
| Add AWS S3 healthcheck module
This will be required for the AWS S3 healthcheck.
|
diff --git a/lib/tasks/lucene.rake b/lib/tasks/lucene.rake
index abc1234..def5678 100644
--- a/lib/tasks/lucene.rake
+++ b/lib/tasks/lucene.rake
@@ -7,20 +7,19 @@ source = File.read(file).
gsub(/\n\s*/, ''). # Our JS multiline string implementation :-p
gsub(/\/\*.*?\*\//, '') # And strip multiline comments as well.
- document = JSON.parse source
+
+ document = CouchRest::Design.new JSON.parse(source)
+ document.database = CouchRest::Model::Base.database
document['_id'] ||= "_design/#{File.basename(file, '.js')}"
document['language'] ||= 'javascript'
- db = CouchRest::Model::Base.database
- id = document['_id']
-
- curr = db.get(id) rescue nil
- if curr.nil?
- db.save_doc(document)
+ current = document.database.get(document.id) rescue nil
+ if current.nil?
+ document.save
else
- db.delete_doc(curr)
- db.save_doc(document)
+ current.update(document)
+ current.save
end
end
end
| Refactor design document creation/update using CouchRest::Design
|
diff --git a/lib/kosmos/packages/firespitter.rb b/lib/kosmos/packages/firespitter.rb
index abc1234..def5678 100644
--- a/lib/kosmos/packages/firespitter.rb
+++ b/lib/kosmos/packages/firespitter.rb
@@ -0,0 +1,8 @@+class Firespitter < Kosmos::Package
+ title 'Firespitter'
+ url 'http://addons.cursecdn.com/files/2202/682/Firespitter.zip'
+
+ def install
+ merge_directory '.', into: 'GameData'
+ end
+end
| Add a package for Firespitter.
|
diff --git a/lib/str_sanitizer/html_entities.rb b/lib/str_sanitizer/html_entities.rb
index abc1234..def5678 100644
--- a/lib/str_sanitizer/html_entities.rb
+++ b/lib/str_sanitizer/html_entities.rb
@@ -20,12 +20,15 @@ #
# Params:
# +str+:: A +string+ which needs to be escaped from html entities
+ # +options+:: Options for encoding. You can provide one or more than one option.
+ # If no option is given, :basic option will be used by default.
+ # Options available :basic, :named, :decimal, :hexadecimal
#
# Returns:
# +string+:: An HTML entities escaped +string+
- def html_encode(string)
+ def html_encode(string, *options)
@coder = HTMLEntities.new
- @coder.encode(string)
+ @coder.encode(string, *options)
end
# Decodes the HTML entities of the given string
| Add 'options' param to the html_encode method
|
diff --git a/test/integration/name_controller_supplemental_test.rb b/test/integration/name_controller_supplemental_test.rb
index abc1234..def5678 100644
--- a/test/integration/name_controller_supplemental_test.rb
+++ b/test/integration/name_controller_supplemental_test.rb
@@ -0,0 +1,18 @@+require "test_helper"
+
+# Tests which supplement controller/name_controller_test.rb
+class NameControllerSupplementalTest < IntegrationTestCase
+ # Email tracking template should not contain ":mailing_address"
+ # because, when email is sent, that will be interpreted as
+ # recipient's mailing_address
+ def test_email_tracking_template_no_email_address_symbol
+ visit("/account/login")
+ fill_in("User name or Email address:", with: "rolf")
+ fill_in("Password:", with: "testpassword")
+ click_button("Login")
+
+ visit("/name/email_tracking/#{names(:boletus_edulis).id}")
+ template = find("#notification_note_template")
+ template.assert_no_text(":mailing_address")
+ end
+end
| Write test which fails when `:mailing_address` in email tracking template.
When tracking email is received, `:mailing_address` will be interpreted as
**recipient's** address, asking her to send a specimen to herself.
|
diff --git a/lib/dossier/result.rb b/lib/dossier/result.rb
index abc1234..def5678 100644
--- a/lib/dossier/result.rb
+++ b/lib/dossier/result.rb
@@ -51,8 +51,20 @@ end
result_row.each_with_index.map do |field, i|
- method = "format_#{headers[i]}"
- report.respond_to?(method) ? report.public_send(method, field) : field
+ method_name = "format_#{headers[i]}"
+
+ if report.respond_to?(method_name)
+
+ # Provide the row as context if the formatter takes two arguments
+ if report.method(method_name).arity == 2
+ report.public_send(method_name, field, result_row)
+ else
+ report.public_send(method_name, field)
+ end
+
+ else
+ field
+ end
end
end
end
| Send the row to the formatter if it expects it |
diff --git a/cookbooks/chef/attributes/default.rb b/cookbooks/chef/attributes/default.rb
index abc1234..def5678 100644
--- a/cookbooks/chef/attributes/default.rb
+++ b/cookbooks/chef/attributes/default.rb
@@ -5,7 +5,7 @@ default[:chef][:server][:version] = "12.0.8-1"
# Set the default client version
-default[:chef][:client][:version] = "12.5.1-1"
+default[:chef][:client][:version] = "12.6.0-1"
# A list of gems needed by chef recipes
default[:chef][:gems] = []
| Update chef client to 12.6.0
|
diff --git a/lib/masamune/tasks/hive_thor.rb b/lib/masamune/tasks/hive_thor.rb
index abc1234..def5678 100644
--- a/lib/masamune/tasks/hive_thor.rb
+++ b/lib/masamune/tasks/hive_thor.rb
@@ -13,6 +13,7 @@ desc 'hive', 'Launch a Hive session'
method_option :file, :aliases => '-f', :desc => 'SQL from files'
method_option :exec, :aliases => '-e', :desc => 'SQL from command line'
+ method_option :output, :aliases => '-o', :desc => 'Save SQL output to file'
def hive_exec
hive(options.merge(print: true))
end
| Add option for specifying hive output file
|
diff --git a/lib/specinfra/command/fedora.rb b/lib/specinfra/command/fedora.rb
index abc1234..def5678 100644
--- a/lib/specinfra/command/fedora.rb
+++ b/lib/specinfra/command/fedora.rb
@@ -1,50 +1,28 @@ module SpecInfra
module Command
- class Fedora < Linux
- def check_access_by_user(file, user, access)
- # Redhat-specific
- "runuser -s /bin/sh -c \"test -#{access} #{file}\" #{user}"
+ class Fedora < RedHat
+ def check_enabled(service, target="multi-user.target")
+ host = SpecInfra.configuration.ssh ? SpecInfra.configuration.ssh.host : 'localhost'
+ if property.has_key?(:os_by_host) && property[:os_by_host][host][:release].to_i < 15
+ super
+ else
+ # Fedora 15+ uses systemd which no longer has runlevels but targets
+ # For backwards compatibility, Fedora provides pseudo targets for
+ # runlevels
+ if target.is_a? Integer
+ target = "runlevel#{target}.target"
+ end
+ "systemctl --plain list-dependencies #{target} | grep '^#{escape(service)}.service$'"
+ end
end
- def check_enabled(service, target="multi-user.target")
- # Fedora-specific
- # Fedora uses systemd which no longer has runlevels but targets
- # For backwards compatibility, Fedora provides pseudo targets for
- # runlevels
- if target.is_a? Integer
- target = "runlevel#{target}.target"
+ def check_running(service)
+ host = SpecInfra.configuration.ssh ? SpecInfra.configuration.ssh.host : 'localhost'
+ if property.has_key?(:os_by_host) && property[:os_by_host][host][:release].to_i < 15
+ super
+ else
+ "systemctl is-active #{escape(service)}.service"
end
- "systemctl --plain list-dependencies #{target} | grep '^#{escape(service)}.service$'"
- end
-
- def check_yumrepo(repository)
- "yum repolist all -C | grep ^#{escape(repository)}"
- end
-
- def check_yumrepo_enabled(repository)
- "yum repolist all -C | grep ^#{escape(repository)} | grep enabled"
- end
-
- def check_installed(package,version=nil)
- cmd = "rpm -q #{escape(package)}"
- if version
- cmd = "#{cmd} | grep -w -- #{escape(version)}"
- end
- cmd
- end
-
- alias :check_installed_by_rpm :check_installed
-
- def check_running(service)
- "systemctl is-active #{escape(service)}.service"
- end
-
- def install(package)
- cmd = "yum -y install #{package}"
- end
-
- def get_package_version(package, opts=nil)
- "rpm -qi #{package} | grep Version | awk '{print $3}'"
end
end
end
| Support SysV for Fedora 14 and under and share common functions with RedHat
|
diff --git a/lib/attache/job.rb b/lib/attache/job.rb
index abc1234..def5678 100644
--- a/lib/attache/job.rb
+++ b/lib/attache/job.rb
@@ -5,7 +5,9 @@ config = Attache::VHost.new(env)
config.send(method, args.symbolize_keys)
rescue Exception
- puts "[JOB] #{$!}", $@
+ Attache.logger.error $@
+ Attache.logger.error $!
+ Attache.logger.error [method, args].inspect
self.class.perform_in(RETRY_DURATION, method, env, args)
end
@@ -25,5 +27,6 @@ else
include Sidekiq::Worker
sidekiq_options :queue => :attache_vhost_jobs
+ sidekiq_retry_in {|count| RETRY_DURATION} # uncaught exception, retry after RETRY_DURATION
end
end
| Improve logging on error; also, add retry config in case of uncaught exception
|
diff --git a/lib/istwox/issn.rb b/lib/istwox/issn.rb
index abc1234..def5678 100644
--- a/lib/istwox/issn.rb
+++ b/lib/istwox/issn.rb
@@ -0,0 +1,73 @@+module Istwox
+ class ISSN
+ attr_accessor :code, :original, :ponderated, :check_digit
+
+ NB_CHAR = 8
+ PRIME_NUMBER = 11
+
+ def initialize(original)
+ @original = original if original.is_a? String
+ @ponderated = []
+ @code = []
+ extract_code()
+ end
+
+ def extract_code
+ @original.chars.map do |c|
+ @code.push c.to_i if c[/\d+/]
+ end
+ end
+
+ def first_part
+ @code[0..3].to_s
+ end
+
+ def second_part
+ @code[4..7].to_s
+ end
+
+ def check_digit_char
+ if @check_digit.eql? 10
+ return 'X'
+ else
+ return @check_digit.to_s
+ end
+ end
+
+ def is_valid?
+ @code[-1, 1].first.eql? @check_digit
+ end
+
+ def calculate_ponderated_values
+ nb_char = NB_CHAR
+
+ @code.take(NB_CHAR - 1).each do |c|
+ @ponderated.push(c * nb_char)
+ nb_char = nb_char - 1
+ end
+ end
+
+ def calculate_check_digit
+ calculate_ponderated_values
+
+ sum = 0
+
+ @ponderated.each {|p| sum = sum + p }
+
+ reminder = sum % PRIME_NUMBER
+
+ if reminder.zero?
+ @check_digit = 0
+ else
+ @check_digit = PRIME_NUMBER - reminder
+ end
+
+ @check_digit
+ end
+
+ def to_s
+ 'ISSN ' + first_part() + '-' + second_part()
+ end
+ end
+end
+
| Create firt version of ISSN class
|
diff --git a/backup.rb b/backup.rb
index abc1234..def5678 100644
--- a/backup.rb
+++ b/backup.rb
@@ -34,9 +34,9 @@
if board_to_archive != -1
puts "Would you like to provide a filename? (y/n)"
- response = gets.downcase
-
- if response=="y"
+ response = gets.downcase.chomp
+
+ if response.to_s =="y"
puts "Enter filename:"
filename = gets
else
| Fix code to chomp user input correctly so that it doesn't include newline
|
diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/comments_controller.rb
+++ b/app/controllers/comments_controller.rb
@@ -4,17 +4,19 @@ @trail = Trail.find(params[:trail_id])
@comment = Comment.new
if request.xhr?
- render :_form, locals: {comment: @comment}, layout:false
+ render :_form, locals: {comment: @comment}, layout: false
else
render :new
end
end
def create
+ # binding.pry
@comment = Comment.new(comment_params)
@comment.user_id = current_user.id
- if @comment.save
- redirect_to trail_path(:id => params[:trail_id])
+ if request.xhr? && @comment.save
+ # redirect_to trail_path(:id => params[:comment][:trail_id])
+ render :_form, locals: {comment: @comment}, layout: false
else
render :new
end
| Include logic for ajax request on comment submission
|
diff --git a/lib/reel/server.rb b/lib/reel/server.rb
index abc1234..def5678 100644
--- a/lib/reel/server.rb
+++ b/lib/reel/server.rb
@@ -11,6 +11,7 @@ def initialize(host, port, backlog = DEFAULT_BACKLOG, &callback)
# This is actually an evented Celluloid::IO::TCPServer
@server = TCPServer.new(host, port)
+ @server.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
@server.listen(backlog)
@callback = callback
async.run
| Disable Nagle's algorithm by default.
|
diff --git a/lib/citibike_trips.rb b/lib/citibike_trips.rb
index abc1234..def5678 100644
--- a/lib/citibike_trips.rb
+++ b/lib/citibike_trips.rb
@@ -3,15 +3,17 @@ require 'citibike_trips/stations'
require 'citibike_trips/trip'
require 'citibike_trips/trips'
-require 'highline/import'
+require 'highline'
require 'mechanize'
module CitibikeTrips
LOGIN_URL = 'https://www.citibikenyc.com/login'
- def self.login(page)
+ def self.login(page, options={})
+ stdout = options[:stdout] || $stdout
+ h = HighLine.new($stdin, stdout)
page.form_with(action: LOGIN_URL) do |form|
- form.subscriberUsername = ask('Citi Bike username: ')
- form.subscriberPassword = ask('Citi Bike password: ') {|q| q.echo = false}
+ form.subscriberUsername = h.ask('Citi Bike username: ')
+ form.subscriberPassword = h.ask('Citi Bike password: ') {|q| q.echo = false}
form.click_button(form.button_with(name: 'login_submit'))
end
end
| Allow user to change prompting file descriptor
Primarily useful if the user wants to be prompted on stderr instead of
stdout, if stdout is redirected to a file for example.
|
diff --git a/lib/cucumber/rails.rb b/lib/cucumber/rails.rb
index abc1234..def5678 100644
--- a/lib/cucumber/rails.rb
+++ b/lib/cucumber/rails.rb
@@ -20,3 +20,24 @@
World(Cucumber::Rails::World)
+ActionController::Base.class_eval do
+ cattr_accessor :allow_rescue
+end
+
+ActionDispatch::ShowExceptions.class_eval do
+ alias __cucumber_orig_call__ call
+
+ def call(env)
+ env['action_dispatch.show_exceptions'] = !!ActionController::Base.allow_rescue
+ __cucumber_orig_call__(env)
+ end
+end
+
+Before('@allow-rescue') do
+ @__orig_allow_rescue = ActionController::Base.allow_rescue
+ ActionController::Base.allow_rescue = true
+end
+
+After('@allow-rescue') do
+ ActionController::Base.allow_rescue = @__orig_allow_rescue
+end
| Allow user to control show_exceptions in tests
|
diff --git a/lib/models_watcher.rb b/lib/models_watcher.rb
index abc1234..def5678 100644
--- a/lib/models_watcher.rb
+++ b/lib/models_watcher.rb
@@ -28,8 +28,7 @@
module InstanceMethods
def update_changes_to_apply
- Configuration.changes_to_apply = true
- Configuration.save!
+ Configuration.first.update_attribute(:changes_to_apply, true)
end
end
| Speed up the attribute update
|
diff --git a/lib/onebox/preview.rb b/lib/onebox/preview.rb
index abc1234..def5678 100644
--- a/lib/onebox/preview.rb
+++ b/lib/onebox/preview.rb
@@ -1,6 +1,5 @@ require_relative "preview/example"
require_relative "preview/amazon"
-
module Onebox
class Preview
@@ -12,8 +11,8 @@
def to_s
case @url
- when /example\.com/ then Example
- when /amazon\.com/ then Amazon
+ when /example\.com/ then Example
+ when /amazon\.com/ then Amazon
end.new(@document, @url).to_html
end
| Indent case as deep as when |
diff --git a/lib/tasks/router.rake b/lib/tasks/router.rake
index abc1234..def5678 100644
--- a/lib/tasks/router.rake
+++ b/lib/tasks/router.rake
@@ -22,6 +22,7 @@ %w(/homepage exact),
%w(/tour exact),
%w(/ukwelcomes exact),
+ %w(/visas-immigration exact),
]
routes << %w(/oil-and-gas prefix) if Frontend.industry_sectors_browse_enabled?
| Make sure /visas-immigration is added to the Router
Unfinished business from #508
|
diff --git a/lib/tasks/topics.rake b/lib/tasks/topics.rake
index abc1234..def5678 100644
--- a/lib/tasks/topics.rake
+++ b/lib/tasks/topics.rake
@@ -21,7 +21,7 @@
[Announcement, Publicationesque].each do |edition_type|
logger.info "-- Associating #{edition_type.name.downcase.pluralize} directly with policies' topics"
- edition_type.includes(:policy_topics).find_each do |announcement|
+ edition_type.find_each do |announcement|
TopicTransfer.new(logger, announcement).copy_topics_from_policies
end
end
| Remove includes as it's buggy
@heathd and I have dug into this more - when using `includes(:policy_topics)`
the `class_name` directive for the association isn't used, which causes this to
load WorldwidePriority objects instead of the Policy objects we actually
wanted.
Removing this will make the query slower but won't hit this bug, which
is arguably a bug in ActiveRecord.
The Edition which triggers this the first instance of this error is 160804.
|
diff --git a/lib/when_committed.rb b/lib/when_committed.rb
index abc1234..def5678 100644
--- a/lib/when_committed.rb
+++ b/lib/when_committed.rb
@@ -12,7 +12,7 @@ end
def when_committed!(&block)
- if self.connection.open_transactions > 0
+ if self.class.connection.open_transactions > 0
when_committed(&block)
else
block.call
| Fix method removed in rails 4
ActiveRecord::Base#connection was removed in rails 4; we need to access
the database connection from the class instead of the instance.
|
diff --git a/lib/abcing/scanner.rb b/lib/abcing/scanner.rb
index abc1234..def5678 100644
--- a/lib/abcing/scanner.rb
+++ b/lib/abcing/scanner.rb
@@ -6,29 +6,38 @@ end
def results
- # p class_names contents(app_files)
- p app_class_names
- # { test_scan_results: [],
- # app_letter_matches: app_class_names }
+ test_classes = []
+
+ app_class_names.each do |a|
+ @test_directories.each do |t|
+ entries = test_class_names(a)
+ test_classes << entries unless entries.empty?
+ end
+ end
+
+ result = { test_scan_results: first_letters(test_classes.flatten.uniq),
+ app_letter_matches: first_letters(app_class_names) }
+
+ p result
+ result
end
private
- def app_class_names
- class_names contents(app_files)
+ def test_class_names(app_class_name)
+ contents(test_files).collect { |e| e.scan(/^.*(#{app_class_name}).*$/) }.flatten
end
+ def app_class_names
+ class_names contents(files @app_directories)
+ end
def contents(files)
files.collect { |f| File.read(f) }
end
- def app_files
- files @app_directories
- end
-
def test_files
- files @test_directories
+ files = @test_directories.collect { |dir| Dir["#{dir}/**/*.rb"] }.flatten
end
def files(directories)
@@ -38,5 +47,9 @@ def class_names(file_contents)
ABCing::ClassNameFinder.new(file_contents).find
end
+
+ def first_letters(class_names)
+ ABCing::AlphabetMatch.new(class_names).letters
+ end
end
end
| Fix up test class name finding to be based on app classes previously found
|
diff --git a/lib/backlogjp/base.rb b/lib/backlogjp/base.rb
index abc1234..def5678 100644
--- a/lib/backlogjp/base.rb
+++ b/lib/backlogjp/base.rb
@@ -34,7 +34,7 @@ attributes = self.class.instance_variable_get(:@attributes)
attributes.each do |var|
- instance_variable_set(:"@#{var}", hash[var.to_s])
+ instance_variable_set(:"@#{var}", hash[var.to_s] || hash[var.to_sym])
end
end
| Allow symbol-keyed hashes in creating objects |
diff --git a/lib/filmbuff/title.rb b/lib/filmbuff/title.rb
index abc1234..def5678 100644
--- a/lib/filmbuff/title.rb
+++ b/lib/filmbuff/title.rb
@@ -4,16 +4,16 @@ :poster_url, :genres, :release_date
def initialize(options = {})
- @imdb_id = options["tconst"]
- @title = options["title"]
- @tagline = options["tagline"]
- @plot = options["plot"]["outline"] if options["plot"]
- @runtime = options["runtime"]["time"] if options["runtime"]
- @rating = options["rating"]
- @votes = options["num_votes"]
- @poster_url = options["image"]["url"] if options["image"]
- @genres = options["genres"] || []
- @release_date = Date.strptime(options["release_date"]["normal"], '%Y-%m-%d')
+ @imdb_id = options['tconst']
+ @title = options['title']
+ @tagline = options['tagline']
+ @plot = options['plot']['outline'] if options['plot']
+ @runtime = options['runtime']['time'] if options['runtime']
+ @rating = options['rating']
+ @votes = options['num_votes']
+ @poster_url = options['image']['url'] if options['image']
+ @genres = options['genres'] || []
+ @release_date = Date.strptime(options['release_date']['normal'], '%Y-%m-%d')
end
end
end
| Replace double quotes with single quotes
|
diff --git a/lib/kosmos/web/app.rb b/lib/kosmos/web/app.rb
index abc1234..def5678 100644
--- a/lib/kosmos/web/app.rb
+++ b/lib/kosmos/web/app.rb
@@ -18,6 +18,10 @@ post '/' do
Kosmos.configure do |config|
config.output_method = Proc.new do |str|
+ # Send to STDOUT
+ puts str
+
+ # And to the in-browser UI
str.split("\n").each do |line|
settings.connection << "data: #{line}\n\n"
end
| Send Util.log to both STDOUT and UI when in server mode.
|
diff --git a/lib/logsaber/entry.rb b/lib/logsaber/entry.rb
index abc1234..def5678 100644
--- a/lib/logsaber/entry.rb
+++ b/lib/logsaber/entry.rb
@@ -46,20 +46,21 @@ secondary.map{|item| analyze item }.join ' | '
end
- def analyze object
- object.is_a?(String) ? object : object.inspect
+ def view object
+ viewable?(object) ? object.to_s : object.inspect
end
- def view object
- if object.nil? || object.empty? || viewable?(object) then
- object.to_s
- else
- object.inspect
- end
+ def analyze object
+ analyzeable?(object) ? object : object.inspect
end
def viewable? object
- [String, Symbol, Numeric].any?{|klass| object.is_a? klass}
+ object && (analyzeable?(object) || object.is_a?(Symbol))
end
+
+ def analyzeable? object
+ object.is_a?(String) && !object.empty?
+ end
+
end
end
| Improve handling of nil and empty objects.
- Numeric#to_s or #inspect looks the same, so don't bother
distinguishing
- Realized nil.to_s gives an empty string, which is not helpful,
nil.inspect actually tells us we're nil
- Since we always want to inspect empty Strings, we can reuse the code
for both view and analyze in the analyzeable? method
|
diff --git a/lib/lita-pagerduty.rb b/lib/lita-pagerduty.rb
index abc1234..def5678 100644
--- a/lib/lita-pagerduty.rb
+++ b/lib/lita-pagerduty.rb
@@ -1,7 +1,7 @@ require 'lita'
Lita.load_locales Dir[File.expand_path(
- File.join('..', '..', 'locales', '*.yml'), __FILE__
+ File.join('..', '..', 'locales', '*.yml'), __FILE__
)]
require 'pagerduty'
| Remove extra spacing to get the build passing
|
diff --git a/spec/shard_monitor/config_spec.rb b/spec/shard_monitor/config_spec.rb
index abc1234..def5678 100644
--- a/spec/shard_monitor/config_spec.rb
+++ b/spec/shard_monitor/config_spec.rb
@@ -4,7 +4,7 @@ RSpec.describe ShardMonitor::Config do
subject { ShardMonitor::Config.new }
- let(:argv) { %w(--redis redis://blah.com/5) }
+ let(:argv) { %w(--redis redis://blah.com/5 --table thingy) }
before do
subject.parse_options argv
@@ -12,5 +12,6 @@
it 'takes command line arguments' do
expect(subject.redis).to eq('redis://blah.com/5')
+ expect(subject.table_name).to eq('thingy')
end
end
| Fix config spec for table name |
diff --git a/spec/shared/operation_behavior.rb b/spec/shared/operation_behavior.rb
index abc1234..def5678 100644
--- a/spec/shared/operation_behavior.rb
+++ b/spec/shared/operation_behavior.rb
@@ -4,7 +4,9 @@ end
it 'is idempotent on equivalency' do
- should eql(instance_eval(&self.class.subject))
+ first = subject
+ __memoized.delete(:subject)
+ should eql(first)
end
its(:scalar) { should be_kind_of(::Rational) }
| Update shared spec to fit into newest rspec api
|
diff --git a/spec/unit/recipes/default_spec.rb b/spec/unit/recipes/default_spec.rb
index abc1234..def5678 100644
--- a/spec/unit/recipes/default_spec.rb
+++ b/spec/unit/recipes/default_spec.rb
@@ -3,7 +3,7 @@ platforms = [
{
platform: 'debian',
- version: '9.3',
+ version: '9',
package: 'cron',
},
{
@@ -18,12 +18,12 @@ },
{
platform: 'fedora',
- version: '27',
+ version: '30',
package: 'cronie',
},
{
platform: 'centos',
- version: '7.4.1708',
+ version: '7',
package: 'cronie',
},
{
@@ -37,13 +37,13 @@ package: 'cronie',
},
{
- platform: 'suse',
- version: '11.4',
- package: 'cron',
+ platform: 'opensuse',
+ version: '15',
+ package: 'cronie',
},
{
platform: 'suse',
- version: '12.3',
+ version: '12',
package: 'cronie',
},
]
| Update specs for newer platforms
Signed-off-by: Tim Smith <764ef62106582a09ed09dfa0b6bff7c05fd7d1e4@chef.io>
|
diff --git a/spec/unit/recipes/default_spec.rb b/spec/unit/recipes/default_spec.rb
index abc1234..def5678 100644
--- a/spec/unit/recipes/default_spec.rb
+++ b/spec/unit/recipes/default_spec.rb
@@ -2,8 +2,8 @@
describe 'default recipe' do
let(:chef_run) do
- runner = ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '16.04')
- runner.converge('kickstart::default')
+ runner = ChefSpec::ServerRunner.new(platform: 'centos', version: '6.8')
+ runner.converge('kickstart::server')
end
it 'converges successfully' do
| Test the correct recipe and test on RHEL not Ubuntu
Signed-off-by: Tim Smith <764ef62106582a09ed09dfa0b6bff7c05fd7d1e4@chef.io>
|
diff --git a/vmdb/app/models/file_depot_smb.rb b/vmdb/app/models/file_depot_smb.rb
index abc1234..def5678 100644
--- a/vmdb/app/models/file_depot_smb.rb
+++ b/vmdb/app/models/file_depot_smb.rb
@@ -5,7 +5,7 @@
def self.validate_settings(settings)
res = MiqSmbSession.new(settings).verify
- raise "Log Depot Settings validation failed with error: #{res.last}" unless res.first
+ raise "Depot Settings validation failed with error: #{res.last}" unless res.first
res
end
end
| Fix the log message about depot settings.
Which is used by both log depot and DB backup.
https://bugzilla.redhat.com/show_bug.cgi?id=1173213
|
diff --git a/lib/tasks/assets.rake b/lib/tasks/assets.rake
index abc1234..def5678 100644
--- a/lib/tasks/assets.rake
+++ b/lib/tasks/assets.rake
@@ -0,0 +1,50 @@+require 'active_support/ordered_options'
+
+namespace :half_pipe do
+
+ half_pipe = ActiveSupport::OrderedOptions.new
+
+ task :clean do
+ Rake::Task["half_pipe:environment"].invoke
+ Rake::Task["half_pipe:execute_grunt_command"].invoke("clean")
+ end
+
+ task :execute_grunt_command, [:command] => ["half_pipe:environment",
+ "half_pipe:generate_grunt_runner"] do |_,params|
+ half_pipe.grunt_command = "#{half_pipe.grunt_runner} #{params[:command]}"
+ puts "executing: #{half_pipe.grunt_command.inspect}"
+ system half_pipe.grunt_command
+ end
+
+ task :generate_grunt_runner do
+ paths = %W(#{half_pipe.cwd} node_modules .bin grunt)
+ half_pipe.grunt_runner = File.join(*paths)
+ end
+
+ task :environment do
+
+ # For great Capistrano
+ half_pipe.cwd = (respond_to?(:release_path) ? release_path : Dir.pwd)
+
+ end
+
+ namespace :precompile do
+
+ task :noop
+
+ task :all do
+ Rake::Task["half_pipe:environment"].invoke
+ Rake::Task["half_pipe:execute_grunt_command"].invoke("build")
+ end
+
+ end
+
+ desc "Precompile half-pipe-managed assets"
+ task :precompile => ["half_pipe:precompile:all"]
+
+end
+
+task "assets:precompile" => ["half_pipe:precompile"]
+task "assets:clean" => ["half_pipe:clean"]
+task "assets:clobber" => ["half_pipe:clean"]
+task "assets:environemnt" => ["half_pipe:environment"]
| Add rake tasks for great deployments
|
diff --git a/lib/valanga/client.rb b/lib/valanga/client.rb
index abc1234..def5678 100644
--- a/lib/valanga/client.rb
+++ b/lib/valanga/client.rb
@@ -7,7 +7,7 @@
LOGIN_PAGE = "https://p.eagate.573.jp/gate/p/login.html"
- attr_reader :session
+ attr_reader :session, :pages
def initialize(username, password)
Capybara.register_driver :poltergeist do |app|
@@ -15,6 +15,7 @@ end
@session = Capybara::Session.new(:poltergeist)
+ @pages = {}
login!(username, password)
end
| Add `@page` instance
* to cache the music info page url
|
diff --git a/db/data_migration/20170628130725_redirect_organisations_to_slash_world.rb b/db/data_migration/20170628130725_redirect_organisations_to_slash_world.rb
index abc1234..def5678 100644
--- a/db/data_migration/20170628130725_redirect_organisations_to_slash_world.rb
+++ b/db/data_migration/20170628130725_redirect_organisations_to_slash_world.rb
@@ -0,0 +1,6 @@+# Redirect the current finder sitting at /government/world/organisations to the new location
+
+content_id = "b8faa6b3-e9b0-41fb-a415-92af505277ca"
+destination = "/world/organisations"
+
+PublishingApiRedirectWorker.new.perform(content_id, destination, I18n.default_locale.to_s)
| Add migration to redirect organisations
Currently a finder exists at /government/world/organisations.
We are moving all things under /goverment/world to /world.
As such we must send a redirect to the Publishing Api so that
/government/world/organisations redirects to /world/organisations
|
diff --git a/app/models/spree/order_updater_decorator.rb b/app/models/spree/order_updater_decorator.rb
index abc1234..def5678 100644
--- a/app/models/spree/order_updater_decorator.rb
+++ b/app/models/spree/order_updater_decorator.rb
@@ -0,0 +1,6 @@+Spree::OrderUpdater.class_eval do
+ # Override spree method to make it update all adjustments as in Spree v2.0.4
+ def update_shipping_adjustments
+ order.adjustments.reload.each { |adjustment| adjustment.update! }
+ end
+end
| Make OrderUpdate update all adjustments again as in v2.0.4 otherwise adjustments that are not shipment adjustments will not be calculated correctly
|
diff --git a/lib/bencode/parser.rb b/lib/bencode/parser.rb
index abc1234..def5678 100644
--- a/lib/bencode/parser.rb
+++ b/lib/bencode/parser.rb
@@ -7,11 +7,14 @@ end
def self.parse(scanner)
- new(scanner).parse!
+ val = new(scanner).parse!
+
+ raise BEncode::DecodeError if val.nil?
+
+ return val
end
def parse!
- val = \
case scanner.peek(1)[0]
when ?i
parse_integer!
@@ -22,10 +25,6 @@ when ?0 .. ?9
parse_string!
end
-
- raise BEncode::DecodeError if val.nil?
-
- val
end
private
| Move error handling up in the call chain
|
diff --git a/spec/dcell/node_spec.rb b/spec/dcell/node_spec.rb
index abc1234..def5678 100644
--- a/spec/dcell/node_spec.rb
+++ b/spec/dcell/node_spec.rb
@@ -2,6 +2,8 @@
describe DCell::Node do
before do
+ fail "testing that failed tests break the build on travis"
+
@node = DCell::Node['test_node']
@node.id.should == 'test_node'
end
| Test failed builds on Travis
|
diff --git a/spec/is_crawler_spec.rb b/spec/is_crawler_spec.rb
index abc1234..def5678 100644
--- a/spec/is_crawler_spec.rb
+++ b/spec/is_crawler_spec.rb
@@ -1,12 +1,50 @@ describe IsCrawler do
+ let(:user_agent) { "Commodo Vestibulum/1.0" }
describe '#is_any_crawler?' do
- let(:user_agent) { "Commodo Vestibulum/1.0" }
subject { Test.new.is_any_crawler?(user_agent) }
it 'defers to Crawler#matches_any?' do
Crawler.should_receive(:matches_any?).with(user_agent)
subject
end
end
+
+ describe '#is_crawler?' do
+ subject { Test.new.is_crawler?(user_agent, :facebook, :google) }
+ context 'When the provided string matches a crawler' do
+ context 'and it is in the specified list' do
+ context 'as the first element' do
+ let(:user_agent) { "facebookexternalhit/1.1" }
+ it { should be_true }
+ end
+
+ context 'as a subsequent element' do
+ let(:user_agent) { "Googlebot/1.1" }
+ it { should be_true }
+ end
+ end
+
+ context 'and it is not in the specified list' do
+ let(:user_agent) { "Twitterbot/1.1" }
+ it { should be_false }
+ end
+ end
+
+ context 'When the provided string matches no crawlers' do
+ it { should be_false }
+ end
+ end
+
+ describe '#which_crawler' do
+ subject { Test.new.which_crawler(user_agent) }
+ context 'When the provided string matches a crawler' do
+ let(:user_agent) { "facebookexternalhit/1.1" }
+ its(:name) { should == :facebook }
+ end
+
+ context 'When the provided string matches no crawlers' do
+ it { should be_nil }
+ end
+ end
end
class Test; include IsCrawler; end
| Add more test coverage for is_crawler.rb
|
diff --git a/mixlib-config.gemspec b/mixlib-config.gemspec
index abc1234..def5678 100644
--- a/mixlib-config.gemspec
+++ b/mixlib-config.gemspec
@@ -14,7 +14,8 @@ "LICENSE",
"README.md"
]
- s.files = [ "LICENSE", "NOTICE", "README.md", "Gemfile", "Rakefile" ] + Dir.glob("{lib,spec}/**/*")
+ s.files = [ "LICENSE", "NOTICE", "README.md", "Gemfile", "Rakefile" ] + Dir.glob("*.gemspec") +
+ Dir.glob("{lib,spec}/**/*", File::FNM_DOTMATCH).reject {|f| File.directory?(f) }
s.homepage = "http://www.chef.io"
s.require_paths = ["lib"]
s.rubygems_version = "1.8.23"
| Add gemspec files to allow bundler to run from the gem
|
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index abc1234..def5678 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -9,7 +9,7 @@ end
def home_page_title
- if @current_user.unread_count > 0
+ if @current_user and @current_user.unread_count > 0
"(#{@current_user.unread_count}) CSH WebNews"
else
'CSH WebNews'
| Fix maintenance page not working
|
diff --git a/app/controllers/tips_controller.rb b/app/controllers/tips_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/tips_controller.rb
+++ b/app/controllers/tips_controller.rb
@@ -25,6 +25,7 @@ end
def edit
+ redirect_to tip_path(@tip), alert: "That's not yours to edit!" unless can? :update, @tip
end
def update
@@ -38,6 +39,7 @@ end
def destroy
+ redirect_to tip_path(@tip), alert: "That's not yours to delete!" unless can? :destroy, @tip
end
def send_destroy_email
| Fix security issue with updating and deleting other users tips
|
diff --git a/app/policies/application_policy.rb b/app/policies/application_policy.rb
index abc1234..def5678 100644
--- a/app/policies/application_policy.rb
+++ b/app/policies/application_policy.rb
@@ -62,9 +62,9 @@ teacher? && user.as_teacher
end
- # def student
- # student? && user.as_student
- # end
+ def student
+ student? && user
+ end
class Scope
attr_reader :user, :scope
| Fix time table for students |
diff --git a/lib/mumukit/runner.rb b/lib/mumukit/runner.rb
index abc1234..def5678 100644
--- a/lib/mumukit/runner.rb
+++ b/lib/mumukit/runner.rb
@@ -33,6 +33,7 @@ [Mumukit::Directives::Sections.new,
Mumukit::Directives::Interpolations.new('test'),
Mumukit::Directives::Interpolations.new('extra'),
+ Mumukit::Directives::Interpolations.new('content'),
Mumukit::Directives::Flags.new],
config.comment_type)
else
| Add content interpolation directive to pipeline
|
diff --git a/multi_json.gemspec b/multi_json.gemspec
index abc1234..def5678 100644
--- a/multi_json.gemspec
+++ b/multi_json.gemspec
@@ -1,20 +1,20 @@ # coding: utf-8
-require File.expand_path('../lib/multi_json/version.rb', __FILE__)
+require File.expand_path("../lib/multi_json/version.rb", __FILE__)
Gem::Specification.new do |spec|
- spec.authors = ['Michael Bleigh', 'Josh Kalderimis', 'Erik Michaels-Ober', 'Pavel Pravosud']
- spec.cert_chain = %w(certs/rwz.pem)
- spec.summary = 'A common interface to multiple JSON libraries.'
- spec.description = 'A common interface to multiple JSON libraries, including Oj, Yajl, the JSON gem (with C-extensions), the pure-Ruby JSON gem, NSJSONSerialization, gson.rb, JrJackson, and OkJson.'
- spec.email = %w(michael@intridea.com josh.kalderimis@gmail.com sferik@gmail.com pavel@pravosud.com)
- spec.files = Dir['CHANGELOG.md', 'CONTRIBUTING.md', 'LICENSE.md', 'README.md', 'multi_json.gemspec', 'lib/**/*']
- spec.homepage = 'http://github.com/intridea/multi_json'
- spec.license = 'MIT'
- spec.name = 'multi_json'
- spec.require_path = 'lib'
- spec.signing_key = File.expand_path('~/.ssh/gem-private_key.pem') if $PROGRAM_NAME =~ /gem\z/
+ spec.authors = ["Michael Bleigh", "Josh Kalderimis", "Erik Michaels-Ober", "Pavel Pravosud"]
+ spec.email = %w[michael@intridea.com josh.kalderimis@gmail.com sferik@gmail.com pavel@pravosud.com]
+ spec.cert_chain = %w[certs/rwz.pem]
+ spec.summary = "A common interface to multiple JSON libraries."
+ spec.description = "A common interface to multiple JSON libraries, including Oj, Yajl, the JSON gem (with C-extensions), the pure-Ruby JSON gem, NSJSONSerialization, gson.rb, JrJackson, and OkJson."
+ spec.files = Dir["*.md", "lib/**/*"]
+ spec.homepage = "http://github.com/intridea/multi_json"
+ spec.license = "MIT"
+ spec.name = "multi_json"
+ spec.require_path = "lib"
+ spec.signing_key = File.expand_path("~/.ssh/gem-private_key.pem") if $PROGRAM_NAME =~ /gem\z/
spec.version = MultiJson::Version
- spec.required_rubygems_version = '>= 1.3.5'
- spec.add_development_dependency 'bundler', '~> 1.0'
+ spec.required_rubygems_version = ">= 1.3.5"
+ spec.add_development_dependency "bundler", "~> 1.0"
end
| Tidy up gemspec a bit
|
diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/pages_controller.rb
+++ b/app/controllers/pages_controller.rb
@@ -1,3 +1,4 @@+
class PagesController < ApplicationController
include HighVoltage::StaticPage
@@ -6,11 +7,6 @@ private
def layout_for_page
- case params[:id]
- when 'landing'
- 'landing'
- else
- 'application'
- end
+ 'application'
end
end
| Switch to using nav on home page.
|
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -23,8 +23,10 @@ return
end
- UserFetchJob.perform_later(@organization.id)
- @organization.update(queued_at: Time.now)
+ ActiveRecord::Base.transaction do
+ @organization.update(queued_at: Time.now)
+ UpdateUserJob.perform_later(@organization.id)
+ end
redirect_to user_path(@organization), notice: 'Update request is successfully queued. Please wait a moment.'
end
@@ -35,8 +37,10 @@ return
end
- UserFetchJob.perform_later(current_user.id)
- current_user.update(queued_at: Time.now)
+ ActiveRecord::Base.transaction do
+ current_user.update(queued_at: Time.now)
+ UpdateUserJob.perform_later(current_user.id)
+ end
redirect_to current_user, notice: 'Update request is successfully queued. Please wait a moment.'
end
| Migrate from Sidekiq to Java worker
|
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -16,7 +16,7 @@ def show
@user = User.find(session[:user_id])
@topics = @user.topics
- redirect_to new_topics_path if @topics.length == 0
+ redirect_to new_topic_path if @topics.length == 0
end
def login
| Fix redirect path if a user has no topics
|
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -17,6 +17,7 @@ end
def show
+ @user = User.find_by(id:) user_params[:id]
end
def update
@@ -32,4 +33,4 @@ end
-end+end
| Create action for user show
|
diff --git a/app/controllers/votes_controller.rb b/app/controllers/votes_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/votes_controller.rb
+++ b/app/controllers/votes_controller.rb
@@ -2,13 +2,28 @@
def create
@vote = Vote.new(vote_params)
- @question = Question.find(params[:vote][:votable_id])
- if @vote.save
- redirect_to question_path(@question)
- else
- flash[:notice] = @vote.errors.full_messages.join(", ")
- render 'questions/show.html.erb'
+ type = (params[:vote][:votable_type])
+ if type == "Question"
+ @question = Question.find(params[:vote][:votable_id])
+ end
+ if type == "Response"
+ response = Response.find(params[:vote][:votable_id])
+ if response.respondable_type == "Question"
+ @question = Question.find(response.respondable_id)
end
+ if response.respondable_type == "Answer"
+ @question = Answer.find(response.respondable_id).question
+ end
+ end
+ if type == "Answer"
+ @question = Answer.find(params[:vote][:votable_id]).question
+ end
+ if @vote.save
+ redirect_to question_path(@question)
+ else
+ flash[:notice] = @vote.errors.full_messages.join(", ")
+ render 'questions/show.html.erb'
+ end
end
def vote_params
| Update votes controller to handle question voting and response voting on create action
|
diff --git a/lib/timecrunch/cli.rb b/lib/timecrunch/cli.rb
index abc1234..def5678 100644
--- a/lib/timecrunch/cli.rb
+++ b/lib/timecrunch/cli.rb
@@ -5,7 +5,7 @@
desc "start MINUTES", "Starts a new timer for MINUTES"
option :s, :banner => "seconds"
- def start(minutes)
+ def start(minutes=0)
seconds = options[:s].to_i if options[:s]
minutes = minutes.to_i
times = {
| Add default 0 minutes if minutes aren't supplied
It would be convenient to not have to include minutes if all you want is
just to use the seconds argument.
|
diff --git a/cookbooks/universe_ubuntu/test/recipes/default_test.rb b/cookbooks/universe_ubuntu/test/recipes/default_test.rb
index abc1234..def5678 100644
--- a/cookbooks/universe_ubuntu/test/recipes/default_test.rb
+++ b/cookbooks/universe_ubuntu/test/recipes/default_test.rb
@@ -29,7 +29,7 @@ end
end
-describe file '/tmp/kitchen/cache/Anaconda3-4.2.0-Linux-x86_64.sh' do
+describe file "#{Chef::Config[:file_cache_path]}/Anaconda3-4.2.0-Linux-x86_64.sh" do
it { should exist }
it { should be_file }
its('owner') { should eq 'vagrant' }
| Use relative path on integration test
|
diff --git a/test/test_name_br.rb b/test/test_name_br.rb
index abc1234..def5678 100644
--- a/test/test_name_br.rb
+++ b/test/test_name_br.rb
@@ -8,7 +8,7 @@ end
def test_name
- assert_match(/\A[[:alpha:]]+ [[:alpha:]]+\z/, @tester.name)
+ assert_match(/\A[a-zA-ZéúôóíáÍã\s]+\z/, @tester.name)
end
def test_name_with_prefix
| Fix regexp for NameBR tests
|
diff --git a/simplecov-html.gemspec b/simplecov-html.gemspec
index abc1234..def5678 100644
--- a/simplecov-html.gemspec
+++ b/simplecov-html.gemspec
@@ -11,9 +11,10 @@ s.homepage = "https://github.com/colszowka/simplecov-html"
s.summary = %Q{Default HTML formatter for SimpleCov code coverage tool for ruby 1.9+}
s.description = %Q{Default HTML formatter for SimpleCov code coverage tool for ruby 1.9+}
+ s.license = "MIT"
s.rubyforge_project = "simplecov-html"
-
+
s.add_development_dependency 'rake'
s.add_development_dependency 'sprockets'
s.add_development_dependency 'sass'
@@ -22,4 +23,4 @@ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]
-end+end
| Add license to gemspec, is MIT
|
diff --git a/light-service.gemspec b/light-service.gemspec
index abc1234..def5678 100644
--- a/light-service.gemspec
+++ b/light-service.gemspec
@@ -21,5 +21,5 @@ gem.add_development_dependency("rspec", "~> 3.0")
gem.add_development_dependency("rspec-its", "~> 1.0")
gem.add_development_dependency("simplecov", "~> 0.7.1")
- gem.add_development_dependency("pry", "0.9.12.2")
+ gem.add_development_dependency("pry", "~> 0.10")
end
| Use a newer version of pry
|
diff --git a/db/migrate/013_create_track_artists.rb b/db/migrate/013_create_track_artists.rb
index abc1234..def5678 100644
--- a/db/migrate/013_create_track_artists.rb
+++ b/db/migrate/013_create_track_artists.rb
@@ -0,0 +1,14 @@+class CreateTrackArtists < ActiveRecord::Migration[4.2]
+ def self.up
+ create_table :track_artists do |t|
+ t.uuid :track_id , :null => false
+ t.uuid :artist_id, :null => false
+ t.timestamps
+ end
+ add_index :track_artists, [:track_id, :artist_id], :unique => true
+ end
+
+ def self.down
+ drop_table :track_artists
+ end
+end
| Add migrations that create track_artists table
|
diff --git a/app/services/nomis/prisoner_detailed_availability.rb b/app/services/nomis/prisoner_detailed_availability.rb
index abc1234..def5678 100644
--- a/app/services/nomis/prisoner_detailed_availability.rb
+++ b/app/services/nomis/prisoner_detailed_availability.rb
@@ -21,6 +21,7 @@ end
def error_messages_for_slot(slot)
+ sentry_debugging_context(slot)
availability_for(slot).unavailable_reasons(slot)
end
@@ -31,5 +32,13 @@ date_availability.date == slot.to_date
end
end
+
+ # :nocov:
+ def sentry_debugging_context(slot)
+ Raven.extra_context(
+ slot: slot,
+ dates: dates
+ )
+ end
end
end
| Add sentry extra debugging for an issue
There is an error reported infruenquently with prisoner detailed availability
where one of the requested dates appears to not be on the response. When
checking, it appears to be fine so hopefully this will let us know what exactly
is going on next time the error happens.
|
diff --git a/validates_email_format_of.gemspec b/validates_email_format_of.gemspec
index abc1234..def5678 100644
--- a/validates_email_format_of.gemspec
+++ b/validates_email_format_of.gemspec
@@ -11,7 +11,6 @@ s.email = ['code@dunae.ca', 'iybetesh@gmail.com']
s.homepage = 'https://github.com/validates-email-format-of/validates_email_format_of'
s.license = 'MIT'
- s.test_files = s.files.grep(%r{^test/})
s.files = `git ls-files`.split($/)
s.require_paths = ['lib']
| Drop now-unused directive from gemspec
The test_files directive is no longer used by RubyGems.org. |
diff --git a/NSObject-SafeExpectations.podspec b/NSObject-SafeExpectations.podspec
index abc1234..def5678 100644
--- a/NSObject-SafeExpectations.podspec
+++ b/NSObject-SafeExpectations.podspec
@@ -5,7 +5,7 @@ s.homepage = "https://github.com/wordpress-mobile/NSObject-SafeExpectations"
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.authors = { "Jorge Bernal" => "jbernal@gmail.com", "Aaron Douglas" => "astralbodies@gmail.com" }
- s.source = { :git => "https://github.com/wordpress-mobile/NSObject-SafeExpectations.git", :tag => "s.version.to_s" }
+ s.source = { :git => "https://github.com/wordpress-mobile/NSObject-SafeExpectations.git", :tag => s.version.to_s }
s.source_files = 'Sources/*.{h,m}'
s.platform = :ios, "8.0"
s.requires_arc = true
| Fix pod spec version reference.
|
diff --git a/partials/_rspec.rb b/partials/_rspec.rb
index abc1234..def5678 100644
--- a/partials/_rspec.rb
+++ b/partials/_rspec.rb
@@ -3,7 +3,8 @@ remove_dir 'test'
run "#{@rvm} exec rails generate rspec:install"
+copy_static_file 'spec/spec_helper.rb'
git :add => '.'
git :commit => "-aqm 'Configured RSpec.'"
-puts "\n"+puts "\n"
| Copy spec/spec_helper.rb to the project.
|
diff --git a/flip_fab.gemspec b/flip_fab.gemspec
index abc1234..def5678 100644
--- a/flip_fab.gemspec
+++ b/flip_fab.gemspec
@@ -23,4 +23,6 @@ spec.add_development_dependency 'rspec'
spec.add_development_dependency 'rutabaga'
spec.add_development_dependency 'timecop'
+
+ spec.add_development_dependency 'rubocop'
end
| Add rubocop gem for development
|
diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/admin_controller.rb
+++ b/app/controllers/admin_controller.rb
@@ -1,11 +1,5 @@ class AdminController < ApplicationController
layout "admin"
-
- # Don't serve admin assets from the CDN
- # Respond.js needs to run on the same domain to request stylesheets,
- # parse them and render a non-mobile layout on <IE9
- # https://github.com/scottjehl/Respond#cdnx-domain-setup
- ActionController::Base.asset_host = nil
prepend_before_filter :authenticate_user!
before_filter :require_signin_permission!
| Revert "Don’t serve admin assets from the CDN"
The intention was to only affect admin pages, but in production-like
environments it also broke assets on the frontend.
For now, we'll live with the bug for respond.js and IE<9, until we have switched
the frontend to a finder.
This reverts commit 4396cc8e0c6477e9ca794ce7de03cd0c608ce85c.
|
diff --git a/app/controllers/auth0_controller.rb b/app/controllers/auth0_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/auth0_controller.rb
+++ b/app/controllers/auth0_controller.rb
@@ -1,7 +1,15 @@ class Auth0Controller < ApplicationController
- def callback
+def callback
+ # This stores all the user information that came from Auth0
+ # and the IdP
+ session[:userinfo] = request.env['omniauth.auth']
+
+ # Redirect to the URL you want after successfull auth
+ redirect_to '/dashboard'
end
def failure
+ # show a failure page or redirect to an error page
+ @error_msg = request.params['message']
end
end
| Add the shell for the code that will hand the success and failure of the callback
|
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -27,6 +27,6 @@ protected
def user_params
- params.require(:user).permit(:email, :admin, :name, :roles, :deleted)
+ params.require(:user).permit(:email, :name, :roles, :deleted)
end
end
| Remove :admin key in param to stop Brakeman warning
The issue that brakeman was complaining about is that admin was being allowed in .permit in the users_controller.rb.
I think this was a mistake in that these params are only used on to update a user and the form that controls this has no :admin value to return. A completely filled in form has the following keys returned:
"user"=>{ "name"=>"New OldName",
"email"=>"admin@something.com",
"roles"=>"PQUSER",
"deleted"=>"0"}
Similarly the models in the app have no 'admin' flag at all.
I think this was just an oversight or left over from an earlier iteration of the page.
I have removed the :admin key here, and this brakeman warning no longer occurs
|
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -3,7 +3,7 @@ before_action :authenticate_user!
def dashboard
- flash.notice = "Welcome #{current_user.email}! It's currently #{Time.new}"
+ flash.notice = "Welcome to Not Bored Tonight, todd@example.com!"
render 'dashboard'
end
| Fix User Controller to make user_sign_up_spec test pass
|
diff --git a/lib/rightscale_cli/monkey_patches/client_attributes.rb b/lib/rightscale_cli/monkey_patches/client_attributes.rb
index abc1234..def5678 100644
--- a/lib/rightscale_cli/monkey_patches/client_attributes.rb
+++ b/lib/rightscale_cli/monkey_patches/client_attributes.rb
@@ -15,6 +15,7 @@ # limitations under the License.
module RightApi
+ # Client monkey patch to read API connection properties
class Client
attr_reader :api_version, :api_url, :account_id
end
| Add missing class header comment.
|
diff --git a/week-5/nums-commas/my_solution.rb b/week-5/nums-commas/my_solution.rb
index abc1234..def5678 100644
--- a/week-5/nums-commas/my_solution.rb
+++ b/week-5/nums-commas/my_solution.rb
@@ -1,3 +1,4 @@+=begin
# Numbers to Commas Solo Challenge
# I spent [] hours on this challenge.
@@ -9,13 +10,39 @@ # 0. Pseudocode
# What is the input?
+ - a positive integer
# What is the output? (i.e. What should the code return?)
+ - a comma-spearated integer as a string
# What are the steps needed to solve the problem?
+
+CREATE a method called separate_comma that accepts a positive integer
+ CONVERT the input to a string
+ IF the input is more than three characters long
+ beginning from the end of the string, insert a comma every three characters
+ END the if statement
+ return the input
+END the method
# 1. Initial Solution
+=end
+def separate_comma(integer)
+ num = integer.to_s
+ if num.length == 4
+ num[0] += ','
+ elsif num.length == 5
+ num[1] += ','
+ elsif num.length == 6
+ num[2] += ','
+ elsif num.length == 7
+ num[0] += ','
+ num[4] += ','
+ end
+ p num
+end
+p separate_comma(1000000) == "1,000,000"
# 2. Refactored Solution
| Complete pseudocode and begin initial solution
|
diff --git a/CoreDataHelper.podspec b/CoreDataHelper.podspec
index abc1234..def5678 100644
--- a/CoreDataHelper.podspec
+++ b/CoreDataHelper.podspec
@@ -4,6 +4,7 @@ s.summary = "A series of helper methods for managing your core data context as well as selecting, inserting, deleting, and sorting"
s.license = 'MIT'
s.author = { "Daniel Bowden" => "github@bowden.in" }
+ s.homepage = "http://www.danielbowden.com.au"
s.source = { :git => "https://github.com/danielbowden/CoreDataHelper.git", :tag => s.version.to_s }
s.platform = :ios, '5.0'
| Add missing required homepage attribute |
diff --git a/app/reports/asset_subtype_report.rb b/app/reports/asset_subtype_report.rb
index abc1234..def5678 100644
--- a/app/reports/asset_subtype_report.rb
+++ b/app/reports/asset_subtype_report.rb
@@ -24,7 +24,7 @@
subtypes.each do |x|
count = organization.assets.where("asset_subtype_id = ?", x.id).count
- a << [x.name, count]
+ a << [x.name, count] unless count == 0
end
return {:labels => labels, :data => a}
| Remove blank lines from asset subtype report
|
diff --git a/config.ru b/config.ru
index abc1234..def5678 100644
--- a/config.ru
+++ b/config.ru
@@ -26,4 +26,14 @@ t.complete
end
-run Bumbleworks::Gui::RackApp
+if ENV['MOUNT_AT']
+ app = Rack::Builder.new do
+ map ENV['MOUNT_AT'] do
+ run Bumbleworks::Gui::RackApp
+ end
+ end
+ run app
+else
+ run Bumbleworks::Gui::RackApp
+end
+
| Enable mounting manual testing server at path
(Use the MOUNT_AT env variable when launching the server) |
diff --git a/app/serializers/movie_serializer.rb b/app/serializers/movie_serializer.rb
index abc1234..def5678 100644
--- a/app/serializers/movie_serializer.rb
+++ b/app/serializers/movie_serializer.rb
@@ -1,3 +1,4 @@ class MovieSerializer < ActiveModel::Serializer
attributes :id, :title, :gross, :release_date, :mpaa_rating, :description
+ has_many :reviews
end
| Add has_many reviews to movie serializer so child reviews show up in reviews index json response
|
diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/events_controller.rb
+++ b/app/controllers/events_controller.rb
@@ -1,7 +1,7 @@ class EventsController < ApplicationController
- before_action :load_community, only: [:index, :create]
- before_action :load_event, only: [:show, :update, :destroy]
+ before_action :set_community, only: [:index, :create]
+ before_action :set_event, only: [:show, :update, :destroy]
def index
@events = @community.events
@@ -46,11 +46,11 @@ params.require(:event).permit(:name, :description)
end
- def load_event
+ def set_event
@event = Event.find(params[:id])
end
- def load_community
+ def set_community
@community = Community.find(params[:community_id])
end
| Modify wording from 'load' to 'set'
|
diff --git a/app/controllers/rss_controller.rb b/app/controllers/rss_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/rss_controller.rb
+++ b/app/controllers/rss_controller.rb
@@ -9,7 +9,7 @@ # rss filter
ads = Ad
ads = params[:type] == 'want' ? ads.want : ads.give
- ads = ads.where(woeid_code: params[:woeid])
+ ads = ads.by_woeid_code(params[:woeid])
ads = case params[:status]
when 1, nil
| Use helper for filtering by woeid
|
diff --git a/examples/blink_led.rb b/examples/blink_led.rb
index abc1234..def5678 100644
--- a/examples/blink_led.rb
+++ b/examples/blink_led.rb
@@ -1,7 +1,7 @@ require 'bundler/setup'
require 'firmata'
-board = Firmata::Board.new('/dev/tty.usbmodemfd13131')
+board = Firmata::Board.new('/dev/tty.usbmodemfa131')
board.connect
| Use correct serialport for demo.
|
diff --git a/features/step_definitions/antivirus_steps.rb b/features/step_definitions/antivirus_steps.rb
index abc1234..def5678 100644
--- a/features/step_definitions/antivirus_steps.rb
+++ b/features/step_definitions/antivirus_steps.rb
@@ -8,8 +8,10 @@ s3 = Aws::S3::Resource.new(region: 'eu-west-1') # actual region is unimportant
@s3_obj = s3.bucket(dm_documents_bucket_name).object(destination_key)
@s3_obj_response = @s3_obj.put(
+ acl: "bucket-owner-full-control",
body: file_contents,
)
+ puts "File etag: #{@s3_obj_response.etag}"
end
Then /^I receive a notification regarding that file within ([0-9]+) minutes?$/ do |minutes_string|
| antivirus: PUT file with "bucket-owner-full-control" acl
|
diff --git a/app/models/commit_monitor_repo.rb b/app/models/commit_monitor_repo.rb
index abc1234..def5678 100644
--- a/app/models/commit_monitor_repo.rb
+++ b/app/models/commit_monitor_repo.rb
@@ -3,6 +3,27 @@
validates :name, :presence => true, :uniqueness => true
validates :path, :presence => true, :uniqueness => true
+
+ def self.create_from_github!(upstream_user, name, path)
+ GitService.call(path) do |git|
+ git.checkout("master")
+ git.pull
+
+ repo = self.create!(
+ :upstream_user => upstream_user,
+ :name => name,
+ :path => File.expand_path(path)
+ )
+
+ repo.branches.create!(
+ :name => "master",
+ :commit_uri => CommitMonitorBranch.github_commit_uri(upstream_user, name),
+ :last_commit => git.current_ref
+ )
+
+ repo
+ end
+ end
def path=(val)
super(File.expand_path(val))
| Add helper method for adding a new github based repo.
|
diff --git a/app/models/concerns/searchable.rb b/app/models/concerns/searchable.rb
index abc1234..def5678 100644
--- a/app/models/concerns/searchable.rb
+++ b/app/models/concerns/searchable.rb
@@ -43,10 +43,28 @@ }
})
- # Do something like #name_prefix_search('FOR') to get everything starting with FOR
+ # Do something like #name_prefix_search('FOR') to get all names starting with FOR
def self.name_prefix_search(str)
- es.search(index: es.index.name, body: {query: {match_phrase_prefix: {name: str}}})
- end
-
- end
+
+ scroll = es.client.search index: es.index.name,
+ scroll: '5m',
+ search_type: 'scan',
+ body: {
+ query: {
+ match_phrase_prefix: {
+ name: str
+ }
+ }
+ }
+
+ results = []
+ loop do
+ scroll = es.client.scroll(scroll_id: scroll['_scroll_id'], scroll: '5m')
+ break if scroll['hits']['hits'].empty?
+ results.concat scroll['hits']['hits'].map { |x| x['_source']['name'] }
+ end
+ results.uniq
+ end
+
+ end
end
| Use scroll to get all elasticsearch results
|
diff --git a/app/models/journal_spreadsheet.rb b/app/models/journal_spreadsheet.rb
index abc1234..def5678 100644
--- a/app/models/journal_spreadsheet.rb
+++ b/app/models/journal_spreadsheet.rb
@@ -28,7 +28,7 @@ line[3] = row.activity
line[4] = row.program
line[5] = row.account
- line[6] = row.amount
+ line[6] = sprintf("%.2f", row.amount)
line[7] = row.description
line[8] = row.reference
| Convert floats to strings for spreadsheet writing.
|
diff --git a/app/models/spree/bp_order_note.rb b/app/models/spree/bp_order_note.rb
index abc1234..def5678 100644
--- a/app/models/spree/bp_order_note.rb
+++ b/app/models/spree/bp_order_note.rb
@@ -11,7 +11,7 @@ Nacre::API::OrderRow.create @order.brightpearl_id, match_fields
end
- def create(order)
+ def self.create(order)
bp_note = new(order)
bp_save
end
| Make create instance method class method
|
diff --git a/app/views/papers/show.json.jbuilder b/app/views/papers/show.json.jbuilder
index abc1234..def5678 100644
--- a/app/views/papers/show.json.jbuilder
+++ b/app/views/papers/show.json.jbuilder
@@ -14,7 +14,7 @@ if @paper.editor
json.editor_name @paper.editor.full_name
json.editor_url @paper.editor.url if @paper.editor.url
- json.editor_orcid @paper.editor.orcid
+ json.editor_orcid @paper.editor.orcid if @paper.editor.user
end
json.reviewers @paper.metadata_reviewers
json.languages @paper.language_tags.join(', ')
| Handle case of missing user (ORCID)
|
diff --git a/app/views/posts/_post.json.jbuilder b/app/views/posts/_post.json.jbuilder
index abc1234..def5678 100644
--- a/app/views/posts/_post.json.jbuilder
+++ b/app/views/posts/_post.json.jbuilder
@@ -1 +1 @@-json.(post, :guid, :url, :published_at, :edited_at, :referenced_guid, :body, :body_html, :domain, :slug, :sha, :previous_shas, :tags)
+json.(post, :guid, :url, :published_at, :edited_at, :referenced_guid, :title, :body, :body_html, :domain, :slug, :sha, :previous_shas, :tags)
| Include post titles in JSON.
|
diff --git a/app/workers/publish_links_worker.rb b/app/workers/publish_links_worker.rb
index abc1234..def5678 100644
--- a/app/workers/publish_links_worker.rb
+++ b/app/workers/publish_links_worker.rb
@@ -10,8 +10,11 @@ links_update = LinksUpdate.new(
base_path: base_path,
tag_mappings: tag_mappings,
- links: links)
+ links: links
+ )
+ # In case the tag_mappings referenced by this job have been deleted by the
+ # time the job runs.
return if links_update.tag_mappings.empty?
LinksPublisher.publish(links_update: links_update)
| Add comment explaining early return in PublishLinksWorker
|
diff --git a/db/migrate/20170317013214_create_saved_enclosures.rb b/db/migrate/20170317013214_create_saved_enclosures.rb
index abc1234..def5678 100644
--- a/db/migrate/20170317013214_create_saved_enclosures.rb
+++ b/db/migrate/20170317013214_create_saved_enclosures.rb
@@ -0,0 +1,14 @@+class CreateSavedEnclosures < ActiveRecord::Migration[5.0]
+ def change
+ create_table :saved_enclosures do |t|
+ t.uuid :user_id , null: false
+ t.string :enclosure_id , null: false
+ t.string :enclosure_type, null: false
+
+ t.timestamps null: false
+ end
+ add_index :saved_enclosures, [:user_id, :enclosure_id], unique: true
+
+ add_column :enclosures, :saved_count, :integer
+ end
+end
| Add migration that creates saved_enclosures table
|
diff --git a/aws/rakefiles/setup_versions.rake b/aws/rakefiles/setup_versions.rake
index abc1234..def5678 100644
--- a/aws/rakefiles/setup_versions.rake
+++ b/aws/rakefiles/setup_versions.rake
@@ -1,7 +1,7 @@ require "yaml"
task :setup_versions, [:path_to_version_yml] do |taskname, args|
- args.with_defaults(path_to_version_yml: "../../common/versions.yml")
+ args.with_defaults(path_to_version_yml: "../../../common/versions.yml")
version_yml = File.read(args[:path_to_version_yml])
@versions = YAML.load(version_yml)
end
| Fix relative path to versions.yml
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.