diff
stringlengths
65
26.7k
message
stringlengths
7
9.92k
diff --git a/features/step_definitions/repository_steps.rb b/features/step_definitions/repository_steps.rb index abc1234..def5678 100644 --- a/features/step_definitions/repository_steps.rb +++ b/features/step_definitions/repository_steps.rb @@ -1,3 +1,15 @@+require 'rugged' + +Given(/^a public repository hosted by GitBud$/) do + repository = Rugged::Repository.init_at(File.expand_path('../../../repositories/hello_world.git', __FILE__), :bare) + blob = "puts 'Hello, world!'\n" + oid = repository.write(blob, :blob) + index = Rugged::Index.new + index.add(path: 'hello_world.rb', oid: oid) + tree = index.write_tree(repository) + commit = Rugged::Commit.create(repository, message: 'Initial commit', parents: [], tree: tree, update_ref: 'HEAD') +end + When(/^I enter the (.*) URL of a public repository$/) do |transport| url = case transport
Add step for creating a repository
diff --git a/Casks/sound-control.rb b/Casks/sound-control.rb index abc1234..def5678 100644 --- a/Casks/sound-control.rb +++ b/Casks/sound-control.rb @@ -1,8 +1,9 @@ cask 'sound-control' do - version '2.1.6,4297' - sha256 '33feccad185a1cc53ac5e8e89202484254ca2f737ebf3ea86a988296f93c44a9' + version '2.2.0' + sha256 '6b5c30e51713351679d052f9d315f48b77e04e7e95a01fec1fba53e7424c0c31' - url "https://staticz.com/download/#{version.after_comma}/" + # staticz.net was verified as official when first introduced to the cask + url "http://staticz.net/downloads/SoundControlInstaller_#{version}.dmg" name 'Sound Control' homepage 'https://staticz.com/soundcontrol/'
Update Sound Control to 2.2.0
diff --git a/app/serializers/page_serializer.rb b/app/serializers/page_serializer.rb index abc1234..def5678 100644 --- a/app/serializers/page_serializer.rb +++ b/app/serializers/page_serializer.rb @@ -5,5 +5,5 @@ :meta_description, :meta_title, :category_names, :layout_identifier - has_many :blocks, serliazer: BlockSerializer + has_many :blocks, serializer: BlockSerializer end
Fix typo in serializer option on page serializer
diff --git a/rack-protection/lib/rack/protection/authenticity_token.rb b/rack-protection/lib/rack/protection/authenticity_token.rb index abc1234..def5678 100644 --- a/rack-protection/lib/rack/protection/authenticity_token.rb +++ b/rack-protection/lib/rack/protection/authenticity_token.rb @@ -17,14 +17,17 @@ # authenticity_param: Defines the param's name that should contain the token on a request. # class AuthenticityToken < Base - default_options :authenticity_param => 'authenticity_token' + default_options :authenticity_param => 'authenticity_token', + :allow_if => nil def accepts?(env) session = session env token = session[:csrf] ||= session['_csrf_token'] || random_string + safe?(env) || env['HTTP_X_CSRF_TOKEN'] == token || - Request.new(env).params[options[:authenticity_param]] == token + Request.new(env).params[options[:authenticity_param]] == token || + ( options[:allow_if] && options[:allow_if].call(env) ) end end end
Add allow_if to authenticity token
diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index abc1234..def5678 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -0,0 +1,58 @@+class CommentsController < ApplicationController + before_action :set_comment, only: [:show, :edit, :update, :destroy] + + # do we need this? + # def index + # @comments = Comment.all + # end + + def show + end + + def new + @comment = Comment.new + end + + def edit + end + + def create + @comment = Comment.new(comment_params) + + respond_to do |format| + if @comment.save + format.html { redirect_to @comment, notice: 'Comment was successfully created.' } + else + format.html { render :new } + end + end + end + + def update + respond_to do |format| + if @comment.update(comment_params) + format.html { redirect_to @comment, notice: 'Comment was successfully updated.' } + else + format.html { render :edit } + end + end + end + + def destroy + @comment.destroy + respond_to do |format| + format.html { redirect_to comments_url, notice: 'Comment was successfully destroyed.' } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_comment + @comment = Comment.find(params[:id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def comment_params + params.require(:comment).permit(:author, :content, :pin_id) + end +end
Create comments controller with some notes
diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index abc1234..def5678 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -6,12 +6,7 @@ def index @exercises = Exercise.all - success_response = { - logged: true, - } - - # render json: @exercises - render json: success_response + render json: @exercises end def show
Fix bug in exercise controller
diff --git a/spec/container_spec.rb b/spec/container_spec.rb index abc1234..def5678 100644 --- a/spec/container_spec.rb +++ b/spec/container_spec.rb @@ -20,10 +20,35 @@ expect(chef_run).to run_docker_container('drone') end - it 'sets drone container hosts' do - drone_container_resource = chef_run.docker_container 'drone' - expect(drone_container_resource.env).to include('DOCKER_HOST_1=unix:///var/run/docker.sock') - expect(drone_container_resource.env).to include('DOCKER_HOST_2=unix:///var/run/docker.sock') + describe 'drone container environment' do + let(:drone_env) do + chef_run.docker_container('drone').env + end + + it 'does not set database driver' do + expect(drone_env).to include('DATABASE_DRIVER=sqlite3') + end + + it 'does not set database config' do + expect(drone_env).to include('DATABASE_CONFIG=/var/lib/drone/drone.sqlite') + end + + it 'sets remote driver' do + expect(drone_env).to include('REMOTE_DRIVER=github') + end + + it 'sets remote config' do + expect(drone_env).to include('REMOTE_CONFIG=https://github.com?client_id=${CLIENT}&client_secret=${SECRET}') + end + + it 'sets drone docker hosts' do + expect(drone_env).to include('DOCKER_HOST_1=unix:///var/run/docker.sock') + expect(drone_env).to include('DOCKER_HOST_2=unix:///var/run/docker.sock') + end + + it 'sets PLUGIN_FILTER' do + expect(drone_env).to include('PLUGIN_FILTER=plugins/*') + end end end end
Add ENV values we expect in drone container
diff --git a/app/controllers/services_controller.rb b/app/controllers/services_controller.rb index abc1234..def5678 100644 --- a/app/controllers/services_controller.rb +++ b/app/controllers/services_controller.rb @@ -1,4 +1,5 @@ class ServicesController < ApplicationController + before_action :authenticate_user!, only [:new, :create, :edit, :update] before_action :set_service, only: [:show, :edit, :update] def index @@ -6,10 +7,12 @@ end def new + # TODO: check if user is an admin @service = Service.new end def create + # TODO: check if user is an admin @service = Service.new(service_params) if @service.save redirect_to @service, notice: 'Your new service has been created.' @@ -19,14 +22,14 @@ end def show - # @service = Service.find(params[:id]) end def edit - # @service = Service.find(params[:id]) + # TODO: check if user is an admin end def update + # TODO: check if user is an admin if @service.save redirect_to @service, notice: 'Your new service has been created.' else
Add authentication check to services
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index abc1234..def5678 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -35,7 +35,7 @@ cookies[:cookies_policy] = cookies_policy.merge(usage: true).to_json end - redirect_if_not_test(callback[:redirect_path] || Plek.find("account-manager")) + redirect_if_not_test(callback[:redirect_path] || default_redirect_path) end def delete @@ -52,4 +52,8 @@ redirect_to url end end + + def default_redirect_path + Plek.find("account-manager") + end end
Fix default redirect if already logged in
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index abc1234..def5678 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -7,12 +7,22 @@ user = Session.login_by_username_or_email(params[:user_input]) if user && user.authenticate(params[:password]) - session[:user_id] = user.id - flash[:success] = "Welcome, #{user.username}!" - redirect_to root_path + respond_to do |format| + format.json { render json: 'logged in ok', status: 200} + format.html { + session[:user_id] = user.id + flash[:success] = "Welcome, #{user.username}!" + redirect_to root_path + } + end else - flash[:failure] = "Login failed." - render :login + respond_to do |format| + format.json { render json: 'login failed', status: 400} + format.html { + flash[:failure] = "Login failed." + render :login + } + end end end
Add API handling to session login
diff --git a/config/initializers/bootstrap_errors.rb b/config/initializers/bootstrap_errors.rb index abc1234..def5678 100644 --- a/config/initializers/bootstrap_errors.rb +++ b/config/initializers/bootstrap_errors.rb @@ -0,0 +1,27 @@+# From: https://gist.github.com/bogdanconstantinescu/2645498 + +ActionView::Base.field_error_proc = Proc.new do |html_tag, instance| + html = %(<div class="field_with_errors">#{html_tag}</div>).html_safe + # add nokogiri gem to Gemfile + + form_fields = [ + 'textarea', + 'input', + 'select' + ] + + elements = Nokogiri::HTML::DocumentFragment.parse(html_tag).css "label, " + form_fields.join(', ') + + elements.each do |e| + if e.node_name.eql? 'label' + html = %(<div class="control-group error">#{e}</div>).html_safe + elsif form_fields.include? e.node_name + if instance.error_message.kind_of?(Array) + html = %(<div class="control-group error">#{html_tag}<span class="help-inline">&nbsp;#{instance.error_message.join(',')}</span></div>).html_safe + else + html = %(<div class="control-group error">#{html_tag}<span class="help-inline">&nbsp;#{instance.error_message}</span></div>).html_safe + end + end + end + html +end
Add gist to render bootstrap-style errors on forms
diff --git a/test/test_fuzzy_io.rb b/test/test_fuzzy_io.rb index abc1234..def5678 100644 --- a/test/test_fuzzy_io.rb +++ b/test/test_fuzzy_io.rb @@ -3,8 +3,8 @@ require 'fuzzy_io' require 'fuzzy_io/version' -API_KEY = "AAAABBBBB" -AGENT_ID = "CCCCDDDD" +API_KEY = ENV["FUZZY_IO_API_KEY"] +AGENT_ID = ENV["FUZZY_IO_AGENT_ID"] class TestFuzzyIo < MiniTest::Unit::TestCase
Use API key from ENV
diff --git a/cookbooks/wt_haproxy/recipes/default.rb b/cookbooks/wt_haproxy/recipes/default.rb index abc1234..def5678 100644 --- a/cookbooks/wt_haproxy/recipes/default.rb +++ b/cookbooks/wt_haproxy/recipes/default.rb @@ -19,8 +19,8 @@ include_recipe "haproxy::install_#{node['haproxy']['install_method']}" -cookbook_file "/etc/default/haproxy" do - source "haproxy-default" +cookbook_file "/etc/default/wt_haproxy" do + source "wt_haproxy-default" owner "root" group "root" mode 00644
Use wt_haproxy as cookbook name instead of haproxy Former-commit-id: 88afa05ed72046d35b251a7a14887b91b8790235 [formerly 4d5596a4cbe4bb5af10cb24205a9b2d0d9b3c07c] [formerly bc7f30c4c916a3d7b31498cb0e9505dbd37e12c1 [formerly 2f80096a9841f987de90caf9331fb92419edde55]] Former-commit-id: 380e269a00f59955c50acfe6b3cadf6df7d954a1 [formerly 9400df5cf61d5b6323c5d3b3805f912da31a06a2] Former-commit-id: ef2b90c1a0f8ffeb0b81fe1cf9fcff361c7d5fd9
diff --git a/split-export.gemspec b/split-export.gemspec index abc1234..def5678 100644 --- a/split-export.gemspec +++ b/split-export.gemspec @@ -8,7 +8,6 @@ s.authors = ["Andrew Nesbitt"] s.email = ["andrewnez@gmail.com"] s.homepage = "https://github.com/splitrb/split-export" - s.bug_tracker_uri = "https://github.com/splitrb/split-export/issues" s.summary = "Split extension to export your data" s.license = 'MIT'
Remove bug tracker from gemspec
diff --git a/app/controllers/alumni_controller.rb b/app/controllers/alumni_controller.rb index abc1234..def5678 100644 --- a/app/controllers/alumni_controller.rb +++ b/app/controllers/alumni_controller.rb @@ -13,7 +13,7 @@ if @tie = TieAlumniWithStudentMember.find_by_Alumni_id(@thisID) @assignedtoid = @tie.StudentMember_id - if @assignedtoid == current_student_member.id + if student_member_signed_in? && @assignedtoid == current_student_member.id @editingAllowed = true end else
Fix bug in the rendering of the student profile Signed-off-by: Siddharth Kannan <805f056820c7a1cecc4ab591b8a0a604b501a0b7@gmail.com>
diff --git a/lib/antir/engine/hypervisor/domain_handler.rb b/lib/antir/engine/hypervisor/domain_handler.rb index abc1234..def5678 100644 --- a/lib/antir/engine/hypervisor/domain_handler.rb +++ b/lib/antir/engine/hypervisor/domain_handler.rb @@ -26,10 +26,12 @@ end def find(id) + id = id.to_i @@connection.domains.select{|d| d.id == id}[0].xml end def destroy(id) + id = id.to_i dom = @@connection.domains.select{|d| d.id == id}[0] puts dom.inspect dom.stop
Fix bug on destroying VPS
diff --git a/lib/calyx/production/weighted_choices.rb b/lib/calyx/production/weighted_choices.rb index abc1234..def5678 100644 --- a/lib/calyx/production/weighted_choices.rb +++ b/lib/calyx/production/weighted_choices.rb @@ -1,6 +1,11 @@ module Calyx module Production class WeightedChoices + # Parse a given list or hash of productions into a syntax tree of weighted + # choices. + # + # @param productions [Array<Array>, Hash<#to_s, Float>] + # @param registry [Calyx::Registry] def self.parse(productions, registry) weights_sum = productions.reduce(0) do |memo, choice| memo += choice.last @@ -19,10 +24,20 @@ self.new(choices) end + # Initialize a new choice with a list of child nodes. + # + # @param collection [Array] def initialize(collection) @collection = collection end + # Evaluate the choice by randomly picking one of its possible options, + # balanced according to the given weights. + # + # The method for selecting weighted probabilities is based on a snippet + # of code recommended in the Ruby standard library documentation. + # + # @return [Array] def evaluate choice = @collection.max_by do |_, weight| rand ** (1.0 / weight)
Add method comments to `Production::WeightedChoices`
diff --git a/lib/devise_cas_authenticatable/routes.rb b/lib/devise_cas_authenticatable/routes.rb index abc1234..def5678 100644 --- a/lib/devise_cas_authenticatable/routes.rb +++ b/lib/devise_cas_authenticatable/routes.rb @@ -8,11 +8,9 @@ # service endpoint for CAS server get mapping.fullpath, :to => "#{controllers[:cas_sessions]}#service" - scope mapping.fullpath do - get mapping.path_names[:sign_in], :to => "#{controllers[:cas_sessions]}#create", :as => :"new_#{mapping.name}_session" - post mapping.path_names[:sign_in], :to => "#{controllers[:cas_sessions]}#create", :as => :"#{mapping.name}_session" - get mapping.path_names[:sign_out], :to => "#{controllers[:cas_sessions]}#destroy", :as => :"destroy_#{mapping.name}_session" - end + get mapping.path_names[:sign_in], :to => "#{controllers[:cas_sessions]}#create", :as => :"new_#{mapping.name}_session" + post mapping.path_names[:sign_in], :to => "#{controllers[:cas_sessions]}#create", :as => :"#{mapping.name}_session" + get mapping.path_names[:sign_out], :to => "#{controllers[:cas_sessions]}#destroy", :as => :"destroy_#{mapping.name}_session" end end end
Update to Devise 1.1 stable route generation
diff --git a/app/models/renalware/address.rb b/app/models/renalware/address.rb index abc1234..def5678 100644 --- a/app/models/renalware/address.rb +++ b/app/models/renalware/address.rb @@ -17,7 +17,7 @@ def to_s(*fields) if fields.any? - fields.map { |f| send(f) }.compact.join(', ') + fields.map { |f| send(f) }.reject(&:blank?).join(', ') else orig_to_s end
Remove empty strings as well
diff --git a/lib/migrate.rb b/lib/migrate.rb index abc1234..def5678 100644 --- a/lib/migrate.rb +++ b/lib/migrate.rb @@ -2,6 +2,17 @@ # the pods table, but be independent of each other, we can # run all trunk migrations first, then all others. # + +# Helper method +# +def foreign_key_delete_cascade source_table, target_table, foreign_key + <<-SQL + ALTER TABLE #{source_table} DROP CONSTRAINT #{source_table}_#{foreign_key}_fkey; + ALTER TABLE #{source_table} ADD FOREIGN KEY (#{foreign_key}) + REFERENCES #{target_table} (id) + ON DELETE CASCADE; + SQL +end # NOTE Set the versions to the ones you want to migrate to. # @@ -12,7 +23,7 @@ DB, File.join(ROOT, 'migrations/trunk'), table: 'schema_info', - version: 12 + version: 13 ) # Metrics migrations. @@ -25,7 +36,7 @@ # This enables us to have separate migrations # for each app. table: 'schema_info_metrics', - version: 3 + version: 4 ) Sequel::Migrator.run( @@ -34,7 +45,7 @@ # This enables us to have separate migrations # for each app. table: 'schema_info_cocoadocs', - version: 2 + version: 3 )
Add helper method for replacing the old foreign_keys with cascading deletes.
diff --git a/attributes/package_repo.rb b/attributes/package_repo.rb index abc1234..def5678 100644 --- a/attributes/package_repo.rb +++ b/attributes/package_repo.rb @@ -11,7 +11,7 @@ "default" => node["platform_version"].to_i ) -default["percona"]["apt"]["key"] = "0x1C4CBDCDCD2EFD2A" +default["percona"]["apt"]["key"] = "0x9334A25F8507EFA5" default["percona"]["apt"]["keyserver"] = "hkp://keys.gnupg.net:80" default["percona"]["apt"]["uri"] = "http://repo.percona.com/apt"
Update the Signing Key for Percona Debian and Ubuntu Packages See: https://www.percona.com/blog/2016/10/13/new-signing-key-for-percona-debian-and-ubuntu-packages/
diff --git a/subversion/bindings/swig/ruby/test/run-test.rb b/subversion/bindings/swig/ruby/test/run-test.rb index abc1234..def5678 100644 --- a/subversion/bindings/swig/ruby/test/run-test.rb +++ b/subversion/bindings/swig/ruby/test/run-test.rb @@ -13,4 +13,8 @@ $LOAD_PATH.unshift(ext_dir) $LOAD_PATH.unshift(Dir.pwd) -exit Test::Unit::AutoRunner.run(false, File.dirname($0)) +if Test::Unit::AutoRunner.respond_to?(:standalone?) + exit Test::Unit::AutoRunner.run($0, File.dirname($0)) +else + exit Test::Unit::AutoRunner.run(false, File.dirname($0)) +end
Support Test::Unit distributed in ruby 1.8.3. * subversion/bindings/swig/ruby/test/run-test.rb: Pass $0 instead of false as the first argument of Test::Unit::AutoRunner.run when using Test::Unit is the one that distributed in ruby 1.8.3. git-svn-id: f8a4e5e023278da1e04e203c7fe051e3c4285d88@855141 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/tasks/check-for-new-rootfs-cves/run.rb b/tasks/check-for-new-rootfs-cves/run.rb index abc1234..def5678 100644 --- a/tasks/check-for-new-rootfs-cves/run.rb +++ b/tasks/check-for-new-rootfs-cves/run.rb @@ -6,7 +6,7 @@ buildpacks_ci_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', '..')) stacks_dir = File.expand_path(File.join(buildpacks_ci_dir, '..', stack.gsub(/m$/, ''))) if stack == 'tiny' - stacks_dir = File.expand_path(File.join(buildpacks_ci_dir, '..', 'tiny', 'tiny', 'base', 'run')) + stacks_dir = File.expand_path(File.join(buildpacks_ci_dir, '..', 'tiny', 'tiny', 'dockerfile', 'run')) end cves_dir = File.expand_path(File.join(buildpacks_ci_dir, '..', 'output-new-cves', 'new-cve-notifications'))
Fix directory for tiny stack [#168707057]
diff --git a/lib/active_esp/rfc822.rb b/lib/active_esp/rfc822.rb index abc1234..def5678 100644 --- a/lib/active_esp/rfc822.rb +++ b/lib/active_esp/rfc822.rb @@ -0,0 +1,36 @@+# encoding: binary +# +# RFC822 Email Address Regex +# -------------------------- +# +# Originally written by Cal Henderson +# c.f. http://iamcal.com/publish/articles/php/parsing_email/ +# +# Translated to Ruby by Tim Fletcher, with changes suggested by Dan Kubb. +# +# Licensed under a Creative Commons Attribution-ShareAlike 2.5 License +# http://creativecommons.org/licenses/by-sa/2.5/ +# +# Source: http://tfletcher.com/lib/rfc822.rb +# RFC822: http://www.w3.org/Protocols/rfc822/#z8 + +module ActiveESP + module RFC822 + EmailAddress = begin + qtext = '[^\\x0d\\x22\\x5c\\x80-\\xff]' + dtext = '[^\\x0d\\x5b-\\x5d\\x80-\\xff]' + atom = '[^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-' + + '\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+' + quoted_pair = '\\x5c[\\x00-\\x7f]' + domain_literal = "\\x5b(?:#{dtext}|#{quoted_pair})*\\x5d" + quoted_string = "\\x22(?:#{qtext}|#{quoted_pair})*\\x22" + domain_ref = atom + sub_domain = "(?:#{domain_ref}|#{domain_literal})" + word = "(?:#{atom}|#{quoted_string})" + domain = "#{sub_domain}(?:\\x2e#{sub_domain})*" + local_part = "#{word}(?:\\x2e#{word})*" + addr_spec = "#{local_part}\\x40#{domain}" + pattern = /\A#{addr_spec}\z/ + end + end +end
Add RFC822 specification for validating an email address.
diff --git a/lib/gds_api/publisher.rb b/lib/gds_api/publisher.rb index abc1234..def5678 100644 --- a/lib/gds_api/publisher.rb +++ b/lib/gds_api/publisher.rb @@ -26,7 +26,7 @@ end def licences_for_ids(ids) - response = get_json("#{@endpoint}/licences.json?ids=#{ids.join(',')}") + response = get_json("#{@endpoint}/licences.json?ids=#{ids.map(&:to_s).sort.join(',')}") response.to_ostruct end
Sort id's in licence query for cache efficiency.
diff --git a/lib/hooks/kibela/hook.rb b/lib/hooks/kibela/hook.rb index abc1234..def5678 100644 --- a/lib/hooks/kibela/hook.rb +++ b/lib/hooks/kibela/hook.rb @@ -4,10 +4,14 @@ icon_url hook_image_url('icon.png') template_name { "#{action}.html.haml" } before_render do - skip_processing! if payload.action == "update" && !payload.notify + skip_processing! if skip? end private + + def skip? + payload.action == "update" && (action == "comment" || !payload.notify) + end def action payload.action
Fix skip check at comment update for kibela
diff --git a/test/integration/test_toy_robot.rb b/test/integration/test_toy_robot.rb index abc1234..def5678 100644 --- a/test/integration/test_toy_robot.rb +++ b/test/integration/test_toy_robot.rb @@ -3,7 +3,7 @@ module ToyRobot class ToyRobotTest < MiniTest::Unit::TestCase def test_that_it_is_executable - assert `bin/toyrobot < data/example_input_a.txt` + assert system('[ -x bin/toyrobots ]') end end end
Fix executable assertion in ToyRobotTest
diff --git a/app/controllers/spree/checkout_controller_decorator.rb b/app/controllers/spree/checkout_controller_decorator.rb index abc1234..def5678 100644 --- a/app/controllers/spree/checkout_controller_decorator.rb +++ b/app/controllers/spree/checkout_controller_decorator.rb @@ -3,7 +3,8 @@ super.push(permitted_komoju_konbini_attributes) super.push(permitted_komoju_banktransfer_attributes) super.push(permitted_komoju_pay_easy_attributes) - super.flatten.uniq + super.push(permitted_komoju_web_money_attributes) + super.flatten end private @@ -19,5 +20,8 @@ def permitted_komoju_pay_easy_attributes [:email, :phone, :family_name, :given_name, :family_name_kana, :given_name_kana] end + + def permitted_komoju_web_money_attributes + [:email, :prepaid_number] + end end -
Add permitted attributes for webmoney
diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index abc1234..def5678 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -2,6 +2,8 @@ # Version of your assets, change this if you want to expire all your assets. Rails.application.config.assets.version = '1.0' + +Rails.application.config.assets.initialize_on_precompile = false # Precompile additional assets. # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
Disable connecting to a database on precompile
diff --git a/lib/jmespath/nodes/or.rb b/lib/jmespath/nodes/or.rb index abc1234..def5678 100644 --- a/lib/jmespath/nodes/or.rb +++ b/lib/jmespath/nodes/or.rb @@ -9,7 +9,7 @@ def visit(value) result = @left.visit(value) - if result == false || result.nil? || result.empty? + if result == false || result.nil? || (result.respond_to?(:empty?) && result.empty?) @right.visit(value) else result
Fix OR expressions where the left side is true TrueClass does not respond to `#empty?`, which makes `foo || bar` where foo resolves to true fail.
diff --git a/lib/curator/railtie.rb b/lib/curator/railtie.rb index abc1234..def5678 100644 --- a/lib/curator/railtie.rb +++ b/lib/curator/railtie.rb @@ -5,7 +5,7 @@ config.bucket_prefix = app.class.name.split("::").first.underscore config.environment = Rails.env config.migrations_path = Rails.root.join('db', 'migrate') - config.riak_config_file = Rails.root.join('config', 'riak_with_protobuf.yml') + config.riak_config_file = Rails.root.join('config', 'riak.yml') end end
Revert breaking change that renames default config file name
diff --git a/lib/god/diagnostics.rb b/lib/god/diagnostics.rb index abc1234..def5678 100644 --- a/lib/god/diagnostics.rb +++ b/lib/god/diagnostics.rb @@ -12,26 +12,26 @@ class BleakHouseDiagnostic LOG_FILE = File.join(File.dirname(__FILE__), *%w[.. .. logs bleak.log]) - class << self - attr_accessor :logger + def self.install + require 'snapshot' + self.spin end - def self.install - require 'bleak_house' - self.logger = BleakHouse::Logger.new - File.delete(LOG_FILE) rescue nil + def self.snapshot + @count ||= 0 + filename = "/tmp/god-bleak-%s-%03i.dump" % [Process.pid,@count] + STDERR.puts "** BleakHouse: working..." + BleakHouse.ext_snapshot(filename, 3) + STDERR.puts "** BleakHouse: complete\n** Bleakhouse: Run 'bleak #{filename}' to analyze." + @count += 1 end - def self.snapshot(name) - self.logger.snapshot(LOG_FILE, name, false) if self.logger - end - - def self.spin(delay = 1) + def self.spin(delay = 60) Thread.new do loop do + sleep(delay) self.snapshot - sleep(delay) end end end -end+end
Update to work with latest bleak-house.
diff --git a/lib/mnemosyne/railtie.rb b/lib/mnemosyne/railtie.rb index abc1234..def5678 100644 --- a/lib/mnemosyne/railtie.rb +++ b/lib/mnemosyne/railtie.rb @@ -8,8 +8,10 @@ config['application'] ||= app.class.name.underscore.titleize - config['logger'] ||= Rails.logger - config['enabled'] ||= config.key?('server') + config['logger'] ||= Rails.logger + + # If a server URL is configured, we assume that Mnemosyne should be enabled + config['enabled'] = config.key?('server') unless config.key?('enabled') config = ::Mnemosyne::Config.new(config)
Fix falsy "enabled" flag being ignored Because of using the `||=` operator, falsy values for `enabled` were being ignored and overwritten when the `server` flag existed. For mnemosyne.yml files like the following: common: &common server: amqp://localhost development: <<: *common enabled: false ...this meant that the `enabled: false` was being ignored for the development environment.
diff --git a/spec/dummy/config/initializers/i18n.rb b/spec/dummy/config/initializers/i18n.rb index abc1234..def5678 100644 --- a/spec/dummy/config/initializers/i18n.rb +++ b/spec/dummy/config/initializers/i18n.rb @@ -1 +1,10 @@ I18n.enforce_available_locales = true + +# raise exceptions when there is an incorrect or missing i18n key +# in development and test +module I18n + def self.just_raise_that_exception(*args) + raise "i18n #{args.first}" + end +end +I18n.exception_handler = :just_raise_that_exception
Raise exceptions in dev/test if incorrect or missing translation keys are encountered
diff --git a/spec/fixtures/plugins/request_times.rb b/spec/fixtures/plugins/request_times.rb index abc1234..def5678 100644 --- a/spec/fixtures/plugins/request_times.rb +++ b/spec/fixtures/plugins/request_times.rb @@ -0,0 +1,11 @@+Nark::Plugin.define :request_times do |plugin| + plugin.variables :last_request_time => nil + + plugin.add_hook :before_call do |env| + @start_time = Time.now + end + + plugin.add_hook :after_call do |env| + plugin.last_request_time = (Time.now - @start_time) + end +end
Add a plugin fixture for testing
diff --git a/spec/support/shared/shopify_request.rb b/spec/support/shared/shopify_request.rb index abc1234..def5678 100644 --- a/spec/support/shared/shopify_request.rb +++ b/spec/support/shared/shopify_request.rb @@ -4,11 +4,8 @@ before :each do ActiveResource::Base.format = :json ShopifyAPI.constants.each do |const| - begin - const = "ShopifyAPI::#{const}".constantize - const.format = :json if const.respond_to?(:format=) - rescue NameError - end + const = "ShopifyAPI::#{const}".constantize + const.format = :json if const.respond_to?(:format=) end ShopifyAPI::Base.clear_session
Remove Useless Rescue In Shared Context These style of rescues are relatively useless and they make Rubocop a very unhappy customer. Cleaned up for code cleanliness and to make all the Cops happy.
diff --git a/lib/minimal_logging.rb b/lib/minimal_logging.rb index abc1234..def5678 100644 --- a/lib/minimal_logging.rb +++ b/lib/minimal_logging.rb @@ -39,13 +39,9 @@ end def make_color_codes - color_hash = {} - color_hash[1] = color_hash[2] = :green - color_hash[3] = :yellow - color_hash[4] = :red - color_hash[5] = :light_red - - color_hash + status_codes = [1, 2, 3, 4, 5] + colors = [:light_green, :green, :yellow, :red, :light_red] + Hash[status_codes.zip(colors)] end end
Refactor color code hash creation.
diff --git a/lib/pry-vterm_aliases.rb b/lib/pry-vterm_aliases.rb index abc1234..def5678 100644 --- a/lib/pry-vterm_aliases.rb +++ b/lib/pry-vterm_aliases.rb @@ -8,8 +8,8 @@ def create_aliases aliases.each { |k, v| ::Pry::Commands.create_command(/^\.(#{k})(.*)/) { - description "Alias for: #{v}." - group "Terminal Aliases" + description "AKA: .#{Pry::Helpers::Text.bold(k)} - an alias for: #{Pry::Helpers::Text.bold(v)}." + group "Terminal Aliases [pry-vterm_aliases] (#{Pry::VTermAliases::VERSION})" def process(cmd, extra) ::Pry::VTermAliases.run_command(cmd, extra, output)
Make the help output prettier; highlight the cmd.
diff --git a/app/controllers/crowdblog_core/posts_controller.rb b/app/controllers/crowdblog_core/posts_controller.rb index abc1234..def5678 100644 --- a/app/controllers/crowdblog_core/posts_controller.rb +++ b/app/controllers/crowdblog_core/posts_controller.rb @@ -16,7 +16,7 @@ @post.author = current_user @post.regenerate_permalink @post.save - respond_with [:admin, @post] + respond_with @post end def destroy
Fix redirection after creating the Post
diff --git a/lib/plugins/kpoppin.rb b/lib/plugins/kpoppin.rb index abc1234..def5678 100644 --- a/lib/plugins/kpoppin.rb +++ b/lib/plugins/kpoppin.rb @@ -10,15 +10,14 @@ match /(help kpoppin)$/, method: :help def execute(m) - page = Nokogiri::HTML(open('http://www.arirang.co.kr/Radio/Radio_MessageBoard.asp?PROG_CODE=RADR0143&MENU_CODE=101862&code=Be6')) - text = page.css('tr.ntce td.subjt')[2].text + page = Nokogiri::HTML(open("http://www.arirang.com/Radio/Radio_Announce.asp?PROG_CODE=RADR0143&MENU_CODE=101536&code=Be4")) lineup = [] - page.css('tr.ntce td.subjt').each do |subject| - lineup << subject.text if subject.text[0] == '0' - lineup << subject.text if subject.text[0].to_i > 0 + page.css('table.annlistTbl').first.css('td').each do |td| + next unless td.text.include? '(' + lineup << td.text end - lineup = ['No guests have been announced'] if lineup.size == 0 - m.reply "[#{lineup.reverse.join('], [')}] 12:00 ~ 14:00KST" + air_time = page.css('div.airtime p').first.text + 'KST' + m.reply "[#{lineup.join('], [')}] #{air_time}" end def help(m)
Update Kpoppin plugin (new source url)
diff --git a/immortal.gemspec b/immortal.gemspec index abc1234..def5678 100644 --- a/immortal.gemspec +++ b/immortal.gemspec @@ -3,8 +3,11 @@ Gem::Specification.new do |s| s.name = 'immortal' - s.version = '1.0.5' - s.authors = ['Jordi Romero', 'Saimon Moore'] + s.version = '2.0.0' + s.authors = [ + 'Jordi Romero', 'Saimon Moore', 'Pau Ramon', 'Carlos Saura', 'Andres Bravo', + 'Fran Casas', 'Pau Perez' + ] s.email = ['jordi@jrom.net', 'saimon@saimonmoore.net'] s.homepage = 'http://github.com/teambox/immortal' s.summary = 'Replacement for acts_as_paranoid for Rails 4'
Prepare 2.0.0 release with Rails 4 support
diff --git a/lib/tasks/base_path.rake b/lib/tasks/base_path.rake index abc1234..def5678 100644 --- a/lib/tasks/base_path.rake +++ b/lib/tasks/base_path.rake @@ -1,24 +1,13 @@ namespace :base_path do desc "Edits the base_path of a document, given its content_id and the new base_path" - task :edit, [:content_id, :base_path] => [:environment] do |_t, args| - content_id = args[:content_id] - base_path = args[:base_path] + task :edit, %i[content_id new_base_path] => %i[environment] do |_t, args| + document = Document.find(args[:content_id]) + old_base_path = document.base_path - begin - document = Document.find(content_id) - rescue DocumentFinder::RecordNotFound => e - puts "Error finding the document: #{e.inspect}" - end + document.base_path = args[:new_base_path] + document.update_type = 'minor' + document.save! - if document - document.base_path = base_path - document.update_type = 'minor' - if document.save - puts "The #{document.class} with title \"#{document.title}\" has been successfully edited" - puts "Its new base_path is now \"#{document.base_path}\"" - else - puts "Couldn't edit the #{document.class} with title \"#{document.title}\"" - end - end + puts "#{old_base_path} -> #{document.base_path}" end end
Remove rescue and let it fail Letting it fail, we get a useful stack trace that will point us to the right direction.
diff --git a/lib/tasks/metric_fu.rake b/lib/tasks/metric_fu.rake index abc1234..def5678 100644 --- a/lib/tasks/metric_fu.rake +++ b/lib/tasks/metric_fu.rake @@ -2,6 +2,7 @@ require 'metric_fu' MetricFu::Configuration.run do |config| config.rcov[:test_files] = 'spec/**/*_spec.rb' + config.rcov[:rcov_opts] << '-Ispec' end rescue LoadError end
Include spec/ when calling rcov. This is needed because spec_helper is required without the full path now.
diff --git a/lib/saves/game_list.rb b/lib/saves/game_list.rb index abc1234..def5678 100644 --- a/lib/saves/game_list.rb +++ b/lib/saves/game_list.rb @@ -0,0 +1,37 @@+module Saves + class GameList + include Enumerable + + attr_reader :games + attr_reader :games_data + + def initialize(games_data = []) + @games_data = games_data + end + + def to_s + game_names.join(', ') + end + + def inspect + names = game_names.map { |game_name| %{"#{game_name}"} } + "GameList(#{names.join(', ')})" + end + + def games + @games ||= @games_data.map do |game_data| + Game.new(game_data).parse + end + end + + alias :parse :games + + def game_names + games.map { |game| game.name } + end + + def self.empty + new + end + end +end
Add a Game List model for parsing the config file
diff --git a/helpers/graphite.rb b/helpers/graphite.rb index abc1234..def5678 100644 --- a/helpers/graphite.rb +++ b/helpers/graphite.rb @@ -3,7 +3,7 @@ require 'socket' def graphite_plot(logString) if Deployinator.graphite_host - s = TCPSocket.new(Deployinator.graphite_host,Deployinator.graphite_po + s = TCPSocket.new(Deployinator.graphite_host,Deployinator.graphite_port || 2003) s.write "#{logString} #{Time.now.to_i}\n" s.close end
Fix copy and paste error
diff --git a/db/migrate/20131023143833_add_discount_type_and_discount_percent_to_coupons.rb b/db/migrate/20131023143833_add_discount_type_and_discount_percent_to_coupons.rb index abc1234..def5678 100644 --- a/db/migrate/20131023143833_add_discount_type_and_discount_percent_to_coupons.rb +++ b/db/migrate/20131023143833_add_discount_type_and_discount_percent_to_coupons.rb @@ -0,0 +1,6 @@+class AddDiscountTypeAndDiscountPercentToCoupons < ActiveRecord::Migration + def change + add_column :couponable_coupons, :discount_type, :string, :null => false, :default => "dollars" + add_column :couponable_coupons, :discount_percent, :integer + end +end
Add migration to support percentage coupon.
diff --git a/test/integration/chocolatey/default.rb b/test/integration/chocolatey/default.rb index abc1234..def5678 100644 --- a/test/integration/chocolatey/default.rb +++ b/test/integration/chocolatey/default.rb @@ -0,0 +1,16 @@+control 'commands should exist' do + describe command('node -v') do + its('exit_status') { should eq 0 } + end + + describe command('npm -v') do + its('exit_status') { should eq 0 } + end + + describe command('npm list -json -global') do + its('stdout') { should match(/express/) } + its('stdout') { should match(/async@0.6.2/) } + its('stdout') { should match(/request/) } + its('stdout') { should match(/mocha/) } + end +end
Add a test for the windows install
diff --git a/diameter.gemspec b/diameter.gemspec index abc1234..def5678 100644 --- a/diameter.gemspec +++ b/diameter.gemspec @@ -8,7 +8,7 @@ s.files = Dir["lib/diameter/*.rb", "lib/diameter.rb"] s.homepage = 'http://rkday.github.io/ruby-diameter/api-docs/master/' - s.add_runtime_dependency 'concurrent-ruby', '~> 0.8' + s.add_runtime_dependency 'concurrent-ruby', '~> 0.9' s.add_runtime_dependency 'dnsruby', '~> 1' s.add_development_dependency 'rubocop', '~> 0.28'
Document proper concurrent-ruby version dependency
diff --git a/crawlers/lib/short_crawler.rb b/crawlers/lib/short_crawler.rb index abc1234..def5678 100644 --- a/crawlers/lib/short_crawler.rb +++ b/crawlers/lib/short_crawler.rb @@ -8,7 +8,7 @@ def_delegators :@extractor, :initial_urls, :next_page, :blocks, :news, :comments - PAGES_LIMIT = 2 + PAGES_LIMIT = 50 def all_blocks all_start_pages = initial_urls.map { |url| @agent.get(url) }.flatten
Increase request cap for facebook scraper
diff --git a/lib/autobots/runner.rb b/lib/autobots/runner.rb index abc1234..def5678 100644 --- a/lib/autobots/runner.rb +++ b/lib/autobots/runner.rb @@ -40,6 +40,28 @@ # before hook where you have parsed @options when loading tests def self.before_run host_env = @options[:env] + if host_env.nil? + # TODO(phu): default host needs to be set in a new env file + host = 'rent' + puts "No argument given for option -e \nLoading tests using default host: #{host}" + else + host = host_env.split(/_/)[0] + end + self.load_tests(host) + end + + # only load tests you need by specifying env option in command line + def self.load_tests(host) + Dir.glob("web_tests/#{host}/*.rb") do |f| + f.sub!(/^web_tests\//, '') + require f + end + + # files under subdirectories shouldn't be loaded, eg. archive/ + Dir.glob("web_tests/#{host}/test_cases/*.rb") do |f| + f.sub!(/^web_tests\//, '') + require f + end end end
[PH][99263050] OnePlatform: Load tests under certain host dir in before_run hook
diff --git a/lib/cave/model_form.rb b/lib/cave/model_form.rb index abc1234..def5678 100644 --- a/lib/cave/model_form.rb +++ b/lib/cave/model_form.rb @@ -30,8 +30,8 @@ private #----------- def check_instance_model + model = self.class.model if @instance - model = self.class.model # Pry alters models in such a way that the first check may fail when it # shouldn't. The second should still be fairly safe. unless @instance.is_a?(model) || @instance.class.name == model.name
Fix regression in model class checking
diff --git a/lib/lims-laboratory-app/laboratory/tube/bulk_create_tube.rb b/lib/lims-laboratory-app/laboratory/tube/bulk_create_tube.rb index abc1234..def5678 100644 --- a/lib/lims-laboratory-app/laboratory/tube/bulk_create_tube.rb +++ b/lib/lims-laboratory-app/laboratory/tube/bulk_create_tube.rb @@ -1,23 +1,13 @@-require 'lims-core/actions/action' +require 'lims-core/actions/bulk_action' require 'lims-laboratory-app/laboratory/tube' require 'lims-laboratory-app/laboratory/tube/create_tube' module Lims::LaboratoryApp module Laboratory class Tube - class BulkCreateTube - include Lims::Core::Actions::Action - - attribute :tubes, Array, :required => true, :writer => :private - - def _call_in_session(session) - result = tubes.map do |parameters| - tube_action = CreateTube.new(parameters) - tube_action.send(:_call_in_session, session) - end - - {:tubes => result.map { |e| e[:tube] }} - end + class BulkCreateTube + include Lims::Core::Actions::BulkAction + initialize_class(:tube, :tubes, CreateTube) end end end
Refactor BulkCreateTube to use BulkAction.
diff --git a/config.rb b/config.rb index abc1234..def5678 100644 --- a/config.rb +++ b/config.rb @@ -34,8 +34,8 @@ activate :gzip - ignore "javascripts/all.js" - ignore "stylesheets/site" + ignore "assets/javascripts/all.js" + ignore "assets/stylesheets/site" activate :minify_html do |html| html.remove_quotes = false
Add directory to Gzip ignores Without "assets/", mm build would error and complain that the @bourbon import in site.css could not be found
diff --git a/_plugins/_tag_gen.rb b/_plugins/_tag_gen.rb index abc1234..def5678 100644 --- a/_plugins/_tag_gen.rb +++ b/_plugins/_tag_gen.rb @@ -8,7 +8,7 @@ @dir = dir @name = 'index.html' self.process(@name) - self.read_yaml(File.join(base, '_layouts'), 'tag_index.html') + self.read_yaml(File.join(base, '_layouts'), 'tag.html') self.data['tag'] = tag end end
Rename file to execute in.
diff --git a/fair_dice_roll.gemspec b/fair_dice_roll.gemspec index abc1234..def5678 100644 --- a/fair_dice_roll.gemspec +++ b/fair_dice_roll.gemspec @@ -14,6 +14,6 @@ spec.files = `git ls-files -z`.split("\x0") spec.test_files = spec.files.grep(/^spec/) - spec.add_development_dependency "bundler", "~> 1.8" + spec.add_development_dependency "bundler", "~> 1.9" spec.add_development_dependency "rake", "~> 10.4" end
Update the bundler development gem dependency
diff --git a/lib/vagrant-libvirt/action/halt_domain.rb b/lib/vagrant-libvirt/action/halt_domain.rb index abc1234..def5678 100644 --- a/lib/vagrant-libvirt/action/halt_domain.rb +++ b/lib/vagrant-libvirt/action/halt_domain.rb @@ -13,41 +13,9 @@ end def call(env) - env[:ui].info(I18n.t('vagrant_libvirt.halt_domain')) - - timeout = env[:machine].config.vm.graceful_halt_timeout domain = env[:machine].provider.driver.connection.servers.get(env[:machine].id.to_s) - raise Errors::NoDomainError if domain.nil? - - if env[:force_halt] - domain.poweroff - return @app.call(env) - end - - begin - Timeout.timeout(timeout) do - begin - env[:machine].guest.capability(:halt) - rescue Timeout::Error - raise - rescue - @logger.info('Trying Libvirt graceful shutdown.') - # Read domain object again - dom = env[:machine].provider.driver.connection.servers.get(env[:machine].id.to_s) - if dom.state.to_s == 'running' - dom.shutdown - end - end - - domain.wait_for(timeout) do - !ready? - end - end - rescue Timeout::Error - @logger.info('VM is still running. Calling force poweroff.') - domain.poweroff - rescue - @logger.error('Failed to shutdown cleanly. Calling force poweroff.') + if env[:machine].state.id == :running + env[:ui].info(I18n.t('vagrant_libvirt.halt_domain')) domain.poweroff end
Update HaltDomain action to only forcibly halt domain
diff --git a/config/environments/development.rb b/config/environments/development.rb index abc1234..def5678 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -19,7 +19,7 @@ # Print deprecation notices to the Rails logger config.active_support.deprecation = :log - config.middleware.use Slimmer::App + config.slimmer.asset_host = ENV["STATIC_DEV"] || Plek.new("preview").find("assets") config.action_mailer.default_url_options = { :host => "www.dev.gov.uk" } end
Allow overriding of asset host using ENV var.
diff --git a/config/initializers/paper_trail.rb b/config/initializers/paper_trail.rb index abc1234..def5678 100644 --- a/config/initializers/paper_trail.rb +++ b/config/initializers/paper_trail.rb @@ -2,9 +2,9 @@ module PaperTrail def self.with_actor(actor) - current_actor = self.actor + original_actor = self.actor self.whodunnit = actor yield - self.whodunnit = current_actor + self.whodunnit = original_actor end end
Use better name when pulling switcheroo
diff --git a/hangman.old.rb b/hangman.old.rb index abc1234..def5678 100644 --- a/hangman.old.rb +++ b/hangman.old.rb @@ -0,0 +1,78 @@+# HangMan that I first wrote in my interview + +class HangMan + require 'SecureRandom' + + def initialize + @lives = 8 + @wrong_letters = [] + + all_words = File.new('words.txt').readlines() + @word = all_words[SecureRandom.random_number(all_words.length)].chomp + puts "pssst, the word is #{@word}" + + @word_progress = '_' * @word.length + @won = false + end + + def play_game + while @lives > 0 && !@won + play_turn + end + + if @won + puts 'You have won the game 😀' + else + puts 'You die painfully 😲' + end + end + + def valid_letter?(guess_letter) + # Check for weird inputs (or no newlines) + (guess_letter =~ /[[:alpha:]]/) || + !@wrong_letters.include?(guess_letter) || + !@word_progress.include?(guess_letter) + end + + def correct_choice?(guess_letter) + correct_guess = false + + @word.chars.each_with_index do |letter,i| + if guess_letter == letter + @word_progress[i] = guess_letter + correct_guess = true + end + end + + correct_guess + end + + def won_game? + !(@word_progress.include?('_')) + end + + def play_turn + puts @word_progress + puts @wrong_letters.join(',') + puts "You have #{@lives} lives left!" + + guess = gets + # We only allow the first letter of the guess, discard the rest + guess_letter = guess[0] + + puts 'Not a valid guess char' unless valid_letter?(guess_letter) + + unless correct_choice?(guess_letter) + @lives -= 1 + @wrong_letters.push guess_letter + end + + # Have we won the game yet? + if won_game? + @won = true + end + end +end + +HangMan.new.play_game +
Add my original hangman written during interview
diff --git a/test/integration_test_helper.rb b/test/integration_test_helper.rb index abc1234..def5678 100644 --- a/test/integration_test_helper.rb +++ b/test/integration_test_helper.rb @@ -3,7 +3,7 @@ require 'webmock' Capybara.javascript_driver = :webkit -DatabaseCleaner.strategy = :transaction +DatabaseCleaner.strategy = :truncation WebMock.disable_net_connect!(:allow_localhost => true) class ActionDispatch::IntegrationTest @@ -12,7 +12,7 @@ include Warden::Test::Helpers setup do - DatabaseCleaner.clean + DatabaseCleaner.start end teardown do @@ -27,7 +27,9 @@ end end + class JavascriptIntegrationTest < ActionDispatch::IntegrationTest + self.use_transactional_fixtures = false setup do Capybara.current_driver = Capybara.javascript_driver end
Disable transactions for integration tests. Capybara/webkit tests don't play well with transactional fixtures since they run in a separate process and therefore don't see db writes that are in a different transaction. Set use_transactional_fixtures to false and use the truncation strategy in DatabaseCleaner.
diff --git a/test/support/vagrant_wrapper.rb b/test/support/vagrant_wrapper.rb index abc1234..def5678 100644 --- a/test/support/vagrant_wrapper.rb +++ b/test/support/vagrant_wrapper.rb @@ -45,7 +45,8 @@ host_options = { user: vm['user'] || 'vagrant', hostname: vm['hostname'] || 'localhost', - port: vm['port'] || '22' + port: vm['port'] || '22', + password: vm['password'] || 'vagrant' }
Fix running functional tests with vagrant The tests were unable to SSH to the vagrant boxes without the password
diff --git a/lib/chronicle.rb b/lib/chronicle.rb index abc1234..def5678 100644 --- a/lib/chronicle.rb +++ b/lib/chronicle.rb @@ -32,7 +32,7 @@ is_valid = Proc.new {|msg| msg.include?(@char)} commits = @log.map {|hash| @git.gcommit(hash).message}.select(&is_valid) - lines = commits.map {|msg| msg.split(/\r?\n/).select(&is_valid)}.flatten.join("\n- ") + lines = commits.map {|msg| msg.split(/\r?\n/).select(&is_valid)}.flatten.join("\n").gsub!(@char, "-") puts "#{lines}" end
Use dashes for new lines <*> replace the filter character with a delimiter
diff --git a/spec/convection/model/template/resource/events_rule_spec.rb b/spec/convection/model/template/resource/events_rule_spec.rb index abc1234..def5678 100644 --- a/spec/convection/model/template/resource/events_rule_spec.rb +++ b/spec/convection/model/template/resource/events_rule_spec.rb @@ -9,7 +9,9 @@ # TODO: Test simple properties of EventsRule as well? events_rule 'MyEventsRule' do event_pattern 'source', %w(aws.ec2) - event_pattern 'detail', 'state' => %w(running) + event_pattern 'detail', + 'state' => %w(shutting-down stopped stopping terminated), + 'instance-id' => 'i-deadb33f' event_pattern 'detail-type', ['EC2 Instance State-change Notification'] end end @@ -25,7 +27,10 @@ it 'combines all event pattern calls into a single event pattern JSON object' do expect(subject['EventPattern']).to include( 'source' => %w(aws.ec2), - 'detail' => { 'state' => %w(running) }, + 'detail' => { + 'state' => %w(shutting-down stopped stopping terminated), + 'instance-id' => 'i-deadb33f' + }, 'detail-type' => ['EC2 Instance State-change Notification'] ) end
Use a more realistic event pattern This is an anonymised version (don't want anyone having out instance ID right?) of one of our patterns.
diff --git a/src/api-umbrella/web-app/config/initializers/delayed_job.rb b/src/api-umbrella/web-app/config/initializers/delayed_job.rb index abc1234..def5678 100644 --- a/src/api-umbrella/web-app/config/initializers/delayed_job.rb +++ b/src/api-umbrella/web-app/config/initializers/delayed_job.rb @@ -1,3 +1,13 @@+# Exit immediately when the delayed_job process receives a kill signal. +# +# This prevents some race conditions that can lead to API Umbrella stopping +# taking a long time. If mongo is running on the same server and mongo exits +# first, then without exiting immediately, delayed_job can get stuck waiting +# for a new mongo primary (until the 30s server_selection_timeout is hit) +# before exiting. +Delayed::Worker.raise_signal_exceptions = true + +# Keep failed jobs in the database. Delayed::Worker.destroy_failed_jobs = false if(Rails.env.test?)
Fix api-umbrella process stop sometimes taking a long time.
diff --git a/lib/tty.rb b/lib/tty.rb index abc1234..def5678 100644 --- a/lib/tty.rb +++ b/lib/tty.rb @@ -18,7 +18,6 @@ require 'tty/version' require 'tty/terminal' -require 'tty/vector' require 'tty/logger' require 'tty/plugins' require 'tty/plugins/plugin'
Change to stop loading vector.
diff --git a/lib/zmb.rb b/lib/zmb.rb index abc1234..def5678 100644 --- a/lib/zmb.rb +++ b/lib/zmb.rb @@ -0,0 +1,51 @@+class Zmb + require 'socket' + + def initialize + @plugins = {'core/zmb' => self} + @sockets = Hash.new + end + + def run + begin + while 1 + socket_select(timeout) + end + rescue Interrupt + return + end + end + + def timeout + 60.0 + end + + def socket_add(delegate, socket) + @sockets[socket] = delegate + end + + def socket_delete(item) + if @sockets.include?(item) then + @sockets.select{|sock, delegate| delegate == item}.each{|key, value| @sockets.delete(key)} + end + + if @sockets.has_key?(item) then + @sockets.delete(item) + end + end + + def socket_select(timeout) + result = select(@sockets.keys, nil, nil, timeout) + + if result != nil then + result[0].select{|sock| @sockets.has_key?(sock)}.each do |sock| + if sock.eof? then + @sockets[sock].disconnected(self, sock) if @sockets[sock].respond_to?('disconnected') + socket_delete sock + else + @sockets[sock].received(self, sock, sock.gets()) if @sockets[sock].respond_to?('received') + end + end + end + end +end
Add Zmb class and socket manager system
diff --git a/lib/hash_to_json.rb b/lib/hash_to_json.rb index abc1234..def5678 100644 --- a/lib/hash_to_json.rb +++ b/lib/hash_to_json.rb @@ -12,21 +12,23 @@ on param('q') do | hash | input = hash old = hash[ /=>/ ] - # hash = hash.to_s.stringify_keys - # if old - # hash = Hash[hash.to_s.gsub('{', '').gsub('}', '').split(",").collect{|x| - # x.gsub(/:| |\'/,'').gsub('nil', 'null').split("=>") - # }] - # p hash - # hash = hash.stringify_keys - # p hash - # end - json = if hash && old - JSON.parse(hash.to_s.gsub('=>', ':')).to_json - else - hash + isjson = hash[/:{/] + unless isjson + hash = hash.to_s.gsub('{', '').gsub('}', '') + if old + hash = Hash[hash.split(",").collect{|x| + x.gsub(/:| |\'/,'').gsub('nil', 'null').split("=>") + }] + else + hash = Hash[hash.split(",").collect{|x| + x.gsub('nil', 'null').split(': :') + }] + end + hash = hash.stringify_keys end - hash.gsub!('\\','') + if hash + json = JSON.parse(hash.to_s.gsub('=>', ':').gsub('\\','')).to_json + end res.write render('templates/home.haml', hash: input , json: json) end res.write render('templates/home.haml', hash: '' , json: '') @@ -35,11 +37,13 @@ end -# class Hash -# def stringify_keys -# t = self.dup -# self.clear -# t.each_pair{|k, v| self[k.to_s] = v} -# self -# end -# end +class Hash + def stringify_keys + t = self.dup + self.clear + t.each_pair{|k, v| + self[k.to_s.gsub(/^\"|\"$/, '')] = v.gsub(/^\"|\"$/, '') + } + self + end +end
Support for new hash syntax * support for json as well
diff --git a/lib/katex/engine.rb b/lib/katex/engine.rb index abc1234..def5678 100644 --- a/lib/katex/engine.rb +++ b/lib/katex/engine.rb @@ -6,7 +6,7 @@ # We deliberately do not place the assets in vendor/assets but in # vendor/katex instead, as vendor/assets is added to asset paths # by default but have to avoid including the non-sprockets stylesheet. - %w(fonts javascripts).each do |sub| + %w(fonts javascripts images).each do |sub| app.config.assets.paths << root.join('vendor', 'katex', sub).to_s end # Use sprockets versions of katex CSS that use asset-path for
Add vendor/images to asset lookup path
diff --git a/lib/nyaplot/plot.rb b/lib/nyaplot/plot.rb index abc1234..def5678 100644 --- a/lib/nyaplot/plot.rb +++ b/lib/nyaplot/plot.rb @@ -7,6 +7,7 @@ def initialize set_property(:diagrams, []) + set_property(:options, {}) end def add(type, *data) @@ -27,7 +28,7 @@ diagrams = get_property(:diagrams) [:xrange, :yrange].each do |symbol| - if get_property(symbol).nil? + if get_property(:options)[symbol].nil? range = [] diagrams.each{|diagram| range.push(diagram.send(symbol))}
Enable xrange and yrange options
diff --git a/config/deploy.rb b/config/deploy.rb index abc1234..def5678 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -12,6 +12,8 @@ set :linked_files, fetch(:linked_files, []).push( 'cached_departures.json', + 'cached_stops.json', + 'error_messages.json', 'config.json', 'route_mappings.json' )
Add cached stops and error messages to shared files
diff --git a/app/controllers/channels/channels_subscribers_controller.rb b/app/controllers/channels/channels_subscribers_controller.rb index abc1234..def5678 100644 --- a/app/controllers/channels/channels_subscribers_controller.rb +++ b/app/controllers/channels/channels_subscribers_controller.rb @@ -12,8 +12,8 @@ return redirect_to root_path end # This is needed when you press the follow channel button without being signed in - rescue - return redirect_to new_user_session_path + #rescue + #return redirect_to new_user_session_path end def destroy
Remove rescue from channels subscribers
diff --git a/ndb-ruby.gemspec b/ndb-ruby.gemspec index abc1234..def5678 100644 --- a/ndb-ruby.gemspec +++ b/ndb-ruby.gemspec @@ -9,8 +9,7 @@ spec.authors = ["Alex Stophel"] spec.email = ["alexstophel@gmail.com"] - spec.summary = "Gem to wrap NDB API" - spec.description = "Gem to wrap NDB API" + spec.summary = "Ruby wrapper for the National Nutrient Database RESTful API" spec.license = "MIT" spec.files = `git ls-files`.split("\n") @@ -21,11 +20,11 @@ spec.add_development_dependency "bundler", "~> 1.10" spec.add_development_dependency "rake", "~> 10.0" - spec.add_development_dependency "vcr" - spec.add_development_dependency "webmock" - spec.add_development_dependency "rspec" - spec.add_development_dependency "factory_girl" - spec.add_development_dependency "codeclimate-test-reporter" + spec.add_development_dependency "vcr", "~> 2.0" + spec.add_development_dependency "webmock", "~> 1.0" + spec.add_development_dependency "rspec", "3.0" + spec.add_development_dependency "factory_girl", "~> 4.0" + spec.add_development_dependency "codeclimate-test-reporter", "~> 0" spec.add_dependency "faraday" spec.add_dependency "json"
Add version constraints to gemspec. RubyGems was whining when I went to build the gem because of the limited version constrains on the various development dependencies. Also I've updated the description in the gemspec.
diff --git a/lib/tasks/untied.rb b/lib/tasks/untied.rb index abc1234..def5678 100644 --- a/lib/tasks/untied.rb +++ b/lib/tasks/untied.rb @@ -0,0 +1,14 @@+require "untied" +require "untied/worker" + +namespace :untied do + desc "Starts untied's worker" + task :work do + AMQP.start do |connection| + channel = AMQP::Channel.new(connection) + exchange = channel.topic("untied", :auto_delete => true) + worker = Untied::Worker.new(:channel => channel, :exchange => exchange) + worker.start + end + end +end
Define rake task wich starts Untied::Worker
diff --git a/lib/test/autorun.rb b/lib/test/autorun.rb index abc1234..def5678 100644 --- a/lib/test/autorun.rb +++ b/lib/test/autorun.rb @@ -0,0 +1,18 @@+$TEST_SUITE = [] unless defined?($TEST_SUITE) + +at_exit { + if RUBY_VERSION < '1.9' + require 'test/runner' + else + require_relative 'runner' + end + + suite = $TEST_SUITE + options = { + :format => ENV['ruby-test-format'] # TODO: better name? + } + + runner = Test::Runner.new(suite, options) + success = runner.run + exit -1 unless success +}
Add autrun.rb which test.rb loads.
diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index abc1234..def5678 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -9,7 +9,7 @@ @scrapers = Scraper.search @q, fields: [{full_name: :word_middle}, :description, {scraped_domain_names: :word_end}], highlight: true, page: params[:page], per_page: 10 else @scrapers_total_count = (Scraper.search @q, fields: [{full_name: :word_middle}, :description, {scraped_domain_names: :word_end}]).count - @scrapers = Scraper.search @q, where: {sqlite_db_size: {not: 0}}, fields: [{full_name: :word_middle}, :description, {scraped_domain_names: :word_end}], highlight: true, page: params[:page], per_page: 10 + @scrapers = Scraper.search @q, where: {has_data?: true}, fields: [{full_name: :word_middle}, :description, {scraped_domain_names: :word_end}], highlight: true, page: params[:page], per_page: 10 end end end
Fix bug in search 'where' query by using indexed method The query was not returning correct results because the target data was not in the index.
diff --git a/config/router.rb b/config/router.rb index abc1234..def5678 100644 --- a/config/router.rb +++ b/config/router.rb @@ -15,8 +15,8 @@ match('/feed/:action(.xml)').to(:controller=> 'feed_controller').name(:feeds) match('/',:query_string=>/feed=rss2/).to(:controller => 'feed_controller', :action =>'rss') #old wordpress format - match('/',:query_string=>/.+/).defer_to do |request, params| - raise Merb::ControllerExceptions::NotAcceptable, "Query String Unknown: #{request.query_string}" + match('/',:query_string=>/(tag|cat)=/).defer_to do |request, params| + raise Merb::ControllerExceptions::NotAcceptable, "Query String Unknown: #{request.query_string[0,20]}" end # Adds the required routes for merb-auth using the password slice
Allow messages through so login isn't broken
diff --git a/sinatra_asset_packager.gemspec b/sinatra_asset_packager.gemspec index abc1234..def5678 100644 --- a/sinatra_asset_packager.gemspec +++ b/sinatra_asset_packager.gemspec @@ -17,6 +17,7 @@ gem.add_dependency "sprockets" gem.add_dependency "uglifier" gem.add_dependency "yui-compressor" + gem.add_dependency "json", "~> 1.7.7" gem.add_development_dependency "pry" gem.add_development_dependency "rspec"
Update json to disable warning to those using the packager
diff --git a/config/routes.rb b/config/routes.rb index abc1234..def5678 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,3 +1,5 @@ AssetManager::Application.routes.draw do + # Temporary dummy route to keep healthcheck happy + root :to => lambda {|*args| [200, {}, ["Hello"]]} end
Add a dummy route to keep the healthcheck happy
diff --git a/config/routes.rb b/config/routes.rb index abc1234..def5678 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,11 +1,14 @@ Rails.application.routes.draw do - devise_for :users get 'login/index' + resources :transactions + + authenticated :user do + root 'transactions#index', as: "authenticated_root" + end + root 'login#index' - resources :costs resources :incomes resources :categories - resources :transactions end
Change root based on whether or not the user is signed in
diff --git a/spec/defines/mc/ostype_spec.rb b/spec/defines/mc/ostype_spec.rb index abc1234..def5678 100644 --- a/spec/defines/mc/ostype_spec.rb +++ b/spec/defines/mc/ostype_spec.rb @@ -22,4 +22,15 @@ .that_notifies('Class[sendmail::makeall]') } end + + context 'on FreeBSD' do + let(:title) { 'freebsd6' } + + it { + should contain_concat__fragment('sendmail_mc-ostype-freebsd6') \ + .with_content(/^OSTYPE\(`freebsd6'\)dnl$/) \ + .with_order('05') \ + .that_notifies('Class[sendmail::makeall]') + } + end end
Add test for OSTYPE macro on FreeBSD
diff --git a/spec/features/playback_spec.rb b/spec/features/playback_spec.rb index abc1234..def5678 100644 --- a/spec/features/playback_spec.rb +++ b/spec/features/playback_spec.rb @@ -17,7 +17,7 @@ it "is successful" do visit asciicast_path(asciicast, speed: 5) find(".start-prompt .play-button").click - page.should have_css('.time-remaining', visible: false, text: '-00:0') + expect(page).to have_css('.time-remaining', visible: false, text: '-00:0') end end
Fix playback spec - use "expect" syntax
diff --git a/spec/node/node_version_spec.rb b/spec/node/node_version_spec.rb index abc1234..def5678 100644 --- a/spec/node/node_version_spec.rb +++ b/spec/node/node_version_spec.rb @@ -3,13 +3,13 @@ # Node 4.x if property[:name] =~ /v4./ describe command('node -v') do - its(:stdout) { should contain('v4.8.0') } + its(:stdout) { should contain('v4.8.1') } end end # Node 6.x if property[:name] =~ /v6./ describe command('node -v') do - its(:stdout) { should contain('v6.10.0') } + its(:stdout) { should contain('v6.10.1') } end end
Update for Node v4.8.1 and v6.10.1
diff --git a/spec/support/validator_spec.rb b/spec/support/validator_spec.rb index abc1234..def5678 100644 --- a/spec/support/validator_spec.rb +++ b/spec/support/validator_spec.rb @@ -1,5 +1,5 @@ RSpec.shared_examples "validate valid parameter" do |validator_class, parameter| - context parameter.to_s do + context "with parameter #{parameter}" do subject(:valid_parameter_validator) { validator_class.new('name', validator_definition, parameter).tap {|validator| validator.validate} } it 'is valid' do @@ -9,7 +9,7 @@ end RSpec.shared_examples "validate invalid parameter" do |validator_class, parameter, errored_parameters| - context parameter.to_s do + context "with parameter #{parameter}" do subject(:invalid_parameter_validator) { validator_class.new(name, validator_definition, parameter).tap {|validator| validator.validate} } it 'is not valid' do @@ -17,7 +17,6 @@ end it 'has an error' do - puts parameter expect(invalid_parameter_validator.error).to eql error_message.call(errored_parameters, validator_definition) end end
Make output a little purtier
diff --git a/app/controllers/api/consultations_controller.rb b/app/controllers/api/consultations_controller.rb index abc1234..def5678 100644 --- a/app/controllers/api/consultations_controller.rb +++ b/app/controllers/api/consultations_controller.rb @@ -1,7 +1,7 @@ module API class ConsultationsController < BaseController def last - consultation = patient.consultations.last + consultation = patient.consultations.most_recent render json: consultation end @@ -16,6 +16,14 @@ end private + + def patient + Patient.find(params[:patient_id]) + end + + def patient_consultations + @consultations ||= patient.consultations.ordered_by_date.pluck(:id).reverse + end def previous_consultation_id patient_consultations[current_consultation_index.succ] @@ -35,13 +43,5 @@ def current_consultation params[:current_consultation].to_i end - - def patient - Patient.find(params[:patient_id]) - end - - def patient_consultations - @consultations ||= patient.consultations.pluck(:id).reverse - end end end
Refactor: Use `most_recent` instead of `last` on consultations
diff --git a/app/controllers/concerns/comments_controller.rb b/app/controllers/concerns/comments_controller.rb index abc1234..def5678 100644 --- a/app/controllers/concerns/comments_controller.rb +++ b/app/controllers/concerns/comments_controller.rb @@ -0,0 +1,9 @@+class CommentsController < ApplicationController + include AuthsHelper + + def index(commentable_id, commentable_type) + @comments = Comment.where(commentable_id: commentable_id, commentable_type: commentable_type) + end + + +end
Add comments controller and index method.
diff --git a/app/controllers/mixins/generic_session_mixin.rb b/app/controllers/mixins/generic_session_mixin.rb index abc1234..def5678 100644 --- a/app/controllers/mixins/generic_session_mixin.rb +++ b/app/controllers/mixins/generic_session_mixin.rb @@ -1,6 +1,5 @@ module Mixins module GenericSessionMixin - private def get_session_data
Fix rubocop warnings in GenericSessionMixin
diff --git a/db/data_migration/20130423122400_mainstream_category_for_uk_export_finance.rb b/db/data_migration/20130423122400_mainstream_category_for_uk_export_finance.rb index abc1234..def5678 100644 --- a/db/data_migration/20130423122400_mainstream_category_for_uk_export_finance.rb +++ b/db/data_migration/20130423122400_mainstream_category_for_uk_export_finance.rb @@ -0,0 +1,6 @@+puts 'Creating MainstreamCategory for UK Export Finance' +MainstreamCategory.create!( parent_title: 'Imports and exports', + parent_tag: 'business/imports-exports', + title: 'Export finance', + slug: 'export-finance', + description: 'How UK exporters can apply for loans, lines of credit, guarantees and insurance policies')
Add new MainstreamCategory for UK Export Finance
diff --git a/cookbooks/lib/features/neo4j_spec.rb b/cookbooks/lib/features/neo4j_spec.rb index abc1234..def5678 100644 --- a/cookbooks/lib/features/neo4j_spec.rb +++ b/cookbooks/lib/features/neo4j_spec.rb @@ -1,11 +1,13 @@+def furbies + @furbies ||= rand(200..299) +end + describe 'neo4j installation' do describe command('which neo4j') do its(:stdout) { should match 'bin/neo4j' } end describe 'neo4j commands', sudo: true do - let(:furbies) { rand(200..299) } - before :all do sh('sudo neo4j start') tcpwait('127.0.0.1', 7474)
Move furbies from let block to method
diff --git a/lib/heroclix/hero.rb b/lib/heroclix/hero.rb index abc1234..def5678 100644 --- a/lib/heroclix/hero.rb +++ b/lib/heroclix/hero.rb @@ -1,35 +1,39 @@-module Heroclix - class Hero - attr_reader :name, :description, :clicks - - def initialize(name, combat_values, description = nil) - @name, @combat_values, @description = name, combat_values, description - @clicks = 0 - end - - def speed - @combat_values[:speed][@clicks] - end - - def attack - @combat_values[:attack][@clicks] - end - - def defense - @combat_values[:defense][@clicks] - end - - def damage - @combat_values[:damage][@clicks] - end - - def damage!(amount = 1) - @clicks += amount - end - - def heal!(amount = 1) - @clicks -= amount - @clicks = 0 if @clicks < 0 - end - end +module Heroclix + class Hero + attr_reader :name, :description, :clicks + + def initialize(name, combat_values, description = nil) + @name, @combat_values, @description = name, combat_values, description + @clicks = 0 + end + + def speed + @combat_values[:speed][@clicks] + end + + def attack + @combat_values[:attack][@clicks] + end + + def defense + @combat_values[:defense][@clicks] + end + + def damage + @combat_values[:damage][@clicks] + end + + def damage!(amount = 1) + @clicks += amount + end + + def heal!(amount = 1) + @clicks -= amount + reset! if @clicks < 0 + end + + def reset! + @clicks = 0 + end + end end
Add reset method to Hero to completely heal after a game or test.
diff --git a/lib/nyaplot/scale.rb b/lib/nyaplot/scale.rb index abc1234..def5678 100644 --- a/lib/nyaplot/scale.rb +++ b/lib/nyaplot/scale.rb @@ -3,6 +3,7 @@ include Nyaplot::Base type :row_scale required_args :data, :column, :range + optional_args :domain end class DataFrameScale
Add :domain options to RowScale
diff --git a/lib/rack/revision.rb b/lib/rack/revision.rb index abc1234..def5678 100644 --- a/lib/rack/revision.rb +++ b/lib/rack/revision.rb @@ -6,12 +6,7 @@ @@revision = nil def initialize(app, options={}) - @options = { - :header => options[:header].nil? ? 'X-Revision' : options[:header], - :filename => options[:filename] || 'REVISION', - :default => options[:default] || 'UNDEFINED', - :rack_env => options[:rack_env].nil? ? 'rack.app_revision' : options[:rack_env] - } + initialize_options(options) @app = app end @@ -40,5 +35,14 @@ def detected_filename @file ||= (@options[:filename] =~ /\A\// ? @options[:filename] : File.join(Dir.pwd, @options[:filename])) end + + def initialize_options(options) + @options = { + :header => options[:header].nil? ? 'X-Revision' : options[:header], + :filename => options[:filename] || 'REVISION', + :default => options[:default] || 'UNDEFINED', + :rack_env => options[:rack_env].nil? ? 'rack.app_revision' : options[:rack_env] + } + end end end
Move options initialization to a separate method
diff --git a/lib/json_expressions/rspec/matchers/match_json_expression.rb b/lib/json_expressions/rspec/matchers/match_json_expression.rb index abc1234..def5678 100644 --- a/lib/json_expressions/rspec/matchers/match_json_expression.rb +++ b/lib/json_expressions/rspec/matchers/match_json_expression.rb @@ -22,10 +22,12 @@ def failure_message_for_should "expected #{@target.inspect} to match JSON expression #{@expected.inspect}\n" + @expected.last_error end + alias_method :failure_message, :failure_message_for_should def failure_message_for_should_not "expected #{@target.inspect} not to match JSON expression #{@expected.inspect}" end + alias_method :failure_message_when_negated, :failure_message_for_should_not def description "should equal JSON expression #{@expected.inspect}"
Add support for rspec 3+ Alias new rspec matcher protocol names (rspec 3+) to the old (rspec 2). From https://www.relishapp.com/rspec/rspec-expectations/docs/changelog: Update matcher protocol and custom matcher DSL to better align with the newer expect syntax. If you want your matchers to maintain compatibility with multiple versions of RSpec, you can alias the new names to the old. (Myron Marston) * failure_message_for_should => failure_message * failure_message_for_should_not => failure_message_when_negated * match_for_should => match * match_for_should_not => match_when_negated
diff --git a/spec/controllers/ansible_playbook_controller_spec.rb b/spec/controllers/ansible_playbook_controller_spec.rb index abc1234..def5678 100644 --- a/spec/controllers/ansible_playbook_controller_spec.rb +++ b/spec/controllers/ansible_playbook_controller_spec.rb @@ -18,6 +18,11 @@ it "renders correct template" do is_expected.to render_template(:partial => "layouts/_textual_groups_generic") end + + it "does not display tags" do + get :show, :params => {:id => playbook.id} + expect(response.body).not_to include("Smart Management") + end end context "#show_list" do
Add spec for tags removal from Ansible Playbook summary page
diff --git a/spec/features/consumer/caching/shops_caching_spec.rb b/spec/features/consumer/caching/shops_caching_spec.rb index abc1234..def5678 100644 --- a/spec/features/consumer/caching/shops_caching_spec.rb +++ b/spec/features/consumer/caching/shops_caching_spec.rb @@ -0,0 +1,68 @@+# frozen_string_literal: true + +require "spec_helper" + +feature "Shops caching", js: true, caching: true do + include WebHelper + include UIComponentHelper + + let!(:distributor) { create(:distributor_enterprise, with_payment_and_shipping: true, is_primary_producer: true) } + let!(:order_cycle) { create(:open_order_cycle, distributors: [distributor], coordinator: distributor) } + + describe "API action caching on taxons and properties" do + let!(:taxon) { create(:taxon, name: "Cached Taxon") } + let!(:taxon2) { create(:taxon, name: "New Taxon") } + let!(:property) { create(:property, presentation: "Cached Property") } + let!(:property2) { create(:property, presentation: "New Property") } + let!(:product) { create(:product, taxons: [taxon], primary_taxon: taxon, properties: [property]) } + let(:exchange) { order_cycle.exchanges.to_enterprises(distributor).outgoing.first } + + let(:test_domain) { "#{Capybara.current_session.server.host}:#{Capybara.current_session.server.port}" } + let(:taxons_key) { "views/#{test_domain}/api/order_cycles/#{order_cycle.id}/taxons?distributor=#{distributor.id}" } + let(:properties_key) { "views/#{test_domain}/api/order_cycles/#{order_cycle.id}/properties?distributor=#{distributor.id}" } + let(:options) { { expires_in: CacheService::FILTERS_EXPIRY } } + + before do + exchange.variants << product.variants.first + end + + it "caches rendered response for taxons and properties, with the provided options" do + visit enterprise_shop_path(distributor) + + expect(page).to have_content "Cached Taxon" + expect(page).to have_content "Cached Property" + + expect_cached taxons_key, options + expect_cached properties_key, options + end + + it "keeps data cached for a short time on subsequent requests" do + # One minute ago... + Timecop.travel(Time.zone.now - 1.minute) do + visit enterprise_shop_path(distributor) + + expect(page).to have_content taxon.name + expect(page).to have_content property.presentation + + product.update_attribute(:taxons, [taxon2]) + product.update_attribute(:primary_taxon, taxon2) + product.update_attribute(:properties, [property2]) + + visit enterprise_shop_path(distributor) + + expect(page).to have_content taxon.name # Taxon list is unchanged + expect(page).to have_content property.presentation # Property list is unchanged + end + + # A while later... + visit enterprise_shop_path(distributor) + + expect(page).to have_content taxon2.name + expect(page).to have_content property2.presentation + end + end + + def expect_cached(key, options = {}) + expect(Rails.cache.exist?(key, options)).to be true + end +end
Add feature spec for action caching of taxon and properties endpoints
diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb index abc1234..def5678 100644 --- a/config/initializers/session_store.rb +++ b/config/initializers/session_store.rb @@ -1,6 +1,6 @@ # Be sure to restart your server when you modify this file. -Cyclescape::Application.config.session_store :cookie_store, key: '_cyclekit_session' +Cyclescape::Application.config.session_store :cookie_store, key: '_cyclekit_session', domain: :all # Use the database for sessions instead of the cookie-based default, # which shouldn't be used to store highly confidential information
Add magical incantation to session store config for subdomain cookies.
diff --git a/app/models/import.rb b/app/models/import.rb index abc1234..def5678 100644 --- a/app/models/import.rb +++ b/app/models/import.rb @@ -1,13 +1,15 @@ # frozen_string_literal: true class Import < ApplicationRecord + FILE_TYPES = ['text/plain', 'text/csv'].freeze + self.inheritance_column = false + + belongs_to :account, required: true enum type: [:following, :blocking, :muting] - belongs_to :account - - FILE_TYPES = ['text/plain', 'text/csv'].freeze + validates :type, presence: true has_attached_file :data, url: '/system/:hash.:extension', hash_secret: ENV['PAPERCLIP_SECRET'] validates_attachment_content_type :data, content_type: FILE_TYPES
Add presence validation to Import ``` *An* `ActiveRecord::StatementInvalid` *occurred while* `POST </settings/import>` *was processed by* `imports#create` Exception ---------------- PG::NotNullViolation: ERROR: null value in column "type" violates not-null constraint ```
diff --git a/app/models/season.rb b/app/models/season.rb index abc1234..def5678 100644 --- a/app/models/season.rb +++ b/app/models/season.rb @@ -1,4 +1,6 @@ class Season < ActiveRecord::Base + has_many :musics + validates :name, presence: true validates :start, presence: true validates :expiry, presence: true
Add association to music for Season
diff --git a/infopen-docker.gemspec b/infopen-docker.gemspec index abc1234..def5678 100644 --- a/infopen-docker.gemspec +++ b/infopen-docker.gemspec @@ -12,7 +12,7 @@ 'lib/docker/lifecycle.rb', 'lib/errors/errors.rb' ] - spec.homepage = 'http://rubygems.org/gems/infopen-docker' + spec.homepage = 'https://github.com/infOpen/ruby-gem-infopen-docker' spec.license = 'MIT' # Development ependencies
Change gem homepage to github repository
diff --git a/omnibus.rb b/omnibus.rb index abc1234..def5678 100644 --- a/omnibus.rb +++ b/omnibus.rb @@ -11,7 +11,6 @@ # Customize compiler bits # ------------------------------ -solaris_compiler 'gcc' build_retries 3 fetcher_read_timeout 120
Remove deprecated solaris compiler config.
diff --git a/lib/vagrant-vmware-freebsd/cap/mount_vmware_shared_folder.rb b/lib/vagrant-vmware-freebsd/cap/mount_vmware_shared_folder.rb index abc1234..def5678 100644 --- a/lib/vagrant-vmware-freebsd/cap/mount_vmware_shared_folder.rb +++ b/lib/vagrant-vmware-freebsd/cap/mount_vmware_shared_folder.rb @@ -6,9 +6,16 @@ machine.communicate.tap do |comm| comm.sudo("rm \"#{guestpath}\"") if comm.test("test -L \"#{guestpath}\"", :sudo => true) comm.sudo("rm -Rf \"#{guestpath}\"") if comm.test("test -d \"#{guestpath}\"", :sudo => true) - comm.sudo("mkdir -p \"#{guestpath}\"") # mkdir -p doesn't care if it exists already - comm.sudo("mount -t vmhgfs \".host:/#{name}\" \"#{guestpath}\"") + intermediate_dir = File.dirname(guestpath) + comm.sudo("mkdir -p \"#{intermediate_dir}\"") # mkdir -p doesn't care if it exists already + + unless comm.test("test -d \"/mnt/hgfs/#{name}\"") + comm.sudo("mkdir -p /mnt/hgfs") + comm.sudo("mount -t vmhgfs \".host:/\" \"/mnt/hgfs\"") + end + + comm.sudo("ln -s \"/mnt/hgfs/#{name}\" \"#{guestpath}\"") end end end
Change MountVmwareSharedFolder to use symlinks. The vmhgfs mount only ever seems to mount the virtual directory and never any of its subdirectories. So instead of trying to mount them in the desired path we instead mount on /mnt/hgfs and then symlink the named directories to the guest paths.