diff
stringlengths
65
26.7k
message
stringlengths
7
9.92k
diff --git a/lib/moped/read_preference.rb b/lib/moped/read_preference.rb index abc1234..def5678 100644 --- a/lib/moped/read_preference.rb +++ b/lib/moped/read_preference.rb @@ -5,9 +5,17 @@ require "moped/read_preference/secondary_preferred" module Moped + + # Provides behaviour around getting various read preference implementations. + # + # @since 2.0.0 module ReadPreference extend self + # Hash lookup for the read preference classes based off the symbols + # provided in configuration. + # + # @since 2.0.0 PREFERENCES = { nearest: Nearest, primary: Primary, @@ -16,6 +24,21 @@ secondary_preferred: SecondaryPreferred } + # Get a read preference for the provided name. Valid names are: + # - :nearest + # - :primary + # - :primary_preferred + # - :secondary + # - :secondary_preferred + # + # @example Get the primary read preference. + # Moped::ReadPreference.get(:primary) + # + # @param [ Symbol ] name The name of the preference. + # + # @return [ Object ] The appropriate read preference. + # + # @since 2.0.0 def get(name) PREFERENCES.fetch(name) end
Add read preference getter rdoc
diff --git a/lib/rubygems/defaults/rbx.rb b/lib/rubygems/defaults/rbx.rb index abc1234..def5678 100644 --- a/lib/rubygems/defaults/rbx.rb +++ b/lib/rubygems/defaults/rbx.rb @@ -13,12 +13,8 @@ File.join Rubinius::GEMS_PATH, Gem::ConfigMap[:ruby_version] end - def self.default_preinstalled_dir - File.join Rubinius::GEMS_PATH, "rubinius", "preinstalled" - end - def self.default_path - dirs = [default_dir, default_preinstalled_dir] + dirs = [default_dir] # This is the same test rubygems/defaults.rb uses dirs.unshift(Gem.user_dir) if File.exists?(Gem.user_home) dirs
Remove obsolete pre-installed gems dir from gem env.
diff --git a/library/open3/popen3_spec.rb b/library/open3/popen3_spec.rb index abc1234..def5678 100644 --- a/library/open3/popen3_spec.rb +++ b/library/open3/popen3_spec.rb @@ -2,27 +2,41 @@ require 'open3' describe "Open3.popen3" do - after :each do - [@in, @out, @err].each do |io| - io.close if io && !io.closed? + it "returns in, out, err and a thread waiting the process" do + stdin, out, err, waiter = Open3.popen3(ruby_cmd("print :foo")) + begin + stdin.should be_kind_of IO + out.should be_kind_of IO + err.should be_kind_of IO + waiter.should be_kind_of Thread + + out.read.should == "foo" + ensure + stdin.close + out.close + err.close + waiter.join end end it "executes a process with a pipe to read stdout" do - @in, @out, @err = Open3.popen3(ruby_cmd("print :foo")) - @out.read.should == "foo" + Open3.popen3(ruby_cmd("print :foo")) do |stdin, out, err| + out.read.should == "foo" + end end it "executes a process with a pipe to read stderr" do - @in, @out, @err = Open3.popen3(ruby_cmd("STDERR.print :foo")) - @err.read.should == "foo" + Open3.popen3(ruby_cmd("STDERR.print :foo")) do |stdin, out, err| + err.read.should == "foo" + end end it "executes a process with a pipe to write stdin" do - @in, @out, @err = Open3.popen3(ruby_cmd("print STDIN.read")) - @in.write("foo") - @in.close - @out.read.should == "foo" + Open3.popen3(ruby_cmd("print STDIN.read")) do |stdin, out, err| + stdin.write("foo") + stdin.close + out.read.should == "foo" + end end it "needs to be reviewed for spec completeness"
Fix leak in the Open3.popen3 spec and add an example
diff --git a/app/controllers/backend/backend_controller.rb b/app/controllers/backend/backend_controller.rb index abc1234..def5678 100644 --- a/app/controllers/backend/backend_controller.rb +++ b/app/controllers/backend/backend_controller.rb @@ -11,7 +11,7 @@ redirect_to cas_auth_path(:redirect => request.fullpath) else if session[:club].blank? - session[:club] = club_for_ugent_login(session[:cas][:user]) + session[:club] = club_for_ugent_login(session[:cas]['user']) end @club = Club.find_by_internal_name(session[:club])
Fix FK backend access using CA
diff --git a/app/controllers/timeline_events_controller.rb b/app/controllers/timeline_events_controller.rb index abc1234..def5678 100644 --- a/app/controllers/timeline_events_controller.rb +++ b/app/controllers/timeline_events_controller.rb @@ -7,7 +7,7 @@ before_filter :set_atom show.failure.wants.html { rescue_404 } - index.wants.atom { @events = @timeline_events } + index.wants.atom { @events = TimelineEvent.recent } index.wants.js { render :partial => "paginated_events", :locals => { :events => @timeline_events } } private
Use correct set of timeline events for the atom feed
diff --git a/app/workers/publishing_api_schedule_worker.rb b/app/workers/publishing_api_schedule_worker.rb index abc1234..def5678 100644 --- a/app/workers/publishing_api_schedule_worker.rb +++ b/app/workers/publishing_api_schedule_worker.rb @@ -11,12 +11,12 @@ # Coming soon needs to be sent first, as currently content-store deletes # an intent when a content item is created for that path. publish_coming_soon unless @model.document.published? - publish_intent + publish_publish_intent end private - def publish_intent + def publish_publish_intent presenter = PublishingApiPresenters.publish_intent_for(model) I18n.with_locale(locale) do Whitehall.publishing_api_client.put_intent(
Rename method for consistency and clarity
diff --git a/db/migrate/20140915123504_move_to_has_and_belongs_to_many_for_ontologies_tasks_end.rb b/db/migrate/20140915123504_move_to_has_and_belongs_to_many_for_ontologies_tasks_end.rb index abc1234..def5678 100644 --- a/db/migrate/20140915123504_move_to_has_and_belongs_to_many_for_ontologies_tasks_end.rb +++ b/db/migrate/20140915123504_move_to_has_and_belongs_to_many_for_ontologies_tasks_end.rb @@ -1,7 +1,7 @@ class MoveToHasAndBelongsToManyForOntologiesTasksEnd < ActiveRecord::Migration def up - remove_column(:ontologies, :task_id) - remove_column(:tasks, :ontology_id) + execute('ALTER TABLE "ontologies" DROP COLUMN IF EXISTS "task_id";') + execute('ALTER TABLE "tasks" DROP COLUMN IF EXISTS "ontology_id";') end def down
Drop column only if it exists.
diff --git a/samples/scripts/selection/checkFreeMemory.rb b/samples/scripts/selection/checkFreeMemory.rb index abc1234..def5678 100644 --- a/samples/scripts/selection/checkFreeMemory.rb +++ b/samples/scripts/selection/checkFreeMemory.rb @@ -1,6 +1,8 @@ require 'java' SelectionUtils = Java::org.ow2.proactive.scripting.helper.selection.SelectionUtils + +expectedMemorySize = 1073741824 #check if free memory is at least 1Go if SelectionUtils.checkFreeMemory(expectedMemorySize) @@ -8,4 +10,3 @@ else $selected = false; end -
Define missing variable in selection script sample
diff --git a/app/controllers/documents_controller.rb b/app/controllers/documents_controller.rb index abc1234..def5678 100644 --- a/app/controllers/documents_controller.rb +++ b/app/controllers/documents_controller.rb @@ -1,8 +1,16 @@ class DocumentsController < ApplicationController + include AdminHelper def index # @documents = Document.all - @groups = Group.all + if admin? + @groups = Group.all + elsif session? + user = User.find(session[:user_id]) + @groups = user.groups.all + else + redirect_to login_path + end end def show
Document display user based on group
diff --git a/vim-flavor.gemspec b/vim-flavor.gemspec index abc1234..def5678 100644 --- a/vim-flavor.gemspec +++ b/vim-flavor.gemspec @@ -18,8 +18,8 @@ spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ['lib'] - spec.add_dependency('parslet', '~> 1.7') - spec.add_dependency('thor', '~> 0.19') + spec.add_dependency('parslet', '~> 1.8') + spec.add_dependency('thor', '~> 0.20') spec.add_development_dependency('aruba', '~> 0.14.0') spec.add_development_dependency('cucumber', '~> 3.0')
Update parslet ~> 1.8 and thor ~> 0.20
diff --git a/lib/arsi/arel_tree_manager.rb b/lib/arsi/arel_tree_manager.rb index abc1234..def5678 100644 --- a/lib/arsi/arel_tree_manager.rb +++ b/lib/arsi/arel_tree_manager.rb @@ -2,6 +2,10 @@ module Arsi module ArelTreeManager + AREL_WHERE_SQL_ARITY_1 = ::Arel::VERSION[0].to_i < 7 + # Arel 9 has no engine reader + AREL_WHERE_SQL_ENGINE_ACCESSOR = ::Arel::VERSION[0].to_i < 9 + # This is from Arel::SelectManager which inherits from Arel::TreeManager. # We need where_sql on both Arel::UpdateManager and Arel::DeleteManager so we add it to the parent class. def where_sql(provided_engine = :none) @@ -9,15 +13,14 @@ selected_engine = provided_engine if selected_engine == :none - # Arel 9 has no engine reader - selected_engine = if self.respond_to?(:engine) + selected_engine = if AREL_WHERE_SQL_ENGINE_ACCESSOR self.engine || Arel::Table.engine else Arel::Table.engine end end - viz = if ::Arel::Visitors::WhereSql.instance_method(:initialize).arity == 1 + viz = if AREL_WHERE_SQL_ARITY_1 ::Arel::Visitors::WhereSql.new selected_engine.connection else ::Arel::Visitors::WhereSql.new(selected_engine.connection.visitor, selected_engine.connection)
Switch to checking Arel versions
diff --git a/lib/color-schema-validator.rb b/lib/color-schema-validator.rb index abc1234..def5678 100644 --- a/lib/color-schema-validator.rb +++ b/lib/color-schema-validator.rb @@ -1,6 +1,6 @@ class ColorSchemaValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) - unless value =~ /^#(\h{6}|\h{3})$/ + unless value =~ /\A#(\h{6}|\h{3})\z/ record.errors.add(attribute, options[:message] || :invalid) end end
Fix regexp to more strong According to the following error on Rails 4: ArgumentError: The provided regular expression is using multiline anchors (^ or $), which may present a security risk. Did you mean to use \A and \z, or forgot to add the :multiline => true option? from /some/where/vendor/bundle/ruby/2.2.0/gems/activemodel-4.2.3/lib/active_model/validations/format.rb:39:in `check_options_validity'
diff --git a/lib/moped/protocol/command.rb b/lib/moped/protocol/command.rb index abc1234..def5678 100644 --- a/lib/moped/protocol/command.rb +++ b/lib/moped/protocol/command.rb @@ -13,7 +13,7 @@ # @param [Hash] command the command to run # @param [Hash] additional query options def initialize(database, command, options = {}) - super database, :$cmd, command, options.merge(limit: -1) + super database, '$cmd', command, options.merge(limit: -1) end def log_inspect
Use string for Protocol::Command collection name
diff --git a/lib/multidb/log_subscriber.rb b/lib/multidb/log_subscriber.rb index abc1234..def5678 100644 --- a/lib/multidb/log_subscriber.rb +++ b/lib/multidb/log_subscriber.rb @@ -1,19 +1,21 @@ module Multidb - module LogSubscriber - extend ActiveSupport::Concern + module LogSubscriberExtension + def sql(event) + if name = Multidb.balancer.current_connection_name + event.payload[:db_name] = name + end + super + end - included do - def debug_with_multidb(msg) - if name = Multidb.balancer.current_connection_name - db = color("[DB: #{name}]", ActiveSupport::LogSubscriber::GREEN, true) - debug_without_multidb(db + msg) - else - debug_without_multidb(msg) - end + def debug(msg) + if name = Multidb.balancer.current_connection_name + db = color("[DB: #{name}]", ActiveSupport::LogSubscriber::GREEN, true) + super(db + msg) + else + super end - alias_method_chain :debug, :multidb end end end -ActiveRecord::LogSubscriber.send(:include, Multidb::LogSubscriber) +ActiveRecord::LogSubscriber.prepend(Multidb::LogSubscriberExtension)
Use prepend to change LogSubscriber; add db_name to the payload
diff --git a/lib/specinfra/backend/base.rb b/lib/specinfra/backend/base.rb index abc1234..def5678 100644 --- a/lib/specinfra/backend/base.rb +++ b/lib/specinfra/backend/base.rb @@ -43,11 +43,11 @@ @example = e end - def set_stdout_handler(&block) + def stdout_handler=(block) @stdout_handler = block end - def set_stderr_handler(&block) + def stderr_handler=(block) @stderr_handler = block end end
Change the methods to set handlers
diff --git a/approvals.gemspec b/approvals.gemspec index abc1234..def5678 100644 --- a/approvals.gemspec +++ b/approvals.gemspec @@ -17,7 +17,7 @@ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } s.require_paths = ["lib"] - s.add_dependency 'rspec', '~> 2.7' + s.add_development_dependency 'rspec', '~> 2.7' s.add_dependency 'thor' s.add_dependency 'nokogiri' end
Make rspec a development dependency
diff --git a/lib/stack_master/validator.rb b/lib/stack_master/validator.rb index abc1234..def5678 100644 --- a/lib/stack_master/validator.rb +++ b/lib/stack_master/validator.rb @@ -11,7 +11,7 @@ def perform StackMaster.stdout.print "#{@stack_definition.stack_name}: " - template_body = TemplateCompiler.compile(@config, @stack_definition.template_file_path) + template_body = Stack.generate(@stack_definition, @config).maybe_compressed_template_body cf.validate_template(template_body: template_body) StackMaster.stdout.puts "valid" true
Compress the template when we attempt to validate it
diff --git a/piece.rb b/piece.rb index abc1234..def5678 100644 --- a/piece.rb +++ b/piece.rb @@ -13,4 +13,52 @@ def to_s "#{@type} - #{col}#{row}" end + + def is_pawn? + if @type.eql? Chess::B_PAWN or @type.eql? Chess::W_PAWN then + return true + else + return false + end + end + + def is_rook? + if @type.eql? Chess::B_ROOK or @type.eql? Chess::W_ROOK then + return true + else + return false + end + end + + def is_knight? + if @type.eql? Chess::B_KNIGHT or @type.eql? Chess::W_KNIGHT then + return true + else + return false + end + end + + def is_bishop? + if @type.eql? Chess::B_BISHOP or @type.eql? Chess::W_BISHOP then + return true + else + return false + end + end + + def is_queen? + if @type.eql? Chess::B_QUEEN or @type.eql? Chess::W_QUEEN then + return true + else + return false + end + end + + def is_king? + if @type.eql? Chess::B_KING or @type.eql? Chess::W_KING then + return true + else + return false + end + end end
Add identity methods to Piece
diff --git a/lib/synapse_payments/users.rb b/lib/synapse_payments/users.rb index abc1234..def5678 100644 --- a/lib/synapse_payments/users.rb +++ b/lib/synapse_payments/users.rb @@ -20,7 +20,6 @@ phone_numbers: phone.is_a?(Array) ? phone : [phone], legal_names: name.is_a?(Array) ? name : [name], extra: { - note: args[:note], supp_id: args[:supp_id], is_business: is_business }
Remove note as it doesn't seem to be supported
diff --git a/lib/tasks/feedshub_tasks.rake b/lib/tasks/feedshub_tasks.rake index abc1234..def5678 100644 --- a/lib/tasks/feedshub_tasks.rake +++ b/lib/tasks/feedshub_tasks.rake @@ -6,7 +6,8 @@ GitFeedsHandler.update_github_feeds end - task :whenverize do + desc 'add cron task to update feeds' + task whenverize: :environment do env = ARGV.last exec("cd #{Feedshub::Engine.root} && whenever -i -s 'path=#{Rails.root}' -r #{env}") end
Add task support for rails 3; CR: DF
diff --git a/lib/twilio-ruby/rest/utils.rb b/lib/twilio-ruby/rest/utils.rb index abc1234..def5678 100644 --- a/lib/twilio-ruby/rest/utils.rb +++ b/lib/twilio-ruby/rest/utils.rb @@ -4,9 +4,9 @@ def twilify(something) if something.is_a? Hash - Hash[*something.to_a.map {|a| [twilify(a[0]).to_sym, a[1]]}.flatten(1)] + Hash[*something.to_a.map! {|a| [twilify(a[0]).to_sym, a[1]]}.flatten(1)] else - something.to_s.split('_').map do |s| + something.to_s.split('_').map! do |s| [s[0,1].capitalize, s[1..-1]].join end.join end @@ -14,7 +14,7 @@ def detwilify(something) if something.is_a? Hash - Hash[*something.to_a.map {|pair| [detwilify(pair[0]).to_sym, pair[1]]}.flatten] + Hash[*something.to_a.map! {|pair| [detwilify(pair[0]).to_sym, pair[1]]}.flatten] else something.to_s.gsub(/[A-Z][a-z]*/) {|s| "_#{s.downcase}"}.gsub(/^_/, '') end
Change `map` to `map!` to save extra array creation on new array
diff --git a/lib/yarrow/html/asset_tags.rb b/lib/yarrow/html/asset_tags.rb index abc1234..def5678 100644 --- a/lib/yarrow/html/asset_tags.rb +++ b/lib/yarrow/html/asset_tags.rb @@ -2,6 +2,10 @@ module HTML module AssetTags + def config + Yarrow::Configuration.instance + end + # TODO: make sprockets manifest optional/pluggable def manifest Yarrow::Assets::Manifest.new(config || {})
Embed configuration in asset tag library
diff --git a/lib/fabrication/fabricator.rb b/lib/fabrication/fabricator.rb index abc1234..def5678 100644 --- a/lib/fabrication/fabricator.rb +++ b/lib/fabrication/fabricator.rb @@ -2,7 +2,7 @@ def initialize(class_name, &block) klass = class_for(class_name) - if klass.ancestors.include?(ActiveRecord::Base) + if defined?(ActiveRecord) && klass.ancestors.include?(ActiveRecord::Base) @fabricator = Fabrication::Generator::ActiveRecord.new(klass, &block) else @fabricator = Fabrication::Generator::Base.new(klass, &block)
Allow it to work without activerecord loaded
diff --git a/lib/io_actors/writer_actor.rb b/lib/io_actors/writer_actor.rb index abc1234..def5678 100644 --- a/lib/io_actors/writer_actor.rb +++ b/lib/io_actors/writer_actor.rb @@ -39,7 +39,7 @@ num_bytes = begin @io.write_nonblock(bytes) - rescue IO::WaitWritable + rescue IO::WaitWritable, Errno::EAGAIN 0 end
Handle Errno::EAGAIN errors when writing
diff --git a/ltsv_logger_formatter.gemspec b/ltsv_logger_formatter.gemspec index abc1234..def5678 100644 --- a/ltsv_logger_formatter.gemspec +++ b/ltsv_logger_formatter.gemspec @@ -13,9 +13,7 @@ spec.homepage = 'https://github.com/ryu39/ltsv_logger_formatter' spec.license = 'MIT' - spec.files = `git ls-files -z`.split("\x0").reject do |f| - f.match(%r{^(test|spec|features)/}) - end + spec.files = %w(LICENSE.txt) + Dir['lib/**/*.rb'] spec.bindir = 'exe' spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ['lib']
Remove unnecessary files from gem
diff --git a/lib/lita/handlers/hal_9000.rb b/lib/lita/handlers/hal_9000.rb index abc1234..def5678 100644 --- a/lib/lita/handlers/hal_9000.rb +++ b/lib/lita/handlers/hal_9000.rb @@ -8,13 +8,16 @@ def handle_unhandled(payload:) message = payload[:message] if message.command? - private_message = message.source.private_message - target = unless private_message - Source.new(room: message.source.room) - else - Source.new(user: message.user, private_message: true) - end + target = reply_target(message: message) robot.send_message(target, "I'm sorry, I can't do that @#{message.user.mention_name} http://bit.ly/11wwIP2") + end + end + + def reply_target(message:) + if message.source.private_message + Source.new(user: message.user, private_message: true) + else + Source.new(room: message.source.room) end end
Refactor getting target into separate method
diff --git a/lib/message_broker/message.rb b/lib/message_broker/message.rb index abc1234..def5678 100644 --- a/lib/message_broker/message.rb +++ b/lib/message_broker/message.rb @@ -1,6 +1,8 @@ # encoding: utf-8 # frozen_string_literal: true module MessageBroker + # Message parses raw line recieved from event sourse + # and caries this information for futher processing class Message attr_reader :sequence, :type, :from, :to, :raw
Add description for Message class
diff --git a/app/models/skill.rb b/app/models/skill.rb index abc1234..def5678 100644 --- a/app/models/skill.rb +++ b/app/models/skill.rb @@ -23,6 +23,7 @@ def increment_current_streak self.current_streak += 1 + self.longest_streak = self.current_streak if self.current_streak > self.longest_streak self.save end
Add conditional to increment longest streak if current streak becomes larger than longest streak
diff --git a/features/support/env.rb b/features/support/env.rb index abc1234..def5678 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -5,5 +5,5 @@ ENV['PATH'] = "#{root}/features/support/bin#{File::PATH_SEPARATOR}#{ENV['PATH']}" Before do - @aruba_timeout_seconds = 60 * 2 + @aruba_timeout_seconds = 60 * 3 end
Increase aruba timeout because installing gems might take a lot of time
diff --git a/lib/rolistic/class_methods.rb b/lib/rolistic/class_methods.rb index abc1234..def5678 100644 --- a/lib/rolistic/class_methods.rb +++ b/lib/rolistic/class_methods.rb @@ -25,7 +25,7 @@ def traits_map return @traits_map if defined?(@traits_map) - @traits_map = {} + @traits_map = {everything: Everything} end def abilities_for(name)
Create default trait mapped to Rolistic::Everything
diff --git a/lib/tasks/publishing_api.rake b/lib/tasks/publishing_api.rake index abc1234..def5678 100644 --- a/lib/tasks/publishing_api.rake +++ b/lib/tasks/publishing_api.rake @@ -1,11 +1,28 @@ namespace :publishing_api do - desc "export all whitehall content to draft environment of publishing api" - task :populate_draft_environment => :environment do - Whitehall::PublishingApi::DraftEnvironmentPopulator.new(logger: Logger.new(STDOUT)).call + namespace :draft do + namespace :populate do + desc "export all whitehall content to draft environment of publishing api" + task :all => :environment do + Whitehall::PublishingApi::DraftEnvironmentPopulator.new(logger: Logger.new(STDOUT)).call + end + + desc "export Case studies to draft environment of publishing api" + task :case_studies => :environment do + Whitehall::PublishingApi::DraftEnvironmentPopulator.new(items: CaseStudy.latest_edition.find_each, logger: Logger.new(STDOUT)).call + end + end end - desc "export all published whitehall content to live environment of publishing api" - task :populate_live_environment => :environment do - Whitehall::PublishingApi::LiveEnvironmentPopulator.new(logger: Logger.new(STDOUT)).call + namespace :live do + namespace :populate do + desc "export all published whitehall content to live environment of publishing api" + task :all => :environment do + Whitehall::PublishingApi::LiveEnvironmentPopulator.new(logger: Logger.new(STDOUT)).call + end + + task :case_studies => :environment do + Whitehall::PublishingApi::LiveEnvironmentPopulator.new(items: CaseStudy.latest_published_edition.find_each, logger: Logger.new(STDOUT)).call + end + end end end
Define rake tasks for repopulating case studies into either the draft or live environment.
diff --git a/lib/torkify/log/test_error.rb b/lib/torkify/log/test_error.rb index abc1234..def5678 100644 --- a/lib/torkify/log/test_error.rb +++ b/lib/torkify/log/test_error.rb @@ -1,5 +1,14 @@ module Torkify::Log - class TestError < Struct.new(:filename, :lnum, :text, :type) + class TestError + attr_accessor :filename, :lnum, :text, :type + + def initialize(filename, lnum, text, type) + @filename = filename + @lnum = lnum + @text = text + @type = type + end + def clean_text text.strip end
Fix superclass mismatch by using struct
diff --git a/lib/virtus/typecast/object.rb b/lib/virtus/typecast/object.rb index abc1234..def5678 100644 --- a/lib/virtus/typecast/object.rb +++ b/lib/virtus/typecast/object.rb @@ -17,6 +17,51 @@ # @api public def self.to_string(value) value.to_s + end + + # Passthrough given value + # + # @return [object] + # + # @api private + def self.to_date(value) + value + end + + # Passthrough given value + # + # @return [object] + # + # @api private + def self.to_datetime(value) + value + end + + # Passthrough given value + # + # @return [object] + # + # @api private + def self.to_time(value) + value + end + + # Passthrough given value + # + # @return [object] + # + # @api private + def self.to_array(value) + value + end + + # Passthrough given value + # + # @return [object] + # + # @api private + def self.to_hash(value) + value end # Passthrough given value
Add missing methods to Virtus::Typecast::Object
diff --git a/spec/lib/tasks/gem/bump_task_spec.rb b/spec/lib/tasks/gem/bump_task_spec.rb index abc1234..def5678 100644 --- a/spec/lib/tasks/gem/bump_task_spec.rb +++ b/spec/lib/tasks/gem/bump_task_spec.rb @@ -4,12 +4,12 @@ describe Gem::BumpTask do describe '#task' do subject { Gem::BumpTask.new :major } + before { subject.stub(:read_version).and_return('2.0.0') } it 'bumps the version and writes it' do - subject.stub(:read_version).and_return('2.0.0') - subject.should_receive(:write_version) + expect(subject).to receive(:write_version) - subject.task.should eq('3.0.0') + expect(subject.task).to eq('3.0.0') end end end
Use new rspec expectations sintax
diff --git a/spec/observers/user_observer_spec.rb b/spec/observers/user_observer_spec.rb index abc1234..def5678 100644 --- a/spec/observers/user_observer_spec.rb +++ b/spec/observers/user_observer_spec.rb @@ -2,4 +2,24 @@ describe UserObserver do + describe '#before_validation' do + let(:user) { build(:user, password: nil) } + before { user.valid? } + it { expect(user.password).to_not be_empty } + end + + describe '#after_create' do + before { UserObserver.any_instance.unstub(:after_create) } + context 'when the user is with temporary email' do + let(:user) { create(:user, email: "change-your-email+#{Time.now.to_i}@neighbor.ly") } + before { expect_any_instance_of(WelcomeWorker).to_not receive(:perform_async) } + it { user } + end + + context 'when the user is not with temporary email' do + before { expect(WelcomeWorker).to receive(:perform_async) } + it { create(:user) } + end + end + end
Add specs for user observer
diff --git a/spec/unit/tables/table_utils_spec.rb b/spec/unit/tables/table_utils_spec.rb index abc1234..def5678 100644 --- a/spec/unit/tables/table_utils_spec.rb +++ b/spec/unit/tables/table_utils_spec.rb @@ -18,6 +18,10 @@ @subject.index_path_to_section_index(given).should == expected end + it "return the original param when converting an index path with incorrect values" do + @subject.index_path_to_section_index(17).should == 17 + end + it "should properly determine if all members of an array are the same class" do @subject.array_all_members_of([1, 2, 3, 4], Fixnum).should == true @subject.array_all_members_of(["string", 'string2'], String).should == true
Add failing test for index_path_to_section_index util method
diff --git a/app/controllers/root_controller.rb b/app/controllers/root_controller.rb index abc1234..def5678 100644 --- a/app/controllers/root_controller.rb +++ b/app/controllers/root_controller.rb @@ -11,6 +11,6 @@ private def should_list_app?(permission, application) - permission.permissions.include?("signin") || application.name == "Support" + permission.permissions.include?("signin") || application.name.downcase == "support" end end
Make support app hack slightly less fragile
diff --git a/app/services/post_stream_window.rb b/app/services/post_stream_window.rb index abc1234..def5678 100644 --- a/app/services/post_stream_window.rb +++ b/app/services/post_stream_window.rb @@ -1,6 +1,6 @@ class PostStreamWindow def self.for(topic:, from: (topic.highest_post_number+1), order: :desc, limit: SiteSetting.babble_page_size) - lt_or_gt = (order.to_sym == :desc) ? '<' : '>' + lt_or_gt = (order.to_sym == :desc) ? '<=' : '>=' topic.posts.includes(:user) .where("post_number #{lt_or_gt} ?", from) .order(post_number: order)
Use lt/gt or equal to in post stream window
diff --git a/polymorphic_preloader.gemspec b/polymorphic_preloader.gemspec index abc1234..def5678 100644 --- a/polymorphic_preloader.gemspec +++ b/polymorphic_preloader.gemspec @@ -9,6 +9,7 @@ spec.authors = ['Anthony Dmitriyev'] spec.email = ['antstorm@gmail.com'] spec.summary = 'Eager loading nested polymorphic associations in ActiveRecord' + spec.description = 'Adds the ability to preload nested polymorphic associations in your ActiveRecord queries' spec.homepage = 'https://github.com/antstorm/polymorphic_preloader' spec.license = 'MIT'
Add gemspec description to fix gem build warnings
diff --git a/app/state.rb b/app/state.rb index abc1234..def5678 100644 --- a/app/state.rb +++ b/app/state.rb @@ -6,16 +6,16 @@ @move_order = [] end - def [](r, c) - @board[r, c] + def [](row, col) + @board[row, col] end - def []=(r, c, value) - i = [r, c] + def []=(row, col, value) + i = [row, col] @move_order.push(i) # Override private method because Matrices are default immutable - @board.send(:'[]=', r, c, value) - Log.debug("Filling cell (#{r+1}, #{c+1}) with (#{value}):") + @board.send(:'[]=', row, col, value) + Log.debug("Filling cell (#{row+1}, #{col+1}) with (#{value}):") Log.tab(@board, "debug_only") end
Increase variable verboseness for clarity (ih/2π).(∂ψ/∂t) = (–h2/8π2m)∇2ψ + Vψ
diff --git a/stack.rb b/stack.rb index abc1234..def5678 100644 --- a/stack.rb +++ b/stack.rb @@ -1,26 +1,61 @@ require_relative 'linked_list' # Linked List Version +# class Stack +# attr_reader :stack + +# def initialize +# @stack = LinkedList.new +# end + +# def top +# node = stack.get(0) +# reveal_node(node) +# end + +# def push(element) +# node = Node.new(element) +# stack.insert_first(node) +# end + +# def pop +# node = stack.remove_first +# reveal_node(node) +# end + +# def empty? +# self.top == nil +# end + +# private +# def reveal_node(node) +# if node +# node.element +# else +# nil +# end +# end + +# end + +#Array List Version class Stack - attr_reader :stack - def initialize - @stack = LinkedList.new + @stack = ArrayList.new(5) end def top - node = stack.get(0) - reveal_node(node) + @stack.get(0) end def push(element) - node = Node.new(element) - stack.insert_first(node) + @stack.insert(0,element) end def pop - node = stack.remove_first - reveal_node(node) + value = self.top + create_new_array_list + value end def empty? @@ -28,12 +63,13 @@ end private - def reveal_node(node) - if node - node.element - else - nil + def create_new_array_list + old_stack_length = @stack.size + new_stack = ArrayList.new(5) + old_stack_length.times do |index| + old_value = @stack.get(index + 1) + new_stack.set(index, old_value) end + @stack = new_stack end - end
Add ArrayList version of Stacks
diff --git a/artwork.gemspec b/artwork.gemspec index abc1234..def5678 100644 --- a/artwork.gemspec +++ b/artwork.gemspec @@ -4,20 +4,22 @@ require 'artwork/version' Gem::Specification.new do |spec| - spec.name = "artwork" + spec.name = 'artwork' spec.version = Artwork::VERSION - spec.authors = ["Dimitar Dimitrov"] - spec.email = ["me@ddimitrov.name"] - spec.summary = %q{TODO: Write a short summary. Required.} - spec.description = %q{TODO: Write a longer description. Optional.} - spec.homepage = "" - spec.license = "MIT" + spec.authors = ['Dimitar Dimitrov'] + spec.email = ['dimitar@live.bg'] + spec.summary = 'Automated image size scaling view helpers.' + spec.description = 'Works for any browser and uses cookies for transporting browser info to the backend.' + spec.homepage = '' + spec.license = 'MIT' spec.files = `git ls-files -z`.split("\x0") spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) - spec.require_paths = ["lib"] + spec.require_paths = ['lib'] - spec.add_development_dependency "bundler", "~> 1.6" - spec.add_development_dependency "rake" + spec.add_development_dependency 'bundler', '~> 1.6' + spec.add_development_dependency 'rake' + + spec.add_dependency 'rails', '>= 2.3' end
Update the gemspec with dependencies and descriptions
diff --git a/lib/thinking_sphinx/deltas/sidekiq_delta/tasks.rb b/lib/thinking_sphinx/deltas/sidekiq_delta/tasks.rb index abc1234..def5678 100644 --- a/lib/thinking_sphinx/deltas/sidekiq_delta/tasks.rb +++ b/lib/thinking_sphinx/deltas/sidekiq_delta/tasks.rb @@ -33,6 +33,6 @@ Rake::Task['thinking_sphinx:unlock_deltas'].invoke end -Rake::Task['ts:reindex'].enhance ['thinking_sphinx:lock_deltas'] do - Rake::Task['thinking_sphinx:unlock_deltas'].invoke -end +# Rake::Task['ts:reindex'].enhance ['thinking_sphinx:lock_deltas'] do +# Rake::Task['thinking_sphinx:unlock_deltas'].invoke +# end
Remove reindex reference for the moment.
diff --git a/Casks/tigervnc-viewer.rb b/Casks/tigervnc-viewer.rb index abc1234..def5678 100644 --- a/Casks/tigervnc-viewer.rb +++ b/Casks/tigervnc-viewer.rb @@ -1,6 +1,6 @@ cask :v1 => 'tigervnc-viewer' do - version '1.4.3' - sha256 'e6c2f17092456f04ccce6d923af3103f7e69123c4a0f80e37b56ee3861149cca' + version '1.5.0' + sha256 '927e956cbda7672c7efdfa9f5e49cb89043d1627132dd2e088a3c0009de4080e' # bintray.com is the official download host per the vendor homepage url "https://bintray.com/artifact/download/tigervnc/stable/TigerVNC-#{version}.dmg"
Update TigerVNC Viewer to v.1.5.0
diff --git a/lib/memory_analyzer/heap_analyzer/parser.rb b/lib/memory_analyzer/heap_analyzer/parser.rb index abc1234..def5678 100644 --- a/lib/memory_analyzer/heap_analyzer/parser.rb +++ b/lib/memory_analyzer/heap_analyzer/parser.rb @@ -27,11 +27,9 @@ end def self.parse_file(file) - File.open(file) do |f| - f.each_line.collect do |l| - yield if block_given? # For progress reporting - clean_node(JSON.parse(l)) - end + File.foreach(file).collect do |line| + yield if block_given? # For progress reporting + clean_node(JSON.parse(line)) end end
Use File.foreach instead of interating ourselves.
diff --git a/MKLog.podspec b/MKLog.podspec index abc1234..def5678 100644 --- a/MKLog.podspec +++ b/MKLog.podspec @@ -9,7 +9,7 @@ Pod::Spec.new do |s| s.name = "MKLog" - s.version = "0.1.1" + s.version = "0.1.2" s.summary = "Lightweight log with multiple log levels" s.description = <<-DESC A lightweight logger implementation for Objective-C with multiple log levels.
Increase version number in preparation for release
diff --git a/test/models/area_test.rb b/test/models/area_test.rb index abc1234..def5678 100644 --- a/test/models/area_test.rb +++ b/test/models/area_test.rb @@ -3,4 +3,12 @@ class AreaTest < ActiveSupport::TestCase should have_many(:areas_messages) should have_many(:messages).through(:areas_messages) + + def setup + @area = areas(:one) + end + + test 'geometry should return GeoRuby' do + assert_instance_of GeoRuby::SimpleFeatures::MultiPolygon, @area.geometry + end end
Add test for getting area geometry
diff --git a/routes/player_counts.rb b/routes/player_counts.rb index abc1234..def5678 100644 --- a/routes/player_counts.rb +++ b/routes/player_counts.rb @@ -22,10 +22,10 @@ app.get '/player_counts-latest.json' do content_type :json - if !redis.exists("latest-counts") + if !redis.exists("latest-player-counts") return [] else - return redis.get("latest-counts") + return redis.get("latest-player-counts") end end
Fix typo in latest player counts
diff --git a/spec/controllers/comments_controller_spec.rb b/spec/controllers/comments_controller_spec.rb index abc1234..def5678 100644 --- a/spec/controllers/comments_controller_spec.rb +++ b/spec/controllers/comments_controller_spec.rb @@ -1,34 +1,22 @@ require "rails_helper" describe CommentsController do - describe 'GET #index' do - it 'populates an array of all comment to a question' do - comment1 = create(:q_comment) - comment2 = create(:q_comment) - get :index, :commentable_id => 1, :commentable_type => "Question", format: :json - expect(assigns(:q_comment)).to match_array([comment1, comment2]) - end - it 'populates an array of all comment to an answer' do - comment1 = create(:a_comment) - comment2 = create(:a_comment) - get :index, commentable_id: 1, commentable_type: "Answer" - expect(assigns(:q_question)).to match_array([comment1, comment2]) - end - - end - - describe 'GET #show' do - - end - - describe 'GET #new' do - + describe 'POST #create' do + it 'adds a comment to the comments table' + it 'does not save a comment without a body' end describe 'GET #edit' do + it 'renders an edit form with original body text' end - describe 'POST #create' do + describe 'PUT #update' do + it 'updates the comment in the comments table' + it 'does not update a comment without a body' + end + describe 'DELETE #destroy' do + it 'deletes the comment from the comments table' + it 're-renders the same page after delete' end end
Define initial rspec tests for comments controller.
diff --git a/spec/libraries/sign_in_with_callback_spec.rb b/spec/libraries/sign_in_with_callback_spec.rb index abc1234..def5678 100644 --- a/spec/libraries/sign_in_with_callback_spec.rb +++ b/spec/libraries/sign_in_with_callback_spec.rb @@ -20,7 +20,8 @@ let(:instance) { Instance.default } with_tenant(:instance) do let(:user) { self.class::TestUser.new } - subject { controller.sign_in(:user, user, bypass: true) } + # Set run_callbacks to false to skip Warden callbacks + subject { controller.sign_in(:user, user, run_callbacks: false) } it 'calls #before_sign_in' do expect(user).to receive(:before_callback)
Replace deprecated Devise sign_in bypass option in tests
diff --git a/BHCDatabase/test/models/medical_condition_funder_test.rb b/BHCDatabase/test/models/medical_condition_funder_test.rb index abc1234..def5678 100644 --- a/BHCDatabase/test/models/medical_condition_funder_test.rb +++ b/BHCDatabase/test/models/medical_condition_funder_test.rb @@ -19,4 +19,12 @@ @medical_condition_funder.medical_condition = nil assert_not @medical_condition_funder.valid? end + + test 'index on medical condition and funder' do + @duplicate_funder = @medical_condition_funder.dup + assert_not @duplicate_funder.valid? + assert_no_difference 'MedicalConditionFunder.count' do + @duplicate_funder.save + end + end end
Add test for index on medical_condition and funder for a medical condition funder.
diff --git a/bin/rwiki.rb b/bin/rwiki.rb index abc1234..def5678 100644 --- a/bin/rwiki.rb +++ b/bin/rwiki.rb @@ -9,8 +9,8 @@ working_folder = File.join(Dir.pwd, working_folder) end -WIKIR_ROOT = working_folder.freeze -p "Working folder is: #{WIKIR_ROOT}" -Dir.chdir(WIKIR_ROOT) +RWIKI_ROOT = working_folder.freeze +p "Working folder is: #{RWIKI_ROOT}" +Dir.chdir(RWIKI_ROOT) Rwiki::App.run!
Fix typo in constant name.
diff --git a/lib/ello/kinesis_consumer/mailchimp_processor.rb b/lib/ello/kinesis_consumer/mailchimp_processor.rb index abc1234..def5678 100644 --- a/lib/ello/kinesis_consumer/mailchimp_processor.rb +++ b/lib/ello/kinesis_consumer/mailchimp_processor.rb @@ -8,7 +8,7 @@ def user_was_created(record) mailchimp.upsert_to_users_list record['email'], record['subscription_preferences'], - record['followed_categories'] + record['followed_categories'] || [] end def user_changed_email(record)
Add default value for when `followed_categories` is nil
diff --git a/lib/flipper/instrumentation/statsd_subscriber.rb b/lib/flipper/instrumentation/statsd_subscriber.rb index abc1234..def5678 100644 --- a/lib/flipper/instrumentation/statsd_subscriber.rb +++ b/lib/flipper/instrumentation/statsd_subscriber.rb @@ -3,7 +3,6 @@ # that lives in the same directory as this file. The benefit is that it # subscribes to the correct events and does everything for your. require 'flipper/instrumentation/subscriber' -require 'statsd' module Flipper module Instrumentation
Stop requiring statsd in subscriber Nothing statsd specific is referenced other than the client, but that is just through the class var so no need to require this.
diff --git a/lib/heroku_line_item_billing/models/formation.rb b/lib/heroku_line_item_billing/models/formation.rb index abc1234..def5678 100644 --- a/lib/heroku_line_item_billing/models/formation.rb +++ b/lib/heroku_line_item_billing/models/formation.rb @@ -3,7 +3,7 @@ PRICES = { "1x" => {"cents" => 5, "unit" => "hour"}, "2x" => {"cents" => 10, "unit" => "hour"}, - "2x" => {"cents" => 80, "unit" => "hour"}, + "px" => {"cents" => 80, "unit" => "hour"}, "standard-1x" => {"cents" => 2500, "unit" => "month"}, "standard-2x" => {"cents" => 5000, "unit" => "month"}, "performance" => {"cents" => 50000, "unit" => "month"},
Fix duplicate entry for 2x dynos
diff --git a/spec/features/signin_users_in_spec.rb b/spec/features/signin_users_in_spec.rb index abc1234..def5678 100644 --- a/spec/features/signin_users_in_spec.rb +++ b/spec/features/signin_users_in_spec.rb @@ -19,7 +19,14 @@ end scenario "with invalid credentials" do - + visit "/" + click_link "Sign in" + fill_in "Email", with: "" + fill_in "Password", with: "" + click_button "Log in" + expect(page).to have_content("Invalid Email or password") + expect(page).to have_link("Sign in") + expect(page).to have_link("Sign up") end end
Add test for unsuccessful sign in
diff --git a/spec/helpers/ci_status_helper_spec.rb b/spec/helpers/ci_status_helper_spec.rb index abc1234..def5678 100644 --- a/spec/helpers/ci_status_helper_spec.rb +++ b/spec/helpers/ci_status_helper_spec.rb @@ -6,25 +6,54 @@ let(:success_commit) { double("Ci::Pipeline", status: 'success') } let(:failed_commit) { double("Ci::Pipeline", status: 'failed') } - describe 'ci_icon_for_status' do + describe '#ci_icon_for_status' do it 'renders to correct svg on success' do - expect(helper).to receive(:render).with('shared/icons/icon_status_success.svg', anything) + expect(helper).to receive(:render) + .with('shared/icons/icon_status_success.svg', anything) + helper.ci_icon_for_status(success_commit.status) end + it 'renders the correct svg on failure' do - expect(helper).to receive(:render).with('shared/icons/icon_status_failed.svg', anything) + expect(helper).to receive(:render) + .with('shared/icons/icon_status_failed.svg', anything) + helper.ci_icon_for_status(failed_commit.status) end end + describe '#ci_text_for_status' do + context 'when status is manual' do + it 'changes the status to blocked' do + expect(helper.ci_text_for_status('manual')) + .to eq 'blocked' + end + end + + context 'when status is success' do + it 'changes the status to passed' do + expect(helper.ci_text_for_status('success')) + .to eq 'passed' + end + end + + context 'when status is something else' do + it 'returns status unchanged' do + expect(helper.ci_text_for_status('some-status')) + .to eq 'some-status' + end + end + end + describe "#pipeline_status_cache_key" do + let(:pipeline_status) do + Gitlab::Cache::Ci::ProjectPipelineStatus + .new(build(:project), sha: '123abc', status: 'success') + end + it "builds a cache key for pipeline status" do - pipeline_status = Gitlab::Cache::Ci::ProjectPipelineStatus.new( - build(:project), - sha: "123abc", - status: "success" - ) - expect(helper.pipeline_status_cache_key(pipeline_status)).to eq("pipeline-status/123abc-success") + expect(helper.pipeline_status_cache_key(pipeline_status)) + .to eq("pipeline-status/123abc-success") end end end
Add specs for new ci status helper method
diff --git a/cloudy_ui.rb b/cloudy_ui.rb index abc1234..def5678 100644 --- a/cloudy_ui.rb +++ b/cloudy_ui.rb @@ -2,7 +2,7 @@ require_relative 'cloudy_ui/button' require_relative 'cloudy_ui/slider' - def self.load_images window, load_path=File.join(Dir.pwd, 'cloudy_ui/images') + def self.load_images window, load_path=File.join(File.dirname(__FILE__), 'cloudy_ui/images') CloudyUi::Button.load_images window, load_path CloudyUi::Slider.load_images window, load_path end
Fix for putting files in subdirectory
diff --git a/spec/models/poll/question_spec.rb b/spec/models/poll/question_spec.rb index abc1234..def5678 100644 --- a/spec/models/poll/question_spec.rb +++ b/spec/models/poll/question_spec.rb @@ -2,13 +2,6 @@ RSpec.describe Poll::Question, type: :model do let(:poll_question) { build(:poll_question) } - - describe "#valid_answers" do - it "gets a comma-separated string, but returns an array" do - poll_question.valid_answers = "Yes, No" - expect(poll_question.valid_answers).to eq(["Yes", "No"]) - end - end describe "#poll_question_id" do it "should be invalid if a poll is not selected" do @@ -27,7 +20,6 @@ create_list(:geozone, 3) p = create(:proposal) poll_question.copy_attributes_from_proposal(p) - expect(poll_question.valid_answers).to eq(['Yes', 'No']) expect(poll_question.author).to eq(p.author) expect(poll_question.author_visible_name).to eq(p.author.name) expect(poll_question.proposal_id).to eq(p.id)
Remove no longer needed question model tests for valid_answers
diff --git a/ForecastIOClient.podspec b/ForecastIOClient.podspec index abc1234..def5678 100644 --- a/ForecastIOClient.podspec +++ b/ForecastIOClient.podspec @@ -1,24 +1,8 @@-# -# Be sure to run `pod lib lint ForecastIOClient.podspec' to ensure this is a -# valid spec and remove all comments before submitting the spec. -# -# Any lines starting with a # are optional, but encouraged -# -# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html -# - Pod::Spec.new do |s| s.name = "ForecastIOClient" s.version = "0.1.0" - s.summary = "A short description of ForecastIOClient." - s.description = <<-DESC - An optional longer description of ForecastIOClient - - * Markdown format. - * Don't worry about the indent, we strip it! - DESC + s.summary = "A Swift forecast.io API client." s.homepage = "https://github.com/pwillsey/ForecastIOClient" - # s.screenshots = "www.example.com/screenshots_1", "www.example.com/screenshots_2" s.license = 'MIT' s.author = { "Peter Willsey" => "pwillsey@gmail.com" } s.source = { :git => "https://github.com/pwillsey/ForecastIOClient.git", :tag => s.version.to_s } @@ -32,7 +16,6 @@ 'ForecastIOClient' => ['Pod/Assets/*.png'] } - # s.public_header_files = 'Pod/Classes/**/*.h' s.dependency 'AFNetworking', '~> 2.3' s.dependency 'SwiftyJSON' end
Update podspec with summary and remove extra fields.
diff --git a/lib/asciidoctor/latex/inject_html.rb b/lib/asciidoctor/latex/inject_html.rb index abc1234..def5678 100644 --- a/lib/asciidoctor/latex/inject_html.rb +++ b/lib/asciidoctor/latex/inject_html.rb @@ -23,7 +23,7 @@ </style> -<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> +<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script>
Change http refernce to jquery at google to https
diff --git a/app/controllers/ajo_register/registrations_controller.rb b/app/controllers/ajo_register/registrations_controller.rb index abc1234..def5678 100644 --- a/app/controllers/ajo_register/registrations_controller.rb +++ b/app/controllers/ajo_register/registrations_controller.rb @@ -24,4 +24,10 @@ def thank_you end + protected + + def after_update_path_for(resource) + Rails.logger.info "CALLED" + user_path(resource) + end end
Add after sign up path
diff --git a/tzinfo_completer.gemspec b/tzinfo_completer.gemspec index abc1234..def5678 100644 --- a/tzinfo_completer.gemspec +++ b/tzinfo_completer.gemspec @@ -4,4 +4,5 @@ s.date = "2008-11-17" s.summary = "Contains the parts of the TZInfo gem not included in the slimmed-down version in ActiveSupport" s.homepage = "http://github.com/gbuesing/tzinfo_completer" + s.files = FileList['LICENSE', 'Rakefile', 'README', 'lib/**/*'] end
Add files to gem specification
diff --git a/bootstrap_sb_admin_base_v2.gemspec b/bootstrap_sb_admin_base_v2.gemspec index abc1234..def5678 100644 --- a/bootstrap_sb_admin_base_v2.gemspec +++ b/bootstrap_sb_admin_base_v2.gemspec @@ -19,8 +19,6 @@ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - spec.add_development_dependency "bundler", "~> 1.10" - spec.add_development_dependency "rake", "~> 10.0" - spec.add_development_dependency "jquery-rails" - spec.add_development_dependency "bootstrap-sass" + spec.add_dependency "jquery-rails" + spec.add_dependency "font-awesome-rails" end
Add jquery-rails and font-awesome-rails gems as dependencies
diff --git a/app/mailers/noisy_workflow.rb b/app/mailers/noisy_workflow.rb index abc1234..def5678 100644 --- a/app/mailers/noisy_workflow.rb +++ b/app/mailers/noisy_workflow.rb @@ -19,8 +19,12 @@ def request_fact_check(edition, email_addresses) @edition = edition - mail(:to => email_addresses, - :reply_to => 'eds@alphagov.co.uk', :subject => "[FACT CHECK REQUESTED] #{edition.title} (id:#{edition.fact_check_id})") unless email_addresses.blank? + fact_check_address = "factcheck+#{Rails.env}-#{edition.container.id}@alphagov.co.uk" + mail( + :to => email_addresses, + :reply_to => fact_check_address, + :from => "Gov.UK Editors <#{fact_check_address}>", + :subject => "[FACT CHECK REQUESTED] #{edition.title} (id:#{edition.fact_check_id})") unless email_addresses.blank? end end
Set from/reply-to addresses on fact check requests to proper one
diff --git a/ws/ws_wrapper.rb b/ws/ws_wrapper.rb index abc1234..def5678 100644 --- a/ws/ws_wrapper.rb +++ b/ws/ws_wrapper.rb @@ -0,0 +1,12 @@+module Ldash + # Class that wraps around Faye's ws object so we can send events more easily + class WSWrapper + def initialize(ws) + @ws = ws + end + + def send_ready(session) + # ... + end + end +end
Make a class to wrap around Faye's ws object
diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb index abc1234..def5678 100644 --- a/config/initializers/sidekiq.rb +++ b/config/initializers/sidekiq.rb @@ -0,0 +1,7 @@+Sidekiq.configure_server do |config| + config.redis = { url: ENV['REDIS_URL'] || 'redis://localhost:6379/12' } +end + +Sidekiq.configure_client do |config| + config.redis = { url: ENV['REDIS_URL'] || 'redis://localhost:6379/12' } +end
Allow REDIS_URL to be set with ENV vars
diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb index abc1234..def5678 100644 --- a/config/initializers/sidekiq.rb +++ b/config/initializers/sidekiq.rb @@ -1,7 +1,22 @@ Sidekiq.configure_client do |config| config.client_middleware do |chain| chain.add SidekiqLoggerMiddleware - # See https://github.com/mhenrixon/sidekiq-unique-jobs/blob/921aaa4efc998b102790d1f4ecce2ebac609e464/README.md#add-the-middleware chain.add SidekiqUniqueJobs::Middleware::Client end end + +Sidekiq.configure_server do |config| + config.client_middleware do |chain| + chain.add SidekiqLoggerMiddleware + chain.add SidekiqUniqueJobs::Middleware::Client + end + + config.server_middleware do |chain| + chain.add SidekiqUniqueJobs::Middleware::Server + end + + SidekiqUniqueJobs::Server.configure(config) +end + +# SidekiqUniqueJobs recommends not testing this behaviour https://github.com/mhenrixon/sidekiq-unique-jobs#uniqueness +SidekiqUniqueJobs.config.enabled = !Rails.env.test?
Add missing server side unique jobs config As discussed in the previous commit, when we upgraded sidekiq-unique-gems to 7.0 we didn't add in all the required config. Default config was removed from 7.0 of the unique sidekicks job gem. As a result, you have to manually configure the client and server middleware (see https://github.com/mhenrixon/sidekiq-unique-jobs#add-the-middleware) We missed adding in the server side config. This config deals with removing a key from Redis after a job has run. This has led to us having over 7 million keys which should have been expunged still being persisted. While you would think this issue would fail fast, and loudly, it didn't in this situation. This is due to nearly all jobs having uniq args passed in as discussed in detail in the previous commit. As far as we can tell, conflicts only occurred on the PublishingAPI when downtimes were scheduled on Mainstream. These two issues combined caused surprisingly subtle behaviour which took a lengthy time to investigate and fix. Around 2 weeks, with a couple of mobbing sessions and several pairing sessions.
diff --git a/lib/tasks/grant_group_self_access.rb b/lib/tasks/grant_group_self_access.rb index abc1234..def5678 100644 --- a/lib/tasks/grant_group_self_access.rb +++ b/lib/tasks/grant_group_self_access.rb @@ -19,7 +19,7 @@ # if group is a council, only that council-group, not the parent-group, # should have admin access over the parent-group - if group.council? + if group.council? && group.parent #seem to be come cases where a council doesn't have a parent group. group.parent.grant! group, :all group.parent.revoke! group.parent, :admin end
Tweak to task as there seem to be councils that don't have parent groups.
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index abc1234..def5678 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -36,7 +36,7 @@ def user_owner if current_user != @user flash[:danger] = "You don't have permissions to do that." - redirect_to user_dashboard_path(current_user) + redirect_to(:back) end end
Modify redirection in the user_owner helper
diff --git a/barge.gemspec b/barge.gemspec index abc1234..def5678 100644 --- a/barge.gemspec +++ b/barge.gemspec @@ -10,7 +10,10 @@ spec.authors = ['Ørjan Blom'] spec.email = %w(blom@blom.tv) spec.homepage = 'https://github.com/blom/barge' - spec.files = Dir['lib/**/*.rb', '[A-Z][A-Z]*'] + + spec.files = `git ls-files -z`.split("\x0").keep_if do |file| + file.match(/\A(lib|[A-Z]{2})/) + end spec.required_ruby_version = '>= 1.9.3'
Use `git ls-files` for file inclusion
diff --git a/app/models/duckrails/application_state.rb b/app/models/duckrails/application_state.rb index abc1234..def5678 100644 --- a/app/models/duckrails/application_state.rb +++ b/app/models/duckrails/application_state.rb @@ -7,7 +7,8 @@ default_scope { order(id: :desc) } - validates_inclusion_of :singleton_guard, in: [0] + validates :singleton_guard, inclusion: { in: [0] } + validates :mock_synchronization_token, presence: true class << self # @return [ApplicationState] the one and only application state
Add validations to the singleton guard & the mock synchronization token. Refs 16.
diff --git a/app/models/concerns/core/friendly_globalize_sluggable.rb b/app/models/concerns/core/friendly_globalize_sluggable.rb index abc1234..def5678 100644 --- a/app/models/concerns/core/friendly_globalize_sluggable.rb +++ b/app/models/concerns/core/friendly_globalize_sluggable.rb @@ -22,6 +22,7 @@ private + # FIXME: issue with PostgreSQL and SQLite def slug_candidates [[:title, :deduced_id]] end
Add FIXME annotation to file
diff --git a/spec/tic_tac_toe/rack_spec.rb b/spec/tic_tac_toe/rack_spec.rb index abc1234..def5678 100644 --- a/spec/tic_tac_toe/rack_spec.rb +++ b/spec/tic_tac_toe/rack_spec.rb @@ -6,7 +6,8 @@ include Rack::Test::Methods def app - TicTacToe::RackShell.new_shell + app = TicTacToe::RackShell.new_shell + Rack::Session::Pool.new(app, :expire_after => 18000) end it 'can receive an index/root GET request' do
Add a session pool to the top level app tests
diff --git a/app/controllers/payments_handler_controller.rb b/app/controllers/payments_handler_controller.rb index abc1234..def5678 100644 --- a/app/controllers/payments_handler_controller.rb +++ b/app/controllers/payments_handler_controller.rb @@ -21,7 +21,7 @@ params.permit(:method, :amount) end - def withdrawal + def withdrawal_params params.permit(:method, :amount) end end
Add a test withdrawal function
diff --git a/Casks/djay-pro.rb b/Casks/djay-pro.rb index abc1234..def5678 100644 --- a/Casks/djay-pro.rb +++ b/Casks/djay-pro.rb @@ -1,11 +1,11 @@ cask :v1 => 'djay-pro' do - version '1.1.3-201506261526' - sha256 '47bb67196483e684ce3009088886e915fb9e83049fc263d3cc96d38755f5185c' + version '1.2-201508141249' + sha256 '1abf8861828d6233cf0254b0fe8621f2fb8ce1780201b2d1af1cdb1c3c8463af' url "http://download.algoriddim.com/djay/#{version.sub(%r{.*?-},'')}/djay_Pro_#{version.sub(%r{-\d+$},'')}.zip" name 'djay Pro' appcast 'https://www.algoriddim.com/djay-mac/releasenotes/appcast', - :sha256 => '34da66c26e576ea02d0fbf42e1a655de5752e5389b176b7af18856ef7b202e66', + :sha256 => 'b4289029993baacd8d95e458b65227fdb1c449713efe1696c064e6e2032717e3', :format => :sparkle homepage 'http://algoriddim.com/djay-mac' license :commercial
Update djay Pro to 1.2-201508141249
diff --git a/lib/cutaneous/engine.rb b/lib/cutaneous/engine.rb index abc1234..def5678 100644 --- a/lib/cutaneous/engine.rb +++ b/lib/cutaneous/engine.rb @@ -1,14 +1,14 @@ module Cutaneous + # Manages a set of Loaders that render templates class Engine + attr_accessor :loader_class + def initialize(template_roots, lexer_class) - @roots, @lexer_class = Array(template_roots), lexer_class - end - - def loader(format) - @loader ||= Loader.new(@roots, format).tap do |loader| - loader.lexer_class = @lexer_class - end + @roots = Array(template_roots) + @lexer_class = lexer_class + @loader_class = FileLoader + @loaders = {} end def render_file(path, format, context)
Make loader class configurable & keep copies of loaders on a per-format basis
diff --git a/app/presenters/tree_builder_template_filter.rb b/app/presenters/tree_builder_template_filter.rb index abc1234..def5678 100644 --- a/app/presenters/tree_builder_template_filter.rb +++ b/app/presenters/tree_builder_template_filter.rb @@ -1,6 +1,6 @@ class TreeBuilderTemplateFilter < TreeBuilderVmsFilter def tree_init_options(tree_name) - super.update(:leaf => 'MiqTemplate') + super.update(:leaf => 'ManageIQ::Providers::InfraManager::Template') end def set_locals_for_render
Rename class of leaves for Template filter tree. Rename class of leaves for Template filter tree as earlier renamed elsewhere in the big model rename. https://bugzilla.redhat.com/show_bug.cgi?id=1283642
diff --git a/config/initializers/notifiable_classes.rb b/config/initializers/notifiable_classes.rb index abc1234..def5678 100644 --- a/config/initializers/notifiable_classes.rb +++ b/config/initializers/notifiable_classes.rb @@ -1,3 +1,14 @@ # Set classes that can be notified when # actions happen to them -Inquest::Application.config.notifiable_classes = [Question, Answer, Comment, Vote] +Inquest::Application.config.notifiable_classes = [Question, Answer] + +# Include the notifiable module to make sure they conform to what a notifiable model must do +Inquest::Application.config.notifiable_classes.each do |klass| + unless klass.included_modules.include?(Inquest::Notifiable) + Rails.logger.warn "#{klass.name} does not include Inquest::Notifiable, so may not work correctly." + end +end + +# Set classes that can react to events on notifiable classes. +# These classes should inherit from Inquest::Reactor +Inquest::Application.config.reactor_classes = [EmailReactor]
Check that the notifiable classes include the Inquest::Notifiable module, and warn if they do not. Record reactor classes in config, as trying to automatically determine them is not working correctly.
diff --git a/puppet-lint-duplicate_class_parameters-check.gemspec b/puppet-lint-duplicate_class_parameters-check.gemspec index abc1234..def5678 100644 --- a/puppet-lint-duplicate_class_parameters-check.gemspec +++ b/puppet-lint-duplicate_class_parameters-check.gemspec @@ -22,7 +22,7 @@ spec.add_development_dependency 'rspec', '~> 3.9.0' spec.add_development_dependency 'rspec-its', '~> 1.0' spec.add_development_dependency 'rspec-collection_matchers', '~> 1.0' - spec.add_development_dependency 'rubocop', '~> 0.86.0' + spec.add_development_dependency 'rubocop', '~> 0.87.0' spec.add_development_dependency 'rake', '~> 13.0.0' spec.add_development_dependency 'rspec-json_expectations', '~> 2.2' spec.add_development_dependency 'simplecov', '~> 0.18.0'
Update rubocop requirement from ~> 0.86.0 to ~> 0.87.0 Updates the requirements on [rubocop](https://github.com/rubocop-hq/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop-hq/rubocop/releases) - [Changelog](https://github.com/rubocop-hq/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop-hq/rubocop/compare/v0.86.0...v0.87.0) Signed-off-by: dependabot-preview[bot] <5bdcd3c0d4d24ae3e71b3b452a024c6324c7e4bb@dependabot.com>
diff --git a/lib/hdo/search/index.rb b/lib/hdo/search/index.rb index abc1234..def5678 100644 --- a/lib/hdo/search/index.rb +++ b/lib/hdo/search/index.rb @@ -5,13 +5,15 @@ def update_index_on_change_of(*args) singular = self.to_s.downcase plural = singular.pluralize - classes = args.map { |a| a.to_s.singularize.capitalize.constantize } + classes = args.map { |a| a.to_s.classify.constantize } classes.each do |clazz| if clazz.method_defined? singular clazz.send :after_save, "#{singular}.tire.update_index" elsif clazz.method_defined? plural clazz.send :after_save, "#{plural}.each {|e| e.tire.update_index}" + else + raise "Model #{self} has no relation #{clazz}." end end
Improve the symbol->class resolution in Hdo::Search::Index
diff --git a/spec/app_spec_helper.rb b/spec/app_spec_helper.rb index abc1234..def5678 100644 --- a/spec/app_spec_helper.rb +++ b/spec/app_spec_helper.rb @@ -26,8 +26,8 @@ # production config / requires else # development or testing only - require 'pry' - require 'awesome_print' + #require 'pry' + #require 'awesome_print' use Rack::ShowExceptions end
Remove debug only gem refs.
diff --git a/lib/safely/backtrace.rb b/lib/safely/backtrace.rb index abc1234..def5678 100644 --- a/lib/safely/backtrace.rb +++ b/lib/safely/backtrace.rb @@ -22,16 +22,9 @@ trace_file = File.join( self.trace_directory, "backtrace-#{Time.now.strftime('%Y%m%d%H%M%S')}-#{Process.pid}.log" ) trace_log = Logger.new( trace_file ) - # Find the last exception - e = nil - ObjectSpace.each_object {|o| - if ::Exception === o - e = o - end - } - + # Log the last exception trace_log.info "*** Below you'll find the most recent exception thrown, this will likely (but not certainly) be the exception that made #{DaemonKit.configuration.daemon_name} exit abnormally ***" - trace_log.error e + trace_log.error $! trace_log.info "*** Below you'll find all the exception objects in memory, some of them may have been thrown in your application, others may just be in memory because they are standard exceptions ***" ObjectSpace.each_object {|o|
Use `$!` to report the last Exception. The previous method does not work reliably.
diff --git a/lib/static_sync/meta.rb b/lib/static_sync/meta.rb index abc1234..def5678 100644 --- a/lib/static_sync/meta.rb +++ b/lib/static_sync/meta.rb @@ -15,10 +15,11 @@ def for(file) meta = { - :public => true, :key => file, :body => File.new(file), + :public => true } + MIME::Types::of(file).each do |mime| meta.merge!( :content_type => MIME::Type.simplified(mime) @@ -26,10 +27,13 @@ meta.merge!(@compression.for(file, mime)) meta.merge!(@caching.for(file, mime)) end + + body = meta[:body].read + meta.merge!( - :etag => Digest::MD5.hexdigest(meta[:body].read) + :etag => Digest::MD5.hexdigest(body), # A local version of the etag expected after upload. + :content_md5 => Digest::MD5.base64digest(body) # Enable checksum validation during uploads. ) - meta end end
Enable checksum validation on upload.
diff --git a/lib/vimrunner/errors.rb b/lib/vimrunner/errors.rb index abc1234..def5678 100644 --- a/lib/vimrunner/errors.rb +++ b/lib/vimrunner/errors.rb @@ -1,6 +1,11 @@ module Vimrunner - class NoSuitableVimError < RuntimeError; end class InvalidCommandError < RuntimeError; end + + class NoSuitableVimError < RuntimeError + def message + "No suitable Vim executable could be found for this system." + end + end class TimeoutError < RuntimeError def message
Add a more helpful message to NoSuitableVimError
diff --git a/lib/weather_reporter.rb b/lib/weather_reporter.rb index abc1234..def5678 100644 --- a/lib/weather_reporter.rb +++ b/lib/weather_reporter.rb @@ -2,8 +2,13 @@ require 'weather_reporter/http_service/request' require 'weather_reporter/configuration' require 'weather_reporter/error/invalid_path' +require 'weather_reporter/error/invalid_flag' require 'weather_reporter/error/invalid_file' +require 'weather_reporter/user_input/validator' +require 'pry' module WeatherReporter - # Your code goes here... + def take_user_input + ARGV.each_slice(2).to_a + end end
Set require for added validator class
diff --git a/LambdaKit.podspec b/LambdaKit.podspec index abc1234..def5678 100644 --- a/LambdaKit.podspec +++ b/LambdaKit.podspec @@ -6,7 +6,7 @@ s.homepage = 'https://github.com/Reflejo/ClosureKit' s.social_media_url = 'https://twitter.com/fz' s.authors = { 'Martin Conte Mac Donell' => 'reflejo@gmail.com' } - s.source = { :git => 'https://github.com/Reflejo/ClosureKit.git' } + s.source = { :git => 'https://github.com/Reflejo/ClosureKit.git', :tag => s.version } s.ios.deployment_target = '8.0' s.watchos.deployment_target = '2.0'
Add version to podspec source
diff --git a/core/lib/spree/testing_support/common_rake.rb b/core/lib/spree/testing_support/common_rake.rb index abc1234..def5678 100644 --- a/core/lib/spree/testing_support/common_rake.rb +++ b/core/lib/spree/testing_support/common_rake.rb @@ -17,7 +17,8 @@ puts "Setting up dummy database..." - sh "bundle exec rake db:migrate VERBOSE=false" + sh "bundle exec bin/rails db:environment:set RAILS_ENV=test" + sh "bundle exec rake db:drop db:create db:migrate VERBOSE=false RAILS_ENV=test" begin require "generators/#{ENV['LIB_NAME']}/install/install_generator"
Fix database deletion and creation in test_app In some circumstances, creating and deleting the database was failing when running rake test_app. This was likely broken in by bc8efcb5f66057e0a6e91abaf801528c556d28d0 as well as the rails 5 upgrade. Fixes #1491
diff --git a/configs.gemspec b/configs.gemspec index abc1234..def5678 100644 --- a/configs.gemspec +++ b/configs.gemspec @@ -16,6 +16,5 @@ gem.version = Configs::VERSION gem.add_dependency 'activesupport', '>3.0' - gem.add_development_dependency "test-unit" gem.add_development_dependency "rake" end
Remove redundant test-unit gem dependency
diff --git a/db/migrate/20160605114232_create_users.rb b/db/migrate/20160605114232_create_users.rb index abc1234..def5678 100644 --- a/db/migrate/20160605114232_create_users.rb +++ b/db/migrate/20160605114232_create_users.rb @@ -3,8 +3,9 @@ create_table :users do |t| t.string :first_name, null: false t.string :last_name, null: false - t.string :email, null:false - t.string :username, null:false + t.string :email, null: false + t.string :username, null: false + t.string :password_hash, null: false t.text :personal_description t.string :profile_pic_url t.string :facebook_url
Add column for password hash
diff --git a/site-cookbooks/1password/recipes/default.rb b/site-cookbooks/1password/recipes/default.rb index abc1234..def5678 100644 --- a/site-cookbooks/1password/recipes/default.rb +++ b/site-cookbooks/1password/recipes/default.rb @@ -1,6 +1,6 @@ directory "#{ENV['HOME']}/Applications" -unless File.exists?("#{ENV['HOME']}/Applications/1Password.app") +unless File.exists?("#{ENV['HOME']}/Applications/1Password.app") || File.exists?("/Applications/1Password.app") remote_file "#{Chef::Config[:file_cache_path]}/1password.zip" do source "https://d13itkw33a7sus.cloudfront.net/dist/1P/mac/1Password-3.8.20.zip"
Check for 1password also in /Applications
diff --git a/cru_lib.gemspec b/cru_lib.gemspec index abc1234..def5678 100644 --- a/cru_lib.gemspec +++ b/cru_lib.gemspec @@ -17,6 +17,7 @@ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] + spec.add_dependency "global_registry" spec.add_development_dependency "bundler", "~> 1.6" spec.add_development_dependency "rake"
Add global_registry as a dependency
diff --git a/fluent-plugin-juniper-telemetry.gemspec b/fluent-plugin-juniper-telemetry.gemspec index abc1234..def5678 100644 --- a/fluent-plugin-juniper-telemetry.gemspec +++ b/fluent-plugin-juniper-telemetry.gemspec @@ -4,7 +4,7 @@ Gem::Specification.new do |s| s.name = "fluent-plugin-juniper-telemetry" - s.version = '0.2.8' + s.version = '0.2.9' s.authors = ["Damien Garros"] s.email = ["dgarros@gmail.com"]
Update Gem number to 0.2.9
diff --git a/config/initializers/carrierwave.rb b/config/initializers/carrierwave.rb index abc1234..def5678 100644 --- a/config/initializers/carrierwave.rb +++ b/config/initializers/carrierwave.rb @@ -2,8 +2,6 @@ if Rails.env.production? and Configuration[:aws_access_key] config.fog_credentials = { provider: 'AWS', - host: 's3.amazonaws.com', - endpoint: 'https://s3.amazonaws.com', aws_access_key_id: Configuration[:aws_access_key], aws_secret_access_key: Configuration[:aws_secret_key], fog_region: Configuration[:aws_region]
Remove host and endpoint from CarrierWave configuration
diff --git a/spec/inputs/character_limited_input_spec.rb b/spec/inputs/character_limited_input_spec.rb index abc1234..def5678 100644 --- a/spec/inputs/character_limited_input_spec.rb +++ b/spec/inputs/character_limited_input_spec.rb @@ -0,0 +1,33 @@+require 'spec_helper' + +RSpec.describe CharacterLimitedInput do + include RSpec::Rails::HelperExampleGroup + + describe '#input' do + let(:input) { proc { |f| f.input(:attr_name, as: :character_limited) } } + + subject { helper.simple_form_for(:foo, url: '', &input) } + + it 'returns a textarea with character-limited data attributes' do + tag_attributes = { + 'data-behaviour' => 'character-limited', + 'data-maxlength' => Student::CHARACTER_LIMIT, + 'class' => 'form-control character_limited required', + 'name' => 'foo[attr_name]' + } + + expect(subject).to have_tag('textarea', with: tag_attributes) + end + + it 'does not use the html maxlength attribute' do + expect(subject).not_to include 'maxlengh=' + end + + it 'returns a counter element' do + expect(subject).to have_tag('p') do + with_tag('span', with: { class: 'character_limited_counter' }) + end + end + + end +end
Add specs for custom character limited input
diff --git a/test/features/visit_all_page_test.rb b/test/features/visit_all_page_test.rb index abc1234..def5678 100644 --- a/test/features/visit_all_page_test.rb +++ b/test/features/visit_all_page_test.rb @@ -12,8 +12,10 @@ return if visited.include? current_path visited << current_path all('a').each do |a| - visit a[:href] - visit_all_links(visited) + if a[:href].start_with?('/') + visit a[:href] + visit_all_links(visited) + end end end end
Fix when page has external links, test will fail.
diff --git a/spec/factories/recent_view.rb b/spec/factories/recent_view.rb index abc1234..def5678 100644 --- a/spec/factories/recent_view.rb +++ b/spec/factories/recent_view.rb @@ -9,7 +9,14 @@ # select a random record of the given object class o_id do - type.to_s.camelcase.constantize.order('RANDOM()').first.id + random_function = case ActiveRecord::Base.connection_config[:adapter] + when 'mysql2' + 'RAND' + when 'postgresql' + 'RANDOM' + end + + type.to_s.camelcase.constantize.order("#{random_function}()").first.id end # assign to an existing user, if possible
Modify SQL in RecentView factory to support MySQL
diff --git a/lib/auto_html/filters/twitter.rb b/lib/auto_html/filters/twitter.rb index abc1234..def5678 100644 --- a/lib/auto_html/filters/twitter.rb +++ b/lib/auto_html/filters/twitter.rb @@ -2,7 +2,7 @@ require 'net/http' AutoHtml.add_filter(:twitter).with({}) do |text, options| - regex = %r{https://twitter\.com(/#!)?/[A-Za-z0-9_]{1,15}/status(es)?/(\d+)} + regex = %r{https://twitter\.com(/#!)?/[A-Za-z0-9_]{1,15}/status(es)?/\d+} text.gsub(regex) do |match| params = { :url => match }.merge(options)
Remove unnecessary grouping from Twitter regex
diff --git a/spec/lj_media/author_spec.rb b/spec/lj_media/author_spec.rb index abc1234..def5678 100644 --- a/spec/lj_media/author_spec.rb +++ b/spec/lj_media/author_spec.rb @@ -0,0 +1,29 @@+require 'spec_helper' + +describe LJMedia::Author do + describe '#new' do + it 'must accept initialization by user id only and get username from profile page' do + a = nil + expect(a = LJMedia::Author.new(33479568)).to be_an LJMedia::Author + expect(a.username).to be_a String + expect(a.username).to eq('ext_384967') + end + + it 'must accept initialization by user id and username' do + a = nil + expect(a = LJMedia::Author.new(15140396)).to be_an LJMedia::Author + expect(a.username).to be_a String + expect(a.username).to eq('v_glaza_smotri') + end + + it 'must take already parsed info from cache instead of reloading profile page from server' do + a = nil + b = nil + + expect(a = LJMedia::Author.new(73993180)).to be_an LJMedia::Author + expect(b = LJMedia::Author.new(73993180, 'wrong_username')).to be_an LJMedia::Author + expect(b.username).to_not eq('wrong_username') + expect(b.username).to eq(a.username) + end + end +end
Add basic spec for Author.
diff --git a/spec/routing/routing_spec.rb b/spec/routing/routing_spec.rb index abc1234..def5678 100644 --- a/spec/routing/routing_spec.rb +++ b/spec/routing/routing_spec.rb @@ -0,0 +1,10 @@+require 'spec_helper' + +describe "path helpers", type: :helper do + it do + member = mock_model(Member, url_name: "Foo_Bar", url_electorate: "Twist", + australian_house: "representatives") + expect(helper.member_path2(member)). + to eq "/members/representatives/twist/foo_bar" + end +end
Add test for path helper