diff
stringlengths
65
26.7k
message
stringlengths
7
9.92k
diff --git a/SourceKittenFramework.podspec b/SourceKittenFramework.podspec index abc1234..def5678 100644 --- a/SourceKittenFramework.podspec +++ b/SourceKittenFramework.podspec @@ -8,7 +8,7 @@ s.author = { 'JP Simard' => 'jp@jpsim.com' } s.platform = :osx, '10.9' s.source_files = 'Source/Clang_C/include/*.h', 'Source/SourceKit/include/*.h', 'Source/SourceKittenFramework/*.swift' - s.swift_versions = ['5.1', '5.2', '5.3'] + s.swift_versions = ['5.2', '5.3'] s.pod_target_xcconfig = { 'APPLICATION_EXTENSION_API_ONLY' => 'YES' } s.dependency 'SWXMLHash', '~> 5.0.1' s.dependency 'Yams', '~> 4.0.1'
Remove Swift 5.1 from podspec swift versions
diff --git a/TVGuide/app/models/channel.rb b/TVGuide/app/models/channel.rb index abc1234..def5678 100644 --- a/TVGuide/app/models/channel.rb +++ b/TVGuide/app/models/channel.rb @@ -1,6 +1,6 @@ class Channel < ApplicationRecord belongs_to :category + has_many :schedules, through: :shows has_many :shows - has_many :schedules, through: :shows validates :name, presence: true, uniqueness: true end
Change order of attributes in Channel model.
diff --git a/spec/acceptance/001_basic_spec.rb b/spec/acceptance/001_basic_spec.rb index abc1234..def5678 100644 --- a/spec/acceptance/001_basic_spec.rb +++ b/spec/acceptance/001_basic_spec.rb @@ -37,7 +37,7 @@ }, prospectors => { 'system-logs' => { - log_type => 'system', + doc_type => 'system', paths => [ '/var/log/dmesg', ],
Fix beaker tests (they were using deprecated parameters)
diff --git a/lib/compass-rails/patches/static_compiler.rb b/lib/compass-rails/patches/static_compiler.rb index abc1234..def5678 100644 --- a/lib/compass-rails/patches/static_compiler.rb +++ b/lib/compass-rails/patches/static_compiler.rb @@ -11,6 +11,7 @@ :filename => eval_file, :line => line, :syntax => syntax, + :line_comments => ::Rails.application.config.sass.line_comments, :cache_store => cache_store, :importer => SassImporter.new(context, context.pathname), :load_paths => paths,
Apply 'classic' sass config setting for generating line comments
diff --git a/test/controllers/coronavirus_local_restrictions_controller_test.rb b/test/controllers/coronavirus_local_restrictions_controller_test.rb index abc1234..def5678 100644 --- a/test/controllers/coronavirus_local_restrictions_controller_test.rb +++ b/test/controllers/coronavirus_local_restrictions_controller_test.rb @@ -42,5 +42,13 @@ assert_response :success assert_template :show end + + it "renders the local restriction page when the postcode is blank" do + postcode = "" + post :results, params: { "postcode-lookup" => postcode } + + assert_response :success + assert_template :show + end end end
Add a test for when a blank postcode is submitted
diff --git a/test/test_helper.rb b/test/test_helper.rb index abc1234..def5678 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,7 +1,7 @@ require 'simplecov' require 'minitest/rg' -SimpleCov.minimum_coverage_by_file 80 +SimpleCov.minimum_coverage_by_file 100 SimpleCov.start do add_filter '/test/' end
Increase test coverage requirement from 80% to 100%
diff --git a/test/test_helper.rb b/test/test_helper.rb index abc1234..def5678 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -15,7 +15,12 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) $LOAD_PATH.unshift(File.dirname(__FILE__)) -RAILS_ROOT = File.dirname(__FILE__) +class Rails + def self.root + File.dirname(__FILE__) + end +end + ActiveRecord::Base.establish_connection :adapter => :nulldb, :schema => 'schema.rb' require 'init'
Fix for latest version of nulldb
diff --git a/test/test_helper.rb b/test/test_helper.rb index abc1234..def5678 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,6 +1,7 @@ require File.expand_path("../../test/dummy/config/environment.rb", __FILE__) ActiveRecord::Migrator.migrations_paths = [File.expand_path("../../test/dummy/db/migrate", __FILE__)] require "rails/test_help" +require "rails/test_unit/reporter" # Filter out Minitest backtrace while allowing backtrace from other libraries # to be shown.
Fix raise error on test due to bug of rails generator
diff --git a/test/test_helper.rb b/test/test_helper.rb index abc1234..def5678 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -8,8 +8,8 @@ # make sure we can run redis # -if !system("which redis-server") - puts '', "** can't find `redis-server` in your path" +if !system("which redis-server") || !system("which redis-cli") + puts '', "** missing redis-server and/or redis-cli" puts "** try running `sudo rake install`" abort '' end @@ -25,10 +25,9 @@ exit_code = Test::Unit::AutoRunner.run - pid = `ps -A -o pid,command | grep [r]edis-test`.split(" ")[0] - puts "Killing test redis server[#{pid}]..." + puts "Killing test redis server at localhost:9736..." + `redis-cli -p 9736 shutdown` `rm -f #{dir}/dump.rdb` - Process.kill("KILL", pid.to_i) exit exit_code end
Use redis-cli to shutdown redis server It would appear that the process name as reported by ps has changed, so we weren't getting a pid to use for kill. This should be more fool-proof.
diff --git a/test/test_schema.rb b/test/test_schema.rb index abc1234..def5678 100644 --- a/test/test_schema.rb +++ b/test/test_schema.rb @@ -1,14 +1,19 @@ require 'test/unit' require 'batch/database/schema' -require 'java' -require 'C:/oracle/product/11.2.0/dbhome_1/jdbc/lib/ojdbc6.jar' class TestSchema < Test::Unit::TestCase def setup @schema = Batch::Database::Schema.new - @schema.connect('jdbc:oracle:thin:BATCH/b4tch@localhost:1521:ORCL') + if RUBY_ENGINE == 'java' + require 'java' + require 'C:/oracle/product/11.2.0/dbhome_1/jdbc/lib/ojdbc6.jar' + @schema.connect('jdbc:oracle:thin:BATCH/b4tch@localhost:1521:ORCL') + else + require 'oci8' + @schema.connect(adapter: 'oracle', user: 'BATCH', password: 'b4tch') + end end def test_create_schema
Add support for testing against Oracle using Ruby OCI8
diff --git a/examples/admin_user.rb b/examples/admin_user.rb index abc1234..def5678 100644 --- a/examples/admin_user.rb +++ b/examples/admin_user.rb @@ -0,0 +1,28 @@+ActiveAdmin.register AdminUser do + permit_params :email, :password, :password_confirmation + + index do + selectable_column + id_column + column :email + column :current_sign_in_at + column :sign_in_count + column :created_at + actions + end + + filter :email + filter :current_sign_in_at + filter :sign_in_count + filter :created_at + + form do |f| + f.inputs "Admin Details" do + f.input :email + f.input :password + f.input :password_confirmation + end + f.actions + end + +end
Add folder with examples for testing
diff --git a/test/factories/campuses_factory.rb b/test/factories/campuses_factory.rb index abc1234..def5678 100644 --- a/test/factories/campuses_factory.rb +++ b/test/factories/campuses_factory.rb @@ -6,5 +6,6 @@ name campus_name abbreviation campus_abbreviation mode { ['timetable', 'automatic', 'manual'].sample } + active true end end
ENHANCE: Add active to campus factory
diff --git a/lib/modules/sections_and_questions_shared.rb b/lib/modules/sections_and_questions_shared.rb index abc1234..def5678 100644 --- a/lib/modules/sections_and_questions_shared.rb +++ b/lib/modules/sections_and_questions_shared.rb @@ -20,6 +20,7 @@ private def destroy_answer_type + return true unless self.answer_type #return true without deleting the answer type if the answer_type is associated #with other objects (be it questions or sections) return true if self.is_a?(Question) &&
Return if no answer type
diff --git a/lib/puppet-lint/plugins/no_cron_resources.rb b/lib/puppet-lint/plugins/no_cron_resources.rb index abc1234..def5678 100644 --- a/lib/puppet-lint/plugins/no_cron_resources.rb +++ b/lib/puppet-lint/plugins/no_cron_resources.rb @@ -1,15 +1,14 @@ PuppetLint.new_check(:no_cron_resources) do def check resource_indexes.each do |resource| - if resource[:type].value == 'cron' + next unless resource[:type].value == 'cron' - notify :warning, { - message: 'cron resources should not be used', - line: resource[:type].line, - column: resource[:type].column, - } + notify :warning, { + message: 'cron resources should not be used', + line: resource[:type].line, + column: resource[:type].column, + } - end end end end
Convert to next and early return on non-cron resources Reindent to suit the change
diff --git a/lib/rspec_api_documentation/configuration.rb b/lib/rspec_api_documentation/configuration.rb index abc1234..def5678 100644 --- a/lib/rspec_api_documentation/configuration.rb +++ b/lib/rspec_api_documentation/configuration.rb @@ -1,6 +1,6 @@ module RspecApiDocumentation class Configuration - def self.add_setting(name, opts) + def self.add_setting(name, opts = {}) define_method("#{name}=") { |value| settings[name] = value } define_method("#{name}") { settings.has_key?(name) ? settings[name] : opts[:default] } end
Fix issue where unset, undefaulting settings could raise error.
diff --git a/app/controllers/apps_controller.rb b/app/controllers/apps_controller.rb index abc1234..def5678 100644 --- a/app/controllers/apps_controller.rb +++ b/app/controllers/apps_controller.rb @@ -8,7 +8,7 @@ end def new - @app = App.new + @app = current_user.apps.new authorize! :new, @app end
Fix registration of apps by non-admin users
diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index abc1234..def5678 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -1,7 +1,7 @@ class HomeController < ApplicationController caches_action :index, :expires_in => 1.hour, - :unless => lambda { user_signed_in? || admin_signed_in? }, + :unless => lambda { user_signed_in? || admin_user_signed_in? }, :cache_path => Proc.new {|c| c.params.delete_if { |k,v| %w{lat lon zoom q layers a}.include?(k) } }
Check if admin user is signed in for caching.
diff --git a/high_level_browse.gemspec b/high_level_browse.gemspec index abc1234..def5678 100644 --- a/high_level_browse.gemspec +++ b/high_level_browse.gemspec @@ -17,7 +17,6 @@ spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] - spec.add_dependency 'httpclient', "~> 2.5" spec.add_dependency 'oga', '~> 2.1' spec.add_dependency 'lcsort'
Update gemspec to no longer require httpclient; use stdlib instead
diff --git a/spec/integration/commands/config_spec.rb b/spec/integration/commands/config_spec.rb index abc1234..def5678 100644 --- a/spec/integration/commands/config_spec.rb +++ b/spec/integration/commands/config_spec.rb @@ -0,0 +1,10 @@+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') + +describe "Config command" do + context "config" do + it "should report success" do + response, exit_status = capture_with_status(:stdout){ HP::Cloud::CLI.start(['config']) } + exit_status.should be_exit(:success) + end + end +end
Add spec for new command config.
diff --git a/spec/ruby/1.8/core/method/shared/to_s.rb b/spec/ruby/1.8/core/method/shared/to_s.rb index abc1234..def5678 100644 --- a/spec/ruby/1.8/core/method/shared/to_s.rb +++ b/spec/ruby/1.8/core/method/shared/to_s.rb @@ -1,13 +1,7 @@ shared :method_to_s do |cmd| describe "Method##{cmd}" do it "returns a string representing the method" do - compliant_on :ruby, :jruby do - 11.method("+").send(cmd).should == "#<Method: Fixnum#+>" - end - - deviates_on :rubinius do - 11.method("+").send(cmd).should == "#<Method Fixnum(Fixnum)#+>" - end + 11.method("+").send(cmd).should =~ /#<Method(:)? Fixnum(\(Fixnum\))?#\+>/ end end end
Use a regexp to match the inspect output instead of deviating on rbx
diff --git a/app/services/sweep_data_service.rb b/app/services/sweep_data_service.rb index abc1234..def5678 100644 --- a/app/services/sweep_data_service.rb +++ b/app/services/sweep_data_service.rb @@ -0,0 +1,18 @@+class SweepDataService + def initialize + @response = Faraday.get('https://data.cityofchicago.org/resource/waad-z968.json') + end + + def json_response + JSON.parse(@response.body) + end + + def populate_table + json_response.each do |data| + StreetSweep.create(ward_id: data["ward"], + dates: data["dates"], + month: data["month_number"], + section: data["section"]) + end + end +end
Add SweepDataService to connect to Faraday and pull in the data
diff --git a/app/workers/avatar_purge_worker.rb b/app/workers/avatar_purge_worker.rb index abc1234..def5678 100644 --- a/app/workers/avatar_purge_worker.rb +++ b/app/workers/avatar_purge_worker.rb @@ -28,6 +28,10 @@ record.avatar_purged = true record.save + + return true + rescue Curl::Err::ConnectionFailedError + return false end end
Fix error message in Sidekiq.
diff --git a/spec/features/admin_creates_plot_spec.rb b/spec/features/admin_creates_plot_spec.rb index abc1234..def5678 100644 --- a/spec/features/admin_creates_plot_spec.rb +++ b/spec/features/admin_creates_plot_spec.rb @@ -12,8 +12,8 @@ scenario 'providing valid plot attributes' do visit new_plot_path fill_in('Plot', with: 1) - select('Plant Example', from: 'Featured plant') - fill_in('Location description', with: 'Top of the hill') + select('Plant Example', from: 'Featured Plant') + fill_in('Description', with: 'Top of the hill') fill_in('Latitude', with: 1234) fill_in('Longitude', with: 1234) fill_in('Elevation', with: 3000) @@ -21,8 +21,8 @@ fill_in('Aspect', with: 'South') fill_in('Origin', with: 'Salvage') check('Inoculated') - fill_in('Initial planting date', with: 'Spring 2016') - fill_in('Initial succession', with: 'example succession') + fill_in('Initial Planting Date', with: 'Spring 2016') + fill_in('Initial Succession', with: 'example succession') click_on('Create Plot') expect(page).to have_content('Plot was successfully created.') end
Update wording in test to match updates in form UI
diff --git a/spec/views/users/index.html.haml_spec.rb b/spec/views/users/index.html.haml_spec.rb index abc1234..def5678 100644 --- a/spec/views/users/index.html.haml_spec.rb +++ b/spec/views/users/index.html.haml_spec.rb @@ -0,0 +1,33 @@+require 'rails_helper' + +RSpec.describe "users/index", type: :view do + before(:each) do + assign(:users, [ + User.create!( + :username => "name", + :name => "Name", + :role => 'admin' + ), + User.create!( + :username => "name2", + :name => "Name 2", + :role => 'writer' + ), + User.create!( + :username => "name3", + :name => "Name 3", + :role => 'reader' + ) + ]) + end + + it "renders a list of type_of_relationships" do + render + assert_select "tr>td", :text => "Name", :count => 1 + assert_select "tr>td", :text => "admin", :count => 1 + assert_select "tr>td", :text => "Name 2", :count => 1 + assert_select "tr>td", :text => "writer", :count => 1 + assert_select "tr>td", :text => "Name 3", :count => 1 + assert_select "tr>td", :text => "reader", :count => 1 + end +end
Test case for user view
diff --git a/lib/omniauth/strategies/adstage.rb b/lib/omniauth/strategies/adstage.rb index abc1234..def5678 100644 --- a/lib/omniauth/strategies/adstage.rb +++ b/lib/omniauth/strategies/adstage.rb @@ -2,7 +2,7 @@ module OmniAuth module Strategies - class Doorkeeper < OmniAuth::Strategies::OAuth2 + class Adstage < OmniAuth::Strategies::OAuth2 # change the class name and the :name option to match your application name option :name, :adstage @@ -15,7 +15,8 @@ info do { - :email => raw_info["email"] + :email => raw_info["email"], + :admin => raw_info["admin"] # and anything else you want to return to your API consumers } end
Set admin attribute if we get it from the server.
diff --git a/lib/schnitzelpress/actions/blog.rb b/lib/schnitzelpress/actions/blog.rb index abc1234..def5678 100644 --- a/lib/schnitzelpress/actions/blog.rb +++ b/lib/schnitzelpress/actions/blog.rb @@ -30,7 +30,7 @@ @posts = Schnitzelpress::Model::Post.latest.limit(10).skip(skipped) displayed_count = @posts.length - @show_previous_posts_button = Schnitzelpress::Model::Post.count > skipped + displayed_count + @show_previous_posts_button = Schnitzelpress::Model::Post.posts.count > skipped + displayed_count @show_description = true render_posts
Use posts scope to determine the correct total count of posts
diff --git a/lib/aerosol/connection.rb b/lib/aerosol/connection.rb index abc1234..def5678 100644 --- a/lib/aerosol/connection.rb +++ b/lib/aerosol/connection.rb @@ -6,14 +6,13 @@ include Dockly::Util::Logger::Mixin logger_prefix '[aerosol connection]' - dsl_attribute :user, :host, :jump, :use_private_ip - default_value :use_private_ip, false + dsl_attribute :user, :host, :jump def with_connection(&block) ensure_present! :user, :host unless host.is_a? String - host = :use_private_ip ? host.private_ip_address : host.public_hostname + host = host.public_hostname || host.private_ip_address end if jump
Use ip automatically if public hostname is nil.
diff --git a/spec/factories/organizations.rb b/spec/factories/organizations.rb index abc1234..def5678 100644 --- a/spec/factories/organizations.rb +++ b/spec/factories/organizations.rb @@ -12,6 +12,7 @@ organization_type_id { 1 } sequence(:name) { |n| "Org #{n}" } short_name { name } + legal_name { name } license_holder { true } end
[TTPLAT-1117] Add legal name to organization factories.
diff --git a/spec/requests/customers_spec.rb b/spec/requests/customers_spec.rb index abc1234..def5678 100644 --- a/spec/requests/customers_spec.rb +++ b/spec/requests/customers_spec.rb @@ -16,4 +16,13 @@ expect(JSON.parse(response.body)['first_name']).to eq('J') end end + + describe 'GET /customers/:id/orders' do + it 'successful request' do + customer = Customer.create(first_name: 'J', last_name: 'C') + 2.times { customer.orders.create } + get "/api/customers/#{customer.id}/orders" + expect(response).to have_http_status(200) + end + end end
Add spec for showing a customer's orders
diff --git a/spec/services/join_game_spec.rb b/spec/services/join_game_spec.rb index abc1234..def5678 100644 --- a/spec/services/join_game_spec.rb +++ b/spec/services/join_game_spec.rb @@ -0,0 +1,45 @@+require "rails_helper" + +RSpec.describe JoinGame, type: :service do + fixtures :users, :games + + let(:game) { Game.create! } + let(:user) { users(:user1) } + let(:service) { JoinGame.new(game: game, user: user) } + + describe "#call" do + context "when the game can be joined" do + let!(:call_result) { service.call } + let!(:player) { service.player } + + it "returns true" do + expect(call_result).to be true + end + + it "creates a player" do + expect { JoinGame.new(game: game, user: users(:user2)).call }.to change(Player, :count).by(1) + end + + it "associates the player with the correct user" do + expect(player.user).to eq(user) + end + + it "associates the player with the correct game" do + expect(player.game).to eq(game) + end + end + + context "when the game can't be joined" do + let!(:call_result) { service.call } + let(:game) { games(:playing_game) } + + it "returns false" do + expect(call_result).to be false + end + + it "doesn't creates a player" do + expect { JoinGame.new(game: game, user: users(:user2)).call }.to_not change(Player, :count) + end + end + end +end
Create specs for join game
diff --git a/spec/support/custom_matchers.rb b/spec/support/custom_matchers.rb index abc1234..def5678 100644 --- a/spec/support/custom_matchers.rb +++ b/spec/support/custom_matchers.rb @@ -21,11 +21,11 @@ failure_message_for_should do |actual| actual = 'nil' unless actual - "expected that #{actual} (#{actual.to_i}) would be #{expected} (#{expected.to_i})" + "expected that #{actual} (#{actual.to_i}) would be #{expected} (#{DateTime.parse(expected).to_i})" end failure_message_for_should_not do |actual| actual = 'nil' unless actual - "expected that #{actual} (#{actual.to_i}) would not be #{expected} (#{expected.to_i})" + "expected that #{actual} (#{actual.to_i}) would not be #{expected} (#{DateTime.parse(expected).to_i})" end end
Fix error messages for be_at
diff --git a/db/migrate/20170309132554_add_default_config_to_application.rb b/db/migrate/20170309132554_add_default_config_to_application.rb index abc1234..def5678 100644 --- a/db/migrate/20170309132554_add_default_config_to_application.rb +++ b/db/migrate/20170309132554_add_default_config_to_application.rb @@ -1,6 +1,6 @@ class AddDefaultConfigToApplication < ActiveRecord::Migration def change - add_column :applications, :default_config, :jsonb, default: '{}' - add_column :application_instances, :config, :jsonb, default: '{}' + add_column :applications, :default_config, :jsonb, default: {} + add_column :application_instances, :config, :jsonb, default: {} end end
Set default config to hash instead of string
diff --git a/Casks/phpstorm-eap.rb b/Casks/phpstorm-eap.rb index abc1234..def5678 100644 --- a/Casks/phpstorm-eap.rb +++ b/Casks/phpstorm-eap.rb @@ -1,6 +1,6 @@ cask :v1 => 'phpstorm-eap' do - version '141.792' - sha256 'a4cbd4f72f2b7edad5a39381850a5ea33991b83331401a383f2807120dff8f4d' + version '141.891' + sha256 '5fca9d16de932905109decc442889f1534b5e77b5226ff15c77bd8259aa88ec0' url "http://download.jetbrains.com/webide/PhpStorm-EAP-#{version}.dmg" homepage 'http://confluence.jetbrains.com/display/PhpStorm/PhpStorm+Early+Access+Program'
Upgrade PhpStorm EAP to 141.891
diff --git a/lib/codeclimate_ci/cli.rb b/lib/codeclimate_ci/cli.rb index abc1234..def5678 100644 --- a/lib/codeclimate_ci/cli.rb +++ b/lib/codeclimate_ci/cli.rb @@ -13,22 +13,18 @@ def check CodeclimateCi.configuration.load_from_options(options) - bad_connection unless api_requester.connection_established? + exit_invalid_credentials! unless api_requester.connection_established? if compare_gpa.worse?(branch_name) - worse_code + exit_worse_code! else - good_code + exit_good_code! end end default_task :check private - - def diff - compare_gpa.diff(branch_name) - end def compare_gpa @compare_gpa ||= CompareGpa.new(api_requester) @@ -41,20 +37,25 @@ ) end + def diff + compare_gpa.diff(branch_name) + end + def branch_name CodeclimateCi.configuration.branch_name end - def worse_code + def exit_worse_code! Report.worse_code(diff) exit(1) end - def good_code + def exit_good_code! Report.good_code(diff) + exit(0) end - def bad_connection + def exit_invalid_credentials! Report.invalid_credentials exit(1) end
Refactor methods in CLI class
diff --git a/spec/sidekiq/limit_fetch/global/monitor_spec.rb b/spec/sidekiq/limit_fetch/global/monitor_spec.rb index abc1234..def5678 100644 --- a/spec/sidekiq/limit_fetch/global/monitor_spec.rb +++ b/spec/sidekiq/limit_fetch/global/monitor_spec.rb @@ -22,7 +22,7 @@ 2.times { queue.acquire } described_class.send(:invalidate_old_processors) queue.busy.should == 2 - sleep 2 + sleep 3 described_class.send(:invalidate_old_processors) queue.busy.should == 0 end
Fix sporadic failures caused by timing
diff --git a/lib/deploy/recipes/app.rb b/lib/deploy/recipes/app.rb index abc1234..def5678 100644 --- a/lib/deploy/recipes/app.rb +++ b/lib/deploy/recipes/app.rb @@ -0,0 +1,16 @@+Capistrano::Configuration.instance(:must_exist).load do + after "deploy:finalize_update", "app:permissions" + + namespace :app do + desc <<-DESC + Change application permissions. + + Because the user deploying the application is different to the user + running the application we need to ensure that the permissions on + directories are what we expect. + DESC + task :permissions, :except => {:no_release => true} do + run "chmod -R g+w #{latest_release}/tmp" + end + end +end
Make tmp group writable after deploy.
diff --git a/spec/defines/rbenv__compile_spec.rb b/spec/defines/rbenv__compile_spec.rb index abc1234..def5678 100644 --- a/spec/defines/rbenv__compile_spec.rb +++ b/spec/defines/rbenv__compile_spec.rb @@ -25,4 +25,9 @@ it "installs ruby-build plugin from official repository" do should contain_rbenv__plugin__rubybuild("rbenv::rubybuild::#{user}") end + + it "installs bundler" do + should contain_rbenv__gem("rbenv::bundler #{user} #{ruby_version}"). + with_ensure('present') + end end
Add bundler gem test to rbenv compile spec
diff --git a/test/integration/advanced_search_test.rb b/test/integration/advanced_search_test.rb index abc1234..def5678 100644 --- a/test/integration/advanced_search_test.rb +++ b/test/integration/advanced_search_test.rb @@ -10,6 +10,19 @@ visit advanced_search_path end + test "searches for a gem while scoping advanced attributes" do + rubygem = create(:rubygem, name: "LDAP", number: "1.0.0", downloads: 3) + create(:version, summary: "some summary", description: "Hello World", rubygem: rubygem) + + import_and_refresh + + fill_in "Search Gems…", with: "downloads: <5" + click_button "advanced_search_submit" + + assert current_path == search_path + assert has_content? "LDAP" + end + test "enter inside any field will submit form" do ["#name", "#summary", "#description", "#downloads", "#updated"].each do |el| visit advanced_search_path @@ -18,6 +31,16 @@ end end + test "forms search query out of advanced attributes" do + fill_in "name", with: "hello" + fill_in "summary", with: "world" + fill_in "description", with: "foo" + fill_in "downloads", with: ">69" + fill_in "updated", with: ">2021-05-05" + + page.find("#home_query").assert_text "name: hello summary: world description: foo downloads: >69 updated: >2021-05-05" + end + teardown do Capybara.reset_sessions! Capybara.use_default_driver
Add integration tests for advanced search
diff --git a/test/integration/default/default_spec.rb b/test/integration/default/default_spec.rb index abc1234..def5678 100644 --- a/test/integration/default/default_spec.rb +++ b/test/integration/default/default_spec.rb @@ -14,3 +14,6 @@ it { should be_listening } end +describe ssh_config do + its('UseRoaming') { should eq 'no' } +end
Add test for UseRoaming no
diff --git a/test/integration/user_suspension_test.rb b/test/integration/user_suspension_test.rb index abc1234..def5678 100644 --- a/test/integration/user_suspension_test.rb +++ b/test/integration/user_suspension_test.rb @@ -10,7 +10,7 @@ visit new_user_session_path signin(@user) - assert_response_contains("account has been temporarily suspended") + assert_response_contains("account has been suspended") end should "show the suspension reason to admins" do
Update test for change to suspension message Update the test for the change made to the suspension message made in https://github.com/alphagov/signonotron2/commit/68514ef43b71f5e645c597d3b2f3202cf207c732
diff --git a/test/integration/progress_test.rb b/test/integration/progress_test.rb index abc1234..def5678 100644 --- a/test/integration/progress_test.rb +++ b/test/integration/progress_test.rb @@ -30,7 +30,7 @@ within "#request_fact_check_form" do fill_in "Comment", with: "Blah" fill_in "Email address", with: "user@example.com" - click_on "Save" + click_on "Send" end wait_until { page.has_content? "Status: Fact check requested" }
Update integration test as button label had changed
diff --git a/lib/tasks/deployment/20190417100245_remove_old_email_data.rake b/lib/tasks/deployment/20190417100245_remove_old_email_data.rake index abc1234..def5678 100644 --- a/lib/tasks/deployment/20190417100245_remove_old_email_data.rake +++ b/lib/tasks/deployment/20190417100245_remove_old_email_data.rake @@ -3,8 +3,8 @@ task remove_old_email_data: :environment do puts "Running deploy task 'remove_old_email_data'" + AlertSubscriptionEvent.delete_all Email.delete_all - AlertSubscriptionEvent.delete_all AfterParty::TaskRecord.create version: '20190417100245' end
Switch order of deletions around
diff --git a/core/lib/spree/localized_number.rb b/core/lib/spree/localized_number.rb index abc1234..def5678 100644 --- a/core/lib/spree/localized_number.rb +++ b/core/lib/spree/localized_number.rb @@ -16,9 +16,10 @@ non_number_characters = /[^0-9\-#{separator}]/ # strip everything else first - number.gsub!(non_number_characters, '') + number = number.gsub(non_number_characters, '') + # then replace the locale-specific decimal separator with the standard separator if necessary - number.gsub!(separator, '.') unless separator == '.' + number = number.gsub(separator, '.') unless separator == '.' number.to_d end
Stop mutating input in LocalizedNumber.parse Previously, LocalizedNumber.parse would perform it's gsub! replacements directly on the string passed in.
diff --git a/lib/knapsack/presenter.rb b/lib/knapsack/presenter.rb index abc1234..def5678 100644 --- a/lib/knapsack/presenter.rb +++ b/lib/knapsack/presenter.rb @@ -12,12 +12,12 @@ JSON.pretty_generate(Knapsack.tracker.spec_files_with_time) end + def report_details + "Knapsack report was generated. Preview:\n" + Presenter.report_json + end + def global_time "Knapsack global time execution for specs: #{Knapsack.tracker.global_time}s" - end - - def report_details - "Knapsack report was generated. Preview:\n" + Presenter.report_json end end end
Move report details above the gobal time method
diff --git a/lib/notify_user/engine.rb b/lib/notify_user/engine.rb index abc1234..def5678 100644 --- a/lib/notify_user/engine.rb +++ b/lib/notify_user/engine.rb @@ -9,5 +9,7 @@ g.assets false g.helper false end + + Rails.application.config.assets.precompile += %w{ notify_user/notify_user.css } end end
Add CSS to precompile, now it's not added to application.css by the installer
diff --git a/lib/tasks/panopticon.rake b/lib/tasks/panopticon.rake index abc1234..def5678 100644 --- a/lib/tasks/panopticon.rake +++ b/lib/tasks/panopticon.rake @@ -7,10 +7,7 @@ logger = GdsApi::Base.logger = Logger.new(STDERR).tap { |l| l.level = Logger::INFO } logger.info "Registering with panopticon..." - registerer = GdsApi::Panopticon::Registerer.new( - owning_app: "calendars", - kind: "answer" - ) + registerer = GdsApi::Panopticon::Registerer.new(owning_app: "calendars") Dir.glob(Rails.root.join("lib/data/*.json")).each do |file| details = RegisterableCalendar.new(file) registerer.register(details)
Revert "Add a 'kind' parameter when registering calendars." These artefacts should be registered as custom applications, and should be passed through as such to Rummager. The actual fix for the reported problem of these being displayed as custom applications on the public search page is to add a condition in Rummager itself. This reverts commit 9bcf7ce7a6e9397797f0604440a730fb6843d4d3.
diff --git a/spec/entities/locomotive/page_entity_spec.rb b/spec/entities/locomotive/page_entity_spec.rb index abc1234..def5678 100644 --- a/spec/entities/locomotive/page_entity_spec.rb +++ b/spec/entities/locomotive/page_entity_spec.rb @@ -41,14 +41,13 @@ end context 'overrides' do - let(:site) { create(:site) } - let(:page) { site.pages.root.first } + let(:page) { create(:page_with_editable_element) } subject { Locomotive::PageEntity.new(page) } let(:exposure) { subject.serializable_hash } describe 'editable_elements' do it 'returns the editable elements' do - expect(exposure[:editable_elements]).to eq [] + expect(exposure[:editable_elements].count).to eq 1 end end
Use page with editable element
diff --git a/spec/features/search/question_search_spec.rb b/spec/features/search/question_search_spec.rb index abc1234..def5678 100644 --- a/spec/features/search/question_search_spec.rb +++ b/spec/features/search/question_search_spec.rb @@ -10,7 +10,7 @@ let!(:question2) { create(:question, name: "How many pies?") } let!(:user) { create(:user, role_name: "coordinator", admin: true) } - scenario "search" do + scenario "search results" do login(user) visit "/en/m/#{mission.compact_name}/questions" expect(page).to have_content("Displaying all 2 Questions") @@ -36,4 +36,15 @@ "Error: Your search query could not be understood due to unexpected text near the end." ) end + + scenario "search filters" do + login(user) + visit "/en/m/#{mission.compact_name}/questions" + + search_for(%(foo)) + expect(page).to have_field("search", with: "foo") + + # Filters UI shouldn't be active on this page. + expect(page).to_not(have_css("#form-filter")) + end end
9775: Add basic question_search filter specs
diff --git a/lib/assignments_ics.rb b/lib/assignments_ics.rb index abc1234..def5678 100644 --- a/lib/assignments_ics.rb +++ b/lib/assignments_ics.rb @@ -20,6 +20,9 @@ end end + # It looks bad to Rubocop because every line is at least two method calls. + # But, it's really just a builder pattern. + # rubocop:disable Metrics/AbcSize def event(assignment) Icalendar::Event.new.tap do |e| e.uid = "#{assignment.id}@screaming-dinosaur" @@ -35,4 +38,5 @@ DESC end end + # rubocop:enable Metrics/AbcSize end
Disable Abc cop on event builder
diff --git a/lib/dc/search/field.rb b/lib/dc/search/field.rb index abc1234..def5678 100644 --- a/lib/dc/search/field.rb +++ b/lib/dc/search/field.rb @@ -16,7 +16,8 @@ end def entity? - DC::ENTITY_KINDS.include? @kind.downcase.to_sym + #DC::ENTITY_KINDS.include? @kind.downcase.to_sym + false end def to_s
Fix searches that used to employ entity matching
diff --git a/lib/eastwood/engine.rb b/lib/eastwood/engine.rb index abc1234..def5678 100644 --- a/lib/eastwood/engine.rb +++ b/lib/eastwood/engine.rb @@ -2,9 +2,12 @@ class Engine < Rails::Engine initializer 'eastwood.setup' do |app| + # include helpers in the sprockets context app.assets.context_class.instance_eval do include Eastwood::Context end + # watch for changes in eastwood initializer + app.config.watchable_files << 'config/initializers/eastwood.rb' end end end
Watch for changes in eastwood initializer
diff --git a/lib/sunspot/mongoid.rb b/lib/sunspot/mongoid.rb index abc1234..def5678 100644 --- a/lib/sunspot/mongoid.rb +++ b/lib/sunspot/mongoid.rb @@ -51,7 +51,7 @@ class DataAccessor < Sunspot::Adapters::DataAccessor def load(id) - @clazz.find(id) rescue nil + @clazz.find(BSON::ObjectID.from_string(id)) rescue nil end def load_all(ids)
Convert id to BSON before loading
diff --git a/lib/tasks/frankiz.rake b/lib/tasks/frankiz.rake index abc1234..def5678 100644 --- a/lib/tasks/frankiz.rake +++ b/lib/tasks/frankiz.rake @@ -1,7 +1,16 @@ namespace :frankiz do task :refresh_promo, [:promo] => :environment do |_, args| - fkz = FrankizLdap.new - fkz.crawl_promo(args[:promo]) + FrankizLdap.new.crawl_promo(args[:promo]) + end + + task refresh_oldest_promo: :environment do + promo = User.select(:promo, 'MIN(updated_at) updated_at') + .where.not(promo: nil) + .group(:promo) + .having('COUNT(1) > 1') + .order(:updated_at).first.promo + promo = User.maximum(:promo) + 1 if Random.rand(10) == 0 + FrankizLdap.new.crawl_promo(promo) end task :associate_accounts, [:promo] => :environment do |_, args|
Add rake task to refresh oldest promo
diff --git a/lib/tictactoe_rules.rb b/lib/tictactoe_rules.rb index abc1234..def5678 100644 --- a/lib/tictactoe_rules.rb +++ b/lib/tictactoe_rules.rb @@ -1,3 +1,5 @@+$: << File.dirname(__FILE__) + class TictactoeRules attr_reader :desc
Add file to load path
diff --git a/test/end_to_end/tasks_test.rb b/test/end_to_end/tasks_test.rb index abc1234..def5678 100644 --- a/test/end_to_end/tasks_test.rb +++ b/test/end_to_end/tasks_test.rb @@ -5,7 +5,6 @@ do_into_tmp_module('testmod', t) end - let(:fixture_module) { File.join(fixture_dir, 'testmod') } let(:task_list) { `rake -T` } [:install, :clean, :deb, :rpm].each do |task|
Fix shadowing bug in the test suite. A small piece has been left out from the last refactoring, so the `fixture_module` function was actually shadowed by a variable; this broken all the tests for the amended file.
diff --git a/config/initializers/sentry.rb b/config/initializers/sentry.rb index abc1234..def5678 100644 --- a/config/initializers/sentry.rb +++ b/config/initializers/sentry.rb @@ -4,4 +4,6 @@ config.dsn = 'https://1150348b449a444bb3ac47ddd82b37c4:5fd368489fe44c0f83f1f2e5df10a7ef@sentry.io/251669' config.current_environment = ENV['DEPLOYMENT_ENVIRONMENT'] || Rails.env config.environments = %w[production test] + config.release = Version::VERSION + config.tags = { app: 'ukhpi' } end
Annotate Sentry reports with version and app
diff --git a/app/helpers/tracks_helper.rb b/app/helpers/tracks_helper.rb index abc1234..def5678 100644 --- a/app/helpers/tracks_helper.rb +++ b/app/helpers/tracks_helper.rb @@ -9,6 +9,7 @@ I18n.t("tracking.user_data.gender.#{user.gender}") else I18n.t("tracking.user_data.gender.unknown") + end end def track_event(data = {})
Add missing end on if else clause
diff --git a/app/models/authentication.rb b/app/models/authentication.rb index abc1234..def5678 100644 --- a/app/models/authentication.rb +++ b/app/models/authentication.rb @@ -10,14 +10,12 @@ def self.find_or_create_by_hash(auth_hash) where(auth_hash.slice(:provider, :uid)).first_or_initialize.tap do |auth| + auth.provider = auth_hash.provider + auth.uid = auth_hash.uid auth.auth = auth_hash - if auth.user.blank? - auth.provider = auth_hash.provider - auth.uid = auth_hash.uid - auth.user = User.create do |u| - u.name = auth.auth.info["name"] - end - end + auth.user = User.new if auth.user.blank? + auth.user.name = auth.auth.info["name"] + auth.user.save! auth.save! end end
Update user info from social network on login
diff --git a/app/models/message_parser.rb b/app/models/message_parser.rb index abc1234..def5678 100644 --- a/app/models/message_parser.rb +++ b/app/models/message_parser.rb @@ -7,7 +7,7 @@ def recipient_name beginning = trigger_word.size remaining = text[beginning..text.size-1] - remaining.strip.split.first + remaining.strip.split.first || "" end private
Fix on case when null was returned
diff --git a/app/models/person_edition.rb b/app/models/person_edition.rb index abc1234..def5678 100644 --- a/app/models/person_edition.rb +++ b/app/models/person_edition.rb @@ -7,13 +7,12 @@ # type (Staff / Trainer / Member / Start-up / Artist): applied by tag field :honorific_prefix, type: String field :honorific_suffix, type: String - # first/last name: uses artefact name + field :affiliation, type: String + # name: uses artefact name field :role, type: String field :description, type: String attaches :image field :url, type: String - field :contact_title, type: String - field :contact_name, type: String field :telephone, type: String field :email, type: String field :twitter, type: String @@ -23,9 +22,8 @@ GOVSPEAK_FIELDS = Edition::GOVSPEAK_FIELDS + [:description] @fields_to_clone = [ - :honorific_prefix, :honorific_suffix, :role, :description, :url, - :contact_title, :contact_name, :telephone, :email, - :twitter, :linkedin, :github, + :honorific_prefix, :honorific_suffix, :affiliation, :role, :description, :url, + :telephone, :email, :twitter, :linkedin, :github, ] def whole_body
Remove contact name/title, and add affiliation string to Person
diff --git a/app/models/responsibility.rb b/app/models/responsibility.rb index abc1234..def5678 100644 --- a/app/models/responsibility.rb +++ b/app/models/responsibility.rb @@ -3,6 +3,7 @@ belongs_to :organization, :polymorphic => true validates_presence_of :organization_id, :message => I18n.translate('problems.new.choose_operator') validates_presence_of :organization_type + has_paper_trail def organization case self.organization_type
Add paper trail to responsibilities.
diff --git a/app/models/rglossa/corpus.rb b/app/models/rglossa/corpus.rb index abc1234..def5678 100644 --- a/app/models/rglossa/corpus.rb +++ b/app/models/rglossa/corpus.rb @@ -21,7 +21,11 @@ end def langs - languages.map { |l| {lang: l[:lang], tags: Rglossa.taggers[l[:tagger].to_s]['tags']} } + if languages + languages.map { |l| {lang: l[:lang], tags: Rglossa.taggers[l[:tagger].to_s]['tags']} } + else + [] + end end # This lets us specify a value_type of 'text', 'integer' etc. when we add a metadata category
Allow corpora without a language specification Language specs is only needed for tagged and/or multilingual corpora.
diff --git a/app/models/tracked_branch.rb b/app/models/tracked_branch.rb index abc1234..def5678 100644 --- a/app/models/tracked_branch.rb +++ b/app/models/tracked_branch.rb @@ -2,15 +2,9 @@ belongs_to :project has_many :test_jobs, dependent: :destroy + delegate :status_text, :status, to: :last_run, allow_nil: true + def last_run test_jobs.sort_by(&:created_at).last end - - def status_text - last_run.status_text if last_run - end - - def status - last_run.status if last_run - end end
Replace method definition with delegations
diff --git a/mnemosyne-ruby.gemspec b/mnemosyne-ruby.gemspec index abc1234..def5678 100644 --- a/mnemosyne-ruby.gemspec +++ b/mnemosyne-ruby.gemspec @@ -26,4 +26,5 @@ spec.add_development_dependency 'rake', '~> 10.0' spec.add_development_dependency 'rspec', '~> 3.0' spec.add_development_dependency 'timecop', '~> 0.8.0' + spec.add_development_dependency 'rubocop', '~> 0.47.1' end
Add rubocop as dev dependency
diff --git a/test/integration/web-frontend/serverspec/memcached_spec.rb b/test/integration/web-frontend/serverspec/memcached_spec.rb index abc1234..def5678 100644 --- a/test/integration/web-frontend/serverspec/memcached_spec.rb +++ b/test/integration/web-frontend/serverspec/memcached_spec.rb @@ -0,0 +1,17 @@+require "serverspec" + +# Required by serverspec +set :backend, :exec + +describe package("memcached") do + it { should be_installed } +end + +describe service("memcached") do + it { should be_enabled } + it { should be_running } +end + +describe port(11211) do + it { should be_listening.with("tcp") } +end
Check that memcached is running on the frontends
diff --git a/test/cookbooks/runit_test/recipes/default.rb b/test/cookbooks/runit_test/recipes/default.rb index abc1234..def5678 100644 --- a/test/cookbooks/runit_test/recipes/default.rb +++ b/test/cookbooks/runit_test/recipes/default.rb @@ -17,6 +17,6 @@ # limitations under the License. # -apt_update 'update' if platform_family?('debian') +apt_update 'update' include_recipe 'runit::default'
Remove guard around apt_update in test There's no need to do this in modern Chef releases Signed-off-by: Tim Smith <764ef62106582a09ed09dfa0b6bff7c05fd7d1e4@chef.io>
diff --git a/lib/date_picker/styles/flatpickr.rb b/lib/date_picker/styles/flatpickr.rb index abc1234..def5678 100644 --- a/lib/date_picker/styles/flatpickr.rb +++ b/lib/date_picker/styles/flatpickr.rb @@ -4,22 +4,27 @@ def types [:date, :datetime, :time] end - def mapping() + def mapping :flatpickr end - def template() + def template %{ <input id="<%= input_id %>" name="<%= name %>"/> <script> (function() { var picker = flatpickr && flatpickr('#<%= input_id %>', { - dateFormat: "<%= picker_format %>", + dateFormat: "<%= data_format %>", timeFormat: '\u2063', enableTime: <%= type.to_s != 'date' %>, noCalendar: <%= type.to_s == 'time' %>, utc: <%= type.to_s == 'time' %>, - defaultDate: new Date(<%= time %>) + defaultDate: new Date(<%= time %>), + minDate: <%= min ? 'new Date("' + min.to_s + '")' : 'undefined' %>, + maxDate: <%= max ? 'new Date("' + max.to_s + '")' : 'undefined' %>, + altInput: true, + altFormat: "<%= picker_format %>", + time_24hr: <%= /(?<!\\\\\\\\)H/ === picker_format %> }); if (picker) { //picker.setDate(new Date(<%= time %>));
Fix data_format submit, handle min and max date
diff --git a/lib/omniauth/strategies/inspire9.rb b/lib/omniauth/strategies/inspire9.rb index abc1234..def5678 100644 --- a/lib/omniauth/strategies/inspire9.rb +++ b/lib/omniauth/strategies/inspire9.rb @@ -13,11 +13,11 @@ uid { raw_info['id'] } info do - {email: raw_info['email']} + raw_info['info'] end extra do - {first_name: extra['first_name'], last_name: extra['last_name']} + raw_info['extra'] end private
Return info/extra hashes directly, no need to recompose them.
diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index abc1234..def5678 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -13,3 +13,7 @@ # ActiveSupport::Inflector.inflections do |inflect| # inflect.acronym 'RESTful' # end + +ActiveSupport::Inflector.inflections do |inflect| + inflect.irregular 'taxon', 'taxa' +end
Add pluralization irregularity for taxon -> taxa
diff --git a/lib/rails_admin/config/labelable.rb b/lib/rails_admin/config/labelable.rb index abc1234..def5678 100644 --- a/lib/rails_admin/config/labelable.rb +++ b/lib/rails_admin/config/labelable.rb @@ -5,8 +5,15 @@ # Try to find a user-friendly label for an object, falling back # to its class and ID. def self.object_label(object) - Config.label_methods.each {|l| label = (object.respond_to? l and object.send l) and return label} - "#{object.class.to_s} ##{object.try :id}" + if method = self.object_label_method(object) + object.send method + else + "#{object.class.to_s} ##{object.try :id}" + end + end + + def self.object_label_method(object) + Config.label_methods.find {|method| object.respond_to? method } end def self.included(klass) @@ -14,6 +21,7 @@ abstract_model.model.model_name.human(:default => abstract_model.model.model_name.titleize) end klass.register_instance_option(:object_label) {Labelable.object_label bindings[:object]} + klass.register_instance_option(:object_label_method) {Labelable.object_label_method bindings[:object]} end end end
Include a method to query object_label method names in Labelable
diff --git a/lib/super_settings/rule_registry.rb b/lib/super_settings/rule_registry.rb index abc1234..def5678 100644 --- a/lib/super_settings/rule_registry.rb +++ b/lib/super_settings/rule_registry.rb @@ -1,5 +1,9 @@ module SuperSettings # RuleRegistry contains allows super_settings users to register themselves + # TODO: allow contexts for RuleRegistry + # user_rule = SuperSettings::RuleRegistry.new(:users) + # vehicle_rule = SuperSettings::RuleRegistry.new(:vehicles) + # vehicle_rule.wheel_count != user_rule.wheel_count class RuleRegistry @value_hash = {}
Add todo tag for creating contexts in the rule registry
diff --git a/test/unit/formatters/test_custom.rb b/test/unit/formatters/test_custom.rb index abc1234..def5678 100644 --- a/test/unit/formatters/test_custom.rb +++ b/test/unit/formatters/test_custom.rb @@ -0,0 +1,65 @@+require 'helper' + +module SSHKit + # Try to maintain backwards compatibility with Custom formatters defined by other people + class TestCustom < UnitTest + + def setup + super + SSHKit.config.output_verbosity = Logger::DEBUG + end + + def output + @output ||= String.new + end + + def custom + @custom ||= CustomFormatter.new(output) + end + + { + log: 'LM 1 Test', + fatal: 'LM 4 Test', + error: 'LM 3 Test', + warn: 'LM 2 Test', + info: 'LM 1 Test', + debug: 'LM 0 Test' + }.each do |level, expected_output| + define_method("test_#{level}_logging") do + custom.send(level, 'Test') + assert_log_output expected_output + end + end + + def test_write_logs_commands + custom.write(Command.new(:ls)) + + assert_log_output 'C 1 /usr/bin/env ls' + end + + def test_double_chevron_logs_commands + custom << Command.new(:ls) + + assert_log_output 'C 1 /usr/bin/env ls' + end + + private + + def assert_log_output(expected_output) + assert_equal expected_output, output + end + + end + + class CustomFormatter < SSHKit::Formatter::Abstract + def write(obj) + original_output << case obj + when SSHKit::Command then "C #{obj.verbosity} #{obj}" + when SSHKit::LogMessage then "LM #{obj.verbosity} #{obj}" + end + end + alias :<< :write + + end + +end
Add test for custom formatters Try to expose when changes may break a ‘typical’ custom formatter which has been implemented based on the Pretty formatter
diff --git a/app/models/plag.rb b/app/models/plag.rb index abc1234..def5678 100644 --- a/app/models/plag.rb +++ b/app/models/plag.rb @@ -1,10 +1,11 @@-class Plag +class Plag < ApplicationRecord include Anemon @anemon = Anemon::Scrapper.new def self.scrap(url) - @anemon.scrap(url) + result = @anemon.scrap(url) + Plag.create({url: result[:url], content: result[:content]}) if result end def self.compare(file_name)
Save the scrapped url and its contents to the db
diff --git a/actionmailbox/app/controllers/action_mailbox/base_controller.rb b/actionmailbox/app/controllers/action_mailbox/base_controller.rb index abc1234..def5678 100644 --- a/actionmailbox/app/controllers/action_mailbox/base_controller.rb +++ b/actionmailbox/app/controllers/action_mailbox/base_controller.rb @@ -3,7 +3,7 @@ module ActionMailbox # The base class for all Action Mailbox ingress controllers. class BaseController < ActionController::Base - skip_forgery_protection + skip_forgery_protection if default_protect_from_forgery before_action :ensure_configured
Fix loading `ActionMailbox::BaseController` when CSRF protection is disabled When `default_protect_from_forgery` is false, `verify_authenticity_token` callback does not define and `skip_forgery_protection` raise exception. Fixes #34837.
diff --git a/hephaestus/lib/resque/base.rb b/hephaestus/lib/resque/base.rb index abc1234..def5678 100644 --- a/hephaestus/lib/resque/base.rb +++ b/hephaestus/lib/resque/base.rb @@ -7,6 +7,7 @@ def self.after_perform(*args) logging('end', args) store_status('end', args.first) + update_history(args.first) Resque.enqueue(DocumentProcessBootstrapTask, *args) end @@ -15,6 +16,7 @@ begin document = Document.find(id) document.update_attribute :status, "FAILED" + document.update_attribute :percentage, -1 store_failure(e, args) rescue Mongoid::Errors::DocumentNotFound logging("Document not found. #{id}") @@ -39,4 +41,10 @@ id = args[0] DocumentFailure.create document_id: id, message: e.message, backtrace: e.backtrace.join("\n") end + + def self.update_history(document_id) + document = Document.find(document_id) + document.status_history << @queue + document.save + end end
[aphrodite] Update status history and percentage
diff --git a/object_tracker.gemspec b/object_tracker.gemspec index abc1234..def5678 100644 --- a/object_tracker.gemspec +++ b/object_tracker.gemspec @@ -13,7 +13,7 @@ spec.homepage = 'https://github.com/ridiculous/object_tracker' spec.license = "MIT" - spec.files = `git ls-files -z`.split("\x0") + spec.files = `git ls-files`.split($/).keep_if { |f| f =~ /object_tracker/ and f !~ %r{test/} } spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"]
Reduce files bundled in gem
diff --git a/cookbooks/homebrew/recipes/cask.rb b/cookbooks/homebrew/recipes/cask.rb index abc1234..def5678 100644 --- a/cookbooks/homebrew/recipes/cask.rb +++ b/cookbooks/homebrew/recipes/cask.rb @@ -1,4 +1,5 @@ cask '1password' +cask 'alacritty' cask 'alfred' cask 'appcleaner' cask 'bartender'
Install alacritty with Homebrew Cask
diff --git a/db/migrate/20141120123833_increase_tag_set_name_column_width.rb b/db/migrate/20141120123833_increase_tag_set_name_column_width.rb index abc1234..def5678 100644 --- a/db/migrate/20141120123833_increase_tag_set_name_column_width.rb +++ b/db/migrate/20141120123833_increase_tag_set_name_column_width.rb @@ -1,6 +1,9 @@ class IncreaseTagSetNameColumnWidth < ActiveRecord::Migration + + def up change_table :iseq_flowcell do |t| t.change "tag_set_name", :string, limit: 100, comment:'WTSI-wide tag set name' + end end def down
Fix missing method around migration No idea how this one happened.
diff --git a/db/migrate/20160711003010_add_entity_source_id_to_entity_ids.rb b/db/migrate/20160711003010_add_entity_source_id_to_entity_ids.rb index abc1234..def5678 100644 --- a/db/migrate/20160711003010_add_entity_source_id_to_entity_ids.rb +++ b/db/migrate/20160711003010_add_entity_source_id_to_entity_ids.rb @@ -5,7 +5,7 @@ add_index [:entity_source_id, :sha1], unique: true end - execute <<~SQL + execute <<-SQL.strip_heredoc UPDATE entity_ids ei LEFT OUTER JOIN entity_descriptors ed ON ed.id = ei.entity_descriptor_id
Switch to Ruby 2.2 compatible non-squiggly heredoc
diff --git a/animate-rails.gemspec b/animate-rails.gemspec index abc1234..def5678 100644 --- a/animate-rails.gemspec +++ b/animate-rails.gemspec @@ -14,6 +14,6 @@ s.description = 'animate.css for rails' s.license = 'MIT' - s.files = Dir['{lib,vendor}/**/*'] + ['MIT-LICENSE', 'Rakefile', 'README.md'] + s.files = Dir['{lib,app}/**/*'] + ['MIT-LICENSE', 'Rakefile', 'README.md'] s.add_dependency 'rails' end
Fix included in gem files in gemspec
diff --git a/app/concerns/couriers/fusionable.rb b/app/concerns/couriers/fusionable.rb index abc1234..def5678 100644 --- a/app/concerns/couriers/fusionable.rb +++ b/app/concerns/couriers/fusionable.rb @@ -36,7 +36,7 @@ notify "Adding to Fusion Tables", photo.key table.select("ROWID", "WHERE name='#{photo.key}'").map(&:values).map(&:first).map { |id| table.delete id } table.insert [photo.to_fusion] - sleep 0.6 # 5 queries per second + sleep 1 # 5 queries per second rescue => e notify "Fusion Tables failed", id end
Extend delay in between fusion table queries
diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index abc1234..def5678 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -1,10 +1,13 @@ require_relative '../services/create_game' +require_relative '../services/create_game_state' + class GamesController < ApplicationController def new; end def show @game = Game.find(params[:id]) + @game_state = CreateGameState.new.call(@game) end def index; end
Create a GameState when showing a game
diff --git a/app/controllers/sales_controller.rb b/app/controllers/sales_controller.rb index abc1234..def5678 100644 --- a/app/controllers/sales_controller.rb +++ b/app/controllers/sales_controller.rb @@ -9,7 +9,16 @@ end def create - sale = Sale.create(sale_params.except(:products_ids)) + sale = Sale.new(sale_params.except(:products_ids)) + if sale.valid? + products_ids = sale_params[:products_ids].reject(&:blank?) + Product.where(id: products_ids).each do |product| + product.sale = sale + product.sold! + product.save + end + sale.save + end redirect_to sales_index_path end
Revert "remove logic which should not be in the controller" This reverts commit f7014e403f99a2308d68ea60772176d6093ea2aa.
diff --git a/lib/tasks/deployment/20180913161001_add_path_to_procedures.rake b/lib/tasks/deployment/20180913161001_add_path_to_procedures.rake index abc1234..def5678 100644 --- a/lib/tasks/deployment/20180913161001_add_path_to_procedures.rake +++ b/lib/tasks/deployment/20180913161001_add_path_to_procedures.rake @@ -0,0 +1,20 @@+namespace :after_party do + desc 'Deployment task: add_path_to_procedures' + task add_path_to_procedures: :environment do + puts "Running deploy task 'add_path_to_procedures'" + + Procedure.publiees.where(path: nil).find_each do |procedure| + procedure.path = procedure.path + procedure.save! + end + + Procedure.archivees.where(path: nil).find_each do |procedure| + procedure.path = procedure.path + procedure.save! + end + + # Update task as completed. If you remove the line below, the task will + # run with every deploy (or every time you call after_party:run). + AfterParty::TaskRecord.create version: '20180913161001' + end +end
Add task to fill procedures table path column
diff --git a/app/models/course/video_settings.rb b/app/models/course/video_settings.rb index abc1234..def5678 100644 --- a/app/models/course/video_settings.rb +++ b/app/models/course/video_settings.rb @@ -0,0 +1,40 @@+# frozen_string_literal: true +class Course::VideoSettings + include ActiveModel::Model + include ActiveModel::Conversion + include ActiveModel::Validations + + # Initialises the settings adapter + # + # @param [#settings] settings The settings object provided by the settings_on_rails gem. + def initialize(settings) + @settings = settings + end + + # Returns the title of video component + # + # @return [String] The custom or default title of video component + def title + @settings.title + end + + # Sets the title of video component + # + # @param [String] title The new title + def title=(title) + title = nil unless title.present? + @settings.title = title + end + + # Update settings with the hash attributes + # + # @param [Hash] attributes The hash who stores the new settings + def update(attributes) + attributes.each { |k, v| send("#{k}=", v) } + valid? + end + + def persisted? #:nodoc: + true + end +end
Add settings for video model
diff --git a/app/services/generate_new_puzzle.rb b/app/services/generate_new_puzzle.rb index abc1234..def5678 100644 --- a/app/services/generate_new_puzzle.rb +++ b/app/services/generate_new_puzzle.rb @@ -7,57 +7,40 @@ grid = Grid.new(size: @game.board_size) grid_array = grid.randomly_populate! - create_clues!(grid_array) + + create_clues!(grid: grid_array, orientation: :row) + create_clues!(grid: grid_array.transpose, orientation: :column) print grid.display_string(@game) end private - def create_clues!(grid) - for column in board_range - clue = @game.clues.new(position: column, orientation: :column) + def create_clues!(grid:, orientation:) + grid.each_with_index do |line, index| + clue = @game.clues.new(position: index, orientation: orientation) - run = 0 - values = [] - for row in board_range - if grid[row][column] - run += 1 - elsif run > 0 - values << run - run = 0 - end - end - - if run > 0 - values << run - end - - clue.values = values + clue.values = calculate_values(line) clue.save! end + end - for row in board_range - clue = @game.clues.new(position: row, orientation: :row) + def calculate_values(line) + values = [] - run = 0 - values = [] - for column in board_range - if grid[row][column] - run += 1 - elsif run > 0 - values << run - run = 0 - end + run = 0 + line.each do |tile| + if tile + run += 1 + elsif run > 0 + values << run + run = 0 end + end - if run > 0 - values << run - end + values << run if run > 0 - clue.values = values - clue.save! - end + values end def board_range
Refactor generate new puzzle ruthlessly
diff --git a/app/services/order_cycle_warning.rb b/app/services/order_cycle_warning.rb index abc1234..def5678 100644 --- a/app/services/order_cycle_warning.rb +++ b/app/services/order_cycle_warning.rb @@ -1,3 +1,5 @@+# frozen_string_literal: true + class OrderCycleWarning def initialize(current_user) @current_user = current_user
Add frozen_string_literal comment to new class
diff --git a/app/controllers/api/poi_log_controller.rb b/app/controllers/api/poi_log_controller.rb index abc1234..def5678 100644 --- a/app/controllers/api/poi_log_controller.rb +++ b/app/controllers/api/poi_log_controller.rb @@ -2,6 +2,13 @@ defaults :resource_class => ::PoiLog, :collection_name => 'poi_logs' actions :index + + resource_description do + short 'Changes stream. Log of changed and deleted Pois' + error :code => 401, :desc => "Authorization Required", meta: { message: "Authentication failed or was not provided. Verify that you have sent valid credentials via an api_key parameter. A 'Www-Authenticate' challenge header will be sent with this type of error response." } + formats ['json', 'jsonp', 'xml'] + param :api_key, String, desc: "You personal API key. Sign up for an account at http://wheelmap.org/users/sign_in", required: true + end api :GET, "/nodes/changes", "Get node changes stream" param :since, Date, :required => true, :desc => "Specifies start date"
Add API docs for PoiLogController
diff --git a/app/controllers/json/status_controller.rb b/app/controllers/json/status_controller.rb index abc1234..def5678 100644 --- a/app/controllers/json/status_controller.rb +++ b/app/controllers/json/status_controller.rb @@ -15,8 +15,8 @@ icecast_status_keys.each do |icecast_status_key| icecast_status = Rails.cache.read(icecast_status_key) next unless icecast_status - icecast_sources = icecast_status['icestats']['source'] - icecast_phateio_sources = Array(icecast_sources).select do |source| + icecast_sources = Array.wrap(icecast_status['icestats']['source']) + icecast_phateio_sources = icecast_sources.select do |source| source['listenurl'] =~ %r{/phateio(?:\.\w+)?\z} end listeners = icecast_phateio_sources.map { |source| source['listeners'] }.inject(0, :+)
Fix array wrap issue of status controller
diff --git a/app/controllers/suggestions_controller.rb b/app/controllers/suggestions_controller.rb index abc1234..def5678 100644 --- a/app/controllers/suggestions_controller.rb +++ b/app/controllers/suggestions_controller.rb @@ -1,6 +1,7 @@ class SuggestionsController < ApplicationController def new @suggestion = Suggestion.new + @sigs = Sig.all end def create
Set up new method to get all sigs.
diff --git a/core/app/models/spree/base.rb b/core/app/models/spree/base.rb index abc1234..def5678 100644 --- a/core/app/models/spree/base.rb +++ b/core/app/models/spree/base.rb @@ -23,6 +23,10 @@ if Kaminari.config.page_method_name != :page def self.page(num) + Spree::Deprecation.warn \ + "Redefining Spree::Base.page for a different kaminari page name is better done inside " \ + "your own app. This will be removed from future versions of solidus." + send Kaminari.config.page_method_name, num end end
Remove hacked support for kaminari page name Historically this looks like it is to support kaminari and will_paginate side-by-side, which doesn't seem like a reasonable thing for us to care about inside of core. Anyone that wanted this functionality can use it inside their own app. Also it wasn't tested.
diff --git a/rocket_job_mission_control.gemspec b/rocket_job_mission_control.gemspec index abc1234..def5678 100644 --- a/rocket_job_mission_control.gemspec +++ b/rocket_job_mission_control.gemspec @@ -17,7 +17,7 @@ s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.markdown"] s.test_files = Dir["spec/**/*"] - s.add_dependency "rails", "~> 4.1.9" + s.add_dependency "rails", ">= 4.1.9" s.add_dependency "bootstrap-sass", ">= 3.2.0.1" s.add_dependency "rubyzip" s.add_dependency "rocket_job", ">= 0.3.0"
Allow Rails versions greater than 4.1
diff --git a/app/models/storage_method_update_event.rb b/app/models/storage_method_update_event.rb index abc1234..def5678 100644 --- a/app/models/storage_method_update_event.rb +++ b/app/models/storage_method_update_event.rb @@ -10,7 +10,7 @@ belongs_to :vehicle_storage_method_type # Validations - validates :vehicle_storage_method_type_id, :presence => true + validates :vehicle_storage_method_type, :presence => true #------------------------------------------------------------------------------ # Scopes @@ -55,7 +55,6 @@ # Set resonable defaults for a new condition update event def set_defaults super - self.vehicle_storage_method_type ||= asset.vehicle_storage_method_type self.asset_event_type ||= AssetEventType.find_by_class_name(self.name) end
Fix issue with storage method update event initialization
diff --git a/attributes/default.rb b/attributes/default.rb index abc1234..def5678 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -8,12 +8,12 @@ # All rights reserved - Do Not Redistribute # -default[:owner] = 'jkiehl' # will be node attributes -default[:group] = 'staff' +default[:p4][:owner] = nil +default[:p4][:group] = nil -default[:p4][:port] = 'PerfLAX01:1666' # environment attribute +default[:p4][:port] = nil # environment attribute -default[:p4][:user] = default[:owner] +default[:p4][:user] = default[:p4][:owner] default[:p4][:passwd] = nil default[:p4][:diff] = nil
Move attributes to node and env attributes
diff --git a/app/serializers/event_group_serializer.rb b/app/serializers/event_group_serializer.rb index abc1234..def5678 100644 --- a/app/serializers/event_group_serializer.rb +++ b/app/serializers/event_group_serializer.rb @@ -2,17 +2,11 @@ class EventGroupSerializer < BaseSerializer attributes :id, :name, :organization_id, :concealed, :available_live, :monitor_pacers, :slug, - :multi_lap, :maximum_laps, :combined_split_attributes, :data_entry_groups, :unpaired_data_entry_groups + :multi_lap, :maximum_laps, :data_entry_groups, :unpaired_data_entry_groups link(:self) { api_v1_event_group_path(object) } has_many :events belongs_to :organization - - def combined_split_attributes - CombineEventGroupSplitAttributes.perform(object, - pair_by_location: pair_by_location?, - node_attributes: [:event_split_ids, :sub_split_kind, :label, :split_name, :display_split_name]) - end def data_entry_groups CombineEventGroupSplitAttributes.perform(object,
Remove combinedSplitAttributes key from EventGroupSerializer.
diff --git a/app/workers/asyncapi/server/job_worker.rb b/app/workers/asyncapi/server/job_worker.rb index abc1234..def5678 100644 --- a/app/workers/asyncapi/server/job_worker.rb +++ b/app/workers/asyncapi/server/job_worker.rb @@ -25,7 +25,7 @@ # the ActiveRecord-Sidekiq race condition. In order to # prevent this just retry running JobWorker until it finds # the job by job_id. - if retries < MAX_RETRIES + if retries <= MAX_RETRIES JobWorker.perform_async(job_id, retries+1) end end
Change '<' to '<=' to be accurate about the 'MAX_RETRIES' variable name [#127624879]
diff --git a/app/controllers/api/v1/teachers_controller.rb b/app/controllers/api/v1/teachers_controller.rb index abc1234..def5678 100644 --- a/app/controllers/api/v1/teachers_controller.rb +++ b/app/controllers/api/v1/teachers_controller.rb @@ -2,14 +2,18 @@ respond_to :json def index - respond_with Teacher.all + if(current_teacher) + respond_with Teacher.all + else + respond_with ({error: "You must be logged in"}), status: 401 + end end def show if(current_teacher) - render current_teacher + respond_with teacher else - render {error: "You must be logged in"}, status: 401 + respond_with ({error: "You must be logged in"}), status: 401 end end
Fix teacher api error respose
diff --git a/app/controllers/deploy_it_ident_controller.rb b/app/controllers/deploy_it_ident_controller.rb index abc1234..def5678 100644 --- a/app/controllers/deploy_it_ident_controller.rb +++ b/app/controllers/deploy_it_ident_controller.rb @@ -22,7 +22,7 @@ def index - render text: compute_authorized_keys + render plain: compute_authorized_keys end @@ -31,7 +31,7 @@ def authenticate_request auth_token = params[:auth_token] || '' - return render text: '' if auth_token.empty? || auth_token != Settings.authentication_token + return render plain: '' if auth_token.empty? || auth_token != Settings.authentication_token end
Fix test rendering in controllers
diff --git a/app/controllers/settings/export_controller.rb b/app/controllers/settings/export_controller.rb index abc1234..def5678 100644 --- a/app/controllers/settings/export_controller.rb +++ b/app/controllers/settings/export_controller.rb @@ -4,9 +4,7 @@ before_action :authenticate_user! def index - if current_user.export_processing - flash[:info] = t(".info") - end + flash[:info] = t(".info") if current_user.export_processing end def create
Improve export processing condition on index view
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index abc1234..def5678 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,3 +1,4 @@ class ApplicationController < ActionController::Base # protect_from_forgery with: :exception + include AlexaInterfaceHelper end
Include helper module in the controller