diff
stringlengths
65
26.7k
message
stringlengths
7
9.92k
diff --git a/spec/adapter/v1/cloudFoundry/cloud_foundry_adapter_spec.rb b/spec/adapter/v1/cloudFoundry/cloud_foundry_adapter_spec.rb index abc1234..def5678 100644 --- a/spec/adapter/v1/cloudFoundry/cloud_foundry_adapter_spec.rb +++ b/spec/adapter/v1/cloudFoundry/cloud_foundry_adapter_spec.rb @@ -2,7 +2,7 @@ describe Paasal::Adapters::V1::CloudFoundryAdapter do before do - @endpoint = 'cf-stackato-local' + @endpoint = 'cf-bosh-local' @api_version = 'v1' @adapter = load_adapter(@endpoint, @api_version) @application_region = 'default'
Use `cf-bosh-local` instead of `cf-stackato-local` for Cloud Foundry tests (--> faster!)
diff --git a/spec/lib/neighborly/balanced/bankaccount/interface_spec.rb b/spec/lib/neighborly/balanced/bankaccount/interface_spec.rb index abc1234..def5678 100644 --- a/spec/lib/neighborly/balanced/bankaccount/interface_spec.rb +++ b/spec/lib/neighborly/balanced/bankaccount/interface_spec.rb @@ -1,7 +1,6 @@ require 'spec_helper' describe Neighborly::Balanced::Bankaccount::Interface do - subject { Neighborly::Balanced::Bankaccount::Interface.new } let(:contribution) { double('Contribution', id: 42) } it 'should return the engine name' do
Remove unnecessary subject on spec
diff --git a/lib/alephant/broker/cache.rb b/lib/alephant/broker/cache.rb index abc1234..def5678 100644 --- a/lib/alephant/broker/cache.rb +++ b/lib/alephant/broker/cache.rb @@ -4,7 +4,6 @@ module Alephant module Broker module Cache - class Client include Logger @@ -19,6 +18,22 @@ @@client = NullClient.new end end + + def get(key, &block) + begin + result = @@client.get(versioned(key)) + logger.info("Broker::Cache::Client#get key: #{key} - #{result ? 'hit' : 'miss'}") + result ? result : set(key, block.call) + rescue StandardError => e + block.call if block_given? + end + end + + def set(key, value, ttl = nil) + value.tap { |o| @@client.set(versioned(key), o, ttl) } + end + + private def config_endpoint Broker.config['elasticache_config_endpoint'] @@ -35,21 +50,6 @@ def cache_version Broker.config['elasticache_cache_version'] end - - def get(key, &block) - begin - result = @@client.get(versioned(key)) - logger.info("Broker::Cache::Client#get key: #{key} - #{result ? 'hit' : 'miss'}") - result ? result : set(key, block.call) - rescue StandardError => e - block.call if block_given? - end - end - - def set(key, value) - value.tap { |o| @@client.set(versioned(key), o) } - end - end class NullClient @@ -59,7 +59,6 @@ value end end - end end end
Set custom TTL in Cache Closes #24
diff --git a/core/spec/models/comable/variant_spec.rb b/core/spec/models/comable/variant_spec.rb index abc1234..def5678 100644 --- a/core/spec/models/comable/variant_spec.rb +++ b/core/spec/models/comable/variant_spec.rb @@ -0,0 +1,10 @@+describe Comable::Variant do + it { is_expected.to belong_to(:product).class_name(Comable::Product.name).inverse_of(:variants) } + it { is_expected.to have_one(:stock).class_name(Comable::Stock.name).inverse_of(:variant).dependent(:destroy).autosave(true) } + it { is_expected.to have_and_belong_to_many(:option_values).class_name(Comable::OptionValue.name).dependent(:destroy) } + + it { is_expected.to validate_presence_of(:product).with_message(Comable.t('admin.is_not_exists')) } + it { is_expected.to validate_presence_of(:price) } + it { is_expected.to validate_numericality_of(:price).is_greater_than_or_equal_to(0) } + it { is_expected.to validate_length_of(:sku).is_at_most(255) } +end
Add the test for Variant
diff --git a/lib/bankscrap/transaction.rb b/lib/bankscrap/transaction.rb index abc1234..def5678 100644 --- a/lib/bankscrap/transaction.rb +++ b/lib/bankscrap/transaction.rb @@ -15,7 +15,7 @@ end def to_a - [effective_date.strftime('%d/%m/%Y'), description, amount] + [:id, effective_date.strftime('%d/%m/%Y'), description, description_details, amount] end def currency
Add `:id` and `:description_details` to `to_a` method for `Bankscrap::Transaction`
diff --git a/config/initializers/secure_headers.rb b/config/initializers/secure_headers.rb index abc1234..def5678 100644 --- a/config/initializers/secure_headers.rb +++ b/config/initializers/secure_headers.rb @@ -6,6 +6,7 @@ config.csp = { enforce: true, default_src: 'https://* self', + style_src: 'https://* self inline', report_uri: '/content_security_policy/forward_report' } end
Allow inline CSS, for now. The form_for helper in the picture upload form generates a <div style="display:none"> tag around the utf8 and authenticity_token input fields.
diff --git a/app/controllers/areas_controller.rb b/app/controllers/areas_controller.rb index abc1234..def5678 100644 --- a/app/controllers/areas_controller.rb +++ b/app/controllers/areas_controller.rb @@ -12,7 +12,7 @@ def update @area = Area.find_by_id params[:id] - if @area.update_attributes params[:area] + if @area.update(area_params) flash[:success] = t 'areas.update_success' redirect_to edit_area_path @area else @@ -24,4 +24,10 @@ def edit_opening_hours_applet @areas = Area.all end + + private + + def area_params + params.require(:area).permit(:page_id, standard_hours_attributes: [:open, :open_time, :close_time, :day, :id]) + end end
Add strong params for areas
diff --git a/db/migrate/1406149630_create_test_set.rb b/db/migrate/1406149630_create_test_set.rb index abc1234..def5678 100644 --- a/db/migrate/1406149630_create_test_set.rb +++ b/db/migrate/1406149630_create_test_set.rb @@ -1,14 +1,7 @@ Sequel.migration do change do - create_table(:testset) do - serial :set, primary_key: true - text :info, unique: true, null: false - text :testdb, null: false - text :testuser, null: false - text :testhost, null: false - text :testport, null: false - text :settings - foreign_key :database_uuid, :databases, type: :uuid + alter_table(:testset) do + add_foreign_key :database_uuid, :databases, type: :uuid end end -end+end
Change testset migration to alter table not create it The testset migration should not create the lone testset table, but it should alter the one created by resultsdb.sql, at least until all of resultsdb.sql is included in the migrations.
diff --git a/db/migrate/20150506084842_create_maps.rb b/db/migrate/20150506084842_create_maps.rb index abc1234..def5678 100644 --- a/db/migrate/20150506084842_create_maps.rb +++ b/db/migrate/20150506084842_create_maps.rb @@ -2,7 +2,6 @@ def change create_table :maps do |t| t.string :name - t.string :string t.timestamps null: false end
Remove string field for maps table
diff --git a/tasks/build-binary-new/source_input.rb b/tasks/build-binary-new/source_input.rb index abc1234..def5678 100644 --- a/tasks/build-binary-new/source_input.rb +++ b/tasks/build-binary-new/source_input.rb @@ -1,9 +1,10 @@ class SourceInput attr_reader :url, :md5, :git_commit_sha - attr_accessor :name, :version, :sha256 + attr_accessor :name, :repo, :version, :sha256 - def initialize(name, url, version, md5, sha256, git_commit_sha = nil) + def initialize(name, repo, url, version, md5, sha256, git_commit_sha = nil) @name = name + @repo = repo @url = url @version = version @md5 = md5 @@ -15,6 +16,7 @@ data = JSON.parse(open(source_file).read) SourceInput.new( data.dig('source', 'name') || '', + data.dig('source', 'repo') || '', data.dig('version', 'url') || '', data.dig('version', 'ref') || '', data.dig('version', 'md5_digest'),
Add source_repo to dependency builder object [#164880949] Co-authored-by: Daniel Thornton <5874b3971aa460e96f75d4dbef8f6aadb66f1697@pivotal.io>
diff --git a/app/controllers/theme_controller.rb b/app/controllers/theme_controller.rb index abc1234..def5678 100644 --- a/app/controllers/theme_controller.rb +++ b/app/controllers/theme_controller.rb @@ -1,4 +1,10 @@ # Theme controller +# Shows information about available user color themes. +# +# ==== Public Actions ===== +# color_themes:: Show general information about color themes +# Agaricus, etc.:: Show sample page, explaining color derivation. +# class ThemeController < ApplicationController # callbacks before_action :login_required, except: MO.themes + [ @@ -6,7 +12,12 @@ ] before_action :disable_link_prefetching - # Displays info on color themes. + # Show general information on color themes def color_themes # :nologin: end + + # Individual theme actions. Each shows a sample page in that theme, + # explaining the colors for that theme. + # These actions are not defined here, but rather are automagically created + # if there's a view template corresponding to the theme. end
Document public actions of ThemeController Includes an explanation why the actions for the individual themes (e.g., `theme/Agaricus`) are not defined in the controller.
diff --git a/lib/facter/root_encrypted.rb b/lib/facter/root_encrypted.rb index abc1234..def5678 100644 --- a/lib/facter/root_encrypted.rb +++ b/lib/facter/root_encrypted.rb @@ -5,7 +5,7 @@ def root_encrypted? system("/usr/bin/fdesetup isactive /") - [0, 2].include? $? + [0, 2].include? $?.exitstatus end setcode do
Fix bug in checking exitstatus When fdesetup returns with exit code 2, $? is actually 512 (512 >> 8 == 2). Need to check for $?.exitstatus
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index abc1234..def5678 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,7 +1,7 @@ class UsersController < ApplicationController respond_to :json + before_filter :authenticate_admin!, only: :create before_filter :find_user, only: [:show, :update] - before_filter :authenticate_admin!, only: :create before_filter :authenticate_admin_if_not_self!, only: :update def index @@ -17,11 +17,11 @@ end def create - respond_with User.create user_params + respond_with User.create user_create_params end def update - @user.update_attributes user_params + @user.update_attributes user_update_params respond_with @user end @@ -30,16 +30,16 @@ @user = User.with_id_or_username(params[:id]).first end - def user_params + def user_create_params + params.require(:user).permit(:password, :password_confirmation, :username, :email, :admin, :balance) + end + + def user_update_params req = params.require(:user) - if current_user.admin? and params[:action] == 'create' - req.permit(:password, :password_confirmation, :username, :email, :admin, :balance) - elsif current_user.admin? + if current_user.admin? req.permit(:username, :email, :admin) - elsif current_user == @user #allow self update of these fields + else req.permit(:username, :email) - else - req.permit() end end
Refactor user create/update params to different methods
diff --git a/lib/logster/configuration.rb b/lib/logster/configuration.rb index abc1234..def5678 100644 --- a/lib/logster/configuration.rb +++ b/lib/logster/configuration.rb @@ -12,7 +12,8 @@ @subdirectory = nil @allow_grouping = false - if defined?(::Rails) && ::Rails.env.production? + + if defined?(::Rails) && defined?(::Rails.env) && ::Rails.env.production? @allow_grouping = true end end
FIX: Check that `Rails.env` is defined as well.
diff --git a/tools/groonga-memory-usage-analyzer.rb b/tools/groonga-memory-usage-analyzer.rb index abc1234..def5678 100644 --- a/tools/groonga-memory-usage-analyzer.rb +++ b/tools/groonga-memory-usage-analyzer.rb @@ -0,0 +1,86 @@+#!/usr/bin/env ruby + +class Memory < Struct.new(:size, :file, :line, :function) + def location + "#{file}:#{line}" + end +end + +class LocationGroup + attr_reader :location + attr_reader :memories + def initialize(location) + @location = location + @memories = [] + end + + def add(memory) + @memories << memory + end + + def total_size + @memories.inject(0) do |sum, memory| + sum + memory.size + end + end +end + +class Statistics + def initialize + @location_groups = {} + end + + def add(memory) + group = location_group(memory.location) + group.add(memory) + end + + def sort_by_size + @location_groups.values.sort_by do |group| + group.total_size + end + end + + private + def location_group(location) + @location_groups[location] ||= LocationGroup.new(location) + end +end + +statistics = Statistics.new + +ARGF.each_line do |line| + case line + when /\Aaddress\[\d+\]\[not-freed\]:\s + (?:0x)?[\da-fA-F]+\((\d+)\):\s + (.+?):(\d+):\s(\S+)/x + size = $1.to_i + file = $2 + line = $3.to_i + function = $4.strip + memory = Memory.new(size, file, line, function) + statistics.add(memory) + end +end + +def format_size(size) + if size < 1024 + "#{size}B" + elsif size < (1024 * 1024) + "%.3fKiB" % (size / 1024.0) + elsif size < (1024 * 1024 * 1024) + "%.3fMiB" % (size / 1024.0 / 1024.0) + elsif size < (1024 * 1024 * 1024 * 1024) + "%.3fGiB" % (size / 1024.0 / 1024.0 / 1024.0) + else + "#{size}B" + end +end + +statistics.sort_by_size.reverse[0, 10].each do |group| + puts("%10s: %s(%d)" % [ + format_size(group.total_size), + group.location, + group.memories.size, + ]) +end
Add a tool to analyze memory usage from memory debug log
diff --git a/lib/cdistance.rb b/lib/cdistance.rb index abc1234..def5678 100644 --- a/lib/cdistance.rb +++ b/lib/cdistance.rb @@ -1,5 +1,35 @@+require 'bundler/setup' +require 'ffi' + module Cdistance extend FFI::Library - ffi_lib FFI::Library::LIBC - attach_function :puts, [ :string ], :int + + lib_file = File.expand_path('../ext/cdistance/cdistance', File.dirname(__FILE__)) + + if FFI::Platform.mac? + lib_file << '.bundle' + end + + ffi_lib FFI.map_library_name(lib_file) + + def self.distance(point1, point2) + geo_point1 = GeoPoint.new(*point1) + geo_point2 = GeoPoint.new(*point2) + + distance_between(geo_point1, geo_point2) + end + + class GeoPoint < FFI::Struct + layout :lat, :float, + :lng, :float + + def initialize(lat, lng) + super() + self[:lat] = lat + self[:lng] = lng + end + end + + attach_function 'to_radians', [ GeoPoint.by_value ], :float + attach_function 'distance_between', [ GeoPoint.by_value, GeoPoint.by_value ], :float end
Add an actual FFI interface for the library
diff --git a/lib/simctl/command/create.rb b/lib/simctl/command/create.rb index abc1234..def5678 100644 --- a/lib/simctl/command/create.rb +++ b/lib/simctl/command/create.rb @@ -14,6 +14,8 @@ def create_device(name, devicetype, runtime) runtime = runtime(name: runtime) unless runtime.is_a?(Runtime) devicetype = devicetype(name: devicetype) unless devicetype.is_a?(DeviceType) + raise "Invalid runtime: #{runtime}" unless runtime.is_a?(Runtime) + raise "Invalid devicetype: #{devicetype}" unless devicetype.is_a?(DeviceType) Executor.execute([COMMAND, Shellwords.shellescape(name), devicetype.identifier, runtime.identifier]) do |identifier| device(udid: identifier) end
Raise exception if runtime or devicetype lookup failed
diff --git a/lib/simple_authentication.rb b/lib/simple_authentication.rb index abc1234..def5678 100644 --- a/lib/simple_authentication.rb +++ b/lib/simple_authentication.rb @@ -3,4 +3,4 @@ require "simple_authentication/model_methods" ApplicationController.send(:include, SimpleAuthentication::ControllerMethods::Application) -I18n.load_path << File.join(File.dirname(__FILE__), '..', 'config', 'locales', 'simple_authentication.yml') +I18n.load_path.unshift(File.join(File.dirname(__FILE__), '..', 'config', 'locales', 'simple_authentication.yml'))
Add i18n load path to the beginning to allow values to be overridden
diff --git a/lib/taskmeister/task_list.rb b/lib/taskmeister/task_list.rb index abc1234..def5678 100644 --- a/lib/taskmeister/task_list.rb +++ b/lib/taskmeister/task_list.rb @@ -9,7 +9,7 @@ end def to_short_list - longest_id = @hash.keys.max {|id| id.length } + longest_id = @hash.keys.max_by(&:length) @hash.map { |id, task| marker = task.notes? ? " »" : "" "%-#{longest_id.length}s - %s%s" % [id, task.text, marker]
Fix column width on short_list
diff --git a/lib/tasks/pull_requests.rake b/lib/tasks/pull_requests.rake index abc1234..def5678 100644 --- a/lib/tasks/pull_requests.rake +++ b/lib/tasks/pull_requests.rake @@ -20,3 +20,11 @@ user.download_pull_requests(load_user.token) rescue nil end end + +desc 'Clean the pulls with empty link' +task :clean_empty_link_pulls => :environment do + PullRequest.year(CURRENT_YEAR).where('issue_url' => nil).each do |pr| + pr.gifts.destroy_all + pr.destroy + end +end
Clean PRs with empty link [fixes #388]
diff --git a/lib/multi_dir.rb b/lib/multi_dir.rb index abc1234..def5678 100644 --- a/lib/multi_dir.rb +++ b/lib/multi_dir.rb @@ -1,3 +1,4 @@+require 'active_support/core_ext/kernel/singleton_class' require 'active_support/core_ext/hash/keys' require 'multi_dir/version'
Revert "Remove AC singleton_class polyfil." This reverts commit c05840f7f00d676f00e0971f828faa09f2d76e8b.
diff --git a/lib/rubbr/cli.rb b/lib/rubbr/cli.rb index abc1234..def5678 100644 --- a/lib/rubbr/cli.rb +++ b/lib/rubbr/cli.rb @@ -19,7 +19,7 @@ end def color?(msg, code) - Rubbr.options[:color] ? "#{code}#{msg}" : msg + Rubbr.options[:color] ? "#{code}#{msg}\e[0m" : msg end def disable_stdout
Reset color after outputting color message
diff --git a/lib/shibaraku.rb b/lib/shibaraku.rb index abc1234..def5678 100644 --- a/lib/shibaraku.rb +++ b/lib/shibaraku.rb @@ -4,4 +4,6 @@ module Shibaraku end -ActiveRecord::Base.include(Shibaraku::ActiveRecordExt) +ActiveSupport.on_load :active_record do + ActiveRecord::Base.include(Shibaraku::ActiveRecordExt) +end
Use ActiveSupport lazy load hook to initialize ActiveRecord Fix breaking `active_record.belongs_to_required_by_default` configuration.
diff --git a/lib/backlog_kit/client/notification.rb b/lib/backlog_kit/client/notification.rb index abc1234..def5678 100644 --- a/lib/backlog_kit/client/notification.rb +++ b/lib/backlog_kit/client/notification.rb @@ -1,18 +1,34 @@ module BacklogKit class Client module Notification + + # Get list of own notifications + # + # @param params [Hash] Request parameters + # @return [BacklogKit::Response] List of notifications def get_notifications(params = {}) get('notifications', params) end + # Get number of own notifications + # + # @param params [Hash] Request parameters + # @return [BacklogKit::Response] Number of notifications def get_notification_count(params = {}) get('notifications/count', params) end + # Reset unread notification count + # + # @return [BacklogKit::Response] Number of notifications def reset_unread_notification_count post('notifications/markAsRead') end + # Mark a notification as read + # + # @param notification_id [Integer, String] Notification id + # @return [BacklogKit::Response] No content response def mark_as_read_notification(notification_id) post("notifications/#{notification_id}/markAsRead") end
Add documentation for the Notification API
diff --git a/lib/cache_comment/comment_formatter.rb b/lib/cache_comment/comment_formatter.rb index abc1234..def5678 100644 --- a/lib/cache_comment/comment_formatter.rb +++ b/lib/cache_comment/comment_formatter.rb @@ -20,7 +20,9 @@ end def start_regex - Regexp.new start.gsub(@time.to_s, '.*').gsub((@time + @options[:expires_in]).to_s, '.*') + regexp = start.gsub(@time.to_s, '.*') + regexp.gsub!((@time + @options[:expires_in]).to_s, '.*') if @options[:expires_in] + Regexp.new regexp end def end
Fix regexp for cache without expiry
diff --git a/lib/kumo_dockercloud/console_jockey.rb b/lib/kumo_dockercloud/console_jockey.rb index abc1234..def5678 100644 --- a/lib/kumo_dockercloud/console_jockey.rb +++ b/lib/kumo_dockercloud/console_jockey.rb @@ -27,7 +27,10 @@ rescue status = false end - status == "yes" + + proceed = status == "yes" + proceed ? puts('Proceeding.') : puts('Aborted!') + proceed end end end
Add feedback after user enters yes, no or timesout
diff --git a/lib/libdolt/gitorious_repo_resolver.rb b/lib/libdolt/gitorious_repo_resolver.rb index abc1234..def5678 100644 --- a/lib/libdolt/gitorious_repo_resolver.rb +++ b/lib/libdolt/gitorious_repo_resolver.rb @@ -0,0 +1,29 @@+# encoding: utf-8 +#-- +# Copyright (C) 2012 Gitorious AS +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +#++ + +module Dolt + class GitoriousRepoResolver + def initialize(repository) + @repository = repository + end + + def resolve(repo) + Dolt::Git::Repository.new(@repository.full_repository_path) + end + end +end
Add very simple Gitorious repo resolver
diff --git a/lib/netsuite/records/pricing_matrix.rb b/lib/netsuite/records/pricing_matrix.rb index abc1234..def5678 100644 --- a/lib/netsuite/records/pricing_matrix.rb +++ b/lib/netsuite/records/pricing_matrix.rb @@ -1,23 +1,11 @@ module NetSuite module Records - class PricingMatrix + class PricingMatrix < Support::Sublist include Namespaces::PlatformCore - def initialize(attributes = {}) - attributes[:pricing] = [attributes[:pricing]] unless - attributes[:pricing].is_a? Array - attributes[:pricing].each do |pricing| - prices << RecordRef.new(pricing) - end if attributes[:pricing] - end + sublist :pricing, RecordRef - def prices - @prices ||= [] - end - - def to_record - { "#{record_namespace}:item" => prices.map(&:to_record) } - end + alias :prices :pricing end end end
Use sublist for pricing matrix If pricing matrix was nil in the XML response, a corrupted pricing matrix item would be contained in `prices`
diff --git a/spec/i18n_spec.rb b/spec/i18n_spec.rb index abc1234..def5678 100644 --- a/spec/i18n_spec.rb +++ b/spec/i18n_spec.rb @@ -6,13 +6,21 @@ let(:missing_keys) { i18n.missing_keys } let(:unused_keys) { i18n.unused_keys } + let(:missing_keys_message) do + "Missing #{missing_keys.leaves.count} i18n keys, run " \ + "`i18n-tasks missing` to show them" + end + + let(:unused_keys_message) do + "#{unused_keys.leaves.count} unused i18n keys, run " \ + "`i18n-tasks unused` to show them" + end + it "does not have missing keys" do - expect(missing_keys).to be_empty, - "Missing #{missing_keys.leaves.count} i18n keys, run `i18n-tasks missing` to show them" + expect(missing_keys).to be_empty, missing_keys_message end it "does not have unused keys" do - expect(unused_keys).to be_empty, - "#{unused_keys.leaves.count} unused i18n keys, run `i18n-tasks unused` to show them" + expect(unused_keys).to be_empty, unused_keys_message end end
Style/AlignParameters: Align the parameters of a method call if they span more than one line.
diff --git a/skroutz_api.gemspec b/skroutz_api.gemspec index abc1234..def5678 100644 --- a/skroutz_api.gemspec +++ b/skroutz_api.gemspec @@ -10,7 +10,7 @@ spec.email = ["zorbash@skroutz.gr"] spec.summary = %q{Skroutz API client} spec.description = %q{Ruby API client for Skroutz} - spec.homepage = "https://github.com/skroutz/skroutz_api.rb" + spec.homepage = "https://github.com/skroutz/skroutz.rb" spec.license = "MIT" spec.files = `git ls-files -z`.split("\x0")
Update project homepage in gemspec
diff --git a/test/benchmark/query.rb b/test/benchmark/query.rb index abc1234..def5678 100644 --- a/test/benchmark/query.rb +++ b/test/benchmark/query.rb @@ -0,0 +1,77 @@+$:.unshift File.expand_path('../../../lib',__FILE__) +require 'rubygems' +require 'bench_press' +require 'tiny_tds' +require 'odbc' +require 'odbc_utf8' + +extend BenchPress + +author 'Ken Collins' +summary 'Query everything.' + +reps 1_000 + +@odbc = ODBC.connect ENV['TINYTDS_UNIT_DATASERVER'], 'tinytds', '' +@odbc.use_time = true + +@odbc_utf8 = ODBC_UTF8.connect ENV['TINYTDS_UNIT_DATASERVER'], 'tinytds', '' +@odbc_utf8.use_time = true + +@tinytds = TinyTds::Client.new( + :dataserver => ENV['TINYTDS_UNIT_DATASERVER'], + :username => 'tinytds', + :password => '', + :database => 'tinytds_test', + :appname => 'TinyTds Dev', + :login_timeout => 5, + :timeout => 5 ) + +@query_all = "SELECT * FROM [datatypes]" + + +measure "ODBC (ascii-8bit)" do + h = @odbc.run(@query_all) + h.fetch_all + h.drop +end + +# measure "ODBC (utf8)" do +# h = @odbc_utf8.run(@query_all) +# h.fetch_all +# h.drop +# end + +measure "TinyTDS (row caching)" do + @tinytds.execute(@query_all).each +end + +measure "TinyTDS (no caching)" do + @tinytds.execute(@query_all).each(:cache_rows => false) +end + + + +=begin + +Author: Ken Collins +Date: January 22, 2011 +Summary: Query everything. + +System Information +------------------ + Operating System: Mac OS X 10.6.6 (10J567) + CPU: Intel Core 2 Duo 1.6 GHz + Processor Count: 2 + Memory: 4 GB + ruby 1.8.7 (2010-04-19 patchlevel 253) [i686-darwin10.4.3], MBARI 0x6770, Ruby Enterprise Edition 2010.02 + +"TinyTDS (row caching)" is up to 79% faster over 1,000 repetitions +------------------------------------------------------------------ + + TinyTDS (row caching) 4.90862512588501 secs Fastest + TinyTDS (no caching) 4.91626906394958 secs 0% Slower + ODBC (ascii-8bit) 23.959536075592 secs 79% Slower + +=end +
Add another benchmark that side by sides clients. UTF8 ruby odbc is so buggy it can not even run the test.
diff --git a/pairhost.gemspec b/pairhost.gemspec index abc1234..def5678 100644 --- a/pairhost.gemspec +++ b/pairhost.gemspec @@ -8,14 +8,14 @@ s.authors = ["Larry Karnowski"] s.email = ["larry@hickorywind.org"] s.homepage = "http://www.github.com/karnowski/pairhost" - s.summary = %q{Automate creation of Relevance pairhost EC2 instances.} - s.description = %q{A Vagrant-like command line interface for creating, managing, and using EC2 instances for remote pairing.} + s.summary = %q{Automate creation of Relevance-style pairhost EC2 instances.} + s.description = %q{A Vagrant-like command line interface for creating, managing, and using EC2 instances for remote pairing like we do at Relevance.} s.files = `git ls-files`.split("\n") s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } - s.add_runtime_dependency "fog", "1.1.2" + s.add_runtime_dependency "fog", "1.3.1" s.add_runtime_dependency "thor", "0.14.6" s.add_development_dependency 'rspec', '~> 2.9.0'
Update fog & gem summary/description
diff --git a/lib/embryo/rspec.rb b/lib/embryo/rspec.rb index abc1234..def5678 100644 --- a/lib/embryo/rspec.rb +++ b/lib/embryo/rspec.rb @@ -12,6 +12,7 @@ def spec_helper_data 'RSpec.configure do |config| + config.color = true config.order = :random config.mock_with :rspec do |mocks| mocks.verify_partial_doubles = true
Configure Rspec to use color
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index abc1234..def5678 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -27,11 +27,12 @@ end end - Given(:container_root) { find('body') } - Given(:container) { Container.new(root: container_root) } + Given(:container_class) { Container } + Given(:container_root) { find('body') } + Given(:container) { container_class.new(root: container_root) } - Given(:path) { path } - Given { visit path } + Given(:path) { path } + Given { visit path } after :all do SaladApp.reset!
[spec] Make default container class name configurable.
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index abc1234..def5678 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -12,7 +12,11 @@ require 'simplecov' require 'simplecov-rcov' SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter - SimpleCov.start + SimpleCov.start do + add_filter '/vendor/' + add_filter '/spec/' + add_group 'lib', 'lib' + end end require 'rails_core_extensions'
Use absolute syntax on filters to avoid matching parent directories: e.g. /home/spec/rails_core_extensions/lib accidently matches spec when only intending to match spec within rails_core_extensions directory
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index abc1234..def5678 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -9,7 +9,7 @@ app = DolphyApp.app do DolphyApp.router do get '/' do - haml :index, body: "Hello" + haml :index, { title: "booyah!", body: "Hello" } end post '/post' do
Add title to test app.
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index abc1234..def5678 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -7,7 +7,7 @@ require 'rspec' require 'factory_girl' -require_relative 'factories' +require 'factories' if RUBY_VERSION >= '1.9'
Use require instead of require_relative
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index abc1234..def5678 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -14,4 +14,15 @@ RSpec.configure do |config| config.order = 'random' + # Configure the DatabaseCleaner + config.before(:suite) do + DatabaseCleaner.strategy = :transaction + DatabaseCleaner.clean_with(:truncation) + end + + config.around(:each) do |example| + DatabaseCleaner.cleaning do + example.run + end + end end
Add database cleanup to suite
diff --git a/lib/rack_tracker.rb b/lib/rack_tracker.rb index abc1234..def5678 100644 --- a/lib/rack_tracker.rb +++ b/lib/rack_tracker.rb @@ -14,6 +14,14 @@ include Rack::Caller include Rack::TrackerPlugins + # + # All Rack::Tracker class variables are settable via this configuration method. + # + # This means that configuration settings are dynamically added dependant on + # what variables you expose via your plugins to Rack::Tracker. + # + # TODO: Refactor so only specific class variables, possibly only setters, are exposed via our plugins. + # class << self def configure yield self
Add notes for the configure block
diff --git a/lib/saves/backup.rb b/lib/saves/backup.rb index abc1234..def5678 100644 --- a/lib/saves/backup.rb +++ b/lib/saves/backup.rb @@ -0,0 +1,81 @@+require 'zlib' +require 'archive/tar/minitar' + +module Saves + class Backup + attr_reader :game, :backup + + def initialize(game) + @game = game + end + + def execute + # We can't backup anything if no files exist + return unless source_exists? + + # Create the directory that we'll place backups in + create_destination + + # Copy the data into a temporary backup directory ... + temp_directory = copy_to_temp_directory(@game.source) + + # ... Then compress the files in the destination specified in the configuration + compress_files(temp_directory, @game.destination) + end + + def filename + return unless @game + prefix = @game.filename + # YYMMDD_HHMMSS + timestamp = Time.now.strftime("%Y%m%d_%H%M%S") + "#{prefix}_#{timestamp}" + end + + def extension + "tar.gz" + end + + def source_exists? + return false unless @game + File.exist? @game.source + end + + def backup_destination_exists? + return false unless @game + File.exist? @game.destination + end + + private + + # private: Create the directory the backup will eventually reside in + def create_destination + return unless @game + # Don't attempt to create the + return if backup_destination_exists? + + FileUtils.mkdir_p(@game.destination) + end + + # public: Copy the files into a temporary directory + # An intermediate directory is used to increase the atomicity of the compression + def copy_to_temp_directory(source_directory) + temp_directory = Dir.mktmpdir + FileUtils.cp_r(source_directory, temp_directory) + + temp_directory + end + + # Compress the + def compress_files(directory_to_compress, destination) + backup_directory = @game.destination + + backup_file = File.join(backup_directory, filename) + # If an extension is provided, append it to the filename + backup_file = "#{backup_file}.#{extension}" if extension + + # Write to the backup file with GZip compression + backup_writer = Zlib::GzipWriter.new(File.open(backup_file, 'wb')) + Archive::Tar::Minitar.pack(directory_to_compress, backup_writer) + end + end +end
Add code for baking up the saves
diff --git a/lib/twitter-vine.rb b/lib/twitter-vine.rb index abc1234..def5678 100644 --- a/lib/twitter-vine.rb +++ b/lib/twitter-vine.rb @@ -1,6 +1,7 @@ require 'twitter-vine/version' require 'twitter' require 'nokogiri' +require 'twitter-vine/client' module TwitterVine DEBUG = false
Fix broken Twitter::Client by requiring client.rb
diff --git a/libraries/sysctl.rb b/libraries/sysctl.rb index abc1234..def5678 100644 --- a/libraries/sysctl.rb +++ b/libraries/sysctl.rb @@ -16,7 +16,7 @@ prefix += '.' unless prefix.empty? v.map { |key, value| compile_attr("#{prefix}#{key}", value) }.flatten.sort else - raise Chef::Exceptions::UnsupportedAction, "Sysctl cookbook can't handle values of type: #{v.class}" + fail Chef::Exceptions::UnsupportedAction, "Sysctl cookbook can't handle values of type: #{v.class}" end end end
Use fail instead of raise
diff --git a/link_shrink.gemspec b/link_shrink.gemspec index abc1234..def5678 100644 --- a/link_shrink.gemspec +++ b/link_shrink.gemspec @@ -22,6 +22,6 @@ spec.add_dependency 'typhoeus', '~> 0.6.3' spec.add_development_dependency 'bundler', '~> 1.3' - spec.add_development_dependency 'rspec', '~> 2.13.0' + spec.add_development_dependency 'rspec', '~> 2.14.0' spec.add_development_dependency 'rake' end
Update gemspec dev_dependency for new versions of rspec
diff --git a/AvitoMediaPicker.podspec b/AvitoMediaPicker.podspec index abc1234..def5678 100644 --- a/AvitoMediaPicker.podspec +++ b/AvitoMediaPicker.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = 'AvitoMediaPicker' s.module_name = 'AvitoMediaPicker' - s.version = '0.0.8' + s.version = '0.0.0' s.summary = 'Avito Media Picker by Avito' s.homepage = 'http://stash.msk.avito.ru/projects/MA/repos/avito-ios-media-picker' s.license = 'Avito'
Change podspec version to 0.0.0
diff --git a/test/data/models.rb b/test/data/models.rb index abc1234..def5678 100644 --- a/test/data/models.rb +++ b/test/data/models.rb @@ -56,7 +56,7 @@ end class UppercaseTableName < ActiveRecord::Base - set_table_name "UPPERCASE_TABLE_NAME" + self.table_name = "UPPERCASE_TABLE_NAME" translates :name end
Fix for deprecation in Rails 3.2
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 @@ -6,4 +6,4 @@ gem 'minitest' require 'minitest/autorun' require 'minitest/pride' - +require 'pry'
Add pry to test helper
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 @@ -6,6 +6,9 @@ require 'database_cleaner' require 'database_cleaner/active_record/base' require 'awesome_print' +require 'minitest/reporters' + +MiniTest::Reporters.use! Rails.backtrace_cleaner.remove_silencers!
Add support for Rubymine test/unit reporter
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,5 +1,4 @@-ENV["RAILS_ENV"] = "test" - +ENV["RAILS_ENV"] ||= "test" require File.expand_path('../../config/environment', __FILE__) require 'minitest/autorun' @@ -41,21 +40,6 @@ end end -# why isn't clearance doing this for us!? -class ActionController::TestCase - setup do - @request.env[:clearance] = Clearance::Session.new(@request.env) - end -end - class SystemTest < ActionDispatch::IntegrationTest include Capybara::DSL - - def setup - Capybara.app = Gemcutter::Application - end - - def teardown - Capybara.reset_sessions! - end end
Remove some unecessary test setup clearance/test_unit , should take care of the clearance session setup capybara/rails , should take care of the capybara app setup
diff --git a/app/controllers/questions_controller.rb b/app/controllers/questions_controller.rb index abc1234..def5678 100644 --- a/app/controllers/questions_controller.rb +++ b/app/controllers/questions_controller.rb @@ -35,3 +35,20 @@ erb :'/questions/show' end end + +get '/questions/:id/edit' do + @question = Question.find(params[:id]) + erb :'/questions/edit' +end + +put '/questions/:id' do + @question = Question.find(params[:id]) + @question.assign_attributes(params[:question]) + + if question.save + redirect "/questions/#{@question.id}" + else + @errors = question.errors.full_messages + erb :'/questions/edit' + end +end
Add route for editing question
diff --git a/app/admin/dashboard.rb b/app/admin/dashboard.rb index abc1234..def5678 100644 --- a/app/admin/dashboard.rb +++ b/app/admin/dashboard.rb @@ -1,5 +1,4 @@ ActiveAdmin.register_page "Dashboard" do - menu :priority => 0, :label => proc{ I18n.t("active_admin.dashboard") } content :title => proc{ I18n.t("active_admin.dashboard") } do @@ -23,5 +22,6 @@ end end end - end # content + end end +
Add some info to dashbard
diff --git a/app/models/gem_typo.rb b/app/models/gem_typo.rb index abc1234..def5678 100644 --- a/app/models/gem_typo.rb +++ b/app/models/gem_typo.rb @@ -14,6 +14,8 @@ end def protected_typo? + return false + return false if @rubygem_name.size < GemTypo::SIZE_THRESHOLD gem_typo_exceptions = GemTypoException.all.pluck(:name)
Disable typo protection for now This is a good idea, but it's blocking a lot of legitimate gems, and it's too hard for our limited support time to go to manually allowing gems through. A Slack feed of gems that look like they might be typos to allow humans to review would be a more practical way to implement this sort of idea. Better yet, a Slack message with a single button to yank the gem and/or the user who pushed the gem. :looks hopefully in @colby-swandale's direction:
diff --git a/app/models/key_pair.rb b/app/models/key_pair.rb index abc1234..def5678 100644 --- a/app/models/key_pair.rb +++ b/app/models/key_pair.rb @@ -23,7 +23,7 @@ private_key_path = dir_path + 'id_rsa' public_key_path = dir_path + 'id_rsa.pub' - unless system("ssh-keygen -f #{private_key_path} -P '' -t rsa -q") + unless system("ssh-keygen -f #{private_key_path} -P '' -t rsa -m pem -q") raise 'RSA key pair generation failed' end
Enforce PEM format when generating private key
diff --git a/app/controllers/calendars_controller.rb b/app/controllers/calendars_controller.rb index abc1234..def5678 100644 --- a/app/controllers/calendars_controller.rb +++ b/app/controllers/calendars_controller.rb @@ -2,38 +2,45 @@ class CalendarsController < ApplicationController def show - @categories = Category.all + raise ActionController::RoutingError.new('Not Found') if current_region.nil? - # Die Monate, die angezeigt werden - begin - @start_date = params[:start].present? ? Date.parse(params[:start]) : Date.today - rescue ArgumentError - @start_date = Date.today - flash.now[:error] = 'Das war kein gültiges Datum... Wir zeigen dir mal den Kalender ab heute' - end + @categories = Category.all + @start_date = determine_start_date + @months = generate_month_list + @dates = generate_day_list + @single_events = generate_single_event_list + end - @months = [] - 8.times { |i| @months << (@start_date + i.months) } - @months = @months.map { |month| MonthPresenter.new(month) } - @months.first.active = true + private - # TODO: This is just for the design, needs to be implemented for real - @dates = (Date.today .. 5.days.from_now).map do |date| + def determine_start_date + params[:start].present? ? Date.parse(params[:start]) : Date.today + rescue ArgumentError + Date.today + end + + def generate_month_list + months = (0..8).map { |i| MonthPresenter.new(@start_date + i.months) } + months.first.active = true + months + end + + # TODO: This is just for the design, needs to be implemented for real + def generate_day_list + dates = (Date.today .. 5.days.from_now).map do |date| DayPresenter.new({ weekday: date.strftime("%A")[0,2], day: date.day, has_events: (rand < 0.6) }) end - @dates.first.active = true - - if current_region.nil? - raise ActionController::RoutingError.new('Not Found') - end - - @single_events = SingleEvent.in_next_from(4.weeks, @start_date).in_region(@region) - @single_events.to_a.select! { |single_event| single_event.is_for_user? current_user } if current_user - @single_events.sort! + dates.first.active = true + dates end + def generate_single_event_list + single_events = SingleEvent.in_next_from(4.weeks, @start_date).in_region(@region) + single_events.to_a.select! { |single_event| single_event.is_for_user? current_user } if current_user + single_events.sort + end end
Make the calendars controller a little easier to understand This shows some points for future extractions
diff --git a/test/test_header.rb b/test/test_header.rb index abc1234..def5678 100644 --- a/test/test_header.rb +++ b/test/test_header.rb @@ -0,0 +1,22 @@+require 'minitest/autorun' +require 'node' +require 'header' + +class TestHeader < MiniTest::Test + + def setup + # Initialize nodes + @header = Header.new + @node_1 = Node.new + @node_2 = Node.new + + # Link to form a column + @header.link({ down: @node_1, up: @node_2 }) + @node_1.link({ down: @node_2, up: @header }) + @node_2.link({ down: @header, up: @node_1 }) + end + + def test_header_total_equals_sum_of_nodes_in_column + assert_equal 2, @header.total + end +end
Test added for calculating header node total
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 @@ -4,8 +4,9 @@ ENV["RAILS_ENV"] = "test" require File.expand_path("../../test/dummy/config/environment.rb", __FILE__) + ActiveRecord::Migration.verbose = false -ENV['VERBOSE'] = 'false' +verbosity, ENV['VERBOSE'] = ENV['VERBOSE'], 'false' if ActiveRecord::Migrator.respond_to? :migrate ActiveRecord::Migrator.migrate(ActiveRecord::Migrator.migrations_paths = [File.expand_path("../../test/dummy/db/migrate", __FILE__)]) else @@ -14,7 +15,7 @@ ActiveRecord::Tasks::DatabaseTasks.create_current 'test' ActiveRecord::Tasks::DatabaseTasks.migrate end -ENV['VERBOSE'] = nil +ENV['VERBOSE'] = verbosity require 'test/unit/rails/test_help'
Return of the verbosity of Shut Up 'n Play Yer Migrations
diff --git a/app/models/coursewareable/assignment.rb b/app/models/coursewareable/assignment.rb index abc1234..def5678 100644 --- a/app/models/coursewareable/assignment.rb +++ b/app/models/coursewareable/assignment.rb @@ -7,7 +7,7 @@ extend FriendlyId include PublicActivity::Model - attr_accessible :content, :title + attr_accessible :content, :title, :quiz # Serialize quiz values as a hash serialize :quiz, JSON
Add quiz attr to accessible list.
diff --git a/app/models/notification_subscription.rb b/app/models/notification_subscription.rb index abc1234..def5678 100644 --- a/app/models/notification_subscription.rb +++ b/app/models/notification_subscription.rb @@ -25,6 +25,10 @@ !self.confirmation_sent_at.nil? end + def override_last_email_sent_at_to!(datetime) + self.update_attribute(:last_email_sent_at, datetime) + end + private def send_confirmation_email
Add method to NotificationSubscription that allows overriding the last_email_sent_at attribute
diff --git a/lib/bigcommerce_api/option_set_option.rb b/lib/bigcommerce_api/option_set_option.rb index abc1234..def5678 100644 --- a/lib/bigcommerce_api/option_set_option.rb +++ b/lib/bigcommerce_api/option_set_option.rb @@ -18,5 +18,21 @@ def parent 'option_set' end + + def find_for_reload + self.class.find(self.option_set_id, self.id) + end + + class << self + def all(option_set_id, params={}) + resources = BigcommerceAPI::Base.get("/option_sets/#{option_set_id}/options", query: date_adjust(params)) + (resources.success? and !resources.nil?) ? resources.collect{|r| self.new(r)} : [] + end + + def find(option_set_id, id) + r = BigcommerceAPI::Base.get("/option_sets/#{option_set_id}/options/#{id}") + (r.success? and !r.nil?) ? self.new(r) : nil + end + end end end
Add custom find query for option set options
diff --git a/lib/brakeman/processors/gem_processor.rb b/lib/brakeman/processors/gem_processor.rb index abc1234..def5678 100644 --- a/lib/brakeman/processors/gem_processor.rb +++ b/lib/brakeman/processors/gem_processor.rb @@ -40,7 +40,7 @@ end def get_rails_version gem_lock - if gem_lock =~ /\srails \((\d+.\d+.\d+)\)$/ + if gem_lock =~ /\srails \((\d+.\d+.\d+.*)\)$/ @tracker.config[:rails_version] = $1 end end
Allow pre-release Rails versions in Gemfile.lock
diff --git a/lib/compare_linker/github_link_finder.rb b/lib/compare_linker/github_link_finder.rb index abc1234..def5678 100644 --- a/lib/compare_linker/github_link_finder.rb +++ b/lib/compare_linker/github_link_finder.rb @@ -1,5 +1,6 @@ require "json" require "httpclient" +require "net/http" class CompareLinker class GithubLinkFinder @@ -22,6 +23,7 @@ if github_url.nil? @homepage_uri = gem_info["homepage_uri"] else + github_url = redirect_url(github_url) _, @repo_owner, @repo_name = github_url.match(%r!github\.com/([^/]+)/([^/]+)!).to_a end end @@ -29,5 +31,20 @@ def repo_full_name "#{@repo_owner}/#{repo_name}" end + + private + + def redirect_url(url, limit = 5) + raise ArgumentError, 'HTTP redirect too deep' if limit <= 0 + response = Net::HTTP.get_response(URI.parse(url)) + case response + when Net::HTTPSuccess + url + when Net::HTTPRedirection + redirect_url(response['location'], limit - 1) + else + raise ItemNotFound + end + end end end
Fix raise error which github url is redirect one Ex. https://rubygems.org/gems/chef
diff --git a/lib/sequent/core/helpers/self_applier.rb b/lib/sequent/core/helpers/self_applier.rb index abc1234..def5678 100644 --- a/lib/sequent/core/helpers/self_applier.rb +++ b/lib/sequent/core/helpers/self_applier.rb @@ -19,12 +19,11 @@ module ClassMethods def on(*message_classes, &block) - @message_mapping ||= {} - message_classes.each { |message_class| @message_mapping[message_class] = block } + message_classes.each { |message_class| message_mapping[message_class] = block } end def message_mapping - @message_mapping || {} + @@message_mapping ||= {} end end @@ -42,4 +41,3 @@ end end end -
Fix handling events on super classes Use a class hierarchy variable to track event message handlers so that a super class can handle certain events. Specifically this is necessary to handle `SnapshotEvent` in `AggregateRoot`.
diff --git a/app/models/source.rb b/app/models/source.rb index abc1234..def5678 100644 --- a/app/models/source.rb +++ b/app/models/source.rb @@ -1,8 +1,8 @@ class Source < ApplicationRecord class UnknownRankable < StandardError; end has_many :imports - validates :name, presence: true + validates :name, presence: true, uniqueness: true validates :email_rank, presence: true, uniqueness: true validates :location_rank, presence: true, uniqueness: true validates :organization_name_rank, presence: true, uniqueness: true
Add uniqueness validation to Source
diff --git a/app/models/status.rb b/app/models/status.rb index abc1234..def5678 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -1,3 +1,11 @@ class Status < ActiveRecord::Base belongs_to :user + + def to_s + if lcd.nil? + "#{text}" + else + "#{text} [#{lcd}]" + end + end end
Add a to_s method to the Status model Before this method was defined, just doing a <%= status %> showed a #<Status::x123...> because that was the default Ruby inspection!
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index abc1234..def5678 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -8,6 +8,7 @@ require "uri" def description_text(text) + text = text.to_s URI.extract(text, ['http', 'https']).uniq.each do |url| sub_text = "" sub_text << "<a href=" << url << " target=\"_blank\">" << url << "</a>"
Support nil description of user.
diff --git a/telemetry.gemspec b/telemetry.gemspec index abc1234..def5678 100644 --- a/telemetry.gemspec +++ b/telemetry.gemspec @@ -1,7 +1,7 @@ # -*- encoding: utf-8 -*- Gem::Specification.new do |s| s.name = 'telemetry' - s.version = '0.1.2' + s.version = '0.1.3' s.summary = 'In-process telemetry based on observers' s.description = ' '
Package version is increased from 0.1.2 to 0.1.3
diff --git a/Casks/silverlight.rb b/Casks/silverlight.rb index abc1234..def5678 100644 --- a/Casks/silverlight.rb +++ b/Casks/silverlight.rb @@ -1,7 +1,7 @@ class Silverlight < Cask - url 'http://silverlight.dlservice.microsoft.com/download/B/A/9/BA94BEC9-5DBC-4B50-BC2B-046A42399067/30214.00/Silverlight.dmg' + url 'http://silverlight.dlservice.microsoft.com/download/D/6/6/D66CF013-1021-437B-9A65-983871CCB3E6/30317.00/Silverlight.dmg' homepage 'http://www.microsoft.com/silverlight/' - version '5.1.30214.0' - sha256 '4b9354d60451b033b4d6695b8d94d8f88663cc8d0b25cebda08b6b4fb0069cba' + version '5.1.30317.0' + sha256 'a425c522f84c8c3b2bcfb5f40abab0f8d67733f824be5c0e383819d06f230007' install 'Silverlight.pkg' end
Update Silverlight to version 5.1.30317
diff --git a/lib/chef/provisioning/machine_spec.rb b/lib/chef/provisioning/machine_spec.rb index abc1234..def5678 100644 --- a/lib/chef/provisioning/machine_spec.rb +++ b/lib/chef/provisioning/machine_spec.rb @@ -21,13 +21,6 @@ def attrs data['normal'] ||= {} data['normal']['chef_provisioning'] ||= {} - end - - # - # Name of the machine. Corresponds to the name in "machine 'name' do" ... - # - def name - data['name'] end #
Use the actual `name` from the superclass, else we get caught in a loop
diff --git a/lib/feidee_utils/record/namespaced.rb b/lib/feidee_utils/record/namespaced.rb index abc1234..def5678 100644 --- a/lib/feidee_utils/record/namespaced.rb +++ b/lib/feidee_utils/record/namespaced.rb @@ -1,3 +1,5 @@+require 'set' + module FeideeUtils class Record module Namespaced
Add require set to namespace.
diff --git a/lib/protobuf/active_record/railtie.rb b/lib/protobuf/active_record/railtie.rb index abc1234..def5678 100644 --- a/lib/protobuf/active_record/railtie.rb +++ b/lib/protobuf/active_record/railtie.rb @@ -1,7 +1,7 @@ module Protobuf module ActiveRecord class Railtie < Rails::Railtie - config.protobuf_activerecord = Protobuf::ActiveRecord.config + config.protobuf_active_record = Protobuf::ActiveRecord.config ActiveSupport.on_load(:active_record) do extend Protobuf::ActiveRecord::LoadHooks if Protobuf::ActiveRecord.config.autoload
Rename the config object to match the gem conventions.
diff --git a/attributes/tomcat.rb b/attributes/tomcat.rb index abc1234..def5678 100644 --- a/attributes/tomcat.rb +++ b/attributes/tomcat.rb @@ -13,5 +13,5 @@ # limitations under the License. override['tomcat']['deploy_manager_apps'] = false -override['tomcat']['java_options'] = '-Djava.awt.headless=true -Xmx512m -XX:+UseConcMarkSweepGC' -override['tomcat']['tomcat_auth'] = false +override['tomcat']['java_options'] = '-Djava.awt.headless=true -Xmx512m -XX:+UseConcMarkSweepGC -Djava.security.egd=file:/dev/./urandom' +override['tomcat']['tomcat_auth'] = falseUsU
Use a non-blocking entropy source to prevent insanely slow startups in Tomcat.
diff --git a/core/spec/ohm-models/graph_user_spec.rb b/core/spec/ohm-models/graph_user_spec.rb index abc1234..def5678 100644 --- a/core/spec/ohm-models/graph_user_spec.rb +++ b/core/spec/ohm-models/graph_user_spec.rb @@ -7,8 +7,8 @@ others end - subject {create :graph_user } - let(:fact) {create(:fact,:created_by => subject)} + subject { create :graph_user } + let(:fact) { create(:fact, created_by: subject) } context "Initially" do context "the subjects channels" do
Use new hash syntax and fix spaces
diff --git a/config/initializers/toot_transformer.rb b/config/initializers/toot_transformer.rb index abc1234..def5678 100644 --- a/config/initializers/toot_transformer.rb +++ b/config/initializers/toot_transformer.rb @@ -1,4 +1,4 @@-if defined?(Rake) || Rails.env.test? +if Rails.env.test? || File.split($0).last == 'rake' Rails.logger.warn { "Using hardcoded values for twitter url length" } TootTransformer::twitter_short_url_length = 23 TootTransformer::twitter_short_url_length_https = 23
Improve rake detection to avoid connecting to twitter
diff --git a/lib/commontator/shared_helper.rb b/lib/commontator/shared_helper.rb index abc1234..def5678 100644 --- a/lib/commontator/shared_helper.rb +++ b/lib/commontator/shared_helper.rb @@ -3,21 +3,16 @@ def commontator_thread(commontable) user = Commontator.current_user_proc.call(self) thread = commontable.thread - + render(:partial => 'commontator/shared/thread', :locals => { :thread => thread, :user => user }).html_safe end def commontator_gravatar_image_tag(user, border = 1, options = {}) - email = Commontator.commontator_email(user) || '' name = Commontator.commontator_name(user) || '' - - base = request.ssl? ? "s://secure" : "://www" - hash = Digest::MD5.hexdigest(email) - url = "http#{base}.gravatar.com/avatar/#{hash}?#{options.to_query}" - - image_tag(url, { :alt => name, + avatar = user.avatar.url(:small) + image_tag(avatar, { :alt => name, :title => name, :border => border }) end
Allow Avatar to simply use a string instead of gravatar use for my own app
diff --git a/test/dummy/app/controllers/application_controller.rb b/test/dummy/app/controllers/application_controller.rb index abc1234..def5678 100644 --- a/test/dummy/app/controllers/application_controller.rb +++ b/test/dummy/app/controllers/application_controller.rb @@ -1,3 +1,10 @@ class ApplicationController < ActionController::Base protect_from_forgery + + #after_filter :flush_metrics_rails + + # manually flush per request + def flush_metrics_rails + Metrics::Rails.flush + end end
Add ability to flush per request for local testing.
diff --git a/lib/feed2email/feed_data_file.rb b/lib/feed2email/feed_data_file.rb index abc1234..def5678 100644 --- a/lib/feed2email/feed_data_file.rb +++ b/lib/feed2email/feed_data_file.rb @@ -9,11 +9,12 @@ end def uri=(new_uri) - if new_uri != uri - remove_file - mark_dirty - @uri = new_uri - end + return if new_uri == uri + + data # load data if not already loaded + remove_file + mark_dirty + @uri = new_uri end def sync
Make sure data is loaded before removing file Otherwise there will be nothing to sync
diff --git a/lib/formalist/output_compiler.rb b/lib/formalist/output_compiler.rb index abc1234..def5678 100644 --- a/lib/formalist/output_compiler.rb +++ b/lib/formalist/output_compiler.rb @@ -1,17 +1,5 @@-require "dry-data" - module Formalist class OutputCompiler - FORM_TYPES = %w[ - bool - date - date_time - decimal - float - int - time - ].freeze - def call(ast) ast.map { |node| visit(node) }.inject(:merge) end @@ -29,9 +17,9 @@ end def visit_field(data) - name, type, display_variant, value, predicates, errors = data + name, _type, _display_variant, value, _predicates, _errors = data - {name => coerce(value, type: type)} + {name => value.to_s} end def visit_group(data) @@ -51,15 +39,5 @@ children.map { |node| visit(node) }.inject(:merge) end - - private - - def coerce(value, type:) - if FORM_TYPES.include?(type) - Dry::Data["form.#{type}"].(value) - else - Dry::Data[type].(value) - end - end end end
Stop coercing form post data in the output compiler Now that we require a schema, we can depend on that for form post data type coercions. Avoiding the coercions here means we also avoid errors due to the naive approach we’d taken so far. This was actually manifested in the formalist-demo app as errors when trying to post the demo form with empty values for the date and date_time fields. Now we just pass every form post value through to the schema as the posted value, or a blank string, and let it coerce things more appropriately.
diff --git a/lib/kosmos/packages/hyperedit.rb b/lib/kosmos/packages/hyperedit.rb index abc1234..def5678 100644 --- a/lib/kosmos/packages/hyperedit.rb +++ b/lib/kosmos/packages/hyperedit.rb @@ -0,0 +1,8 @@+class Hyperedit < Kosmos::Package + title 'Hyperedit' + url 'http://www.kerbaltekaerospace.com/?download=hyperedit%2FHyperEdit-1.2.4.2_for-KSP-0.21.1%2B.zip' + + def install + merge_directory 'GameData' + end +end
Add a package for Hyperedit.
diff --git a/lib/specinfra/command/freebsd.rb b/lib/specinfra/command/freebsd.rb index abc1234..def5678 100644 --- a/lib/specinfra/command/freebsd.rb +++ b/lib/specinfra/command/freebsd.rb @@ -26,6 +26,10 @@ def get_mode(file) "stat -f%Lp #{escape(file)}" end + + def install(package) + "pkg_add -r install #{package}" + end end end end
Support `install` command on FreeBSD
diff --git a/Fibonacci_series/Ruby/jcla1/fib_test.rb b/Fibonacci_series/Ruby/jcla1/fib_test.rb index abc1234..def5678 100644 --- a/Fibonacci_series/Ruby/jcla1/fib_test.rb +++ b/Fibonacci_series/Ruby/jcla1/fib_test.rb @@ -0,0 +1,56 @@+require 'rspec' +require './fib' + +describe '#fib(n)' do + context 'When given 0' do + let(:value) { fib(0) } + + it 'returns 0' do + expect(value).to eq 0 + end + end + + context 'When given 33' do + let (:value) { fib(33) } + + it 'returns 3524578' do + expect(value).to eq 3524578 + end + end +end + +describe '#fib_tco(n, a=0, b=1)' do + context 'When given 0' do + let(:value) { fib_tco(0) } + + it 'returns 0' do + expect(value).to eq 0 + end + end + + context 'When given 33' do + let(:value) { fib_tco(33) } + + it 'returns 3524578' do + expect(value).to eq 3524578 + end + end +end + +describe '#fib_loop(n)' do + context 'When given 0' do + let(:value) { fib_loop(0) } + + it 'returns 0' do + expect(value).to eq 0 + end + end + + context 'When given 33' do + let(:value) { fib_loop(33) } + + it 'returns 3524578' do + expect(value).to eq 3524578 + end + end +end
Add spec to test fib.rb.
diff --git a/Casks/apache-directory-studio.rb b/Casks/apache-directory-studio.rb index abc1234..def5678 100644 --- a/Casks/apache-directory-studio.rb +++ b/Casks/apache-directory-studio.rb @@ -1,6 +1,6 @@ cask 'apache-directory-studio' do - version '2.0.0.v20150606-M9' - sha256 '9eca84d081a500fec84943600723782a6edac05eeab6791fe8a964e49c6d834e' + version '2.0.0.v20151221-M10' + sha256 'b27d116ea6b79268a74ae5057bd542813e186a888c2b4abedd6a2eb83fc2a0d5' # apache.org is the official download host per the vendor homepage url "http://www.us.apache.org/dist/directory/studio/#{version}/ApacheDirectoryStudio-#{version}-macosx.cocoa.x86_64.tar.gz"
Update Apache Directory Studio (2.0.0.v20151221-M10)
diff --git a/Library/Homebrew/unpack_strategy/air.rb b/Library/Homebrew/unpack_strategy/air.rb index abc1234..def5678 100644 --- a/Library/Homebrew/unpack_strategy/air.rb +++ b/Library/Homebrew/unpack_strategy/air.rb @@ -5,7 +5,8 @@ using Magic def self.can_extract?(path) - path.extname == ".air" + mime_type = "application/vnd.adobe.air-application-installer-package+zip" + path.magic_number.match?(/.{59}#{Regexp.escape(mime_type)}/) end def dependencies
Use magic number for Adobe Air.
diff --git a/SwiftJSONRPC.podspec b/SwiftJSONRPC.podspec index abc1234..def5678 100644 --- a/SwiftJSONRPC.podspec +++ b/SwiftJSONRPC.podspec @@ -7,7 +7,7 @@ s.author = { "Denis Kolyasev" => "kolyasev@gmail.com" } s.source = { :git => "https://github.com/kolyasev/SwiftJSONRPC.git", :tag => s.version.to_s } - s.ios.deployment_target = "8.0" + s.ios.deployment_target = "10.0" s.osx.deployment_target = "10.12" s.requires_arc = true
Fix iOS deployment target version in podspec
diff --git a/hubdown.gemspec b/hubdown.gemspec index abc1234..def5678 100644 --- a/hubdown.gemspec +++ b/hubdown.gemspec @@ -12,7 +12,7 @@ gem.summary = %q{CLI for GitHub Flavored markdown to html conversion} gem.homepage = "https://github.com/knomedia/hubdown" - gem.add_dependency 'github/markdown' + gem.add_dependency 'github-markdown' gem.add_dependency 'mixlib-cli' gem.add_dependency 'paint'
Correct syntax for gh markdown
diff --git a/lib/netsuite/records/bin_number_list.rb b/lib/netsuite/records/bin_number_list.rb index abc1234..def5678 100644 --- a/lib/netsuite/records/bin_number_list.rb +++ b/lib/netsuite/records/bin_number_list.rb @@ -2,7 +2,7 @@ module Records # TODO this is fairly messy: shouldn't mix multiple classes in one file # might be possible to trash the GenericField as well - + class GenericField include Support::Attributes include Support::Fields @@ -13,36 +13,18 @@ end class BinNumber < GenericField + include Support::Records end - class BinNumberList - include Support::Fields + class BinNumberList < Support::Sublist include Namespaces::PlatformCore # include Namespaces::ListAcct - fields :bin_number + sublist :bin_number, BinNumber - def initialize(attributes = {}) - initialize_from_attributes_hash(attributes) - end + alias :bin_numbers :bin_number - def bin_number=(items) - case items - when Hash - self.bin_numbers << BinNumber.new(items) - when Array - items.each { |item| self.bin_numbers << BinNumber.new(item) } - end - end - - def bin_numbers - @bin_numbers ||= [] - end - - def to_record - { "#{record_namespace}:item" => bin_numbers.map(&:to_record) } - end end end end
Refactor BinNumberList to use Support::Lists
diff --git a/lib/rmre/active_record/schema_dumper.rb b/lib/rmre/active_record/schema_dumper.rb index abc1234..def5678 100644 --- a/lib/rmre/active_record/schema_dumper.rb +++ b/lib/rmre/active_record/schema_dumper.rb @@ -23,13 +23,5 @@ trailer(stream) stream end - - def self.dump_table(table_name, connection = ActiveRecord::Base.connection, stream=STDOUT) - new(connection).dump_table(table_name, stream) - end - - def dump_table(table_name, stream) - table(table_name, stream) - end end end
Revert - we will not work with table dumps
diff --git a/swipe-rails.gemspec b/swipe-rails.gemspec index abc1234..def5678 100644 --- a/swipe-rails.gemspec +++ b/swipe-rails.gemspec @@ -14,7 +14,7 @@ gem.name = "swipe-rails" gem.require_paths = ["lib"] gem.version = SwipeRails::VERSION - gem.add_dependency 'rails', '~> 3.2.13' + gem.add_dependency 'rails', '>= 3.2.13' gem.add_dependency 'json', '~> 1.8.1' gem.add_development_dependency 'sqlite3' gem.add_development_dependency 'minitest', '~> 4.0'
Allow to be used with Rails 4
diff --git a/EventEmitter.podspec b/EventEmitter.podspec index abc1234..def5678 100644 --- a/EventEmitter.podspec +++ b/EventEmitter.podspec @@ -0,0 +1,16 @@+Pod::Spec.new do |spec| + spec.name = 'EventEmitter' + spec.summary = 'Node.js inspired EventEmitter for Objective C.' + spec.version = '0.1.2' + spec.license = { :type => 'Apache License, Version 2.0', :file => 'LICENSE.txt' } + spec.homepage = 'https://github.com/jerolimov/EventEmitter' + spec.author = "Christoph Jerolimov" + spec.social_media_url = "http://twitter.com/jerolimov" + + spec.source = { :git => 'https://github.com/jerolimov/EventEmitter.git', :tag => "#{spec.version}" } + spec.ios.deployment_target = "5.0" + spec.osx.deployment_target = "10.7" + spec.watchos.deployment_target = "2.0" + spec.tvos.deployment_target = "9.0" + spec.source_files = 'EventEmitter/*.{h,m}' +end
Add local CocoaPods spec file.
diff --git a/rails/app/controllers/home_controller.rb b/rails/app/controllers/home_controller.rb index abc1234..def5678 100644 --- a/rails/app/controllers/home_controller.rb +++ b/rails/app/controllers/home_controller.rb @@ -9,11 +9,10 @@ end def search - @postcode = params[:query] if params[:query] =~ /^\d{4}$/ - - electorates = JSON.parse(open("http://www.openaustralia.org/api/getDivisions?output=js&key=CcV3KBBX2Em7GQeV3RA8qzgS&postcode=#{@postcode}").read) - - if electorates.count == 1 + if params[:query] =~ /^\d{4}$/ + @postcode = params[:query] + electorates = JSON.parse(open("http://www.openaustralia.org/api/getDivisions?output=js&key=CcV3KBBX2Em7GQeV3RA8qzgS&postcode=#{@postcode}").read) + raise unless electorates.count == 1 # FIXME: We should redirect but this is how the PHP app does it currently render nothing: true, location: view_context.electorate_path(Member.find_by_constituency(electorates.first['name'])) end
Rework to make it clearer what this is doing
diff --git a/rb/lib/selenium/webdriver/common/wait.rb b/rb/lib/selenium/webdriver/common/wait.rb index abc1234..def5678 100644 --- a/rb/lib/selenium/webdriver/common/wait.rb +++ b/rb/lib/selenium/webdriver/common/wait.rb @@ -3,14 +3,14 @@ class Wait DEFAULT_TIMEOUT = 5 - DEFAULT_INTERVAL = 0.5 + DEFAULT_INTERVAL = 0.2 # # Create a new Wait instance # # @param [Hash] opts Options for this instance # @option opts [Numeric] :timeout (5) Seconds to wait before timing out. - # @option opts [Numeric] :interval (0.5) Seconds to sleep between polls. + # @option opts [Numeric] :interval (0.2) Seconds to sleep between polls. # @option opts [String] :message Exception mesage if timed out. def initialize(opts = {})
JariBakken: Reduce the polling interval in Ruby's Wait class. git-svn-id: aa1aa1384423cb28c2b1e29129bb3a91de1d9196@15890 07704840-8298-11de-bf8c-fd130f914ac9
diff --git a/app/mutations/saved_gardens/snapshot.rb b/app/mutations/saved_gardens/snapshot.rb index abc1234..def5678 100644 --- a/app/mutations/saved_gardens/snapshot.rb +++ b/app/mutations/saved_gardens/snapshot.rb @@ -7,14 +7,14 @@ def execute SavedGarden.transaction do - binding.pry + # binding.pry create_templates_from_plants SavedGarden.create!(inputs) end end def create_templates_from_plants - raise "NOT IMPLEMENTED - RC" + # raise "NOT IMPLEMENTED - RC" end end end
Add tests for files that were lacking them
diff --git a/api/standard_sets.rb b/api/standard_sets.rb index abc1234..def5678 100644 --- a/api/standard_sets.rb +++ b/api/standard_sets.rb @@ -21,7 +21,8 @@ end - post "/", hidden: true do + desc "To preview the results of a standard set query, we call this api." + post "/from_query", hidden: true do validate_token standards_doc = $db[:standard_documents].find({ :_id => params.standardsDocumentId
Change endpoint for generating standard set from query
diff --git a/test/filter_test.rb b/test/filter_test.rb index abc1234..def5678 100644 --- a/test/filter_test.rb +++ b/test/filter_test.rb @@ -11,7 +11,7 @@ end end - teardown do + setup do Filter.instance_variable_set(:@instance, nil) end
Fix some random test failures
diff --git a/app/models/commit.rb b/app/models/commit.rb index abc1234..def5678 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -1,17 +1,25 @@ class Commit < ActiveRecord::Base validates_format_of :sha1, :with => /^[a-z0-9]+$/ validates_length_of :sha1, :is => 40 + + def check_valid + if ! self.valid? + throw Exception.new("Cannot operate on invalid commit") + end + end def repository_dir "/home/todd/arb/arb" end + def in_repo + Dir.chdir(self.repository_dir) { yield } + end + def diff_tree - if ! self.valid? - throw Exception.new("Cannot diff invalid commit") - end + check_valid - Dir.chdir(self.repository_dir) do + in_repo do return `git-diff-tree --no-commit-id -C --cc #{self.sha1}` end end
Refactor and clean up diff model a little
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 @@ -18,7 +18,7 @@ end def teardown_db - ActiveRecord::Base.connection.tables.each do |table| + ActiveRecord::Base.connection.data_sources.each do |table| ActiveRecord::Base.connection.drop_table(table) end end
Fix deprecation warnings in tests
diff --git a/spec/unit/assertions_spec.rb b/spec/unit/assertions_spec.rb index abc1234..def5678 100644 --- a/spec/unit/assertions_spec.rb +++ b/spec/unit/assertions_spec.rb @@ -9,7 +9,9 @@ it "passes asertion by performing 10K ips" do bench = Benchmark::Perf - assertion = bench.assert_perform_ips(10_000, warmup: 1.3) { 'x' * 1_024 } + assertion = bench.assert_perform_ips(10_000, warmup: 0.1, time: 0.2) do + 'x' * 1_024 + end expect(assertion).to eq(true) end end
Change to reduce test time
diff --git a/Casks/playback.rb b/Casks/playback.rb index abc1234..def5678 100644 --- a/Casks/playback.rb +++ b/Casks/playback.rb @@ -1,6 +1,6 @@ cask :v1 => 'playback' do - version '1.3.0' - sha256 'e161c0589f57f840428e946f3d12301377cdcb9aaba79a5f39c1a5048314b944' + version '1.3.1' + sha256 'bffca6b43363b8a0a511eae6b3376d0bd0fbcf2c04a6d810cf09acbcd087bb38' # github.com is the official download host per the vendor homepage url "https://github.com/mafintosh/playback/releases/download/v#{version}/Playback.app.zip"
Update Playback.app to version 1.3.1
diff --git a/spec/source_spec.rb b/spec/source_spec.rb index abc1234..def5678 100644 --- a/spec/source_spec.rb +++ b/spec/source_spec.rb @@ -0,0 +1,41 @@+# encoding: utf-8 + +require 'spec_helper' + +describe 'kafka::source' do + let :chef_run do + ChefSpec::ChefRunner.new(platform: 'centos', version: '6.4').converge(described_recipe) + end + + it 'includes kafka::default recipe' do + expect(chef_run).to include_recipe('kafka::default') + end + + it 'creates build directory' do + expect(chef_run).to create_directory('/opt/kafka/build') + + directory = chef_run.directory('/opt/kafka/build') + expect(directory).to be_owned_by('kafka', 'kafka') + expect(directory.mode).to eq('755') + end + + it 'downloads remote source of Kafka' do + expect(chef_run).to create_remote_file("#{Chef::Config[:file_cache_path]}/kafka-0.8.0-beta1-src.tgz").with( + source: 'https://dist.apache.org/repos/dist/release/kafka/kafka-0.8.0-beta1-src.tgz', + checksum: 'e069a1d5e47d18944376b6ca30b625dc013045e7e1f948054ef3789a4b5f54b3', + mode: '644' + ) + end + + it 'compiles Kafka source' do + expect(chef_run).to execute_bash_script('compile-kafka').with( + cwd: '/opt/kafka/build' + ) + end + + it 'installs compiled Kafka source' do + expect(chef_run).to execute_bash_script('install-kafka').with( + cwd: '/opt/kafka' + ) + end +end
Add basic specs for source recipe
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index abc1234..def5678 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -20,4 +20,13 @@ config.expect_with :rspec do |expect| expect.syntax = :expect end + + if ENV['CI'] + config.before(:example, :focus) { raise "Do not commit focused specs" } + else + config.filter_run_including :focus => true + config.run_all_when_everything_filtered = true + end + + config.warnings = true end
Enable running specific tests with focus: true
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index abc1234..def5678 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -16,7 +16,6 @@ RSpec.configure do |config| config.use_transactional_fixtures = true config.infer_base_class_for_anonymous_controllers = false - config.treat_symbols_as_metadata_keys_with_true_values = true config.run_all_when_everything_filtered = true config.filter_run :focus
Fix deprecation warning on treat_symbols_as_metadata_keys_with_true_values It is now set to true as default and setting it to false has no effect.
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index abc1234..def5678 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -10,7 +10,7 @@ VCR.configure do |config| config.cassette_library_dir = "spec/fixtures/cassettes" config.hook_into :webmock - config.filter_sensitive_data("__SPTRANS_TOKEN__") { sptrans_token } + config.filter_sensitive_data("__SPTRANS_TOKEN__") { SpecEnv.valid_api_token } config.default_cassette_options = { :serialize_with => :json, :preserve_exact_body_bytes => true, @@ -27,26 +27,35 @@ config.include CustomHelpers end -def sptrans_token - ENV.fetch("SPTRANS_TOKEN", "x" * 64) +class SpecEnv + class << self + + def valid_api_token + ENV.fetch("SPTRANS_TOKEN", "x" * 64) + end + + def invalid_api_token + "a" * 64 + end + + def known_line + 1273 + end + + def unknown_line + 123456789 + end + + def known_search + "largo sao francisco" + end + + def unknown_search + "parque da gare" + end + + def known_search + "largo sao francisco" + end + end end - -def sptrans_invalid_token - "a" * 64 -end - -def sptrans_known_line - 1273 -end - -def sptrans_unknown_line - 123456789 -end - -def sptrans_known_search - "largo sao francisco" -end - -def sptrans_unknown_search - "parque da gare" -end
Create a namespace for spec environment helpers.