diff
stringlengths 65
26.7k
| message
stringlengths 7
9.92k
|
|---|---|
diff --git a/test/exclude_log_messages.rb b/test/exclude_log_messages.rb
index abc1234..def5678 100644
--- a/test/exclude_log_messages.rb
+++ b/test/exclude_log_messages.rb
@@ -0,0 +1,48 @@+require_relative 'test_init'
+
+class ExcludeLogMessages
+ attr_accessor :logger
+
+ def self.build
+ instance = new
+ Telemetry::Logger.configure instance
+ instance
+ end
+
+ def initialize
+ ENV['LOG_EXCLUDE'] = "should be excluded|AlsoExcluded"
+ end
+
+ def log
+ logger.debug message
+ end
+
+ class Excluded < ExcludeLogMessages
+ def message
+ "This should be excluded because of the message content"
+ end
+ end
+
+ class AlsoExcluded < ExcludeLogMessages
+ def message
+ "This should not be written because of the class name"
+ end
+ end
+
+ class Included < ExcludeLogMessages
+ def message
+ "This should be written"
+ end
+ end
+end
+
+excluded = ExcludeLogMessages::Excluded.build
+excluded.log
+
+also_excluded = ExcludeLogMessages::AlsoExcluded.build
+also_excluded.log
+
+included = ExcludeLogMessages::Included.build
+included.log
+
+ENV['LOG_EXCLUDE'] = nil
|
Write tests for excluding log messages based on an environment variable.
|
diff --git a/lib/guided_randomness.rb b/lib/guided_randomness.rb
index abc1234..def5678 100644
--- a/lib/guided_randomness.rb
+++ b/lib/guided_randomness.rb
@@ -1,22 +1,13 @@ class Array
-
- def get_rand(arr)
- raise "Wrong number of arguments" unless arr.size == self.size
- # raise "Currently working only for arrays smaller then 200 elements" if arr.size > 199
- total = arr.inject { |x, y| x+y }
- hash = { }
- counter = (arr.size / 100)+ 1
- self.each_with_index do |arg, i|
- hash[arg] = ((arr[i].to_f / total.to_f) * counter * 100).round
+ def get_rand(weights)
+ raise "Wrong number of array elements!" unless weights.size == self.size
+
+ total = weights.inject(0, :+)
+ point = Kernel.rand * total
+
+ self.each_with_index do |element, i|
+ return element if weights[i] >= point
+ point -= weights[i]
end
- array_to_load = []
- hash.each_pair do |k,v|
- v.times do
- array_to_load << k
- end
- end
- value = rand(3) - 1
- array_to_load.sort { |x,y| rand(3)-1 }.first
end
-
-end+end
|
Rewrite get_rand method - less LOC, better alhorithm, names.
Complexity is now O(N), where N is number of array elements.
|
diff --git a/lib/hets/hets_options.rb b/lib/hets/hets_options.rb
index abc1234..def5678 100644
--- a/lib/hets/hets_options.rb
+++ b/lib/hets/hets_options.rb
@@ -4,6 +4,10 @@
def self.from_hash(hash)
new(hash['options'])
+ end
+
+ def self.from_json(json)
+ from_hash(JSON.parse(json))
end
def initialize(opts = {})
@@ -19,6 +23,10 @@
def merge!(hets_options)
add(hets_options.options)
+ end
+
+ def to_json
+ {'options' => options}.to_json
end
protected
|
Add json converting methods to HetsOptions
Those are needed for async calls with sidekiq, because it can only
pass basic data types to asynchronously called methods.
|
diff --git a/exceltocsv.gemspec b/exceltocsv.gemspec
index abc1234..def5678 100644
--- a/exceltocsv.gemspec
+++ b/exceltocsv.gemspec
@@ -4,7 +4,7 @@ require 'exceltocsv/version'
Gem::Specification.new do |spec|
- spec.name = "xmlutils"
+ spec.name = "exceltocsv"
spec.version = ExcelToCsv::VERSION
spec.authors = ["Jeff McAffee"]
spec.email = ["jeff@ktechsystems.com"]
|
Correct gem name in gemspec
modified: exceltocsv.gemspec
|
diff --git a/app/validators/picture_image_validator.rb b/app/validators/picture_image_validator.rb
index abc1234..def5678 100644
--- a/app/validators/picture_image_validator.rb
+++ b/app/validators/picture_image_validator.rb
@@ -12,14 +12,16 @@ return
end
- new_checksum = record.image_file.blob.checksum
- existing_pictures = record.gallery.pictures
- .includes(:image_file_blob)
- .where(active_storage_blobs: {checksum: new_checksum})
+ if record.new_record?
+ new_checksum = record.image_file.blob.checksum
+ existing_pictures = record.gallery.pictures
+ .includes(:image_file_blob)
+ .where(active_storage_blobs: {checksum: new_checksum})
- if existing_pictures.any?
- record.errors[:base] << "Image already exists in gallery"
- return
+ if existing_pictures.any?
+ record.errors[:base] << "Image already exists in gallery"
+ return
+ end
end
end
end
|
Validate uniqueness of image upload only for new records
|
diff --git a/lib/lysergide.rb b/lib/lysergide.rb
index abc1234..def5678 100644
--- a/lib/lysergide.rb
+++ b/lib/lysergide.rb
@@ -9,10 +9,10 @@ require 'lysergide/jobs'
Lysergide::Jobs.start
require 'lysergide/application'
- lsd = Lysergide::Application
- lsd.set :port, port
- lsd.set :bind, '0.0.0.0'
- lsd.run!
+ lys = Lysergide::Application
+ lys.set :port, port
+ lys.set :bind, '0.0.0.0'
+ lys.run!
Lysergide::Jobs.stop
end
end
|
Rename 'lsd' to 'lys' internally
|
diff --git a/app/workers/completeness_metric_worker.rb b/app/workers/completeness_metric_worker.rb
index abc1234..def5678 100644
--- a/app/workers/completeness_metric_worker.rb
+++ b/app/workers/completeness_metric_worker.rb
@@ -3,9 +3,9 @@ def perform(repository_name)
repository = Repository.find repository_name
schema = JSON.parse File.read 'public/ckan-schema.json'
- schema = symbolize_keys schema
+ schema = self.class.symbolize_keys schema
metric = Metrics::Completeness.new
- compute(repository, metric)
+ compute(repository, metric, schema)
end
end
|
Add missing argument for completeness worker
There was a missing argument, as well as as a missing call to self.class
for symbolize_keys which prevented the completeness metric from working.
This commit fixes that.
Signed-off-by: Konrad Reiche <4ff0213f56e2082fcd8c882d04c546881c579ce4@gmail.com>
|
diff --git a/lib/osrm/route.rb b/lib/osrm/route.rb
index abc1234..def5678 100644
--- a/lib/osrm/route.rb
+++ b/lib/osrm/route.rb
@@ -19,7 +19,7 @@
# HACK: Should fix encoded_polyline gem instead
def fix_float_precision(float)
- decimals = float.to_s.sub(/\A\d+\./, '')
+ decimals = float.to_f.to_s[/\d+\z/]
fixed_decimals = decimals.sub(/(\d)\1{5,}\d{,2}\z/, '')
decimals == fixed_decimals ? float : float.round(fixed_decimals.size)
|
Allow precision algorithm to process integers
|
diff --git a/test/unit/edition/role_appointments_test.rb b/test/unit/edition/role_appointments_test.rb
index abc1234..def5678 100644
--- a/test/unit/edition/role_appointments_test.rb
+++ b/test/unit/edition/role_appointments_test.rb
@@ -9,4 +9,11 @@ published = create(:published_news_article, role_appointments: appointments)
assert_equal appointments, published.create_draft(create(:user)).role_appointments
end
+
+ test "editions with role appointments include them in their search info" do
+ appointment = create(:role_appointment)
+ news_article = create(:news_article, role_appointments: [appointment])
+
+ assert_equal [appointment.slug], news_article.search_index['people']
+ end
end
|
Add additional test coverage for edition role appointments
This adds some missing coverage around exposing the role appointments in search
data when present.
|
diff --git a/app/models/admin.rb b/app/models/admin.rb
index abc1234..def5678 100644
--- a/app/models/admin.rb
+++ b/app/models/admin.rb
@@ -30,4 +30,10 @@ def lead_or_assigned?(*)
true
end
+
+ private
+
+ def min_password_score
+ 3
+ end
end
|
Set minimum password score for Admin model to 3
This is the score for zxcvbn
|
diff --git a/app/models/audit.rb b/app/models/audit.rb
index abc1234..def5678 100644
--- a/app/models/audit.rb
+++ b/app/models/audit.rb
@@ -7,7 +7,7 @@ end),
dataset: (proc do
klass = auditable_type.constantize
- klass.where(klassprimary_key: auditable_id)
+ klass.where(klass.primary_key => auditable_id)
end),
eager_loader: (proc do |eo|
id_map = {}
@@ -17,7 +17,7 @@ end
id_map.each do |klass_name, id_map|
klass = klass_name.constantize
- klass.where(klassprimary_key: id_map.keys).all do |attach|
+ klass.where(klass.primary_key => id_map.keys).all do |attach|
id_map[attach.pk].each do |asset|
asset.associations[:auditable] = attach
end
|
Fix issue with loading polymorphic association from Audit
|
diff --git a/lib/next_step.rb b/lib/next_step.rb
index abc1234..def5678 100644
--- a/lib/next_step.rb
+++ b/lib/next_step.rb
@@ -2,7 +2,7 @@
module NextStep
- StepResult = Struct.new(:continue, :message, :exception, :payload, :step)
+ StepResult = Struct.new(:continue, :message, :exception, :payload, :step, :bag)
EventMissingError = Class.new(StandardError)
autoload :StepRunner, 'next_step/step_runner'
|
Add a data bag to result objects
|
diff --git a/lib/open_hash.rb b/lib/open_hash.rb
index abc1234..def5678 100644
--- a/lib/open_hash.rb
+++ b/lib/open_hash.rb
@@ -4,18 +4,18 @@ new(hash)
end
end
-
+
def initialize(hash = {})
super
self.default = hash.default
end
-
+
def dup
self.class.new(self)
end
protected
- def convert_value(value)
+ def convert_value(value, options = {})
if value.is_a? Hash
OpenHash[value].tap do |oh|
oh.each do |k, v|
@@ -28,23 +28,23 @@ value
end
end
-
+
def method_missing(name, *args, &block)
method = name.to_s
-
+
case method
when %r{.=$}
super unless args.length == 1
self[method[0...-1]] = args.first
-
+
when %r{.\?$}
super unless args.empty?
self.key?(method[0...-1].to_sym)
-
+
when %r{^_.}
ret = self.send(method[1..-1], *args, &block)
- (ret.is_a?(Hash) and meth != :_default) ? OpenHash[ret] : ret
-
+ (ret.is_a?(Hash) and meth != :_default) ? OpenHash[ret] : ret
+
else
if key?(method) or !respond_to?(method)
self[method]
@@ -53,4 +53,4 @@ end
end
end
-end+end
|
Fix crash when runing Rails4
- wrong number of arguments (given 2, expected 1)
|
diff --git a/db/migrate/20130919010513_ensure_shipping_methods_have_distributors.rb b/db/migrate/20130919010513_ensure_shipping_methods_have_distributors.rb
index abc1234..def5678 100644
--- a/db/migrate/20130919010513_ensure_shipping_methods_have_distributors.rb
+++ b/db/migrate/20130919010513_ensure_shipping_methods_have_distributors.rb
@@ -2,9 +2,13 @@ def up
d = Enterprise.is_distributor.first
sms = Spree::ShippingMethod.where('distributor_id IS NULL')
- say "Assigning an arbitrary distributor (#{d.name}) to all shipping methods without one (#{sms.count} total)"
- sms.update_all(distributor_id: d)
+ if d
+ say "Assigning an arbitrary distributor (#{d.name}) to all shipping methods without one (#{sms.count} total)"
+ sms.update_all(distributor_id: d)
+ else
+ say "There are #{sms.count} shipping methods without distributors, but there are no distributors to assign to them"
+ end
end
def down
|
Fix migration for envs without distributors
|
diff --git a/OAuthSwift.podspec b/OAuthSwift.podspec
index abc1234..def5678 100644
--- a/OAuthSwift.podspec
+++ b/OAuthSwift.podspec
@@ -11,6 +11,7 @@ }
s.source = { git: 'https://github.com/OAuthSwift/OAuthSwift.git', tag: s.version }
s.source_files = 'Sources/*.swift'
+ s.swift_version = '4.1'
s.ios.deployment_target = '9.0'
s.osx.deployment_target = '10.11'
s.tvos.deployment_target = '9.0'
|
Add Swift version into podspec
|
diff --git a/lib/trackler/problems.rb b/lib/trackler/problems.rb
index abc1234..def5678 100644
--- a/lib/trackler/problems.rb
+++ b/lib/trackler/problems.rb
@@ -2,8 +2,6 @@ # Problems is the collection of problems that we have metadata for.
class Problems
include Enumerable
-
- SLUG_PATTERN = Regexp.new(".*\/exercises\/([^\/]*)\/")
attr_reader :root
def initialize(root)
@@ -32,9 +30,11 @@ end
def all
- @exercise_ids ||= Dir["%s/common/exercises/*/" % root].sort.map { |f|
- Problem.new(f[SLUG_PATTERN, 1], root)
- }
+ @all_problems ||= exercise_slugs.map { |slug| Problem.new(slug, root) }
+ end
+
+ def exercise_slugs
+ Dir["%s/common/exercises/*/" % root].map { |path| File.basename(path) }.sort
end
def by_slug
|
Use File.basename instead of regex to determine slugs
|
diff --git a/build/dist/bin/generate_build_metadata.rb b/build/dist/bin/generate_build_metadata.rb
index abc1234..def5678 100644
--- a/build/dist/bin/generate_build_metadata.rb
+++ b/build/dist/bin/generate_build_metadata.rb
@@ -3,8 +3,9 @@ require 'rubygems'
require 'json'
require File.join( File.dirname( __FILE__ ), '../../../modules/core/target/torquebox-core.jar' )
+require File.join( File.dirname( __FILE__ ), '../../../modules/core/target/torquebox-core-module/polyglot-core.jar' )
-props = org.torquebox.core.util.BuildInfo.new
+props = org.projectodd.polyglot.core.util.BuildInfo.new( "org/torquebox/torquebox.properties" )
torquebox = props.getComponentInfo( 'TorqueBox' )
metadata = {}
|
Fix build info script to use the correct BuildInfo class.
|
diff --git a/lib/rorr/init.rb b/lib/rorr/init.rb
index abc1234..def5678 100644
--- a/lib/rorr/init.rb
+++ b/lib/rorr/init.rb
@@ -16,7 +16,7 @@ options.banner = 'Usage: rorr [options]'
options.on('-t', '--time SECONDS', 'Delay each turn by seconds (default: 0.6)') { |seconds| Config.delay = seconds.to_f }
options.on('-d', '--difficult', 'Difficult level on RorR (default: NORMAL)') { |level| Config.level = 'difficult' }
- options.on('-n', '--number NUMBER', 'Number of questions (default: 10, all = -1)') { |number| Config.number = ((number.to_i) -1) }
+ options.on('-n', '--number NUMBER', 'Number of questions (default: 10, all = 0)') { |number| Config.number = ((number.to_i) -1) }
options.on('-s', '--solution', 'Show the solution (default: false)') { |number| Config.solution = true }
options.on('-h', '--help', 'Show this message') { puts(options); exit }
options.parse!(@arguments)
|
Fix config all questions arg is 0
|
diff --git a/lib/rubysh/fd.rb b/lib/rubysh/fd.rb
index abc1234..def5678 100644
--- a/lib/rubysh/fd.rb
+++ b/lib/rubysh/fd.rb
@@ -31,6 +31,10 @@ Rubysh.<<(self)
end
+ def inspect
+ to_s
+ end
+
def to_s
"FD: #{@fileno}"
end
|
Add an inspect method to FD
|
diff --git a/lib/ec2_helper.rb b/lib/ec2_helper.rb
index abc1234..def5678 100644
--- a/lib/ec2_helper.rb
+++ b/lib/ec2_helper.rb
@@ -0,0 +1,70 @@+require 'open-uri'
+require 'json'
+require 'fog'
+
+# Support IAM instance profiles
+class EC2Helper
+
+ # Need access_key_id, secret_access_key
+ def initialize(aki, sak)
+ @aki = aki
+ @sak = sak
+ @gettoken = false
+ end
+
+ def connection
+ if token.nil?
+ {:provider => 'AWS', :aws_access_key_id => access_key, :aws_secret_access_key => secret_key, :region => region}
+ else
+ {:provider => 'AWS', :aws_access_key_id => access_key, :aws_secret_access_key => secret_key, :aws_session_token => token, :region => region}
+ end
+ end
+
+ def access_key
+ if @aki.nil?
+ creds = get_creds_from_metadata
+ @aki = creds['AccessKeyId']
+ @gettoken = true
+ end
+ @aki
+ end
+
+ def secret_key
+ if @sak.nil?
+ creds = get_creds_from_metadata
+ @sak = creds['SecretAccessKey']
+ @gettoken = true
+ end
+ @sak
+ end
+
+ def token
+ get_creds_from_metadata['Token]'] if @gettoken
+ end
+
+ def iam_role
+ open('http://169.254.169.254/latest/meta-data/iam/security-credentials').readline
+ end
+
+ def instance_id
+ open('http://169.254.169.254/latest/meta-data/instance-id').readline
+ end
+
+ def region
+ open('http://169.254.169.254/latest/meta-data/placement/availability-zone').readline[0..-2]
+ end
+
+ def availability_zone
+ open('http://169.254.169.254/latest/meta-data/placement/availability-zone').readline
+ end
+
+ private
+
+ def get_creds_from_metadata
+ begin
+ JSON.parse(open("http://169.254.169.254/latest/meta-data/iam/security-credentials/#{iam_role}").read)
+ rescue OpenURI::HTTPError => e
+ { 'AccessKeyId' => nil, 'SecretAccessKey' => nil, 'Token' => nil }
+ end
+ end
+end
|
Create a helper class that constructs Fog::Compute connection strings and gathers AWS IAM credentials from instance metadata.
|
diff --git a/app/models/github_user.rb b/app/models/github_user.rb
index abc1234..def5678 100644
--- a/app/models/github_user.rb
+++ b/app/models/github_user.rb
@@ -36,4 +36,12 @@ rescue Octokit::RepositoryUnavailable, Octokit::NotFound, Octokit::Forbidden, Octokit::InternalServerError, Octokit::BadGateway => e
nil
end
+
+ def download_orgs
+ github_client.orgs(login).each do |org|
+ GithubCreateOrgWorker.perform_async(org.login)
+ end
+ rescue Octokit::Unauthorized, Octokit::RepositoryUnavailable, Octokit::NotFound, Octokit::Forbidden, Octokit::InternalServerError, Octokit::BadGateway => e
+ nil
+ end
end
|
Add a method to download a users public orgs
|
diff --git a/app/models/user_mailer.rb b/app/models/user_mailer.rb
index abc1234..def5678 100644
--- a/app/models/user_mailer.rb
+++ b/app/models/user_mailer.rb
@@ -1,4 +1,5 @@ class UserMailer < Devise::Mailer
+ default :from => "Admin <#{APP_CONFIG[:help_email]}>"
def confirmation_instructions(record, opts={})
end
|
Add default from address to Usermailer class
- Add default from address to Usermailer class
|
diff --git a/SnapKit.podspec b/SnapKit.podspec
index abc1234..def5678 100644
--- a/SnapKit.podspec
+++ b/SnapKit.podspec
@@ -6,7 +6,7 @@ s.homepage = 'https://github.com/SnapKit/SnapKit'
s.authors = { 'Robert Payne' => 'robertpayne@me.com' }
s.social_media_url = 'http://twitter.com/robertjpayne'
- s.source = { :git => 'https://github.com/SnapKit/SnapKit.git', :tag => '4.0.0' }
+ s.source = { :git => 'https://github.com/SnapKit/SnapKit.git', :tag => '4.0.1' }
s.ios.deployment_target = '8.0'
s.osx.deployment_target = '10.11'
@@ -14,5 +14,7 @@
s.source_files = 'Source/*.swift'
+ s.swift_version = '4.0'
+
s.requires_arc = true
end
|
Add swift version to podspec
|
diff --git a/app/tasks/import_needs.rb b/app/tasks/import_needs.rb
index abc1234..def5678 100644
--- a/app/tasks/import_needs.rb
+++ b/app/tasks/import_needs.rb
@@ -1,13 +1,7 @@-require 'gds_api/need_api'
-
class ImportNeeds
class << self
- def api
- @api ||= GdsApi::NeedApi.new( Plek.current.find('need-api'), API_CLIENT_CREDENTIALS )
- end
-
def needs
- api.needs.with_subsequent_pages
+ ContentPlanner.needs_api.needs.with_subsequent_pages
end
def run
|
Simplify code to reuse ContentPlanner.needs_api
|
diff --git a/populate_organisation_types.rb b/populate_organisation_types.rb
index abc1234..def5678 100644
--- a/populate_organisation_types.rb
+++ b/populate_organisation_types.rb
@@ -0,0 +1,14 @@+[
+ "Ministerial department",
+ "Non-ministerial department",
+ "Executive agency",
+ "Executive non-departmental public body",
+ "Advisory non-departmental public body",
+ "Tribunal non-departmental public body",
+ "Public corporation",
+ "Independent monitoring body",
+ "Ad-hoc advisory group",
+ "Other"
+].each do |name|
+ OrganisationType.create!(name: name)
+end
|
Add script to populate org types.
We'll run this on the server, then remove it.
|
diff --git a/test/membership_validators_test.rb b/test/membership_validators_test.rb
index abc1234..def5678 100644
--- a/test/membership_validators_test.rb
+++ b/test/membership_validators_test.rb
@@ -0,0 +1,54 @@+require_relative 'test_helper'
+
+module GitHubLdapMembershipValidatorsTestCases
+ def make_validator(groups)
+ groups = @domain.groups(groups)
+ @validator.new(@ldap, groups)
+ end
+
+ def test_validates_user_in_group
+ validator = make_validator(%w(Enterprise))
+ assert validator.perform(@entry)
+ end
+
+ def test_does_not_validate_user_not_in_group
+ validator = make_validator(%w(People))
+ refute validator.perform(@entry)
+ end
+
+ def test_does_not_validate_user_not_in_any_group
+ @entry = @domain.user?('ldaptest')
+ validator = make_validator(%w(Enterprise People))
+ refute validator.perform(@entry)
+ end
+end
+
+class GitHubLdapMembershipValidatorsClassicTest < GitHub::Ldap::Test
+ include GitHubLdapMembershipValidatorsTestCases
+
+ def self.test_server_options
+ {search_domains: "dc=github,dc=com"}
+ end
+
+ def setup
+ @ldap = GitHub::Ldap.new(options)
+ @domain = @ldap.domain("dc=github,dc=com")
+ @entry = @domain.user?('calavera')
+ @validator = GitHub::Ldap::MembershipValidators::Classic
+ end
+end
+
+class GitHubLdapMembershipValidatorsRecursiveTest < GitHub::Ldap::Test
+ include GitHubLdapMembershipValidatorsTestCases
+
+ def self.test_server_options
+ {search_domains: "dc=github,dc=com"}
+ end
+
+ def setup
+ @ldap = GitHub::Ldap.new(options)
+ @domain = @ldap.domain("dc=github,dc=com")
+ @entry = @domain.user?('calavera')
+ @validator = GitHub::Ldap::MembershipValidators::Recursive
+ end
+end
|
Add rudimentary tests for MembershipValidators
|
diff --git a/rspec_lister.gemspec b/rspec_lister.gemspec
index abc1234..def5678 100644
--- a/rspec_lister.gemspec
+++ b/rspec_lister.gemspec
@@ -22,6 +22,4 @@ spec.add_development_dependency "rake"
spec.add_development_dependency "rspec"
spec.add_development_dependency "aruba"
-
- spec.add_dependency 'rspec'
end
|
Remove RSpec gem install dependency.
|
diff --git a/lib/build-cloud/s3bucket.rb b/lib/build-cloud/s3bucket.rb
index abc1234..def5678 100644
--- a/lib/build-cloud/s3bucket.rb
+++ b/lib/build-cloud/s3bucket.rb
@@ -18,14 +18,19 @@
def create
- return if exists?
+ policy = @options.delete(:policy)
+
+ unless exists?
- @log.info( "Creating new S3 bucket #{@options[:key]}" )
+ @log.info( "Creating new S3 bucket #{@options[:key]}" )
- bucket = @s3.directories.new( @options )
- bucket.save
+ bucket = @s3.directories.new( @options )
+ bucket.save
- @log.debug( bucket.inspect )
+ @log.debug( bucket.inspect )
+ end
+
+ rationalise_policies( policy )
end
@@ -44,6 +49,31 @@ fog_object.destroy
end
+
+ def rationalise_policies( policy )
+
+ policy = JSON.parse(policy) unless policy.nil?
+ @log.debug("Policy inspect #{policy.inspect}")
+
+ begin
+ @log.debug("Inspect #{@s3.get_bucket_policy(fog_object.key)}")
+ current_policy = @s3.get_bucket_policy(fog_object.key)
+ rescue Excon::Error::NotFound
+ current_policy = nil
+ end
+
+ @log.debug("Current Policy inspect #{current_policy.inspect}")
+
+ if policy.nil? and current_policy.nil?
+ return
+ elsif policy.nil? and current_policy.any?
+ @log.info("Existing policy here, deleting it")
+ @s3.delete_bucket_policy(fog_object.key)
+ elsif policy != current_policy
+ @log.info( "For bucket #{fog_object.key} adding/updating policy #{p}" )
+ @s3.put_bucket_policy( fog_object.key, policy )
+ end
+
+ end
end
-
|
Add policy lifecycle to s3 buckets
|
diff --git a/lib/epub/publication/package.rb b/lib/epub/publication/package.rb
index abc1234..def5678 100644
--- a/lib/epub/publication/package.rb
+++ b/lib/epub/publication/package.rb
@@ -5,7 +5,7 @@ class Package
attr_accessor :book,
:version, :unique_identifier_id, :prefix, :xml_lang, :dir, :id
- attr_reader :metadata, :manifest, :spine, :guide, :bindings, :unique_identifier
+ attr_reader :metadata, :manifest, :spine, :guide, :bindings
alias lang xml_lang
alias lang= xml_lang=
|
Remove unique_identifier from attr_reader; it implemented implicitly
|
diff --git a/test/server/run_timed_out_test.rb b/test/server/run_timed_out_test.rb
index abc1234..def5678 100644
--- a/test/server/run_timed_out_test.rb
+++ b/test/server/run_timed_out_test.rb
@@ -44,7 +44,7 @@ @stubs[@n].call
end
def join(_seconds)
- nil
+ self
end
end
|
Use better stubbed return value for Thread.join()
|
diff --git a/lib/tasks/ui.rake b/lib/tasks/ui.rake
index abc1234..def5678 100644
--- a/lib/tasks/ui.rake
+++ b/lib/tasks/ui.rake
@@ -0,0 +1,43 @@+# frozen_string_literal: true
+
+namespace :ui do
+ def log_info(message)
+ puts message
+ end
+
+ def setup_token(project_anchor)
+ unless project_anchor.token
+ puts "INFO skipping no token for #{project_anchor.project.name} (project_anchor_id : #{project_anchor.id})"
+ return
+ end
+ puts "*** setup of token for #{project_anchor.project.name} (project_anchor_id : #{project_anchor.id})"
+ config = { url: "https://orbf2.bluesquare.org", token: project_anchor.token }
+ dhis2 = project_anchor.project.dhis2_connection
+ begin
+ current_config = dhis2.get("dataStore/hesabu/hesabu") rescue nil
+ resp = if current_config
+ dhis2.put("dataStore/hesabu/hesabu", config)
+ else
+ dhis2.post("dataStore/hesabu/hesabu", config)
+ end
+ rescue StandardError => error
+ puts "ERROR #{error&.response&.body} : #{error}"
+ end
+ puts resp
+ end
+
+ desc "Setup the token and url for hesabu ui manager for a given project_anchor_id"
+ task :setup, [:project_anchor_id] => [:environment] do |_task, args|
+ project_anchors = ProjectAnchor.all.where(id: args[:project_anchor_id])
+ project_anchors.find_each do |project_anchor|
+ setup_token(project_anchor)
+ end
+ end
+
+ desc "Setup the token and url for hesabu ui manager for all projects"
+ task :setup_all, [:project_anchor_id] => [:environment] do |_task, _args|
+ ProjectAnchor.find_each do |project_anchor|
+ setup_token(project_anchor)
+ end
+ end
+end
|
Allow to setup hesabu token in dhis2 datastore
|
diff --git a/lib/ebx/aws_s3.rb b/lib/ebx/aws_s3.rb
index abc1234..def5678 100644
--- a/lib/ebx/aws_s3.rb
+++ b/lib/ebx/aws_s3.rb
@@ -9,8 +9,12 @@ app_bucket.objects[Settings.get(:s3_key)].tap do |o|
unless o.exists?
puts 'Bundling and pushing project'
- zip = `git ls-tree -r --name-only HEAD | zip - -q -@`
- o.write(zip)
+ # This seems preferable, unfortunately seems to create an archive
+ # that aws config parsing has a problem w/
+ #zip = `git ls-tree -r --name-only HEAD | zip - -q -@`
+ `git ls-tree -r --name-only HEAD | zip #{Settings.get(:s3_key)}.zip -q -@`
+ o.write(File.open(Settings.get(:s3_key)+'.zip'))
+ File.delete(Settings.get(:s3_key)+".zip")
end
end
end
|
Switch zip generation options to make .config files work
Not sure exactly what the issue is here, but calling `zip - -@` was resulting
in a differently constructed zip file than `zip name.zip -@` and therefore eb
config files were not getting run. Strangely everything else seemed to work and
the archive created in both cases contained the correct files. Could use some more
investigation, but its working now (though it has to use a tmp file)
|
diff --git a/spec/app.rb b/spec/app.rb
index abc1234..def5678 100644
--- a/spec/app.rb
+++ b/spec/app.rb
@@ -1,19 +1,5 @@-require 'sinatra/asset_pipeline'
-
module Example
class App < Sinatra::Base
- configure do
- # Asset configuration and settings
- set root: File.expand_path('../../', __FILE__)
- register Sinatra::AssetPipeline
- set :assets_css_compressor, :sass
- set :assets_js_compressor, :uglifier
- if defined?(RailsAssets)
- RailsAssets.load_paths.each do |path|
- settings.sprockets.append_path(path)
- end
- end
- end
enable :sessions
register Sinatra::Auth::Oauthed
|
Remove references to asset pipeline
|
diff --git a/config/initializers/delayed_job_config.rb b/config/initializers/delayed_job_config.rb
index abc1234..def5678 100644
--- a/config/initializers/delayed_job_config.rb
+++ b/config/initializers/delayed_job_config.rb
@@ -6,7 +6,7 @@ Delayed::Worker.destroy_failed_jobs = false
Delayed::Worker.sleep_delay = 2
Delayed::Worker.max_attempts = 3
-Delayed::Worker.max_run_time = 30.minutes
+Delayed::Worker.max_run_time = 1500.minutes
Delayed::Worker.read_ahead = 10
Delayed::Worker.default_queue_name = 'default'
Delayed::Worker.raise_signal_exceptions = :term
|
Increase delayed jobs max run time
|
diff --git a/lib/phpcop/cli.rb b/lib/phpcop/cli.rb
index abc1234..def5678 100644
--- a/lib/phpcop/cli.rb
+++ b/lib/phpcop/cli.rb
@@ -2,6 +2,8 @@ # The CLI is a class responsible of handling all the command line interface
# logic
class CLI
+ EXT = %w('.php').freeze
+
attr_reader :options, :config_store
def initialize
@@ -11,12 +13,13 @@
# Run all files
def run(_args = ARGV)
- Dir.foreach('.') do |file|
- Logger.debug file
- if file.isDirectory?
- foreach_folder(file)
- else
- execute_tests_in_file(file)
+ Dir.foreach(Dir.pwd) do |file|
+ unless file != '.' && file != '..'
+ if File.directory?(file)
+ foreach_folder(file)
+ else
+ execute_tests_in_file(file)
+ end
end
end
end
@@ -30,7 +33,7 @@ end
def execute_tests_in_file(file)
- PhpTags.new(file) if file.extname('.php')
+ PhpCop::Cop::Files::PhpTags.new(file) if EXT.include?(File.extname(file))
end
end
end
|
Add test file ins php type
|
diff --git a/lib/travis/hub/exception.rb b/lib/travis/hub/exception.rb
index abc1234..def5678 100644
--- a/lib/travis/hub/exception.rb
+++ b/lib/travis/hub/exception.rb
@@ -1,6 +1,6 @@ module Travis
class Hub
- class Exception
+ class Exception < StandardError
attr_reader :event, :payload, :exception
|
Revert "Revert "Hub::Exception should inherit from StandardError""
This reverts commit a1e6d4ccc8fb60c7b812c821b61efaab07ee80fc.
|
diff --git a/lib/tasks/s3.rake b/lib/tasks/s3.rake
index abc1234..def5678 100644
--- a/lib/tasks/s3.rake
+++ b/lib/tasks/s3.rake
@@ -0,0 +1,15 @@+namespace :s3 do
+ desc "Upload clean assets to S3 (percentage: fraction of assets to upload; default: 0)"
+ task :upload_all_clean_assets, [:percentage] => [:environment] do |_t, args|
+ random_number_generator = Random.new
+ Asset.where(state: 'clean').each do |asset|
+ if asset.file.file.exists?
+ if random_number_generator.rand(100) < args[:percentage].to_i
+ asset.delay(priority: 10).save_to_cloud_storage
+ end
+ else
+ puts "Ignoring asset (#{asset.id}) with missing file: #{asset.file.file.path}"
+ end
+ end
+ end
+end
|
Add rake task to upload assets to S3
This iterates through the assets and enqueues a job to upload those that
have a file on the NFS mount (this should be most of them). The jobs are
enqueued with a "lower" priority (10) than the default (0) [1] with the
idea that they should not interfere with publishing apps uploading new
assets.
The percentage argument is intended to allow us to test uploading a
fraction of the assets so we can estimate how long these jobs will take
to run.
Note that it's safe to run the task multiple times, because assets with
identical content will only be uploaded the first time.
[1]: https://github.com/collectiveidea/delayed_job#parameters
|
diff --git a/make-sponsors.rb b/make-sponsors.rb
index abc1234..def5678 100644
--- a/make-sponsors.rb
+++ b/make-sponsors.rb
@@ -0,0 +1,19 @@+require "yaml"
+print "Enter the event in YYYY-city format: "
+cityname = gets.chomp
+config = YAML.load_file("data/events/#{cityname}.yml")
+sponsors = config['sponsors']
+sponsors.each {|s|
+ if File.exist?("data/sponsors/#{s['id']}.yml")
+ puts "The file for #{s['id']} totally exists already"
+ else
+ puts "I need to make a file for #{s['id']}"
+ puts "What is the sponsor URL?"
+ sponsor_url = gets.chomp
+ sponsorfile = File.open("data/sponsors/#{s['id']}.yml", "w")
+ sponsorfile.write "name: #{s['id']}\n"
+ sponsorfile.write "url: #{sponsor_url}\n"
+ sponsorfile.close
+ puts "It will be data/sponsors/#{s['id']}.yml"
+ end
+}
|
Create script for generating sponsor files
This ruby script basically reads in a city config file and creates the sponsor file associated with it. It will NOT create the images, naturally, but this will make it somewhat easier.
|
diff --git a/lib/docker_test.rb b/lib/docker_test.rb
index abc1234..def5678 100644
--- a/lib/docker_test.rb
+++ b/lib/docker_test.rb
@@ -5,10 +5,7 @@ require 'securerandom'
require 'set'
-TIMEOUT = 1000
-
-Excon.defaults[:write_timeout] = TIMEOUT
-Excon.defaults[:read_timeout] = TIMEOUT
+Docker.options = { read_timeout: 0 }
module DockerTest
|
Use a different timeout style
|
diff --git a/lib/kosmos/packages/cacteye.rb b/lib/kosmos/packages/cacteye.rb
index abc1234..def5678 100644
--- a/lib/kosmos/packages/cacteye.rb
+++ b/lib/kosmos/packages/cacteye.rb
@@ -2,6 +2,7 @@ title 'CactEye Telescope'
aliases 'cacteye'
url 'https://app.box.com/s/89skim2e3simjwmuof4c'
+ postrequisite 'cacteye recompiled with latest hullcam vds'
def install
merge_directory 'GameData'
|
Add CactEye bugfix as postrequisite.
|
diff --git a/lib/middleware/health_check.rb b/lib/middleware/health_check.rb
index abc1234..def5678 100644
--- a/lib/middleware/health_check.rb
+++ b/lib/middleware/health_check.rb
@@ -7,9 +7,9 @@ return @app.call(env) unless env["PATH_INFO"] == "/health_check"
if database_up?
- response(200, {status: "ok", database: "up"})
+ response(200, { status: "ok", database: "up" })
else
- response(500, {status: "failure", database: "down"})
+ response(500, { status: "failure", database: "down" })
end
end
|
Fix style issues in health check
|
diff --git a/lib/pagelet_rails/encryptor.rb b/lib/pagelet_rails/encryptor.rb
index abc1234..def5678 100644
--- a/lib/pagelet_rails/encryptor.rb
+++ b/lib/pagelet_rails/encryptor.rb
@@ -41,7 +41,7 @@ def encryptor
@encryptor ||= begin
key = self.class.get_key secret, salt
-
+ key = key[0..31]
ActiveSupport::MessageEncryptor.new(key)
end
end
|
Fix error : key must be 32 bytes
|
diff --git a/lib/podio/models/item_field.rb b/lib/podio/models/item_field.rb
index abc1234..def5678 100644
--- a/lib/podio/models/item_field.rb
+++ b/lib/podio/models/item_field.rb
@@ -12,8 +12,10 @@ class << self
# https://developers.podio.com/doc/items/update-item-field-values-22367
def update(item_id, field_id, values)
+ silent = values[:silent] ? '?silent=1' : ''
+ values.delete(:silent) if values && values[:silent]
response = Podio.connection.put do |req|
- req.url "/item/#{item_id}/value/#{field_id}"
+ req.url "/item/#{item_id}/value/#{field_id}#{silent}"
req.body = values
end
response.body
|
Handle silent updates of item field values
|
diff --git a/lib/lodo/string.rb b/lib/lodo/string.rb
index abc1234..def5678 100644
--- a/lib/lodo/string.rb
+++ b/lib/lodo/string.rb
@@ -3,23 +3,22 @@ LED_COUNT = 100
def initialize
- @core = Core
- @device = @core.open_device
- @buffer = @core::Buffer.new
+ @device = Core.open_device
+ @buffer = Core::Buffer.new
@buffer_cache = {} # TODO replace with retrieval from C buffer?
- @core.set_gamma 2.2, 2.2, 2.2
+ Core.set_gamma 2.2, 2.2, 2.2
raise "Device failed to open" if @device <= 0
- spi_status = @core.spi_init(@device)
+ spi_status = Core.spi_init(@device)
raise "SPI failed to start" if spi_status != 0
- tcl_status = @core.tcl_init(@buffer.pointer, LED_COUNT)
+ tcl_status = Core.tcl_init(@buffer.pointer, LED_COUNT)
raise "TCL failed to start" if tcl_status != 0
end
def []= (led_number, color)
- @core.write_gamma_color_to_buffer(@buffer.pointer, led_number, color[:red], color[:green], color[:blue])
+ Core.write_gamma_color_to_buffer(@buffer.pointer, led_number, color[:red], color[:green], color[:blue])
@buffer_cache[led_number] = color
end
@@ -28,7 +27,7 @@ end
def save
- @core.send_buffer(@device, @buffer.pointer)
+ Core.send_buffer(@device, @buffer.pointer)
end
def each
|
Change back to old Core scheme in String
|
diff --git a/lib/on_the_spot.rb b/lib/on_the_spot.rb
index abc1234..def5678 100644
--- a/lib/on_the_spot.rb
+++ b/lib/on_the_spot.rb
@@ -5,7 +5,9 @@ class Engine < ::Rails::Engine
config.before_initialize do
- config.action_view.javascript_expansions[:on_the_spot] = %w(jquery.jeditable.mini.js on_the_spot_code)
+ if config.action_view.javascript_expansions
+ config.action_view.javascript_expansions[:on_the_spot] = %w(jquery.jeditable.mini.js on_the_spot_code)
+ end
end
# configure our plugin on boot. other extension points such
|
Make sure javascript_expansions config option exists
|
diff --git a/lib/tasks/relocate_manual.rake b/lib/tasks/relocate_manual.rake
index abc1234..def5678 100644
--- a/lib/tasks/relocate_manual.rake
+++ b/lib/tasks/relocate_manual.rake
@@ -0,0 +1,10 @@+require "manual_relocator"
+require "logger"
+
+desc <<-EndDesc
+Relocate manual from <from-slug> to <to-slug>
+Both <from-slug> and <to-slug> need to be published manuals
+EndDesc
+task :relocate_manual, [:from_slug, :to_slug] => :environment do |_, args|
+ ManualRelocator.move(args[:from_slug], args[:to_slug])
+end
|
Add Rake task to relocate manuals
I don't fully understand the use case for this script but we've agreed
to wrap it in a Rake task to prevent us from removing it in future. We
tried to remove it in PR #878 but @h-lame pointed out that it might
still be useful for certain support requests that come in.
Note that commit 21fcb3f971510b3765b51128694a9b73f9c6a766 changed the
behaviour of this utility so that both manuals had to be published
before you could move one to the other. This seems slightly confusing to
me as I think it means that the script essentially overwrites one manual
with the other.
|
diff --git a/lib/update_repo/git_control.rb b/lib/update_repo/git_control.rb
index abc1234..def5678 100644
--- a/lib/update_repo/git_control.rb
+++ b/lib/update_repo/git_control.rb
@@ -0,0 +1,70 @@+require 'update_repo/version'
+require 'update_repo/helpers'
+require 'open3'
+
+module UpdateRepo
+ # Class : GitControl.
+ # This class will update one git repo, and send the output to the logger.
+ # It will also return status of the operation in #status.
+ class GitControl
+ include Helpers
+
+ attr_reader :status
+
+ def initialize(repo, logger)
+ @status = { updated: false, failed: false, unchanged: false }
+ @repo = repo
+ @log = logger
+ end
+
+ def update
+ print_log '* Checking ', Dir.pwd.green, " (#{repo_url})\n"
+ Open3.popen3('git pull') do |stdin, stdout, stderr, thread|
+ stdin.close
+ do_threads(stdout, stderr)
+ thread.join
+ end
+ # reset the updated status in the rare case than both update and failed
+ # are set. This does happen!
+ @status[:updated] = false if @status[:updated] && @status[:failed]
+ end
+
+ private
+
+ # Create 2 individual threads to handle both STDOUT and STDERR streams,
+ # writing to console and log if specified.
+ # @param stdout [stream] STDOUT Stream from the popen3 call
+ # @param stderr [stream] STDERR Stream from the popen3 call
+ # @return [void]
+ def do_threads(stdout, stderr)
+ { out: stdout, err: stderr }.each do |key, stream|
+ Thread.new do
+ while (line = stream.gets)
+ handle_err(line, @status) if key == :err
+ handle_output(line, @status) if key == :out
+ end
+ end
+ end
+ end
+
+ # output an error line and update the metrics
+ # @param line [string] The string containing the error message
+ # @return [void]
+ def handle_err(line, status)
+ return unless line =~ /^fatal:|^error:/
+ print_log ' ', line.red
+ status[:failed] = true
+ err_loc = Dir.pwd + " (#{@repo})"
+ # @metrics[:failed_list].push(loc: err_loc, line: line)
+ end
+
+ # print a git output line and update the metrics if an update has occurred
+ # @param line [string] The string containing the git output line
+ # @return [void]
+ def handle_output(line, status)
+ print_log ' ', line.cyan
+ status[:updated] = true if line =~ /^Updating\s[0-9a-f]{7}\.\.[0-9a-f]{7}/
+ status[:unchanged] = true if line =~ /^Already up-to-date./
+ end
+ end
+end
|
Move all the git update logic into a new class
Signed-off-by: Grant Ramsay <4ab1b2fdb7784a8f9b55e81e3261617f44fd0585@gmail.com>
|
diff --git a/lib/upstream/tracker/helper.rb b/lib/upstream/tracker/helper.rb
index abc1234..def5678 100644
--- a/lib/upstream/tracker/helper.rb
+++ b/lib/upstream/tracker/helper.rb
@@ -29,6 +29,10 @@ File.join(get_config_dir, COMPONENT_FILE)
end
+ def load_component
+ YAML.load_file(get_component_path)
+ end
+
def save_components(components)
path = File.join(get_config_dir, COMPONENT_FILE)
File.open(path, "w+") do |file|
|
Add method to load components from YAML
|
diff --git a/example/config.ru b/example/config.ru
index abc1234..def5678 100644
--- a/example/config.ru
+++ b/example/config.ru
@@ -4,7 +4,7 @@ require 'pact_broker'
# Create a real database, and set the credentials for it here
-DATABASE_CREDENTIALS = {database: "pact_broker_database.sqlite3", adapter: "sqlite"}
+DATABASE_CREDENTIALS = {database: "pact_broker_database.sqlite3", adapter: "sqlite", :encoding => 'utf8'}
# Have a look at the Sequel documentation to make decisions about things like connection pooling
# and connection validation.
|
Set default encoding to utf-8 in example app.
This is required for the sha foreign key to work between the pact table and the pact_version_content table.
|
diff --git a/lib/tic_tac_toe.rb b/lib/tic_tac_toe.rb
index abc1234..def5678 100644
--- a/lib/tic_tac_toe.rb
+++ b/lib/tic_tac_toe.rb
@@ -8,6 +8,6 @@ def TicTacToe.run
game = TicTacToe::Game.new(TicTacToe::Board.new)
shell = TicTacToe::ConsoleShell.new(IO::console, game)
- shell.game_loop
+ shell.main_loop
end
end
|
Make the game use the main loop instead of game loop
|
diff --git a/markdown-style.rb b/markdown-style.rb
index abc1234..def5678 100644
--- a/markdown-style.rb
+++ b/markdown-style.rb
@@ -3,4 +3,5 @@ exclude_rule 'line-length'
exclude_rule 'no-duplicate-header'
+rule 'no-trailing-punctuation', :punctuation => '.,;:!'
rule 'ul-indent', :indent => 4
|
Allow headers to end with a question mark
By default, Markdown lint warns about various header-trailing
punctuation characters, including question marks:
<https://github.com/markdownlint/markdownlint/blob/master/docs/RULES.md#md007---unordered-list-indentation>.
Allowing question marks makes sense here, since the affected header is
asking a question.
|
diff --git a/qa/qa/runtime/api/client.rb b/qa/qa/runtime/api/client.rb
index abc1234..def5678 100644
--- a/qa/qa/runtime/api/client.rb
+++ b/qa/qa/runtime/api/client.rb
@@ -25,15 +25,12 @@ private
def create_personal_access_token
- if @is_new_session
- Runtime::Browser.visit(@address, Page::Main::Login) { do_create_personal_access_token }
- else
- do_create_personal_access_token
- end
+ Runtime::Browser.visit(@address, Page::Main::Login) if @is_new_session
+ do_create_personal_access_token
end
def do_create_personal_access_token
- Page::Main::Login.act { sign_in_using_credentials }
+ Page::Main::Login.perform(&:sign_in_using_credentials)
Resource::PersonalAccessToken.fabricate!.access_token
end
end
|
Allow login validation before block
Removes a block so that the login page is validated before the block,
while the login page is still present, instead of after it when the
login page is long gone
|
diff --git a/queue_classic_admin.gemspec b/queue_classic_admin.gemspec
index abc1234..def5678 100644
--- a/queue_classic_admin.gemspec
+++ b/queue_classic_admin.gemspec
@@ -17,7 +17,7 @@ s.files = Dir["{app,config,db,lib,vendor}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.md"]
s.test_files = Dir["test/**/*"]
- s.add_runtime_dependency "rails", ">= 5.0.0", "< 6.0"
+ s.add_runtime_dependency "rails", ">= 5.0.0", "< 6.1"
s.add_runtime_dependency "queue_classic", "4.0.0.pre.alpha1"
s.add_runtime_dependency "pg"
s.add_runtime_dependency "will_paginate", ">= 3.0.0"
|
Add support for Rails 6.0
|
diff --git a/messaging.gemspec b/messaging.gemspec
index abc1234..def5678 100644
--- a/messaging.gemspec
+++ b/messaging.gemspec
@@ -1,7 +1,7 @@ # -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = 'evt-messaging'
- s.version = '0.18.0.0'
+ s.version = '0.18.1.0'
s.summary = 'Common primitives for platform-specific messaging implementations for Eventide'
s.description = ' '
|
Package version is increased from 0.18.0.0 to 0.18.1.0
|
diff --git a/messaging.gemspec b/messaging.gemspec
index abc1234..def5678 100644
--- a/messaging.gemspec
+++ b/messaging.gemspec
@@ -1,7 +1,7 @@ # -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = 'evt-messaging'
- s.version = '0.29.0.0'
+ s.version = '0.29.0.1'
s.summary = 'Common primitives for platform-specific messaging implementations for Eventide'
s.description = ' '
|
Package version is increased from 0.29.0.0 to 0.29.0.1
|
diff --git a/db/migrate/20121008001854_add_purchases_count_to_tags.rb b/db/migrate/20121008001854_add_purchases_count_to_tags.rb
index abc1234..def5678 100644
--- a/db/migrate/20121008001854_add_purchases_count_to_tags.rb
+++ b/db/migrate/20121008001854_add_purchases_count_to_tags.rb
@@ -1,9 +1,5 @@ class AddPurchasesCountToTags < ActiveRecord::Migration
def change
add_column :tags, :purchases_count, :integer, :default => 0
-
- Tag.all.each do |tag|
- tag.update_column :purchases_count, tag.purchases.count
- end
end
end
|
Fix migration to add purchases counter cache column
|
diff --git a/spec/system/supervisors/editing_incidents_spec.rb b/spec/system/supervisors/editing_incidents_spec.rb
index abc1234..def5678 100644
--- a/spec/system/supervisors/editing_incidents_spec.rb
+++ b/spec/system/supervisors/editing_incidents_spec.rb
@@ -3,33 +3,38 @@ require 'spec_helper'
describe 'editing incidents as a supervisor' do
- before :each do
- @supervisor = create :user, :supervisor
- when_current_user_is @supervisor
- @report = create :incident_report, user: @supervisor
- @incident = create :incident, supervisor_incident_report: @report
- @incident.supervisor_report.assign_attributes(
- test_status: 'Post Accident: No threshold met (no drug test)',
- reason_threshold_not_met: nil
- )
- @incident.supervisor_report.save(validate: false)
+ let(:supervisor) { create :user, :supervisor }
+ let(:report) { build :incident_report, user: supervisor }
+ let(:supervisor_report) { build :supervisor_report, :with_test_status }
+ let(:incident) { create :incident, supervisor_incident_report: report, supervisor_report: supervisor_report }
+
+ before do
+ when_current_user_is supervisor
+ visit edit_incident_report_path(incident.supervisor_incident_report)
end
+
it "says you're editing a supervisor account of incident" do
- visit edit_incident_report_path(@incident.supervisor_incident_report)
expect(page).to have_text 'Editing Supervisor Account of Incident'
end
- it 'puts you into the supervisor report if it needs completing' do
- visit edit_incident_report_path(@incident.supervisor_incident_report)
- fill_in_base_incident_fields
- click_button 'Save report'
- expect(page).to have_selector 'p.notice',
- text: 'Incident report was successfully saved. Please complete the supervisor report.'
+
+ context 'when you somehow skip validations' do
+ before do
+ supervisor_report.assign_attributes(amplifying_comments: nil)
+ supervisor_report.save(validate: false)
+ end
+
+ it 'puts you into the supervisor report if it needs completing' do
+ fill_in_base_incident_fields
+ click_button 'Save report'
+ expect(page).to have_selector 'p.notice',
+ text: 'Incident report was successfully saved. Please complete the supervisor report.'
+ end
end
- context 'admin deletes the incident' do
+
+ context 'when an admin deletes the incident' do
it 'displays a nice error message' do
- visit edit_incident_report_path(@incident.supervisor_incident_report)
expect(page).to have_content 'Editing Supervisor Account of Incident'
- @incident.destroy
+ incident.destroy
click_button 'Save report'
expect(page).to have_selector 'p.notice', text: 'This incident report no longer exists.'
end
|
Update editing incidents supervisor system tests
|
diff --git a/rundeck/rundeck_get_projects.rb b/rundeck/rundeck_get_projects.rb
index abc1234..def5678 100644
--- a/rundeck/rundeck_get_projects.rb
+++ b/rundeck/rundeck_get_projects.rb
@@ -0,0 +1,58 @@+#!/usr/bin/env ruby
+
+#@author:: 'weezhard'
+#@usage:: 'Delete projects rundeck'
+#@licence:: 'GPL'
+#@version: 1.0.0
+
+require 'uri'
+require 'rubygems'
+require 'json'
+require 'net/http'
+require 'optparse'
+
+# default options
+options = {}
+options[:url] = "localhost"
+options[:port] = 4440
+options[:token] = "kfC91qhEZBMNikzY5NFNEywqhOnBKtSC"
+options[:json] = false
+
+# parse options
+optparse = OptionParser.new do |opts|
+ opts.banner = "Usage: #{$0} [options]"
+ opts.on('-u', '--url URL', "URL for Rundeck server", String) { |val| options[:url] = val }
+ opts.on('-p', '--port PORT', "PORT for Rundeck server", Integer) { |val| options[:port] = val }
+ opts.on('-t', '--token TOKEN', "TOKEN for Rundeck server", String) { |val| options[:token] = val }
+ opts.on('-j', '--json', "List of projects JSON") { options[:json] = true }
+ opts.on('-h', '--help') do
+ puts opts
+ exit
+ end
+end
+
+optparse.parse!
+
+# Get Projects
+@headers = {"X-Rundeck-Auth-Token" => options[:token],
+ "Accept" => "application/json"}
+
+def getProjects(url, port)
+ uri = URI.parse("http://#{url}:#{port}/api/1/projects")
+ http = Net::HTTP.new(uri.host, uri.port)
+ resp = http.get(uri.path, @headers)
+ projects = resp.body
+ return JSON.parse(projects)
+end
+
+if __FILE__ == $0
+ if options[:json] == true
+ for project in getProjects(options[:url], options[:port])
+ puts project
+ end
+ else
+ for project in getProjects(options[:url], options[:port])
+ puts project["name"]
+ end
+ end
+end
|
Add script get projects rundeck
|
diff --git a/recipes/vmware_fusion.rb b/recipes/vmware_fusion.rb
index abc1234..def5678 100644
--- a/recipes/vmware_fusion.rb
+++ b/recipes/vmware_fusion.rb
@@ -1,6 +1,2 @@-dmg_package "VMWare Fusion" do
- source "http://download2us.softpedia.com/dl/a5bdb8f0e2faf4dcea62bf272213d56c/513376a7/400024122/mac/System-Utilities/VMware-Fusion-5.0.2-900491-light.dmg"
- action :install
- type "app"
- package_id "com.vmware.tools.application"
-end
+include_recipe "applications::homebrewcask"
+applications_cask "vmware-fusion"
|
Update VMWare Fusion to follow brew-cask
VMWare Fusion was recently added to homebrew-cask.
|
diff --git a/app/models/application_draft.rb b/app/models/application_draft.rb
index abc1234..def5678 100644
--- a/app/models/application_draft.rb
+++ b/app/models/application_draft.rb
@@ -15,6 +15,14 @@ define_method "as_#{role}?" do # def as_student?
team.send(role.pluralize).include? current_user # team.students.include? current_user
end # end
+ end
+
+ def method_missing(method, *args, &block)
+ if match = /^student([01])_(.*)/.match(method.to_s) and index = match[1].to_i and field = match[2]
+ students[index].send(field) if students[index]
+ else
+ super
+ end
end
def students
|
Add proxy methods for students' attributes
|
diff --git a/app/models/budget_statistics.rb b/app/models/budget_statistics.rb
index abc1234..def5678 100644
--- a/app/models/budget_statistics.rb
+++ b/app/models/budget_statistics.rb
@@ -9,4 +9,36 @@ @budget.categories.map {|category| {:value => category.used_this_month.to_i, :color => category.color} }
end
+ def monthly_trend
+ days = (1..Date.today.day).to_a
+ data = calculate_monthly_trend(days)
+
+ {
+ labels: days,
+ datasets: [{
+ fillColor: "rgba(220,220,220,0.5)",
+ strokeColor: "rgba(220,220,220,1)",
+ pointColor: "rgba(220,220,220,1)",
+ pointStrokeColor: "#fff",
+ data: data
+ }]
+ }
+ end
+
+
+ private
+
+ def calculate_monthly_trend(days)
+ transactions_grouped_by_day = @budget.transactions.this_month.group_by {|t| t.date.day}
+ current_value = 0
+ data = []
+
+ days.each do |day|
+ current_value += transactions_grouped_by_day[day].sum(&:amount).to_i if transactions_grouped_by_day.keys.include?(day)
+ data << current_value
+ end
+
+ data
+ end
+
end
|
Add monthly trend to budget statistics
|
diff --git a/app/models/transaction_split.rb b/app/models/transaction_split.rb
index abc1234..def5678 100644
--- a/app/models/transaction_split.rb
+++ b/app/models/transaction_split.rb
@@ -1,3 +1,5 @@ class TransactionSplit < ActiveRecord::Base
belongs_to :transaction_record
+ has_many :pie_piece_transaction_splits
+ has_many :pie_pieces, through: :pie_piece_transaction_splits
end
|
Add TxSplit has_many PiePieces association
|
diff --git a/app/models/manageiq/providers/amazon/cloud_manager/refresher.rb b/app/models/manageiq/providers/amazon/cloud_manager/refresher.rb
index abc1234..def5678 100644
--- a/app/models/manageiq/providers/amazon/cloud_manager/refresher.rb
+++ b/app/models/manageiq/providers/amazon/cloud_manager/refresher.rb
@@ -1,19 +1,45 @@ class ManageIQ::Providers::Amazon::CloudManager::Refresher < ManageIQ::Providers::BaseManager::Refresher
include ::EmsRefresh::Refreshers::EmsRefresherMixin
- def parse_legacy_inventory(ems)
- if refresher_options.try(:[], :inventory_object_refresh)
- ManageIQ::Providers::Amazon::CloudManager::RefreshParserInventoryObject.ems_inv_to_hashes(ems, refresher_options)
- else
- ManageIQ::Providers::Amazon::CloudManager::RefreshParser.ems_inv_to_hashes(ems, refresher_options)
+ def collect_inventory_for_targets(ems, targets)
+ targets_with_data = targets.collect do |target|
+ target_name = target.try(:name) || target.try(:event_type)
+
+ _log.info "Filtering inventory for #{target.class} [#{target_name}] id: [#{target.id}]..."
+
+ inventory = if refresher_options.try(:[], :inventory_object_refresh)
+ ManageIQ::Providers::Amazon::Inventory::Factory.inventory(ems, target)
+ else
+ nil
+ end
+
+ _log.info "Filtering inventory...Complete"
+ [target, inventory]
end
+
+ targets_with_data
+ end
+
+ def parse_targeted_inventory(ems, _target, inventory)
+ log_header = format_ems_for_logging(ems)
+ _log.debug "#{log_header} Parsing inventory..."
+ hashes, = Benchmark.realtime_block(:parse_inventory) do
+ if refresher_options.try(:[], :inventory_object_refresh)
+ ManageIQ::Providers::Amazon::CloudManager::RefreshParserInventoryObject.new(inventory).populate_inventory_collections
+ else
+ ManageIQ::Providers::Amazon::CloudManager::RefreshParser.ems_inv_to_hashes(ems, refresher_options)
+ end
+ end
+ _log.debug "#{log_header} Parsing inventory...Complete"
+
+ hashes
end
# TODO(lsmola) NetworkManager, remove this once we have a full representation of the NetworkManager.
# NetworkManager should refresh base on its own conditions
- def save_inventory(ems, _targets, hashes)
- EmsRefresh.save_ems_inventory(ems, hashes)
- EmsRefresh.queue_refresh(ems.network_manager)
+ def save_inventory(ems, target, inventory_collections)
+ EmsRefresh.save_ems_inventory(ems, inventory_collections)
+ EmsRefresh.queue_refresh(ems.network_manager) if target.kind_of?(ManageIQ::Providers::BaseManager)
end
def post_process_refresh_classes
|
Change AWS Cloud Refresher to the new format
Change AWS Cloud Refresher to the new format separating collection
from parsing. We use Inventory abstraction for the inventory collection
and parsing.
|
diff --git a/app/controllers/admin/features_controller.rb b/app/controllers/admin/features_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/admin/features_controller.rb
+++ b/app/controllers/admin/features_controller.rb
@@ -10,7 +10,7 @@ def create
@features_fields = Feature.non_common_fields.map{|f| f[:name]}
- params_for_insert = Hash[params.select{|key| @features_fields.include?(key)}.map{|key, value| [key, value = value.blank?? nil : value]}]
+ params_for_insert = Hash[params.select{|key, value| @features_fields.include?(key)}.map{|key, value| [key, value = value.blank?? nil : value]}]
@new_feature = CartoDB::Connection.insert_row Cartoset::Config['features_table'], params_for_insert
@@ -20,7 +20,7 @@ def update
@features_fields = Feature.non_common_fields.map{|f| f[:name]}
- params_for_update = params.select{|key| @features_fields.include?(key)}
+ params_for_update = params.select{|key, value| @features_fields.include?(key)}
CartoDB::Connection.update_row Cartoset::Config['features_table'], params[:id], params_for_update
|
Fix a bug with ruby 1.8.7 when inserting/updating features
|
diff --git a/spec/keywhiz_spec.rb b/spec/keywhiz_spec.rb
index abc1234..def5678 100644
--- a/spec/keywhiz_spec.rb
+++ b/spec/keywhiz_spec.rb
@@ -23,21 +23,13 @@ its(:args) { should match(/keywhiz-server-shaded\.jar/) }
end
- # Check if TCP port 4444 is listening
- describe command('nc -z 127.0.0.1 4444') do
- its(:exit_status) do
- sleep(ENV.key?('CIRCLECI') ? 60 : 10)
- should eq 0
+ # Does not work on CircleCI
+ describe port(4444), if: !ENV.key?('CIRCLECI') do
+ it do
+ sleep(10)
+ should be_listening
end
end
-
- # Does not work on CircleCI
- # describe port(4444), if: !ENV.key?('CIRCLECI') do
- # it do
- # sleep(10)
- # should be_listening
- # end
- # end
end
end
end
|
Testing: Disable port checking on CircleCI
|
diff --git a/spec/nomnoml_spec.rb b/spec/nomnoml_spec.rb
index abc1234..def5678 100644
--- a/spec/nomnoml_spec.rb
+++ b/spec/nomnoml_spec.rb
@@ -27,6 +27,6 @@ include_examples "block_macro", :nomnoml, code, [:svg]
end
-describe Asciidoctor::Diagram::NomnomlBlockProcessor, :broken_on_windows do
+describe Asciidoctor::Diagram::NomnomlBlockProcessor do
include_examples "block", :nomnoml, code, [:svg]
-end+end
|
Enable nomnoml tests on Windows
|
diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb
index abc1234..def5678 100644
--- a/spec/rails_helper.rb
+++ b/spec/rails_helper.rb
@@ -2,8 +2,8 @@ require File.expand_path('../../config/environment', __FILE__)
abort("The Rails environment is running in production mode!") if Rails.env.production?
+require 'rspec/rails'
require 'spec_helper'
-require 'rspec/rails'
require 'capybara/rails'
require 'capybara/rspec'
require 'capybara/poltergeist'
|
Change order in requires to fix tests
|
diff --git a/spec/weibull_spec.rb b/spec/weibull_spec.rb
index abc1234..def5678 100644
--- a/spec/weibull_spec.rb
+++ b/spec/weibull_spec.rb
@@ -0,0 +1,120 @@+require 'spec_helper'
+require 'statistical/rng/weibull'
+require 'statistical/distribution/weibull'
+
+describe Statistical::Rng::Weibull do
+ it 'passes the G-test at a 95% significance level' do
+ end
+
+ describe '.new' do
+ context 'when called with no arguments' do
+ it 'should have scale = 1'
+ it 'should have shape = 1'
+ end
+
+ context 'when parameters are specified' do
+ it 'should have the correct scale parameter set'
+ it 'should have the correct shape parameter set'
+ end
+
+ context 'when initialized with a seed' do
+ it 'should be repeatable for the same arguments'
+ end
+ end
+
+ describe '#rand' do
+ it 'returns a non-negative number'
+ end
+
+ describe '#==' do
+ context 'when compared against another uniform distribution' do
+ it 'should return true if the bounds and seed are the same'
+ it 'should return false if bounds / seed differ'
+ end
+
+ context 'when compared against any other distribution class' do
+ it 'should return false if classes are different'
+ end
+ end
+end
+
+
+describe Statistical::Distribution::Weibull do
+ describe '.new' do
+ context 'when called with no arguments' do
+ it 'should have scale = 1'
+ it 'should have shape = 1'
+ end
+
+ context 'when upper and lower bounds are specified' do
+ it 'should have the correct scale parameter set'
+ it 'should have the correct shape parameter set'
+ end
+ end
+
+
+ describe '#pdf' do
+ context 'when called with x < lower_bound' do
+ it {}
+ end
+
+ context 'when called with x > upper_bound' do
+ it {}
+ end
+
+ context 'when called with x in [lower_bound, upper_bound]' do
+ it 'returns a value consistent with the weibull PDF'
+ end
+ end
+
+ describe '#cdf' do
+ context 'when called with x < lower' do
+ it {}
+ end
+
+ context 'when called with x > upper' do
+ it {}
+ end
+
+ context 'when called with x in [lower, upper]' do
+ it 'returns a value consistent with the weibull PMF'
+ end
+ end
+
+ describe '#quantile' do
+ context 'when called for x > 1' do
+ it {}
+ end
+
+ context 'when called for x < 0' do
+ it {}
+ end
+
+ context 'when called for x in [0, 1]' do
+ it {}
+ end
+ end
+
+ describe '#p_value' do
+ it 'should be the same as #quantile'
+ end
+
+ describe '#mean' do
+ it 'should return the correct mean'
+ end
+
+ describe '#variance' do
+ it 'should return the correct variance'
+ end
+
+ describe '#==' do
+ context 'when compared against another Uniform distribution' do
+ it 'returns `true` if they have the same parameters'
+ it 'returns `false` if they have different parameters'
+ end
+
+ context 'when compared against any distribution type' do
+ it 'returns false'
+ end
+ end
+end
|
Add pending specs for weibull distribution
|
diff --git a/lib/autobots/page_objects.rb b/lib/autobots/page_objects.rb
index abc1234..def5678 100644
--- a/lib/autobots/page_objects.rb
+++ b/lib/autobots/page_objects.rb
@@ -31,7 +31,7 @@ require_relative 'page_objects/property_details'
require_relative 'page_objects/my_rent'
require_relative 'page_objects/mbs'
-require_relative 'page_objects/search_by'
+require_relative 'page_objects/generic_search'
require_relative 'page_objects/moving_center1'
require_relative 'page_objects/site_map'
require_relative 'page_objects/fb_signin'
|
[PH][00000000] Restructure search tests: Change SearchBy page object to GenericSearch; move a generic search test to new GenericSearch test case
|
diff --git a/app/models/metrics.rb b/app/models/metrics.rb
index abc1234..def5678 100644
--- a/app/models/metrics.rb
+++ b/app/models/metrics.rb
@@ -1,5 +1,5 @@ class Metrics < Sequel::Model(:metrics)
plugin :timestamps
- one_to_one :pod
+ many_to_one :pod
end
|
[Metrics] Fix model, use many_to_one, even if it is conceptually one_to_one.
|
diff --git a/Casks/firefox-nightly-ja.rb b/Casks/firefox-nightly-ja.rb
index abc1234..def5678 100644
--- a/Casks/firefox-nightly-ja.rb
+++ b/Casks/firefox-nightly-ja.rb
@@ -0,0 +1,9 @@+class FirefoxNightlyJa < Cask
+ version '35.0a1'
+ sha256 '9cde18aabb838684c41e124b50b67006e842f29b12d4f9fa9ab3c5fa964aa12f'
+
+ url 'https://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/latest-mozilla-central-l10n/firefox-35.0a1.ja-JP-mac.mac.dmg'
+ homepage 'https://nightly.mozilla.org/'
+
+ link 'FirefoxNightly.app'
+end
|
Upgrade Firefox Nightly Ja to v35.0a1
|
diff --git a/lib/style/style.rb b/lib/style/style.rb
index abc1234..def5678 100644
--- a/lib/style/style.rb
+++ b/lib/style/style.rb
@@ -19,6 +19,7 @@ if bg_color && !bg_color.empty?
formatting << "," if formatting_changed
formatting << "bg="+bg_color
+ formatting_changed = true
end
formatting << "]"
|
Return formatting even if only the background has changed
|
diff --git a/lib/tapjoy/ldap.rb b/lib/tapjoy/ldap.rb
index abc1234..def5678 100644
--- a/lib/tapjoy/ldap.rb
+++ b/lib/tapjoy/ldap.rb
@@ -2,7 +2,6 @@ require 'yaml'
require 'optimist'
require 'memoist'
-require 'pry'
require_relative 'ldap/cli'
require_relative 'ldap/base'
require_relative 'ldap/key'
|
Remove runtime requirement on pry gem.
|
diff --git a/lib/user_agents.rb b/lib/user_agents.rb
index abc1234..def5678 100644
--- a/lib/user_agents.rb
+++ b/lib/user_agents.rb
@@ -0,0 +1,10 @@+module XP
+ USER_AGENTS = {
+ ipad: 'Mozilla/5.0 (iPad; CPU OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B176 Safari/7534.48.3',
+ iphone: 'Mozilla/5.0 (iPhone; CPU OS 7_0_4 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11B554a Safari/9537.53',
+ mac_firefox: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.75.14 (KHTML, like Gecko) Version/7.0.3 Safari/537.75.14',
+ mac_safari: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.75.14 (KHTML, like Gecko) Version/7.0.3 Safari/537.75.14'
+ }
+
+ USER_AGENTS.default = USER_AGENTS[:mac_safari]
+end
|
Add user agents in separate file
|
diff --git a/lib/tasks/test_security.rake b/lib/tasks/test_security.rake
index abc1234..def5678 100644
--- a/lib/tasks/test_security.rake
+++ b/lib/tasks/test_security.rake
@@ -2,30 +2,58 @@ namespace :security do
task :setup # NOOP - Stub for consistent CI testing
- desc "Run Brakeman"
- task :brakeman do
+ desc "Run Brakeman with the specified report format ('human' or 'json')"
+ task :brakeman, :format do |_, args|
+ format = args.fetch(:format, "human")
+
require "vmdb/plugins"
require "brakeman"
# See all possible options here:
# https://brakemanscanner.org/docs/brakeman_as_a_library/#using-options
- tracker = Brakeman.run(
+ options = {
:app_path => Rails.root.to_s,
:engine_paths => Vmdb::Plugins.paths.values,
:quiet => false,
:print_report => true
- )
+ }
+ if format == "json"
+ options[:output_files] = [
+ Rails.root.join("log/brakeman.json").to_s,
+ Rails.root.join("log/brakeman.log").to_s
+ ]
+ end
- # Exit 1 on any warnings so CI can report the project as red.
- exit tracker.filtered_warnings.empty? ? 0 : 1
+ tracker = Brakeman.run(options)
+
+ exit 1 unless tracker.filtered_warnings.empty?
end
- desc "Run bundler audit"
- task :bundler_audit do
- exit $?.exitstatus unless system("bundle-audit check --update --verbose")
+ desc "Run bundler audit with the specified report format ('human' or 'json')"
+ task :bundler_audit, :format do |_, args|
+ format = args.fetch(:format, "human")
+
+ options = [:update, :verbose]
+ if format == "json"
+ options << {
+ :format => "json",
+ :output => Rails.root.join("log/bundle-audit.json").to_s
+ }
+ end
+
+ require "awesome_spawn"
+ cmd = AwesomeSpawn.build_command_line("bundle-audit check", options)
+
+ exit $?.exitstatus unless system(cmd)
end
end
- desc "Run security tests"
- task :security => %w[security:bundler_audit security:brakeman]
+ desc "Run all security tests with the specified report format ('human' or 'json')"
+ task :security, :format do |_, args|
+ format = args.fetch(:format, "human")
+ ns = defined?(ENGINE_ROOT) ? "app:test:security" : "test:security"
+
+ Rake::Task["#{ns}:bundler_audit"].invoke(format)
+ Rake::Task["#{ns}:brakeman"].invoke(format)
+ end
end
|
Add JSON output format to security scans
Additionally, this commit allows plugins to be able to run the security
scans from the plugin itself.
|
diff --git a/lib/time_tap/editor/xcode.rb b/lib/time_tap/editor/xcode.rb
index abc1234..def5678 100644
--- a/lib/time_tap/editor/xcode.rb
+++ b/lib/time_tap/editor/xcode.rb
@@ -0,0 +1,24 @@+require 'appscript'
+
+class TimeTap::Editor::Xcode
+ include Appscript
+
+ def initialize options = {}
+ end
+
+ def is_running?
+ # Cannot use app('Xcode') because it fails when multiple Xcode versions are installed
+ !app('System Events').processes[its.name.eq('Xcode')].get.empty?
+ end
+
+ def current_path
+ if is_running?
+ # although multiple versions may be installed, tipically they will not be running simultaneously
+ pid = app('System Events').processes[its.name.eq('Xcode')].first.unix_id.get
+ xcode = app.by_pid(pid)
+ document = xcode.document.get
+ return nil if document.blank?
+ path = document.last.path.get rescue nil
+ end
+ end
+end
|
Add (experimental and untested) XCode support
|
diff --git a/sidekiq-unique-jobs.gemspec b/sidekiq-unique-jobs.gemspec
index abc1234..def5678 100644
--- a/sidekiq-unique-jobs.gemspec
+++ b/sidekiq-unique-jobs.gemspec
@@ -17,6 +17,7 @@ gem.add_dependency 'sidekiq', '~> 2.6'
gem.add_dependency 'mock_redis'
gem.add_development_dependency 'rspec', '>= 2'
+ gem.add_development_dependency 'rake'
gem.add_development_dependency 'rspec-sidekiq'
gem.add_development_dependency 'activesupport', '~> 3'
gem.add_development_dependency 'simplecov'
|
Put back accidentally committed rake removal
|
diff --git a/apps/redirects/app.rb b/apps/redirects/app.rb
index abc1234..def5678 100644
--- a/apps/redirects/app.rb
+++ b/apps/redirects/app.rb
@@ -5,7 +5,8 @@ def initialize(app)
super do
# redirect ruby api to rubydoc.info
- r301 %r{/api/cucumber/ruby/yardoc(.*)}, "http://www.rubydoc.info/github/cucumber/cucumber$1"
+ r301 %r{/api/cucumber/ruby/yardoc(.*)}, "http://www.rubydoc.info/github/cucumber/cucumber-ruby$1"
+ r301 %r{/cucumber/api/ruby/latest(.*)}, "http://www.rubydoc.info/github/cucumber/cucumber-ruby$1"
# redirect initials to homepage for tracking business cards
# we may want to create personal pages thanking people for chatting with us
@@ -14,6 +15,7 @@
# redirect all other api traffic to the legacy site
# TODO: figure out a better place to host it
+
r301 %r{(/api/.+)}, "http://cucumber.github.io$1"
r302 %r{/podcast/feed.xml}, "http://feeds.soundcloud.com/users/soundcloud:users:181591133/sounds.rss"
|
Change redirects to cucumber-ruby instead of cucumber on rubydoc
|
diff --git a/spec/models/assessment_spec.rb b/spec/models/assessment_spec.rb
index abc1234..def5678 100644
--- a/spec/models/assessment_spec.rb
+++ b/spec/models/assessment_spec.rb
@@ -21,19 +21,4 @@ end
end
- context 'STAR' do
- context 'valid subject' do
- let(:assessment) { FactoryBot.build(:assessment, family: 'STAR', subject: 'Mathematics') }
- it 'is valid' do
- expect(assessment).to be_valid
- end
- end
- context 'invalid subject' do
- let(:assessment) { FactoryBot.build(:assessment, family: 'STAR', subject: 'Math') }
- it 'is invalid' do
- expect(assessment).to be_invalid
- end
- end
- end
-
end
|
Remove STAR from assessment spec
|
diff --git a/spec/peeek/hook/linker_spec.rb b/spec/peeek/hook/linker_spec.rb
index abc1234..def5678 100644
--- a/spec/peeek/hook/linker_spec.rb
+++ b/spec/peeek/hook/linker_spec.rb
@@ -1,8 +1,15 @@ require 'peeek/hook/linker'
describe Peeek::Hook::Linker, '.classes' do
+ before do
+ @class = Class.new(described_class)
+ end
+
+ after do
+ described_class.classes.delete(@class)
+ end
+
it "returns classes that inherited #{described_class}" do
- klass = Class.new(described_class)
- described_class.classes.should be_include(klass)
+ described_class.classes.should be_include(@class)
end
end
|
Delete class from Peeek::Hook::Linker.classes after test
|
diff --git a/core/app/models/concerns/spree/adjustment_source.rb b/core/app/models/concerns/spree/adjustment_source.rb
index abc1234..def5678 100644
--- a/core/app/models/concerns/spree/adjustment_source.rb
+++ b/core/app/models/concerns/spree/adjustment_source.rb
@@ -4,20 +4,19 @@
included do
def deals_with_adjustments_for_deleted_source
- adjustment_scope = self.adjustments.includes(:order).references(:spree_orders)
+ adjustment_scope = self.adjustments.joins(:order)
# For incomplete orders, remove the adjustment completely.
- adjustment_scope.where("spree_orders.completed_at IS NULL").destroy_all
+ adjustment_scope.where(spree_orders: { completed_at: nil }).destroy_all
# For complete orders, the source will be invalid.
# Therefore we nullify the source_id, leaving the adjustment in place.
# This would mean that the order's total is not altered at all.
- adjustment_scope.where("spree_orders.completed_at IS NOT NULL").each do |adjustment|
- adjustment.update_columns(
- source_id: nil,
- updated_at: Time.now,
- )
- end
+ attrs = {
+ source_id: nil,
+ updated_at: Time.now
+ }
+ adjustment_scope.where.not(spree_orders: { completed_at: nil }).update_all(attrs)
end
end
end
|
Move all calculations to DB in AdjustmentSource
Closes #364
|
diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb
index abc1234..def5678 100644
--- a/spec/spec_helper_acceptance.rb
+++ b/spec/spec_helper_acceptance.rb
@@ -9,7 +9,7 @@ install_puppet
end
hosts.each do |host|
- on hosts, "mkdir -p #{host['distmoduledir']}"
+ on host, "mkdir -p #{host['distmoduledir']}"
end
end
|
Fix the mkdir for moduledir
|
diff --git a/app/controllers/api/v1/countries_controller.rb b/app/controllers/api/v1/countries_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/api/v1/countries_controller.rb
+++ b/app/controllers/api/v1/countries_controller.rb
@@ -1,7 +1,7 @@ class API::V1::CountriesController < API::APIController
def index
- @countries = Portal::Country.all.map{ |c| {name: c.name, id: c.id} }
+ @countries = Portal::Country.all.sort_by{ |k| k["name"]}.map{ |c| {name: c.name, id: c.id} }
render :json => @countries
end
|
Sort countries by name before output in API
|
diff --git a/app/models/nav_item.rb b/app/models/nav_item.rb
index abc1234..def5678 100644
--- a/app/models/nav_item.rb
+++ b/app/models/nav_item.rb
@@ -2,6 +2,7 @@
belongs_to :url_page, class_name: "Page"
+ validates :title, presence: true
validates :url_type, numericality: { only_integer: true }
validates :url_type, inclusion: (0..1)
validates :url_text, presence: true, if: Proc.new { |ni| ni.url_type == 0 }
|
Add presence true validation for title in nav items model file
|
diff --git a/spec/web/controllers/authentication_jwt_strategy_spec.rb b/spec/web/controllers/authentication_jwt_strategy_spec.rb
index abc1234..def5678 100644
--- a/spec/web/controllers/authentication_jwt_strategy_spec.rb
+++ b/spec/web/controllers/authentication_jwt_strategy_spec.rb
@@ -0,0 +1,70 @@+require 'spec_helper'
+require 'minitest/mock'
+require 'bcrypt'
+
+describe AuthenticationJwtStrategy do
+
+ let(:password_digest) { BCrypt::Password.create('secret', cost: 1) }
+ let(:user) { UserRepository.new.create(email: 'test@email.com', password_digest: password_digest) }
+ let(:jwt) { JwtIssuer.encode({ user_id: user.id }) }
+
+ after do
+ UserRepository.new.clear
+ end
+
+ it '.valid? returns true with valid header attributes' do
+ obj = ::AuthenticationJwtStrategy.new(nil)
+ env = { 'HTTP_AUTHORIZATION' => "Bearer #{jwt}" }
+
+ obj.stub :env, env do
+ assert obj.valid?
+ end
+ end
+
+ it '.valid? returns false with invalid header attributes' do
+ obj = ::AuthenticationJwtStrategy.new(nil)
+ env = {}
+
+ obj.stub :env, env do
+ refute obj.valid?
+ end
+ end
+
+ it '.valid? returns false with invalid header jwt' do
+ obj = ::AuthenticationJwtStrategy.new(nil)
+ env = { 'HTTP_AUTHORIZATION' => nil }
+
+ obj.stub :env, env do
+ refute obj.valid?
+ end
+ end
+
+ it '.authenticate! returns success with valid jwt' do
+ obj = ::AuthenticationJwtStrategy.new(nil)
+ env = { 'HTTP_AUTHORIZATION' => "Bearer #{jwt}" }
+
+ obj.stub :env, env do
+ assert_equal :success, obj.authenticate!
+ end
+ end
+
+ it '.authenticate! returns fail with invalid header attributes' do
+ obj = ::AuthenticationJwtStrategy.new(nil)
+ env = { 'HTTP_AUTHORIZATION' => 'Bearer invalid_jwt1232131' }
+
+ obj.stub :env, env do
+ assert_equal :failure, obj.authenticate!
+ end
+ end
+
+ it '.authenticate! returns fail with invalid payload information (user_id)' do
+ obj = ::AuthenticationJwtStrategy.new(nil)
+ wrong_jwt = JwtIssuer.encode({ user_id: 0 })
+ env = { 'HTTP_AUTHORIZATION' => "Bearer #{wrong_jwt}" }
+
+
+ obj.stub :env, env do
+ assert_equal :failure, obj.authenticate!
+ end
+ end
+end
|
Add specs for authentication jwt strategy
|
diff --git a/spec/commands/pipelined_spec.rb b/spec/commands/pipelined_spec.rb
index abc1234..def5678 100644
--- a/spec/commands/pipelined_spec.rb
+++ b/spec/commands/pipelined_spec.rb
@@ -26,7 +26,7 @@ redis.get key2
end
- results.should == [ value1, value2 ]
+ results.should == [value1, value2]
end
it 'returns futures' do
|
Remove spaces around array contents
|
diff --git a/spec/plugin/run_handler_spec.rb b/spec/plugin/run_handler_spec.rb
index abc1234..def5678 100644
--- a/spec/plugin/run_handler_spec.rb
+++ b/spec/plugin/run_handler_spec.rb
@@ -0,0 +1,53 @@+require File.expand_path("spec_helper", File.dirname(File.dirname(__FILE__)))
+
+describe "run_handler plugin" do
+ it "makes r.run :not_found=>:pass keep going on 404" do
+ pr = proc{|env| [(env['PATH_INFO'] == '/a' ? 404 : 201), {}, ['b']]}
+ app(:run_handler) do |r|
+ r.run pr, :not_found=>:pass
+ 'a'
+ end
+
+ status.must_equal 201
+ body.must_equal 'b'
+ status('/a').must_equal 200
+ body('/a').must_equal 'a'
+ end
+
+ it "makes r.run with a block yield rack app to block, and have it be thrown afterward" do
+ pr = proc{|env| [(env['PATH_INFO'] == '/a' ? 404 : 201), {}, ['b']]}
+ app(:run_handler) do |r|
+ r.run(pr){|a| a[0] *= 2}
+ 'a'
+ end
+
+ status.must_equal 402
+ status('/a').must_equal 808
+ end
+
+ it "works when both :not_found=>:pass and block are given" do
+ pr = proc{|env| [(env['PATH_INFO'] == '/a' ? 202 : 201), {}, ['b']]}
+ app(:run_handler) do |r|
+ r.run(pr, :not_found=>:pass){|a| a[0] *= 2}
+ 'a'
+ end
+
+ status.must_equal 402
+ body.must_equal 'b'
+ status('/a').must_equal 200
+ body('/a').must_equal 'a'
+ end
+
+ it "makes r.run work normally if not given an option or block" do
+ pr = proc{|env| [(env['PATH_INFO'] == '/a' ? 404 : 201), {}, ['b']]}
+ app(:run_handler) do |r|
+ r.run pr
+ 'a'
+ end
+
+ status.must_equal 201
+ body.must_equal 'b'
+ status('/a').must_equal 404
+ body('/a').must_equal 'b'
+ end
+end
|
Add spec for run_handler plugin, missed in previous commit
|
diff --git a/spec/requests/error_404_spec.rb b/spec/requests/error_404_spec.rb
index abc1234..def5678 100644
--- a/spec/requests/error_404_spec.rb
+++ b/spec/requests/error_404_spec.rb
@@ -3,7 +3,7 @@
describe "404 Page Not Found" do
- let(:station) { Station.make! }
+ let(:station) { create(:station) }
context "on main domain" do
before(:each) do
|
Move 404 requests spec to factory_girl.
|
diff --git a/core/db/migrate/20130802022321_migrate_tax_categories_to_line_items.rb b/core/db/migrate/20130802022321_migrate_tax_categories_to_line_items.rb
index abc1234..def5678 100644
--- a/core/db/migrate/20130802022321_migrate_tax_categories_to_line_items.rb
+++ b/core/db/migrate/20130802022321_migrate_tax_categories_to_line_items.rb
@@ -1,7 +1,10 @@ class MigrateTaxCategoriesToLineItems < ActiveRecord::Migration
def change
- Spree::LineItem.includes(:variant => { :product => :tax_category }).find_in_batches do |line_items|
- line_items.each do |line_item|
+ Spree::LineItem.includes(:variant => { :product => :tax_category }).find_in_batches do |line_items|
+ line_items.each do |line_item|
+ next if line_item.variant.nil?
+ next if line_item.variant.product.nil?
+ next if line_item.product.nil?
line_item.update_column(:tax_category_id, line_item.product.tax_category_id)
end
end
|
Add exceptions for blank records in tax categories migration
Fixes #4204
|
diff --git a/campfire/polling_bot/plugins/tweet_plugin.rb b/campfire/polling_bot/plugins/tweet_plugin.rb
index abc1234..def5678 100644
--- a/campfire/polling_bot/plugins/tweet_plugin.rb
+++ b/campfire/polling_bot/plugins/tweet_plugin.rb
@@ -31,7 +31,7 @@
# strip links from CF messages
def strip_links(msg)
- msg.gsub(/<a href="(.*?)">.*?<\/a>/, '\1')
+ msg.gsub(/<a href="([^"]*)".*?>.*?<\/a>/, '\1')
end
# post a message to twitter
|
Fix link parsing in TweetPlugin
|
diff --git a/lib/allowance/permissions.rb b/lib/allowance/permissions.rb
index abc1234..def5678 100644
--- a/lib/allowance/permissions.rb
+++ b/lib/allowance/permissions.rb
@@ -34,7 +34,7 @@ if p.is_a?(Hash)
model.where(p)
elsif p.is_a?(Proc)
- (p.arity == 0 ? model.instance_exec(&p) : p.call(model))
+ model.instance_exec(&p)
else
model
end
|
Simplify scope block code for now (fixes problems with 1.8.7)
|
diff --git a/lib/badge_overflow_config.rb b/lib/badge_overflow_config.rb
index abc1234..def5678 100644
--- a/lib/badge_overflow_config.rb
+++ b/lib/badge_overflow_config.rb
@@ -0,0 +1,32 @@+require 'yaml'
+
+class BadgeOverflowConfig
+ attr_reader :config_file
+
+ def self.instance
+ @@instance ||= new('config/users.yml')
+ end
+
+ def self.user_id
+ instance.user_id
+ end
+
+ def initialize(config_file)
+ @config_file = config_file
+ end
+
+ def user_id
+ @user_id ||= config['user_id']
+ @user_id ||= random_user
+ end
+
+ private
+
+ def random_user
+ config['users'].sample['id']
+ end
+
+ def config
+ @@config ||= YAML.load(File.read(config_file))
+ end
+end
|
Add BadgeOverflowConfig class to configure user id
|
diff --git a/lib/bourgeois/view_helper.rb b/lib/bourgeois/view_helper.rb
index abc1234..def5678 100644
--- a/lib/bourgeois/view_helper.rb
+++ b/lib/bourgeois/view_helper.rb
@@ -10,7 +10,6 @@ def present(object, klass = nil, &blk)
return object.map { |o| present(o, klass, &blk) } if object.respond_to?(:to_a)
- presenter = nil
if klass.blank?
if object.is_a?(Bourgeois::Presenter)
presenter = object
|
Remove useless presenter = nil
|
diff --git a/lib/git_release_notes/cli.rb b/lib/git_release_notes/cli.rb
index abc1234..def5678 100644
--- a/lib/git_release_notes/cli.rb
+++ b/lib/git_release_notes/cli.rb
@@ -34,7 +34,7 @@ options[:from],
options[:to],
options[:git_web_url],
- options[:exclude_submodules_without_changes],
+ !options[:exclude_submodules_without_changes],
).generate_html
end
end
|
Fix regression in passing in negation of exclude_submodules option
|
diff --git a/lib/hatokura/fairy_garden.rb b/lib/hatokura/fairy_garden.rb
index abc1234..def5678 100644
--- a/lib/hatokura/fairy_garden.rb
+++ b/lib/hatokura/fairy_garden.rb
@@ -1,5 +1,9 @@ module Hatokura
module FairyGarden
+ def self.const_missing(identifier)
+ Hatokura.const_missing(identifier)
+ end
+
class FarmVillage < Card
Name = '農村'
Cost = 1
|
Enable autoloading also in FairyGarden
|
diff --git a/lib/opal/hike_path_finder.rb b/lib/opal/hike_path_finder.rb
index abc1234..def5678 100644
--- a/lib/opal/hike_path_finder.rb
+++ b/lib/opal/hike_path_finder.rb
@@ -6,7 +6,7 @@ def initialize(paths = Opal.paths)
super()
append_paths *paths
- append_extensions '.js', '.js.rb', '.rb'
+ append_extensions '.js', '.js.rb', '.rb', '.opalerb'
end
def find path
|
Add opalerb to admitted path finder extensions
|
diff --git a/lib/rack_iframe_transport.rb b/lib/rack_iframe_transport.rb
index abc1234..def5678 100644
--- a/lib/rack_iframe_transport.rb
+++ b/lib/rack_iframe_transport.rb
@@ -1,7 +1,8 @@ module Rack
class IframeTransport
- def initialize(app)
+ def initialize(app, tag = 'textarea')
@app = app
+ @tag = tag
end
def call(env)
@@ -31,11 +32,11 @@ end
def html_document_left
- "<!DOCTYPE html><html><body><textarea #{metadata}>"
+ "<!DOCTYPE html><html><body><#{tag} #{metadata}>"
end
def html_document_right
- "</textarea></body></html>"
+ "</#{tag}></body></html>"
end
def metadata
|
Allow to use different tag
Sometimes is better to use pre instead of textarea because it have some issues with html inside of json object.
|
diff --git a/src/test/controllers/dashboard_controller_test.rb b/src/test/controllers/dashboard_controller_test.rb
index abc1234..def5678 100644
--- a/src/test/controllers/dashboard_controller_test.rb
+++ b/src/test/controllers/dashboard_controller_test.rb
@@ -5,7 +5,12 @@ @user = users(:one)
end
- test "should get index" do
+ test "should not get index without sign_in" do
+ get dashboard_url
+ assert_response :found
+ end
+
+ test "should not get index with sign_in" do
sign_in_user(@user)
get dashboard_url
|
Test case without sign_in in addition
|
diff --git a/lib/bundler/feature_flag.rb b/lib/bundler/feature_flag.rb
index abc1234..def5678 100644
--- a/lib/bundler/feature_flag.rb
+++ b/lib/bundler/feature_flag.rb
@@ -1,11 +1,15 @@ # frozen_string_literal: true
module Bundler
class FeatureFlag
- def self.settings_flag(flag)
+ def self.settings_flag(flag, &default)
unless Bundler::Settings::BOOL_KEYS.include?(flag.to_s)
raise "Cannot use `#{flag}` as a settings feature flag since it isn't a bool key"
end
- define_method("#{flag}?") { Bundler.settings[flag] }
+ define_method("#{flag}?") do
+ value = Bundler.settings[flag]
+ value = instance_eval(&default) if value.nil? && !default.nil?
+ value
+ end
end
(1..10).each {|v| define_method("bundler_#{v}_mode?") { major_version >= v } }
|
[FeatureFlag] Add a default value block for settings flags
|
diff --git a/pakyow-test/lib/pakyow-test.rb b/pakyow-test/lib/pakyow-test.rb
index abc1234..def5678 100644
--- a/pakyow-test/lib/pakyow-test.rb
+++ b/pakyow-test/lib/pakyow-test.rb
@@ -19,7 +19,7 @@ module Pakyow
module TestHelp
def self.setup
- Pakyow::App.stage :test
+ Pakyow::App.stage(ENV['TEST_ENV'] || :test)
Pakyow::App.after :match do
@presenter = Pakyow::TestHelp::ObservablePresenter.new(@presenter)
|
Use TEST_ENV when running tests
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.