diff
stringlengths
65
26.7k
message
stringlengths
7
9.92k
diff --git a/lib/flor/punit/cron.rb b/lib/flor/punit/cron.rb index abc1234..def5678 100644 --- a/lib/flor/punit/cron.rb +++ b/lib/flor/punit/cron.rb @@ -47,7 +47,6 @@ th[1] << td th -.tap { |x| pp x } end end
Remove trailing pp debug output
diff --git a/app/workers/export_photos.rb b/app/workers/export_photos.rb index abc1234..def5678 100644 --- a/app/workers/export_photos.rb +++ b/app/workers/export_photos.rb @@ -3,7 +3,6 @@ # Copyright (c) 2010-2011, Diaspora Inc. This file is # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. - module Workers class ExportPhotos < Base @@ -14,9 +13,9 @@ @user.perform_export_photos! if @user.reload.exported_photos_file.present? - ExportMailer.export_photos_complete_for(@user) + ExportMailer.export_photos_complete_for(@user).deliver_now else - ExportMailer.export_photos_failure_for(@user) + ExportMailer.export_photos_failure_for(@user).deliver_now end end end
Fix sending mails after photo export
diff --git a/lib/json_api_routes.rb b/lib/json_api_routes.rb index abc1234..def5678 100644 --- a/lib/json_api_routes.rb +++ b/lib/json_api_routes.rb @@ -10,15 +10,17 @@ constraints = { link_relation: links_regex }.merge(id_constraint(path)) post "/links/:link_relation", to: "#{ path }#update_links", - constraints: constraints, format: :false + constraints: constraints, format: :false delete "/links/:link_relation/:link_ids", to: "#{ path }#update_links", - constraints: constraints, format: :false + constraints: constraints, format: :false end def create_versions(path) - get "/versions", to: "#{ path }#versions", format: false - get "/versions/:id", to: "#{ path }#version", format: false + get "/versions", to: "#{ path }#versions", format: false, + constraints: id_constraint(path) + get "/versions/:id", to: "#{ path }#version", format: false, + constraints: id_constraint(path) end def json_api_resources(path, options={})
Add id constraint to version routes
diff --git a/event_store-messaging.gemspec b/event_store-messaging.gemspec index abc1234..def5678 100644 --- a/event_store-messaging.gemspec +++ b/event_store-messaging.gemspec @@ -2,7 +2,7 @@ Gem::Specification.new do |s| s.name = 'event_store-messaging' s.summary = 'Messaging primitives for EventStore using the EventStore Client HTTP library' - s.version = '0.1.13' + s.version = '0.1.14' s.authors = [''] s.require_paths = ['lib'] s.files = Dir.glob('{lib}/**/*')
Package version is increased from 0.1.13 to 0.1.14
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 @@ -0,0 +1,23 @@+# monkey patch BufferedLogger to allow a custom formatter +class ActiveSupport::BufferedLogger + def formatter=(formatter) + @log.formatter = formatter + end +end + +# ensure DJ is logging to the right file +Delayed::Worker.logger = ActiveSupport::BufferedLogger.new("log/delayed_job.log", Rails.logger.level) +if caller.last =~ /delayed_job/ + # create a custom formatter than includes the pid + # from http://cbpowell.wordpress.com/2012/04/05/beautiful-logging-for-ruby-on-rails-3-2/ + class DJFormatter + def call(severity, time, progname, msg) + formatted_severity = sprintf("%-5s","#{severity}") + "[#{formatted_severity} pid:#{$$}] #{msg.strip}\n" + end + end + Delayed::Worker.logger.formatter = DJFormatter.new + + # log AR calls to the log file + ActiveRecord::Base.logger = Delayed::Worker.logger +end
Isolate all DJ logging to the DJ log files.
diff --git a/lib/tasks/sidekiq.rake b/lib/tasks/sidekiq.rake index abc1234..def5678 100644 --- a/lib/tasks/sidekiq.rake +++ b/lib/tasks/sidekiq.rake @@ -6,7 +6,7 @@ # sidekiq is already running, don't need to run if Sidekiq::ProcessSet.new.size == 0 ss = Sidekiq::ScheduledSet.new - if ss.first.at < Time.now + if ss.first.try { |job| job.at < Time.now } exec "bundle exec sidekiq" end end
Handle case when ScheduledSet is empty
diff --git a/features/step_definitions/directory_steps.rb b/features/step_definitions/directory_steps.rb index abc1234..def5678 100644 --- a/features/step_definitions/directory_steps.rb +++ b/features/step_definitions/directory_steps.rb @@ -1,18 +1,4 @@ require 'tmpdir' - -Given /^a temporary directory called '(.+)'$/ do |name| - path = Dir.mktmpdir - at_exit do - delete_path path - end - variable_table[name] = path -end - -Given /^a home directory called '(.+)' in '(.+)'$/ do |name, virtual_path| - actual_path = expand(virtual_path) - Dir.mkdir actual_path, 0700 - variable_table[name] = actual_path -end Given /^I don't have a directory called '(.+)'$/ do |virtual_path| Dir.should_not exist(expand(virtual_path))
Delete legacy steps about $tmp and $home
diff --git a/lib/tiddle/strategy.rb b/lib/tiddle/strategy.rb index abc1234..def5678 100644 --- a/lib/tiddle/strategy.rb +++ b/lib/tiddle/strategy.rb @@ -13,7 +13,7 @@ return fail(:invalid_token) unless resource token = Tiddle::TokenIssuer.build.find_token(resource, token_from_headers) - if (token) + if token touch_token(token) return success!(resource) end
Improve code style by removing parenthesis
diff --git a/app/models/client.rb b/app/models/client.rb index abc1234..def5678 100644 --- a/app/models/client.rb +++ b/app/models/client.rb @@ -1,6 +1,9 @@ class Client include Mongoid::Document field :name, type: String - field :wisecrack_id, type: String embeds_many :projects + + def wisecrack_id + Wisecrack.get_client_by_name self.name + end end
Move the Wisecrack ID out of Mongo and to the API
diff --git a/db/seeds.rb b/db/seeds.rb index abc1234..def5678 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -19,16 +19,15 @@ ]) end -Jurisdiction.create([{ name: 'County Court', abbr: nil }, - { name: 'High Court', abbr: nil }, +Jurisdiction.create([{ name: 'County', abbr: nil }, + { name: 'Family', abbr: nil }, + { name: 'High', abbr: nil }, { name: 'Insolvency', abbr: nil }, - { name: 'Family Court', abbr: nil }, + { name: 'Magistrates', abbr: nil }, { name: 'Probate', abbr: nil }, - { name: 'Court of Protection', abbr: 'COP' }, - { name: 'Magistrates Civil', abbr: nil }, + { name: 'Employment', abbr: nil }, { name: 'Gambling', abbr: nil }, - { name: 'Employment Tribunal', abbr: nil }, - { name: 'Gender Tribunal', abbr: nil }, - { name: 'Land & Property Chamber', abbr: nil }, - { name: 'Immigration Appeal Chamber', abbr: 'IAC' }, - { name: 'Upper Tribunal Immigration Appeal Chamber', abbr: 'UTIAC' }]) + { name: 'Gender recognition', abbr: nil }, + { name: 'Immigration (first-tier)', abbr: nil }, + { name: 'Immigration (upper)', abbr: nil }, + { name: 'Property', abbr: nil }])
Copy changed of jurisdiction names in seed data
diff --git a/db/seeds.rb b/db/seeds.rb index abc1234..def5678 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,9 +1,11 @@ require 'faker' - 20.times do - Question.create!( + question = Question.create!( title: Faker::Lorem.sentence, content: Faker::Lorem.paragraph, asker_id: rand(100), best_answer_id: rand(100)) -end + 5.times do + question.comments << Comment.create!(content: Faker::Lorem.sentence) + end +end
Add seed file which populates questions with comments
diff --git a/spec/dummy/config/environments/development.rb b/spec/dummy/config/environments/development.rb index abc1234..def5678 100644 --- a/spec/dummy/config/environments/development.rb +++ b/spec/dummy/config/environments/development.rb @@ -19,9 +19,6 @@ # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log - # Raise an error on page load if there are pending migrations - config.active_record.migration_error = :page_load - # Debug mode disables concatenation and preprocessing of assets. # This option may cause significant delays in view rendering with a large # number of complex assets.
Remove a missed reference to ActiveRecord.
diff --git a/spec/dummy/config/initializers/cornerstone.rb b/spec/dummy/config/initializers/cornerstone.rb index abc1234..def5678 100644 --- a/spec/dummy/config/initializers/cornerstone.rb +++ b/spec/dummy/config/initializers/cornerstone.rb @@ -5,7 +5,7 @@ # Specify the method in which your application accesses the authenticated user. # This can either be the method name (as a symbol) such as ':current_user', or # if your application uses warden, use ':warden'. - config.auth_with = :warden + config.auth_with = Proc.new {|controller| controller.current_user} # == Discussion Statuses # An array of strings which specify the status options for a discussion.
Test dummy app with current_user helper.
diff --git a/merb_datamapper.gemspec b/merb_datamapper.gemspec index abc1234..def5678 100644 --- a/merb_datamapper.gemspec +++ b/merb_datamapper.gemspec @@ -10,8 +10,8 @@ gem.name = 'merb_datamapper' gem.version = Merb::DataMapper::VERSION.dup gem.date = Date.today.to_s - gem.authors = [ "Jason Toy" ] - gem.email = "jtoy@rubynow.com" + gem.authors = [ "Jason Toy", "Jonathan Stott" ] + gem.email = "jonathan.stott@gmail.com" gem.homepage = "http://github.com/merb/merb_datamapper" gem.description = "Merb plugin that provides support for datamapper" gem.summary = "Merb plugin that allows you to use datamapper with your merb app"
Make myself person to email
diff --git a/spec/support/capybara.rb b/spec/support/capybara.rb index abc1234..def5678 100644 --- a/spec/support/capybara.rb +++ b/spec/support/capybara.rb @@ -16,4 +16,5 @@ ) end +Capybara.server = :webrick Capybara.javascript_driver = :headless_chrome
Configure Capybara to run `Webrick` in tests This commit resolves dependecy issues due to the absence of `puma` from the project's Gemfiles: ``` Failure/Error: raise LoadError, "Capybara is unable to load `puma` for its server, please add `puma` to your project or specify a different server via something like `Capybara.server = :webrick`." LoadError: Capybara is unable to load `puma` for its server, please add `puma` to your project or specify a different server via something like `Capybara.server = :webrick`. ``` Instead of adding an additional dependency, configure Capybara to use `webrick`, which is available as part of Ruby's standard library.
diff --git a/spec/unit/client_spec.rb b/spec/unit/client_spec.rb index abc1234..def5678 100644 --- a/spec/unit/client_spec.rb +++ b/spec/unit/client_spec.rb @@ -2,11 +2,16 @@ describe Client do - # TODO: this entire class needs a test double for Resting - # which can receive messages - it "has a valid mock" do - client = double('Client') + it "should return all clients through cache" do + clients = Client.all_with_cache + clients.count.should eq 1 end - pending "This test requires a Resting mock" + + it "should return all clients as a hash" do + clients_hash = Client.full_hash + clients_hash.should be_a Hash + clients_hash.should_not be_empty + clients_hash.count.should eq 1 + end end
Add unit tests for client
diff --git a/proxy/recipes/deploy.rb b/proxy/recipes/deploy.rb index abc1234..def5678 100644 --- a/proxy/recipes/deploy.rb +++ b/proxy/recipes/deploy.rb @@ -10,5 +10,17 @@ command "/usr/sbin/proxy2ensite #{application} #{deploy[:deploy_to]} #{deploy[:domains].join(',')}" notifies :reload, "service[nginx]" end + + Chef::Log.info("Restart NodeJS Application #{application}.") + execute "Restart NodeJS Application #{application}." do + cwd deploy[:current_path] + command "sleep #{node[:deploy][application][:nodejs][:sleep_before_restart]} && #{node[:deploy][application][:nodejs][:restart_command]}" + action :run + only_if do + File.exists?(deploy[:current_path]) + end + end + end + end
Add automatically restart nodeJs App
diff --git a/features/support/env.rb b/features/support/env.rb index abc1234..def5678 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -14,6 +14,15 @@ include Capybara::DSL include RSpec::Expectations include RSpec::Matchers + + def db + @db ||= CouchRest.database(settings.db) + end +end + +Before do + db.delete! + db.create! end World do
Delete and create the database on each scenario
diff --git a/activelogic.gemspec b/activelogic.gemspec index abc1234..def5678 100644 --- a/activelogic.gemspec +++ b/activelogic.gemspec @@ -7,11 +7,11 @@ Gem::Specification.new do |s| s.name = "activelogic" s.version = Activelogic::VERSION - s.authors = ["TODO: Your name"] - s.email = ["TODO: Your email"] - s.homepage = "TODO" - s.summary = "TODO: Summary of Activelogic." - s.description = "TODO: Description of Activelogic." + s.authors = ["sorpa'as plat"] + s.email = ["sorpaas@gmail.com"] + s.homepage = "https://github.com/sorpaas/activelogic" + s.summary = "Active Logic for Ruby on Rails" + s.description = "Rails Plugin for Convenient Business Logic" s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"] s.test_files = Dir["test/**/*"]
Change author and app description in gemspec
diff --git a/db/migrate/20160204120652_change_publishing_app_for_email_campaign_content.rb b/db/migrate/20160204120652_change_publishing_app_for_email_campaign_content.rb index abc1234..def5678 100644 --- a/db/migrate/20160204120652_change_publishing_app_for_email_campaign_content.rb +++ b/db/migrate/20160204120652_change_publishing_app_for_email_campaign_content.rb @@ -8,22 +8,21 @@ reservation.save(validate: false) end - DraftContentItem.where(publishing_app: "email-campaign-frontend").each do |content_item| + ContentItem.where(publishing_app: "email-campaign-frontend").each do |content_item| content_item.update_attributes!(publishing_app: "share-sale-publisher") - ContentStoreWorker.perform_async( - content_store: Adapters::DraftContentStore, - draft_content_item_id: content_item.id, - ) - end + state = State.find_by!(content_item: content_item) - LiveContentItem.where(publishing_app: "email-campaign-frontend").each do |content_item| - content_item.update_attributes!(publishing_app: "share-sale-publisher") + if state.name == "draft" + content_store = Adapters::DraftContentStore + elsif state.name == "published" + content_store = Adapters::ContentStore + end ContentStoreWorker.perform_async( - content_store: Adapters::ContentStore, - live_content_item_id: content_item.id, - ) + content_store: content_store, + content_item_id: content_item.id, + ) if content_store end end end
Update EmailCampaignMigration to use the new object model
diff --git a/db/migrate/20161107113454_remove_deleted_removed_document_ids_from_manuals.rb b/db/migrate/20161107113454_remove_deleted_removed_document_ids_from_manuals.rb index abc1234..def5678 100644 --- a/db/migrate/20161107113454_remove_deleted_removed_document_ids_from_manuals.rb +++ b/db/migrate/20161107113454_remove_deleted_removed_document_ids_from_manuals.rb @@ -0,0 +1,43 @@+# The history +# =========== +# +# In the past we have run various scripts and migrations to remove sections +# from some manuals. The ids of these documents live in the +# removed_document_ids field of the ManualRecord::Edition. +# In some cases we've also totally removed the SpecialistDocumentEditions that +# these document ids refer to. This causes a problem when trying to do +# a republishing, or any other bulk operations on these manuals. +# +# This migration searches through all the manuals and all their editions +# to delete any ids in the removed_document_ids that no longer refer to a +# SpecialistDocumentEdition. +# +# This seems dangerous as those document ids might refer to published content +# in the publishing-api, but we've checked all this manually and none of them +# did. +class RemoveDeletedRemovedDocumentIdsFromManuals < Mongoid::Migration + def self.up + ManualRecord.all.to_a.each do |manual_record| + puts %{Looking at "#{manual_record.slug}":#{manual_record.manual_id}} + manual_record.editions.each do |manual_edition| + print " Version: #{manual_edition.version_number} - " + to_remove = (manual_edition.removed_document_ids || []).reject do |id| + SpecialistDocumentEdition.where(document_id: id).exists? + end + if to_remove.size > 0 + puts "#{to_remove.size} entries to remove: #{to_remove.inspect}" + manual_edition.removed_document_ids = (manual_edition.removed_document_ids - to_remove) + manual_edition.save! + else + puts "Nothing to do!" + end + end + end + end + + def self.down + # Whilst it would be possible to reverse this, it would be a lot of work + # for something that is unlikely to ever get run. + raise IrreversibleMigration + end +end
Remove removed_document_ids entries that point to deleted documents At some point in the past, we fully deleted some sections from a manual so that they no longer exist. Unfortunately we left references to their ids in the removed_document_ids of the manual they used to belong to. This means that we can't republish that manual, or do other publishing tasks as publishing does things with the removed_document_ids. To solve this we run a migration that finishes the job by removing any ids in removed_document_ids that no longer point to an instance in SpecialistDocumentEdition. We have done some manual work to check that the ids we remove don't still exist in the publishing-api and they don't so our cleanup is all we need to do.
diff --git a/app/mailers/footprint_mailer.rb b/app/mailers/footprint_mailer.rb index abc1234..def5678 100644 --- a/app/mailers/footprint_mailer.rb +++ b/app/mailers/footprint_mailer.rb @@ -1,5 +1,5 @@ class FootprintMailer < ActionMailer::Base - default :from => "from@example.com" + default :from => "CO4Squared <no-reply@amee.com>" def footprint_email(user, checkins=nil, application_url=nil) @user = user @@ -16,7 +16,7 @@ def send_email_and_update_last_sent(user) user.update_attributes!(:last_email_sent => DateTime.now) - mail(:to => user.email, :subject => "Check out your Checkins") + mail(:to => user.email, :subject => "Your Carbon Fourprint") end end
Update mailer address and subject
diff --git a/app/models/concerns/gravatar.rb b/app/models/concerns/gravatar.rb index abc1234..def5678 100644 --- a/app/models/concerns/gravatar.rb +++ b/app/models/concerns/gravatar.rb @@ -0,0 +1,80 @@+module Gravatar + # Provides methods for social data added through Gravatar's Verified Services + extend ActiveSupport::Concern + + included do + %w(facebook flickr twitter linkedin).map do |network_name| + # Defines predicate methods when module is loaded + # Example: + # User.first.linkedin? + # => true + # + define_method "#{network_name}?" do + account_names.include?(network_name) + end + + # Defines dynamic getter methods when module is loaded + # Example: + # User.first.twitter + # => "JonahBinario" + # + define_method network_name do + social_info.send(network_name) if send("#{network_name}?") + end + end + + after_validation :prefill_social_data, if: :new_record? + end + + def prefill_social_data + self.facebook_username = self.facebook if self.facebook? + self.flickr_username = self.flickr if self.flickr? + self.twitter_username = self.twitter if self.twitter? + self.linkedin_username = self.linkedin if self.linkedin? + self.bio = self.about_me unless self.about_me.nil? + end + + def gravatar_user_hash + Digest::MD5::hexdigest(self.email.downcase) + end + + # Returns an OpenStruct object with methods for each account found + # This enables the methods defined in the included callback. + # Can also be used like this: + # User.first.available_info + # => #<OpenStruct facebook="jose.a.padilla", linkedin="joseapadilla", twitter="jpadilla_"> + # + # User.first.available_info.twitter + # => "jpadilla_" + # + def social_info + user_social_info = {} + + account_data.map do |account| + user_social_info[account['shortname']] = account['username'] + end + OpenStruct.new(user_social_info) + end + + def about_me + info.fetch('aboutMe', nil) + end + + private + + def user_json + JSON.parse(open("http://en.gravatar.com/#{gravatar_user_hash}.json").read) + end + + def info + user_json['entry'][0] + end + + def account_data + info['accounts'] + end + + def account_names + account_data.map { |a| a.fetch('shortname', nil) } + end +end
Add Gravatar module for User model. Prefills data on registration
diff --git a/app/models/departure_fetcher.rb b/app/models/departure_fetcher.rb index abc1234..def5678 100644 --- a/app/models/departure_fetcher.rb +++ b/app/models/departure_fetcher.rb @@ -10,7 +10,7 @@ @departures ||= stop_times.map { |stop_time| stop_time_update = realtime_updates.for_stop_time(stop_time) Departure.new(date: @time.to_date, stop_time: stop_time, stop_time_update: stop_time_update) - } + }.sort_by(&:time) end def stop_times @@ -18,7 +18,6 @@ .where(stop: stop, trips: { service_id: Service.for_time(@time) }) .where("departure_time > :start_time AND departure_time < :end_time", time_query) .includes(:route, :trip, :stop) - .order(:departure_time) end def valid?
Sort departures rather than stop_times There are cases where realtime updates change the order of departures. Ordering by departure.time ensures that they are always ordered by actual departure time.
diff --git a/app/models/role_payment_type.rb b/app/models/role_payment_type.rb index abc1234..def5678 100644 --- a/app/models/role_payment_type.rb +++ b/app/models/role_payment_type.rb @@ -3,8 +3,8 @@ attr_accessor :id, :name - Unpaied = create!(id: 1, name: "Unpaid") + Consultant = create!(id: 4, name: "Paid as a consultant") ParliamentarySecretary = create!(id: 2, name: "Paid as a Parliamentary Secretary") Whip = create!(id: 3, name: "Paid as a whip") - Consultant = create!(id: 4, name: "Paid as a consultant") + Unpaied = create!(id: 1, name: "Unpaid") end
Sort role payment type options alphabetically
diff --git a/lib/active_job/queue_adapters/que_adapter.rb b/lib/active_job/queue_adapters/que_adapter.rb index abc1234..def5678 100644 --- a/lib/active_job/queue_adapters/que_adapter.rb +++ b/lib/active_job/queue_adapters/que_adapter.rb @@ -5,7 +5,7 @@ class QueAdapter class << self def enqueue(job, *args) - JobWrapper.enqueue job, *args, queue: job.queue_name + JobWrapper.enqueue job.to_s, *args, queue: job.queue_name end def enqueue_at(job, timestamp, *args) @@ -15,7 +15,7 @@ class JobWrapper < Que::Job def run(job, *args) - job.new.execute *args + job.constantize.new.execute *args end end end
Fix database serialization of job class names with Que When passing a class constant as a job argument, Que’s stored procedures serialize it to JSON in the database as `{}`. This means that when the job (the ActiveJob “wrapper”) is deserialized from the database, it can’t find the original job class to run again. Changing the Que adapter to serialize the job class as a string fixes this behaviour. This change makes the adapter consistent with other adapters too (which constantize a class string in their JobWrapper#perform methods.
diff --git a/rack-honeytoken.gemspec b/rack-honeytoken.gemspec index abc1234..def5678 100644 --- a/rack-honeytoken.gemspec +++ b/rack-honeytoken.gemspec @@ -6,7 +6,7 @@ Gem::Specification.new do |spec| spec.name = "rack-honeytoken" spec.version = Rack::Honeytoken::VERSION - spec.license = "BSD-2-Clause" + spec.licenses = ["BSD-2-Clause"] spec.authors = ["Matthew Closson"] spec.email = ["matthew.closson@gmail.com"]
Update gemspec licenses to be array of strings
diff --git a/test/server/feature_baseline_speed_test.rb b/test/server/feature_baseline_speed_test.rb index abc1234..def5678 100644 --- a/test/server/feature_baseline_speed_test.rb +++ b/test/server/feature_baseline_speed_test.rb @@ -10,7 +10,7 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - multi_os_test '8A6', - 'baseline average speed is less than 1.7 secs' do + 'baseline average speed is less than 1.5 secs' do timings = [] (1..5).each do started_at = Time.now @@ -22,7 +22,7 @@ timings << (secs * 1000 + millisecs) end mean = timings.reduce(0, :+) / timings.size - assert mean < max=1700, "mean=#{mean}, max=#{max}" + assert mean < max=1500, "mean=#{mean}, max=#{max}" end end
Reduce maximum for baseline speed test
diff --git a/lib/kaminari/models/data_mapper_extension.rb b/lib/kaminari/models/data_mapper_extension.rb index abc1234..def5678 100644 --- a/lib/kaminari/models/data_mapper_extension.rb +++ b/lib/kaminari/models/data_mapper_extension.rb @@ -5,8 +5,10 @@ module Paginatable class_eval <<-RUBY, __FILE__, __LINE__ + 1 def #{Kaminari.config.page_method_name}(num = 1) + model = self + model = self.model if self.is_a? DataMapper::Collection num = [num.to_i, 1].max - 1 - all(:limit => default_per_page, :offset => default_per_page * num).extend Paginating + all(:limit => model.default_per_page, :offset => model.default_per_page * num).extend Paginating end RUBY end
Fix for Model.all.page in DataMapper
diff --git a/lib/skeptic/rules/spaces_around_operators.rb b/lib/skeptic/rules/spaces_around_operators.rb index abc1234..def5678 100644 --- a/lib/skeptic/rules/spaces_around_operators.rb +++ b/lib/skeptic/rules/spaces_around_operators.rb @@ -41,4 +41,4 @@ end end end -end+end
Add newline at the end of a file
diff --git a/lib/sprockets/media_query_combiner/engine.rb b/lib/sprockets/media_query_combiner/engine.rb index abc1234..def5678 100644 --- a/lib/sprockets/media_query_combiner/engine.rb +++ b/lib/sprockets/media_query_combiner/engine.rb @@ -1,9 +1,9 @@ require 'sprockets/media_query_combiner/processor' -if defined?(Rails) +if defined?(::Rails) module Sprockets module MediaQueryCombiner - class Engine < Rails::Engine + class Engine < ::Rails::Engine initializer :setup_media_query_combiner, after: 'sprockets.environment', group: :all do |app| app.assets.register_postprocessor 'text/css', Sprockets::MediaQueryCombiner::Processor app.assets.register_bundle_processor 'text/css', Sprockets::MediaQueryCombiner::Processor
Use ::Rails instead of Rails Prevents Rails 4 Rake error: uninitialized constant Sprockets::Rails::Engine
diff --git a/app/models/delivery.rb b/app/models/delivery.rb index abc1234..def5678 100644 --- a/app/models/delivery.rb +++ b/app/models/delivery.rb @@ -7,15 +7,11 @@ after_save :update_status! def self.today - # Currently created_at on deliveries doesn't get set so have to get the time from emails - # TODO Get rid of join - joins(:email).where('emails.created_at > ?', Date.today.beginning_of_day) + where('created_at > ?', Date.today.beginning_of_day) end def self.this_week - # Currently created_at on deliveries doesn't get set so have to get the time from emails - # TODO Get rid of join - joins(:email).where('emails.created_at > ?', 7.days.ago) + where('created_at > ?', 7.days.ago) end # This delivery is being open tracked
Use created_at time that is now set in deliveries table
diff --git a/ruby/resistor-color-duo/resistor_color_duo.rb b/ruby/resistor-color-duo/resistor_color_duo.rb index abc1234..def5678 100644 --- a/ruby/resistor-color-duo/resistor_color_duo.rb +++ b/ruby/resistor-color-duo/resistor_color_duo.rb @@ -4,10 +4,12 @@ "#{ColorArray.index(colors[0])}#{ColorArray.index(colors[1])}".to_i end + private + ColorArray = [ "black", "brown", - "no_color", + "red", "orange", "yellow", "green", @@ -16,4 +18,5 @@ "grey", "white" ] + end
Add red & make private
diff --git a/db/migrate/20160702205006_create_items.rb b/db/migrate/20160702205006_create_items.rb index abc1234..def5678 100644 --- a/db/migrate/20160702205006_create_items.rb +++ b/db/migrate/20160702205006_create_items.rb @@ -3,7 +3,7 @@ create_table :items do |t| t.integer :user_id, null: false t.integer :section_id, null: false - t.attachment :image + t.attachment :image, null: false t.timestamps(null: false) end
Add null:false constraint to item image attachment
diff --git a/lib/haproxy_weight/config.rb b/lib/haproxy_weight/config.rb index abc1234..def5678 100644 --- a/lib/haproxy_weight/config.rb +++ b/lib/haproxy_weight/config.rb @@ -29,7 +29,7 @@ tempfile = Tempfile.new('haproxy.cfg') tempfile.write(@lines.join("\n")) tempfile.close - File.mv tempfile.path '/etc/haproxy/haproxy.cfg' + FileUtils.mv tempfile.path, @filename end end end
Use FileUtils to move tempfile
diff --git a/lib/iban-tools/conversion.rb b/lib/iban-tools/conversion.rb index abc1234..def5678 100644 --- a/lib/iban-tools/conversion.rb +++ b/lib/iban-tools/conversion.rb @@ -33,7 +33,7 @@ def self.load_config(country_code) default_config = YAML. - load(File.read(File.dirname(__FILE__) + '/conversion_rules.yml')) + load_file(File.join(File.dirname(__FILE__), 'conversion_rules.yml')) default_config[country_code] end
Use YAML.load_file instead of YAML.load(File.Read). Use File.join instead of concatenating bits of path.
diff --git a/lib/rolify/adapters/active_record/resource_adapter.rb b/lib/rolify/adapters/active_record/resource_adapter.rb index abc1234..def5678 100644 --- a/lib/rolify/adapters/active_record/resource_adapter.rb +++ b/lib/rolify/adapters/active_record/resource_adapter.rb @@ -1,25 +1,25 @@ require 'rolify/adapters/base' module Rolify - module Adapter + module Adapter class ResourceAdapter < ResourceAdapterBase def resources_find(roles_table, relation, role_name) - resources = relation.joins("INNER JOIN #{quote(roles_table)} ON #{quote(roles_table)}.resource_type = '#{relation.to_s}' AND - (#{quote(roles_table)}.resource_id IS NULL OR #{quote(roles_table)}.resource_id = #{quote(relation.table_name)}.id)") + resources = relation.joins("INNER JOIN #{quote(roles_table)} ON #{quote(roles_table)}.resource_type = '#{relation.to_s}' AND + (#{quote(roles_table)}.resource_id IS NULL OR #{quote(roles_table)}.resource_id = #{quote(relation.table_name)}.#{relation.primary_key})") resources = resources.where("#{quote(roles_table)}.name IN (?) AND #{quote(roles_table)}.resource_type = ?", Array(role_name), relation.to_s) resources end def in(relation, user, role_names) roles = user.roles.where(:name => role_names) - relation.where("#{quote(role_class.table_name)}.id IN (?) AND ((resource_id = #{quote(relation.table_name)}.id) OR (resource_id IS NULL))", roles) + relation.where("#{quote(role_class.table_name)}.#{role_class.primary_key} IN (?) AND ((resource_id = #{quote(relation.table_name)}.#{relation.primary_key}) OR (resource_id IS NULL))", roles) end - + private - + def quote(column) ActiveRecord::Base.connection.quote_column_name column end end end -end+end
Fix bug only primary key id.
diff --git a/lib/tasks/taxonomy/export_taxonomy_to_json.rake b/lib/tasks/taxonomy/export_taxonomy_to_json.rake index abc1234..def5678 100644 --- a/lib/tasks/taxonomy/export_taxonomy_to_json.rake +++ b/lib/tasks/taxonomy/export_taxonomy_to_json.rake @@ -1,59 +1,23 @@-require 'json' - namespace :taxonomy do - desc <<-DESC + namespace :export do + desc <<-DESC Exports an expanded taxonomy to a single JSON array - DESC - namespace :export do + DESC task :json, [:root_taxon_id] => [:environment] do |_, args| root_taxon_id = args.fetch(:root_taxon_id) - root_taxon = OpenStruct.new(Services.publishing_api.get_content(root_taxon_id).to_h) - taxonomy = Taxonomy::ExpandedTaxonomy.new(root_taxon.content_id) - taxonomy.build - - flattened_taxonomy = flatten_taxonomy(taxonomy.child_expansion) - - puts JSON.generate(flattened_taxonomy) + puts Taxonomy::TaxonTreeExport.new(root_taxon_id).build end - def flatten_taxonomy(taxon) - flattened_taxonomy = [convert_to_content_item(taxon)] + desc 'Export Taxonomy tree to JSON file' + task :to_file, %i[taxon_id file_name] => [:environment] do |_, args| + file_name = args.fetch(:file_name, "taxon") - if taxon.children - taxon.children.each do |child_taxon| - flattened_taxonomy += flatten_taxonomy(child_taxon) - end + taxon_id = args.fetch(:taxon_id) + taxon_tree = Taxonomy::TaxonTreeExport.new(taxon_id).build + + open(Rails.root.join('tmp', "#{file_name}.json"), 'w') do |f| + f << taxon_tree end - - flattened_taxonomy - end - - def convert_to_content_item(taxon, recursion_direction = nil) - taxon_content = OpenStruct.new(Services.publishing_api.get_content(taxon.content_id).to_h) - - content_item = { - base_path: taxon.base_path, - content_id: taxon.content_id, - title: taxon.title, - description: taxon_content.description, - document_type: 'taxon', - publishing_app: 'content-tagger', - rendering_app: 'collections', - schema_name: 'taxon', - user_journey_document_supertype: 'finding', - links: {}, - } - - unless recursion_direction == :parent - content_item[:links][:child_taxons] = taxon.children.map { |child| convert_to_content_item(child, :child) } - end - unless recursion_direction == :child - if taxon.parent - content_item[:links][:parent_taxons] = [convert_to_content_item(taxon.parent, :parent)] - end - end - - content_item end end end
Add to_file task to export namespace This implements the build function on the new TaxonTreeExport class to build the taxon tree array and convert it to JSON. Then saves the JSON to a file in the temp directory The json task now also implements the TaxonTreeExport build function.
diff --git a/lib/liquid/newspaper_drop.rb b/lib/liquid/newspaper_drop.rb index abc1234..def5678 100644 --- a/lib/liquid/newspaper_drop.rb +++ b/lib/liquid/newspaper_drop.rb @@ -34,7 +34,7 @@ def latest_by_section unless @latest_articles_for_sections @latest_articles_for_sections = {} - for article in Articles.find(:all, :from => "/accounts/#{@account.id.to_s}/query.xml", :group_by => "section", :count => 1, :as => @account.access_token ) + for article in Article.find(:all, :from => "/accounts/#{@account.id.to_s}/query.xml", :group_by => "section", :count => 1, :as => @account.access_token ) @latest_articles_for_sections[article.section] = article end end
Fix typo in last commit.
diff --git a/lib/models/team/team_bnet.rb b/lib/models/team/team_bnet.rb index abc1234..def5678 100644 --- a/lib/models/team/team_bnet.rb +++ b/lib/models/team/team_bnet.rb @@ -9,11 +9,15 @@ if characters.any? results = [] characters.each do |character| - character.process_result(RBattlenet::Wow::Character.find( - name: character.name, - realm: character.realm_slug, - fields: BNET_FIELDS, - )) + begin + character.process_result(RBattlenet::Wow::Character.find( + name: character.name, + realm: character.realm_slug, + fields: BNET_FIELDS, + )) + rescue + character.return_error(OpenStruct.new({code: 555})) + end results << ["", character] end
Handle HTTP errors in workaround.
diff --git a/spec/unit/templates/rabbitmq-server-version_spec.rb b/spec/unit/templates/rabbitmq-server-version_spec.rb index abc1234..def5678 100644 --- a/spec/unit/templates/rabbitmq-server-version_spec.rb +++ b/spec/unit/templates/rabbitmq-server-version_spec.rb @@ -0,0 +1,22 @@+require 'spec_helper' +require 'bosh/template/renderer' + +RSpec.describe 'Server version', template: true do + let(:manifest_properties) do + { + 'rabbitmq-server' => { + 'version' => 'fake_version' + } + } + end + + let(:rendered_template) { + compiled_template('rabbitmq-server', 'rabbitmq-server-version', manifest_properties).strip + } + + describe 'environment variables' do + it 'sets RMQ_SERVER_VERSION' do + expect(rendered_template).to include("RMQ_SERVER_VERSION=fake_version") + end + end +end
Add test for new `rabbitmq-server-version` template [#155509097] Signed-off-by: Michal Kuratczyk <304440fa11254af9197fe70f6c35e6528f26afc4@pivotal.io>
diff --git a/rubygems-yardoc.gemspec b/rubygems-yardoc.gemspec index abc1234..def5678 100644 --- a/rubygems-yardoc.gemspec +++ b/rubygems-yardoc.gemspec @@ -21,5 +21,4 @@ gem.add_development_dependency 'bundler' gem.add_development_dependency 'rake' - gem.add_development_dependency 'redcarpet' end
Remove Redcarpet from dev dependencies
diff --git a/diffux-core.gemspec b/diffux-core.gemspec index abc1234..def5678 100644 --- a/diffux-core.gemspec +++ b/diffux-core.gemspec @@ -20,7 +20,7 @@ s.add_dependency 'phantomjs', '1.9.8.0' s.add_dependency 'diff-lcs', '~> 1.2' - s.add_development_dependency 'rspec', '~> 2.14' + s.add_development_dependency 'rspec', '~> 3.3' s.add_development_dependency 'mocha', '~> 1.0' s.add_development_dependency 'codeclimate-test-reporter' end
Update rspec dev dependency from 2.14 -> 3.3
diff --git a/lib/rackjson/rack/builder.rb b/lib/rackjson/rack/builder.rb index abc1234..def5678 100644 --- a/lib/rackjson/rack/builder.rb +++ b/lib/rackjson/rack/builder.rb @@ -1,11 +1,23 @@-module Rack #:nodoc: +module Rack class Builder + # Setup resource collections without authentication. + # + # ===Example + # expose_resource :collections => [:notes, :projects], :db => @mongo_db + # def expose_resource options @ins << lambda do |app| Rack::JSON::Resource.new app, options end end + # Setup resource collections with public read access but write access only + # given to the owner of the document, determened from the session var passed + # as filter. + # + # ===Example + # public_resource :collections => [:notes, :projects], :db => @mongo_db, :filters => [:user_id] + # def public_resource options @ins << lambda do |app| Rack::JSON::Filter.new( @@ -14,6 +26,13 @@ end end + # Setup resource collections with no public access. Read and write access only + # given to the owner of the document, determened from the session vars passed + # as filters. + # + # ===Example + # private_resource :collections => [:notes, :projects], :db => @mongo_db, :filters => [:user_id] + # def private_resource options @ins << lambda do |app| Rack::JSON::Filter.new( @@ -21,33 +40,5 @@ options.merge(:methods => [:get, :post, :put, :delete])) end end - - # Setup resource collections hosted behind OAuth and OpenID auth filters. - # - # ===Example - # contain :notes, :projects - # - def contain(*args) - @ins << lambda do |app| - Rack::Session::Pool.new( - CloudKit::OAuthFilter.new( - CloudKit::OpenIDFilter.new( - CloudKit::Service.new(app, :collections => args.to_a)))) - end - @last_cloudkit_id = @ins.last.object_id - end - - # Setup resource collections without authentication. - # - # ===Example - # expose :notes, :projects - # - def expose(*args) - @ins << lambda do |app| - CloudKit::Service.new(app, :collections => args.to_a) - end - @last_cloudkit_id = @ins.last.object_id - end - end end
Add examples of using the Rack::Builder shortcuts
diff --git a/farmbot.god b/farmbot.god index abc1234..def5678 100644 --- a/farmbot.god +++ b/farmbot.god @@ -2,5 +2,6 @@ w.name = "farmbot_rpi_controller" w.dir = File.expand_path(File.dirname(__FILE__)) w.start = "ruby farmbot.rb" - w.keepalive + w.keepalive(memory_max: 150.megabytes, + cpu_max: 50.percent) end
Add sensible CPU/Mem restart thresholds
diff --git a/DFImageManager.podspec b/DFImageManager.podspec index abc1234..def5678 100644 --- a/DFImageManager.podspec +++ b/DFImageManager.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "DFImageManager" - s.version = "0.0.14" - s.summary = "Complete solution for fetching, preheating, caching and adjusting images" + s.version = "0.0.15" + s.summary = "Complete solution for fetching, preheating, caching and processing images" s.homepage = "https://github.com/kean/DFImageManager" s.license = { :type => "MIT", :file => "LICENSE" } s.author = { "Alexander Grebenyuk" => "grebenyuk.alexander@gmail.com" }
Update podspec to version 0.0.15
diff --git a/lib/web_console/evaluator.rb b/lib/web_console/evaluator.rb index abc1234..def5678 100644 --- a/lib/web_console/evaluator.rb +++ b/lib/web_console/evaluator.rb @@ -19,7 +19,14 @@ end def eval(input) - "=> #{@binding.eval(input).inspect}\n" + # Binding#source_location is available since Ruby 2.6. But if this should + # be removed the `WebConsole::SessionTest#test_use_first_binding_if_no_application_bindings` + # must be adjusted. + if @binding.respond_to? :source_location + "=> #{@binding.eval(input, *@binding.source_location).inspect}\n" + else + "=> #{@binding.eval(input).inspect}\n" + end rescue Exception => exc format_exception(exc) end
Make binding.eval Ruby 3.0 compatible. Ruby 3.0 changes behavior of `binding.eval` [[1]] resulting in test failure: ~~~ WebConsole::EvaluatorTest#test_Evaluator_callers_are_cleaned_up_of_unneeded_backtraces [/home/travis/build/rails/web-console/test/web_console/evaluator_test.rb:63]: --- expected +++ actual @@ -1,3 +1,3 @@ "RuntimeError: oops -\tfrom /home/travis/build/rails/web-console/test/web_console/evaluator_test.rb:61:in `block in <class:EvaluatorTest>' +\tfrom (eval):1:in `block in <class:EvaluatorTest>' ~~~ Fixes #301 [1]: https://bugs.ruby-lang.org/issues/17419
diff --git a/app/mailers/notifier.rb b/app/mailers/notifier.rb index abc1234..def5678 100644 --- a/app/mailers/notifier.rb +++ b/app/mailers/notifier.rb @@ -17,7 +17,7 @@ end def self.admin_addresses - ['sheri.tibbs@duke.edu'] + ['sheri.tibbs@duke.edu','ctti@duke.edu'] end def instructions(user)
Add new citi service account email to Notifier
diff --git a/config/initializers/raven.rb b/config/initializers/raven.rb index abc1234..def5678 100644 --- a/config/initializers/raven.rb +++ b/config/initializers/raven.rb @@ -1,5 +1,6 @@ if Supermarket::Config.sentry_url.present? && !Rails.env.test? require 'raven' + require 'raven/sidekiq' Raven.configure do |config| config.dsn = Supermarket::Config.sentry_url
Send Sidekiq errors to Sentry
diff --git a/web/lib/assets/umakadata/lib/umakadata/void.rb b/web/lib/assets/umakadata/lib/umakadata/void.rb index abc1234..def5678 100644 --- a/web/lib/assets/umakadata/lib/umakadata/void.rb +++ b/web/lib/assets/umakadata/lib/umakadata/void.rb @@ -25,16 +25,18 @@ # @return [Array] attr_reader :publisher + FORMATS = { "Turtle" => TURTLE, "RDF/XML" => RDFXML } + def initialize(http_response, logger: nil) body = http_response.body - data = triples(body, TURTLE) - logger.result = 'VoID is in Turtle format' unless logger.nil? || data.nil? - if data.nil? - data = triples(body, RDFXML) - logger.result = 'VoID is in RDF/XML format' unless logger.nil? + data = nil + FORMATS.each do |key, value| + break unless data.nil? + data = triples(body, value) + logger.result = "VoID is in #{key} format" unless logger.nil? end if data.nil? - logger.result = 'VoID is invalid (valid formats: Turtle or RDF/XML)' unless logger.nil? + logger.result = "VoID is invalid (valid formats: #{FORMATS.keys.join(',')})" unless logger.nil? return end
Change method call to compact.
diff --git a/lib/bond/missions/default_mission.rb b/lib/bond/missions/default_mission.rb index abc1234..def5678 100644 --- a/lib/bond/missions/default_mission.rb +++ b/lib/bond/missions/default_mission.rb @@ -6,14 +6,16 @@ "then", "true", "undef", "unless", "until", "when", "while", "yield" ] + + # Default action which generates methods, private methods, reserved words, local variables and constants. + def self.completions(input=nil) + Bond::Mission.current_eval("methods | private_methods | local_variables | " + + "self.class.constants | instance_variables") | ReservedWords + end + def initialize(options={}) #@private - options[:action] ||= method(:default) + options[:action] ||= self.class.method(:completions) super end def default_on; end #@private - - # Default action which generates methods, private methods, reserved words, local variables and constants. - def default(input) - Bond::Mission.current_eval("methods | private_methods | local_variables | self.class.constants") | ReservedWords - end -end+end
Modify DefaultMission to be reusable, add ivars to default completion
diff --git a/lib/fulmar/service/helper_service.rb b/lib/fulmar/service/helper_service.rb index abc1234..def5678 100644 --- a/lib/fulmar/service/helper_service.rb +++ b/lib/fulmar/service/helper_service.rb @@ -6,6 +6,7 @@ ## # Reverse file lookup in path # @param path [String] + # @param filename [String] def reverse_file_lookup(path, filename) paths = get_parent_directory_paths(path)
[DOCS] Complete documentation of function arguments
diff --git a/spec/debian/grub_spec.rb b/spec/debian/grub_spec.rb index abc1234..def5678 100644 --- a/spec/debian/grub_spec.rb +++ b/spec/debian/grub_spec.rb @@ -4,4 +4,5 @@ it { should be_file } it { should contain "tsc=reliable" } it { should contain "divider=10" } + it { should contain "GRUB_TIMEOUT=5" } end
Test to ensure 5 second grub timout. IMAGE-543
diff --git a/lib/template/lib/endpoints/health.rb b/lib/template/lib/endpoints/health.rb index abc1234..def5678 100644 --- a/lib/template/lib/endpoints/health.rb +++ b/lib/template/lib/endpoints/health.rb @@ -14,11 +14,11 @@ private def database? - raise Pliny::Errors::NotFound if DB.nil? + fail Pliny::Errors::NotFound if DB.nil? end def database_available? - raise Pliny::Errors::ServiceUnavailable unless DB.test_connection + fail Pliny::Errors::ServiceUnavailable unless DB.test_connection rescue Sequel::Error => e message = e.message.strip Pliny.log(db: true, health: true, at: 'exception', message: message)
Use fail instead of raise
diff --git a/lib/virtual-attributes/base/casts.rb b/lib/virtual-attributes/base/casts.rb index abc1234..def5678 100644 --- a/lib/virtual-attributes/base/casts.rb +++ b/lib/virtual-attributes/base/casts.rb @@ -2,7 +2,7 @@ module Casts extend ActiveSupport::Concern - TYPES = ActiveRecord::Base.connection.native_database_types.keys - [:primary_key] + TYPES = ActiveRecord::Type::Value.subclasses.map{ |k| k.name.split('::').last.underscore.to_sym } def write_attribute(column, value) super column, cast_type(column, value)
Change the way the list of types is readen by relaying on classes
diff --git a/spec/models/grok_spec.rb b/spec/models/grok_spec.rb index abc1234..def5678 100644 --- a/spec/models/grok_spec.rb +++ b/spec/models/grok_spec.rb @@ -11,7 +11,7 @@ end it 'should handle timeout errors' do - stub_request(:any, %r{.*}) + stub_request(:any, %r{.*}).to_raise(Errno::ETIMEDOUT) response = Grok.views_for_article('Foo', '2014-08-01'.to_date, 'en') end end
Fix timeout test for grok
diff --git a/spec/pomona/tree_spec.rb b/spec/pomona/tree_spec.rb index abc1234..def5678 100644 --- a/spec/pomona/tree_spec.rb +++ b/spec/pomona/tree_spec.rb @@ -0,0 +1,107 @@+require "spec_helper" + +describe Tree do + let(:tree) { Tree.new } + + describe "readable attributes" do + describe "data" do + it "should be a hash" do + expect(tree.data).to be_a_kind_of(Hash) + end + end + end + + describe "#add_node" do + it 'should create a new Node' do + node = tree.add_node({ name: "Test Node" })[0] + expect(tree.data[:tree_array][0]).to be_a_kind_of(Node) + end + + it 'should append the node to the Tree' do + node = tree.add_node({ name: "Test Node" })[0] + expect(tree.data[:tree_array][0]).to eq(node) + end + + describe "#attach_to_parent" do + before do + tree.add_node({ name: "Alpha Node" }) + end + + context 'parent_id is nil' do + it 'should append the node to data[:tree_array]' do + node = tree.add_node({ name: "Test Node" })[0] + expect(tree.data[:tree_array]).to include(node) + end + end + + context 'parent_id is not nil' do + it 'should append the node to the parent_nodes children array' do + node = tree.add_node({ name: "Test Node" }, 1)[0] + expect(tree.find(1).children).to include(node) + end + end + end + + describe "#next_id" do + it 'should return an Integer' do + node = tree.add_node({ name: "Alpha Node" })[0] + expect(node.id).to be_a_kind_of(Integer) + end + + it 'should return "1" for the first added node to a tree' do + node = tree.add_node({ name: "Alpha Node" })[0] + expect(node.id).to eq(1) + end + end + end + + describe "#remove_node" do + xit 'should delete the selected Node' do + end + + xit 'should delete any descendents of the selected Node' do + end + + context 'node.parent_id is nil' do + xit 'should delete the selected node from data[:tree_array]' do + end + end + + context 'node.parent_id is not nil' do + xit 'should delete the node from the parents children array' do + end + end + end + + describe "#values_at" do + xit "should return an Array" do + end + + context 'Multiple Keys were given' do + xit 'should be a nested array' do + end + end + + context 'Single Key was given' do + xit 'should not be a nested array' do + end + end + end + + describe "#find" do + before do + tree.add_node({ name: "Test" }) + end + + context 'ID exists' do + it 'should return a Node Object' do + expect(tree.find(1)).to be_a_kind_of(Node) + end + end + + context 'ID does not exist' do + xit 'should return raise an Exception' do + end + end + end +end
Write Most of Tree Specs
diff --git a/app/models/kpi/report/dynamic_definitions.rb b/app/models/kpi/report/dynamic_definitions.rb index abc1234..def5678 100644 --- a/app/models/kpi/report/dynamic_definitions.rb +++ b/app/models/kpi/report/dynamic_definitions.rb @@ -10,7 +10,7 @@ end def method_blacklisted?(name) - not_kpi_methods.include?(name) || name =~ /_unmemoized_/ || !self.instance_methods.include?(name) + not_kpi_methods.include?(name) || name =~ /_unmemoized_/ || !self.instance_methods(true).map(&:to_sym).include?(name) end def blacklist(*methods)
Fix for 1.8.7 and instance methods
diff --git a/git_info.rb b/git_info.rb index abc1234..def5678 100644 --- a/git_info.rb +++ b/git_info.rb @@ -41,7 +41,7 @@ def redmine_refs merge_base = `git merge-base HEAD master`.chomp `git log #{merge_base}..HEAD --format='%b' | grep refs`. - gsub('refs #', '').chomp.split(/\s /).uniq.sort_by { |ref| ref.to_i } + gsub('refs #', '').chomp.split(/\s+/).uniq.sort_by { |ref| ref.to_i } end end end
Fix issue reference number splitting Split on one or more whitespace characters, not one whitespace character and a space.
diff --git a/server.rb b/server.rb index abc1234..def5678 100644 --- a/server.rb +++ b/server.rb @@ -3,30 +3,45 @@ require './lib/GameStatistics' require 'curses' require './lib/CursesStatsPrinter' +require 'optparse' + +options = {} +OptionParser.new do |opts| + opts.banner = "Usage: server.rb [options]" + + opts.on('-n', '--use-curses', 'Use curses for GUI') { |v| options[:use_curses] = v } + +end.parse! server = Server.new '0.0.0.0', RobotState::Server::PORT settings = YAML.load_file('settings.yml') - -Curses.init_screen -Curses.curs_set(0) # Invisible cursor server.serial = SerialPort.new settings["serial"]["device"], settings["serial"]["baud"] server.setRobots settings["robots"] statistics = GameStatistics.new server -begin - ncurses_printer = CursesStatsPrinter.new +if options.has_key?(:use_curses) + Curses.init_screen + Curses.curs_set(0) # Invisible cursor + begin + ncurses_printer = CursesStatsPrinter.new + loop do + stats = statistics.robots + ncurses_printer.display_stats stats + sleep 1 + end + + printer.close_all_windows + rescue => ex + Curses.close_screen + puts ex.message + puts ex.backtrace + end +else loop do - stats = statistics.robots - ncurses_printer.display_stats stats + puts statistics.robots sleep 1 end - - printer.close_all_windows -rescue => ex - Curses.close_screen - puts ex.message - puts ex.backtrace end
Add ability to use or disable ncurses
diff --git a/concord_runner.rb b/concord_runner.rb index abc1234..def5678 100644 --- a/concord_runner.rb +++ b/concord_runner.rb @@ -2,7 +2,7 @@ date = "#{"%02d" % day}.09.2010" puts "date = #{date}" - starting_offset_x = 0 + starting_offset_x = 3800 starting_offset_y = 0 size = 4000
Set some offsets for the Concord data.
diff --git a/config/initializers/carrierwave.rb b/config/initializers/carrierwave.rb index abc1234..def5678 100644 --- a/config/initializers/carrierwave.rb +++ b/config/initializers/carrierwave.rb @@ -8,7 +8,7 @@ config.fog_directory = Configuration[:aws_bucket] config.fog_attributes = { 'Cache-Control' => 'max-age=315576000' } # optional, defaults to { } config.asset_host = Configuration[:asset_host] - #config.fog_region = Configuration[:aws_region] + config.fog_region = Configuration[:aws_region] else config.enable_processing = false if Rails.env.test? or Rails.env.cucumber? end
Add Fog Region When upload
diff --git a/cookbooks/bcpc/recipes/cpupower.rb b/cookbooks/bcpc/recipes/cpupower.rb index abc1234..def5678 100644 --- a/cookbooks/bcpc/recipes/cpupower.rb +++ b/cookbooks/bcpc/recipes/cpupower.rb @@ -18,7 +18,7 @@ # package "cpufrequtils" do - action :remove + action :purge end if node['bcpc']['hardware']['powersave']
Purge cpufrequtils instead of removing
diff --git a/cookbooks/npm_package_json/recipes/default.rb b/cookbooks/npm_package_json/recipes/default.rb index abc1234..def5678 100644 --- a/cookbooks/npm_package_json/recipes/default.rb +++ b/cookbooks/npm_package_json/recipes/default.rb @@ -1,3 +1,7 @@ execute "npm install" do - command "su -c \"cd /vagrant; npm install --save-dev; ./node_modules/.bin/bower install\" vagrant" + command "su -c \"cd /vagrant; npm install --save-dev\" vagrant" end + +execute "bower install" do + command "su -c \"cd /vagrant; ./node_modules/.bin/bower install\" vagrant" +end
Split npm and bower install commands
diff --git a/aarons_gnuplot.gemspec b/aarons_gnuplot.gemspec index abc1234..def5678 100644 --- a/aarons_gnuplot.gemspec +++ b/aarons_gnuplot.gemspec @@ -8,9 +8,9 @@ gem.version = AaronsGnuplot::VERSION gem.authors = ["Aaron Marburg"] gem.email = ["amarburg@notetofutureself.org"] - gem.description = %q{TODO: Write a gem description} - gem.summary = %q{TODO: Write a gem summary} - gem.homepage = "" + gem.description = %q{Some of my personal tools for simplifying Gnuplot in Ruby} + gem.summary = %q{Some of my personal tools for simplifying Gnuplot in Ruby} + gem.homepage = "http://github.com/amarburg/aarons_gnuplot" gem.files = `git ls-files`.split($/) gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
Set Gem description and summary.
diff --git a/route_downcaser.gemspec b/route_downcaser.gemspec index abc1234..def5678 100644 --- a/route_downcaser.gemspec +++ b/route_downcaser.gemspec @@ -22,4 +22,5 @@ s.files = Dir['{lib}/**/*'] + ['MIT-LICENSE', 'Rakefile', 'README.rdoc'] s.test_files = Dir['test/**/*'] s.add_runtime_dependency 'activesupport', '>= 3.2' + s.add_development_dependency 'standard' end
Add Standard as a development dependency https://github.com/testdouble/standard Let's just adhere to a common standard for Ruby style without configuration and discussions.
diff --git a/resources/clear_cache.rb b/resources/clear_cache.rb index abc1234..def5678 100644 --- a/resources/clear_cache.rb +++ b/resources/clear_cache.rb @@ -20,7 +20,7 @@ property :databases, Array, default: %w(passwd group hosts services netgroup) action :clear do - databases.each do |cmd| + new_resource.databases.each do |cmd| execute "nscd-clear-#{cmd}" do command "/usr/sbin/nscd -i #{cmd}" action :run
Resolve Chef 14 deprecation warning Signed-off-by: Tim Smith <764ef62106582a09ed09dfa0b6bff7c05fd7d1e4@chef.io>
diff --git a/spec/connection_spec.rb b/spec/connection_spec.rb index abc1234..def5678 100644 --- a/spec/connection_spec.rb +++ b/spec/connection_spec.rb @@ -10,7 +10,7 @@ end describe "mysql adapter option" do - it "returns a new instance of MySql adapter" do + it "returns a new instance of MySQL adapter" do adapter = Oculus::Connection.connect adapter: 'mysql' adapter.should be_an_instance_of Oculus::Connection::Mysql2 end @@ -18,14 +18,14 @@ describe "postgres adapter option" do it "returns a new instance of Postgres adapter" do - adapter = Oculus::Connection.connect adapter: 'postgres' + adapter = Oculus::Connection.connect adapter: 'postgres', database: 'oculus_test' adapter.should be_an_instance_of Oculus::Connection::Postgres end end - describe "pg adapter" do + describe "pg adapter alias" do it "returns a new instance of Postgres adapter" do - adapter = Oculus::Connection.connect adapter: 'pg' + adapter = Oculus::Connection.connect adapter: 'pg', database: 'oculus_test' adapter.should be_an_instance_of Oculus::Connection::Postgres end end
Clean up Postgres bits of connection spec
diff --git a/lib/data_structures_101/hash/base_hash_table.rb b/lib/data_structures_101/hash/base_hash_table.rb index abc1234..def5678 100644 --- a/lib/data_structures_101/hash/base_hash_table.rb +++ b/lib/data_structures_101/hash/base_hash_table.rb @@ -1,8 +1,9 @@ module DataStructures101 module Hash class BaseHashTable + include Enumerable - attr_reader :size, :hash_lambda + attr_reader :size, :hash_lambda, :capacity def initialize(capacity, prime, hash_lambda = nil) @capacity = capacity @@ -41,6 +42,14 @@ bucket_delete(hash_lambda.call(key), key) end + def each + return enum_for(:each) unless block_given? + + bucket_each do |key, value| + yield(key, value) + end + end + private def new_capacity()
Include enumerable and each method implementation
diff --git a/definitions/iptables_rule.rb b/definitions/iptables_rule.rb index abc1234..def5678 100644 --- a/definitions/iptables_rule.rb +++ b/definitions/iptables_rule.rb @@ -22,7 +22,7 @@ template "/etc/iptables.d/#{params[:name]}" do source template_source - mode 0644 + mode '0644' cookbook params[:cookbook] if params[:cookbook] variables params[:variables] backup false
Use a string for mode to preserve the leading 0
diff --git a/test/integration/local_transaction_creation_test.rb b/test/integration/local_transaction_creation_test.rb index abc1234..def5678 100644 --- a/test/integration/local_transaction_creation_test.rb +++ b/test/integration/local_transaction_creation_test.rb @@ -0,0 +1,17 @@+require 'integration_test_helper' + +class LocalTransactionCreationTest < ActionDispatch::IntegrationTest + test "creating a local transaction from panopticon requests an LGSL code" do + setup_users + + panopticon_has_metadata( + "id" => 2357, + "slug" => "foo-bar", + "kind" => "local_transaction", + "name" => "Foo bar" + ) + + visit "/admin/publications/2357" + assert page.has_content? "We need a bit more information to create your local transaction." + end +end
Add very basic integration test for local transaction creation
diff --git a/spec/statistics_spec.rb b/spec/statistics_spec.rb index abc1234..def5678 100644 --- a/spec/statistics_spec.rb +++ b/spec/statistics_spec.rb @@ -0,0 +1,12 @@+require_relative '../lib/statistics' + +describe Workerholic::Statistics do + it 'initializes attributes with without an argument' do + statistics = Workerholic::Statistics.new + expect(statistics.enqueued_at).to be_nil + expect(statistics.retry_count).to eq(0) + expect(statistics.errors).to eq([]) + expect(statistics.started_at).to be_nil + expect(statistics.completed_at).to be_nil + end +end
Add spec for initialize method
diff --git a/Template/{PROJECT}.podspec b/Template/{PROJECT}.podspec index abc1234..def5678 100644 --- a/Template/{PROJECT}.podspec +++ b/Template/{PROJECT}.podspec @@ -13,6 +13,6 @@ s.watchos.deployment_target = "2.0" s.tvos.deployment_target = "9.0" s.source = { :git => "{URL}.git", :tag => "0.1" } - s.source_files = "Sources/{PROJECT}.swift" + s.source_files = "Sources/**/*" s.frameworks = "Foundation" end
Update source files in podspec template
diff --git a/config/initializers/geocoder.rb b/config/initializers/geocoder.rb index abc1234..def5678 100644 --- a/config/initializers/geocoder.rb +++ b/config/initializers/geocoder.rb @@ -1,2 +1,6 @@-Geocoder::Configuration.lookup = :yahoo -Geocoder::Configuration.api_key = "FZGMCffV34GyRHDpvcpT8NrASJtqaZ5_mdzn0gL5tAFGQg8Rv7Mgi5fkWHWyRgDU7A" +if Rails.env.test? + Geocoder::Configuration.lookup = :yahoo + Geocoder::Configuration.api_key = "FZGMCffV34GyRHDpvcpT8NrASJtqaZ5_mdzn0gL5tAFGQg8Rv7Mgi5fkWHWyRgDU7A" +else + Geocoder::Configuration.lookup = :google +end
Use Yahoo as Geocoding API in Tests. They know no limits.
diff --git a/config/initializers/omniauth.rb b/config/initializers/omniauth.rb index abc1234..def5678 100644 --- a/config/initializers/omniauth.rb +++ b/config/initializers/omniauth.rb @@ -1,5 +1,10 @@ OmniAuth.config.logger = Rails.logger Rails.application.config.middleware.use OmniAuth::Builder do - provider :google_oauth2, ENV['GOOGLE_KEY'], ENV['GOOGLE_SECRET'] + provider :google_oauth2, ENV['GOOGLE_KEY'], ENV['GOOGLE_SECRET'], + { + prompt: "none", + image_aspect_ratio: "square", + image_size: 40 + } end
Configure Google auth to be less obnoxious. Also asking a properly-sized avatar image with a a square ratio.
diff --git a/test/appharbor_test.rb b/test/appharbor_test.rb index abc1234..def5678 100644 --- a/test/appharbor_test.rb +++ b/test/appharbor_test.rb @@ -12,6 +12,9 @@ @stubs.post "/application/#{application_slug}/build" do |env| assert_equal token, env[:params]["authorization"] assert_equal 'application/json', env[:request_headers]["accept"] + + branches = JSON.parse(env[:body])['branches'] + assert_equal 1, branches.size end svc = service({"token" => token, "application_slug" => application_slug}, payload)
Verify that there's only a single branch in request body
diff --git a/app/admin/users.rb b/app/admin/users.rb index abc1234..def5678 100644 --- a/app/admin/users.rb +++ b/app/admin/users.rb @@ -6,12 +6,6 @@ index :download_links => false do column :name column :email - column "Invitation Link" do |user| - if user.invitation_token - link_to "Invite link (#{user.invitation_token})", - accept_invitation_url(user, :invitation_token => user.invitation_token) - end - end column :created_at column :last_sign_in_at column :is_admin
Remove invitation link from admin user list
diff --git a/lib/c2y/dsl/context/update.rb b/lib/c2y/dsl/context/update.rb index abc1234..def5678 100644 --- a/lib/c2y/dsl/context/update.rb +++ b/lib/c2y/dsl/context/update.rb @@ -11,14 +11,12 @@ instance_eval(&block) end - private + [:group, :reboot_strategy].each do |attr| + define_method(attr) do |arg| + @result.send("#{attr}=", arg) + end - def group(channel) - @result.group = channel.to_s - end - - def reboot_strategy(strategy) - @result.reboot_strategy = strategy.to_s + private attr end end end
Use dynamic method definition in Update
diff --git a/src/dec6/fire_hazard2.rb b/src/dec6/fire_hazard2.rb index abc1234..def5678 100644 --- a/src/dec6/fire_hazard2.rb +++ b/src/dec6/fire_hazard2.rb @@ -0,0 +1,35 @@+require 'pp' + +@light_grid = [] + + +@light_grid = 1000.times.map do |x| + 1000.times.map{ |y| false } +end + + +File.open('data/dec6/input.txt').each do |line| + line.match(/([a-z\ ]+)([0-9]+),([0-9]+) through ([0-9]+),([0-9]+)$/) do |m| + @instr = m[1] + (@x0,@y0,@x1,@y1) = m[2,4].map {|x| x.to_i } + @width = @x1+1-@x0 + @height = @y1+1-@y0 + puts "#{@width} #{@height}" + if @instr == "turn on " + @light_grid[@x0..@x1].each {|row| row[@y0..@y1] = @height.times.map { true } } + elsif @instr == "turn off " + @light_grid[@x0..@x1].each {|row| row[@y0..@y1] = @height.times.map { false } } + elsif @instr == "toggle " + (@x0..@x1).each { |x| (@y0..@y1).each { |y| @light_grid[x][y] = !@light_grid[x][y] } } + else + puts "Invalid instruction #{m[:instr]}" + end + end + @light_grid.each.with_index do |slice, idx| + puts "#{idx} #{slice.length}" if slice.length < 1000 + end + puts @light_grid.flatten.select { |x| x }.length + puts @light_grid.flatten.length +end + +puts @light_grid.flatten.select { |x| x }.length
Add copy of fire_hazard.rb to rewrite
diff --git a/lib/dhis2/api/data_element.rb b/lib/dhis2/api/data_element.rb index abc1234..def5678 100644 --- a/lib/dhis2/api/data_element.rb +++ b/lib/dhis2/api/data_element.rb @@ -15,7 +15,8 @@ domain_type: element[:domain_type] || "AGGREGATE", value_type: element[:value_type] || "NUMBER", aggregation_type: element[:aggregation_type] || "SUM", - aggregation_operator: element[:aggregation_type] || "SUM", + type: element[:type] || "int", # for backward compatbility + aggregation_operator: element[:aggregation_type] || "SUM", # for backward compatbility category_combo: { id: category_combo_id } } end
Add more backward compatibility options
diff --git a/lib/docker-provider/config.rb b/lib/docker-provider/config.rb index abc1234..def5678 100644 --- a/lib/docker-provider/config.rb +++ b/lib/docker-provider/config.rb @@ -6,13 +6,12 @@ def initialize @image = nil @cmd = UNSET_VALUE - @ports = UNSET_VALUE + @ports = [] @privileged = UNSET_VALUE @volumes = [] end def finalize! - @ports = [] if @ports == UNSET_VALUE @cmd = [] if @cmd == UNSET_VALUE @privileged = false if @privileged == UNSET_VALUE end
Allow ports to be specified from the `Vagrantfile`
diff --git a/test/factories/user.rb b/test/factories/user.rb index abc1234..def5678 100644 --- a/test/factories/user.rb +++ b/test/factories/user.rb @@ -2,6 +2,8 @@ FactoryGirl.define do factory :user do + first_name { Faker::Name.first_name } + last_name { Faker::Name.last_name } email { Faker::Internet.email } password "testpassword1" password_confirmation "testpassword1"
Fix up the User tests
diff --git a/app/controllers/admin/cache_purge_controller.rb b/app/controllers/admin/cache_purge_controller.rb index abc1234..def5678 100644 --- a/app/controllers/admin/cache_purge_controller.rb +++ b/app/controllers/admin/cache_purge_controller.rb @@ -5,6 +5,7 @@ logger.info "[Forest] Performing user-issued cache clear" Rails.cache.clear + Setting.expire_application_cache_key! redirect_to params.delete(:return_to) || admin_path, notice: "Cache has been cleared." end
Expire application cache key when purging cache from admin screen
diff --git a/app/controllers/browse/activities_controller.rb b/app/controllers/browse/activities_controller.rb index abc1234..def5678 100644 --- a/app/controllers/browse/activities_controller.rb +++ b/app/controllers/browse/activities_controller.rb @@ -8,8 +8,8 @@ end @material = ::Activity.find(params[:id]) - if @material.teacher_only? && current_user.anonymous? - flash[:notice] = 'Please log in as a teacher to see this content.' + if @material.teacher_only && current_user.anonymous? + flash.now[:notice] = 'Please log in as a teacher to see this content.' end @wide_content_layout = true
Fix flash notice on material preview page - Fix flash notice for anonymous users on material preview page.
diff --git a/app/models/document.rb b/app/models/document.rb index abc1234..def5678 100644 --- a/app/models/document.rb +++ b/app/models/document.rb @@ -8,6 +8,14 @@ Dir.glob("#{DIR_PATH}/*.md").sort.map do |filename| self.new(File.basename(filename, '.*')) end + end + + def first + self.all.first + end + + def last + self.all.last end end
Add first and last class method to Document model
diff --git a/semantic_logger.gemspec b/semantic_logger.gemspec index abc1234..def5678 100644 --- a/semantic_logger.gemspec +++ b/semantic_logger.gemspec @@ -1,4 +1,5 @@-$:.push File.expand_path("../lib", __FILE__) +lib = File.expand_path('../lib/', __FILE__) +$:.unshift lib unless $:.include?(lib) # Maintain your gem's version: require 'semantic_logger/version'
Update gem spec to pull in version form the source
diff --git a/metadata.rb b/metadata.rb index abc1234..def5678 100644 --- a/metadata.rb +++ b/metadata.rb @@ -6,4 +6,4 @@ long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) source_url 'https://github.com/GSI-HPC/sys-chef-cookbook' issues_url 'https://github.com/GSI-HPC/sys-chef-cookbook/issues' -version '1.37.0' +version '1.38.0'
Add test for fuse recipe
diff --git a/app/models/user.rb b/app/models/user.rb index abc1234..def5678 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -4,4 +4,6 @@ devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :confirmable + has_many :users_questionnaires + has_many :users_questionnaires, through: :users_questionnaires end
Add Questionnaire association to User model
diff --git a/app/models/user.rb b/app/models/user.rb index abc1234..def5678 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -24,4 +24,8 @@ end end + def hours_spent + self.projects.map {|p| p.hours}.sum + end + end
Add hours _spent instance method
diff --git a/app/models/user.rb b/app/models/user.rb index abc1234..def5678 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -8,5 +8,5 @@ validates :email, presence: true, length: { maximum: 255 }, uniqueness: { case_sensitive: false } has_secure_password - validates :password, presence: true, length: { minimum: 6 } + validates :password, length: { minimum: 6 } end
Update password vallidation to only check length
diff --git a/metadata.rb b/metadata.rb index abc1234..def5678 100644 --- a/metadata.rb +++ b/metadata.rb @@ -4,7 +4,7 @@ maintainer 'Sous Chefs' maintainer_email 'help@sous-chefs.org' chef_version '>= 11' if respond_to?(:chef_version) -license 'Apache 2.0' +license 'Apache-2.0' description 'Installs and configures all aspects of apache2 using Debian style symlinks with helper definitions' long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) version '3.3.0'
Use a SPDX standard license string Signed-off-by: Tim Smith <764ef62106582a09ed09dfa0b6bff7c05fd7d1e4@chef.io>
diff --git a/metadata.rb b/metadata.rb index abc1234..def5678 100644 --- a/metadata.rb +++ b/metadata.rb @@ -11,7 +11,7 @@ recommends 'java', '>= 1.21.2' -%w(centos debian redhat scientific ubuntu).each do |os| +%w(amazon centos debian redhat scientific ubuntu).each do |os| supports os end
Add amazon to the list of supported operating systems
diff --git a/lib/sensu/plugin/check/cli.rb b/lib/sensu/plugin/check/cli.rb index abc1234..def5678 100644 --- a/lib/sensu/plugin/check/cli.rb +++ b/lib/sensu/plugin/check/cli.rb @@ -17,6 +17,16 @@ define_method(status.downcase) do |msg| puts "#{status}: #{msg}" code + end + end + + class << self + def check_name(name=nil) + if name + @check_name = name + else + @check_name || self.to_s + end end end
Allow setting a check_name and prepend to the output (default to class name)
diff --git a/app/models/carto/helpers/data_import_commons.rb b/app/models/carto/helpers/data_import_commons.rb index abc1234..def5678 100644 --- a/app/models/carto/helpers/data_import_commons.rb +++ b/app/models/carto/helpers/data_import_commons.rb @@ -2,7 +2,6 @@ require_dependency 'cartodb/import_error_codes' module Carto::DataImportCommons - # Notice that this returns the entire error hash, not just the text def get_error_text if self.error_code == CartoDB::NO_ERROR_CODE @@ -20,7 +19,12 @@ def connector_error_message match = CONNECTOR_ERROR_PATTERN.match(log&.entries) - match && match[1] + if match.present? + { + title: 'Connector Error', + what_about: match[1], + source: ERROR_SOURCE_CARTODB # FIXME, should it typically be ERROR_SOURCE_USER ? + } + end end - end
Fix format of DataImport error text
diff --git a/lib/teamcity/client/common.rb b/lib/teamcity/client/common.rb index abc1234..def5678 100644 --- a/lib/teamcity/client/common.rb +++ b/lib/teamcity/client/common.rb @@ -13,11 +13,10 @@ # Take a list of locators to search on multiple criterias # def locator(options={}) - test = options.inject([]) do |locators, locator| + options.inject([]) do |locators, locator| key, value = locator locators << "#{key}:#{value}" end.join(',') - test end end end
Remove unnecessary storing of results in locator method
diff --git a/lib/veritas/aggregate/mean.rb b/lib/veritas/aggregate/mean.rb index abc1234..def5678 100644 --- a/lib/veritas/aggregate/mean.rb +++ b/lib/veritas/aggregate/mean.rb @@ -22,8 +22,8 @@ # @api public def self.call(accumulator, value) count, mean = accumulator - count = count.succ - [ count, mean.nil? ? value : mean + ((value - mean) / count.to_f) ] + count = Count.call(count, value) + [ count, mean.nil? ? value.to_f : mean + ((value - mean) / count.to_f) ] end # Extract the mean from the accumulator
Use Count.call instead of incrementing the count inline
diff --git a/spec/integration/nutrella/command_integration_spec.rb b/spec/integration/nutrella/command_integration_spec.rb index abc1234..def5678 100644 --- a/spec/integration/nutrella/command_integration_spec.rb +++ b/spec/integration/nutrella/command_integration_spec.rb @@ -2,6 +2,28 @@ vcr_options = { cassette_name: "command", record: :new_episodes } RSpec.describe Command, vcr: vcr_options do - pending + it "finds an existing board" do + task_board_name = "Nutrella" + subject = command("-t", task_board_name) + + task_board = subject.run + + expect(task_board).to have_attributes(name: "Nutrella") + end + + it "creates a new board" do + task_board_name = "nutrella_new_task_board" + subject = command("-t", task_board_name) + + allow(subject).to receive(:confirm_create?).and_return("yes") + + task_board = subject.run + + expect(task_board).to have_attributes(name: task_board_name) + end + + def command(*args) + Command.new(args) + end end end
Implement a basic integration test.
diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb index abc1234..def5678 100644 --- a/spec/controllers/sessions_controller_spec.rb +++ b/spec/controllers/sessions_controller_spec.rb @@ -0,0 +1,93 @@+require 'spec_helper' + +describe SessionsController do + describe '#create' do + before do + @request.env['devise.mapping'] = Devise.mappings[:user] + end + + context 'standard authentications' do + context 'invalid password' do + it 'does not authenticate user' do + post(:create, user: { login: 'invalid', password: 'invalid' }) + + expect(response) + .to set_flash.now[:alert].to /Invalid login or password/ + end + end + + context 'valid password' do + let(:user) { create(:user) } + + it 'authenticates user correctly' do + post(:create, user: { login: user.username, password: user.password }) + + expect(response).to set_flash.to /Signed in successfully/ + expect(subject.current_user). to eq user + end + end + end + + context 'two-factor authentication' do + let(:user) { create(:user, :two_factor) } + + def authenticate_2fa(user_params) + post(:create, { user: user_params }, { otp_user_id: user.id }) + end + + ## + # See #14900 issue + # + context 'authenticating with login and OTP belonging to another user' do + let(:another_user) { create(:user, :two_factor) } + + + context 'OTP valid for another user' do + it 'does not authenticate' do + authenticate_2fa(login: another_user.username, + otp_attempt: another_user.current_otp) + + expect(subject.current_user).to_not eq another_user + end + end + + context 'OTP invalid for another user' do + before do + authenticate_2fa(login: another_user.username, + otp_attempt: 'invalid') + end + + it 'does not authenticate' do + expect(subject.current_user).to_not eq another_user + end + + it 'does not leak information about 2FA enabled' do + expect(response).to_not set_flash.now[:alert].to /Invalid two-factor code/ + end + end + + context 'authenticating with OTP' do + context 'valid OTP' do + it 'authenticates correctly' do + authenticate_2fa(otp_attempt: user.current_otp) + + expect(subject.current_user).to eq user + end + end + + context 'invalid OTP' do + before { authenticate_2fa(otp_attempt: 'invalid') } + + it 'does not authenticate' do + expect(subject.current_user).to_not eq user + end + + it 'warns about invalid OTP code' do + expect(response).to set_flash.now[:alert].to /Invalid two-factor code/ + end + end + end + end + end + end +end
Add specs for sessions controller including 2FA This also contains specs for a bug described in #14900
diff --git a/spec/lib/set_member_subject_selector_spec.rb b/spec/lib/set_member_subject_selector_spec.rb index abc1234..def5678 100644 --- a/spec/lib/set_member_subject_selector_spec.rb +++ b/spec/lib/set_member_subject_selector_spec.rb @@ -0,0 +1,31 @@+require 'spec_helper' + +describe SetMemberSubjectSelector do + let(:count) { create(:subject_workflow_count) } + let(:user) { create(:user) } + + before do + count.workflow.subject_sets = [count.set_member_subject.subject_set] + count.workflow.save! + + SetMemberSubjectSelector + end + + context 'when there is a user and they have participated before' do + before { allow_any_instance_of(SetMemberSubjectSelector).to receive(:select_from_all?).and_return(false) } + + it 'does not include subjects that have been seen' do + seen_subject = create(:subject, subject_sets: [count.set_member_subject.subject_set]) + create(:user_seen_subject, user: user, workflow: count.workflow, subject_ids: [seen_subject.id]) + + sms = SetMemberSubjectSelector.new(count.workflow, user).set_member_subjects + expect(sms).to eq([count.set_member_subject]) + end + + it 'does not include subjects that are retired' do + count.retire! + sms = SetMemberSubjectSelector.new(count.workflow, user).set_member_subjects + expect(sms).to be_empty + end + end +end
Bring SMSSelector somewhat under test
diff --git a/features/support/env.rb b/features/support/env.rb index abc1234..def5678 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -9,10 +9,10 @@ require 'simplecov' require 'sinatra' -SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[ +SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([ SimpleCov::Formatter::HTMLFormatter, Coveralls::SimpleCov::Formatter -] +]) SimpleCov.start do add_filter 'features' end
Update to support newer version of cucumber