diff
stringlengths
65
26.7k
message
stringlengths
7
9.92k
diff --git a/app/controllers/addresses_controller.rb b/app/controllers/addresses_controller.rb index abc1234..def5678 100644 --- a/app/controllers/addresses_controller.rb +++ b/app/controllers/addresses_controller.rb @@ -14,7 +14,7 @@ else @addresses = Address.where(@queries) end - @addresses = @addresses.page(@page).per(@per_page) + @addresses = @addresses.page(@page).per(@per_page).no_timeout render_paginated_addresses end
Use no_timeout for search queries This won't remove the underlying problem, but will at least help me diagnose what's going on
diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index abc1234..def5678 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -6,7 +6,11 @@ puts(current_user.id) @user = User.find(current_user.id) @plants = @user.plants.all - @water_events = WaterEvent.where(plant_id: @plants.ids) + @water_events = [] + @plants.each do |p| + event = WaterEvent.where(plant_id: p.id).order(water_date: :desc).limit(1).first + @water_events << event + end end end
Improve data-load being sent to client
diff --git a/app/controllers/denuncias_controller.rb b/app/controllers/denuncias_controller.rb index abc1234..def5678 100644 --- a/app/controllers/denuncias_controller.rb +++ b/app/controllers/denuncias_controller.rb @@ -2,17 +2,25 @@ def create @denuncia = Denuncia.new(denuncia_params) - respond_to do |format| - if @denuncia.save - redirect_to @denuncia, notice: 'Denuncia was successfully created.' - else - render :new - end + if @denuncia.save + redirect_to root_path, notice: 'Denuncia was successfully created.' + else + redirect_to root_path, notice: 'Denuncia was not created.' end end private def denuncia_params - params.require(:denuncia).permit(:pais_id, :delito_id, :fecha, item_denuncias_attributes: [:pregunta_id, :opcion_id]) + params.require(:denuncia).permit( + :pais_id, + :delito_id, + item_denuncias_attributes: [ + :pregunta_id, + :opcion_id, + :fecha, + :observacion, + opciones_multiples: [] + ] + ) end end
Add correct redirect after denuncia and add additional strong params for items.
diff --git a/app/controllers/feedbacks_controller.rb b/app/controllers/feedbacks_controller.rb index abc1234..def5678 100644 --- a/app/controllers/feedbacks_controller.rb +++ b/app/controllers/feedbacks_controller.rb @@ -1,10 +1,37 @@ class FeedbacksController < ApplicationController def new + @feedback = Feedback.new + @chat_room = ChatRoom.find_by(id: params[:chat_room_id]) + @chat = @chat_room.chats.find_by(native_speaker_id: current_user.id) + @ratings = [["One Star", 1], ["Two Stars", 2], ["Three Stars", 3]] end def create + @feedback = Feedback.new(feedback_params) + user = @feedback.recipient + user.points += @feedback.rating * 2 + if user.points >= 10 + curr_level = user.level + user.level = Level.find_by(language_id: curr_level.language_id, + value: curr_level.value + 1) if user.level.value < 10 + user.points = 0 + end + user.save + if @feedback.save + flash[:notice] = ["Successfully sent feedback."] + redirect_to root_path + else + flash[:alert] = ["Feedback could not be sent."] + redirect_to new_feedback_path + end end def show end + + private + + def feedback_params + params.require(:feedback).permit(:rating, :comment, :chat_id, :sender_id, :recipient_id) + end end
Add new and create actions for feedback
diff --git a/test/controllers/api/story_images_controller_test.rb b/test/controllers/api/story_images_controller_test.rb index abc1234..def5678 100644 --- a/test/controllers/api/story_images_controller_test.rb +++ b/test/controllers/api/story_images_controller_test.rb @@ -13,21 +13,20 @@ end it 'should show' do - get(:show, api_request_opts(id: story_image.id)) + get(:show, api_request_opts(story_id: story.id, id: story_image.id)) assert_response :success end it 'should list' do story_image.id.wont_be_nil - get(:index, api_request_opts) + get(:index, api_request_opts(story_id: story.id)) assert_response :success end it 'should update' do image_hash = { credit: 'blah credit' } - put :update, image_hash.to_json, api_request_opts(story_id: story.id, id: story_image.id) + put(:update, image_hash.to_json, api_request_opts(story_id: story.id, id: story_image.id)) assert_response :success StoryImage.find(story_image.id).credit.must_equal('blah credit') end - end
Access story image nested in story
diff --git a/app/workers/update_milestones_worker.rb b/app/workers/update_milestones_worker.rb index abc1234..def5678 100644 --- a/app/workers/update_milestones_worker.rb +++ b/app/workers/update_milestones_worker.rb @@ -2,8 +2,8 @@ include Sidekiq::Worker def perform(activity_session_uid) - return unless activity_session_uid activity_session = ActivitySession.find_by_uid(activity_session_uid) + return unless activity_session # more milestones can be added here as relevant, for now this just checks to see if a Completed Diagnostic milestone needs to be created if activity_session.state == 'finished' && activity_session.classroom_activity_id && activity_session.classroom_activity.activity.activity_classification_id === 4 teacher_milestones = activity_session.classroom_activity.unit.user.milestones
Make sure we have an activity session.
diff --git a/app/models/document.rb b/app/models/document.rb index abc1234..def5678 100644 --- a/app/models/document.rb +++ b/app/models/document.rb @@ -1,2 +1,5 @@ class Document < ActiveRecord::Base + scope :full_text_search, -> (query) { + where("MATCH(content) AGAINST(? IN BOOLEAN MODE)", "*D+ #{query}") + } end
Add a scope for full text search
diff --git a/cleaner.rb b/cleaner.rb index abc1234..def5678 100644 --- a/cleaner.rb +++ b/cleaner.rb @@ -1,26 +1,40 @@ class Cleaner def self.clean_folder path dirty_folders = [] + Dir.glob(path + "/**").sort.each do |file| if File.directory?(file) self.clean_folder file dirty_folders << file else - puts 'cleaning file' + file - self.rename_file file, path + new_file = self.rename_file file, path + self.cut_file_name(new_file, path) if new_file.length > 128 end end self.rename_folders dirty_folders, path + "Cleaned files in folder: " + path end def self.rename_folders folders, path - folders.each{ |folder| self.rename_file folder, path } + folders.each do |folder| + new_folder = self.rename_file folder, path + self.cut_file_name(new_folder, path) if new_folder.length > 250 + end + end + def self.cut_file_name file, path + extension = File.extname file + base_name = File.basename file, extension + base_name = base_name.slice(0..127) + filename = base_name + extension + filename = path + "/" + filename + File.rename file, filename end def self.rename_file file, path filename = self.clean_file_name file filename = path + "/" + filename File.rename file, filename + filename end def self.clean_file_name file extension = File.extname file
Add check for length restrictions of file name and folders
diff --git a/ohm-contrib.gemspec b/ohm-contrib.gemspec index abc1234..def5678 100644 --- a/ohm-contrib.gemspec +++ b/ohm-contrib.gemspec @@ -10,9 +10,9 @@ s.files = `git ls-files`.split("\n") - s.add_dependency "ohm", "~> 2.0.0" + s.add_dependency "ohm", "~> 2.0" - s.add_development_dependency "cutest" - s.add_development_dependency "iconv" - s.add_development_dependency "override" + s.add_development_dependency "cutest", "~> 1.2" + s.add_development_dependency "iconv", "~> 1.0" + s.add_development_dependency "override", "~> 0.0" end
Fix the gem build warnings
diff --git a/pronto-rubocop.gemspec b/pronto-rubocop.gemspec index abc1234..def5678 100644 --- a/pronto-rubocop.gemspec +++ b/pronto-rubocop.gemspec @@ -20,7 +20,7 @@ s.test_files = `git ls-files -- {spec}/*`.split("\n") s.require_paths = ['lib'] - s.add_dependency 'rubocop', '~> 0.12.0' + s.add_dependency 'rubocop', '~> 0.13.0' s.add_dependency 'pronto', '~> 0.0.3' s.add_development_dependency 'rake', '~> 10.1.0' s.add_development_dependency 'rspec', '~> 2.13.0'
Update rubocop dependency version to 0.13.0
diff --git a/cookbooks/chef/attributes/default.rb b/cookbooks/chef/attributes/default.rb index abc1234..def5678 100644 --- a/cookbooks/chef/attributes/default.rb +++ b/cookbooks/chef/attributes/default.rb @@ -5,7 +5,7 @@ default[:chef][:server][:version] = "11.1.3-1" # Set the default client version -default[:chef][:client][:version] = "11.12.8-2" +default[:chef][:client][:version] = "11.16.0-1" # A list of gems needed by chef recipes default[:chef][:gems] = []
Update chef client to 11.16.0-1
diff --git a/data-aggregation-accumulator.gemspec b/data-aggregation-accumulator.gemspec index abc1234..def5678 100644 --- a/data-aggregation-accumulator.gemspec +++ b/data-aggregation-accumulator.gemspec @@ -1,7 +1,7 @@ # -*- encoding: utf-8 -*- Gem::Specification.new do |s| s.name = 'data_aggregation-accumulator' - s.version = '0.0.0.1' + s.version = '0.0.1.0' s.summary = 'Data aggregation accumulator library' s.description = ' '
Package version is increased from 0.0.0.1 to 0.0.1.0
diff --git a/problem_035.rb b/problem_035.rb index abc1234..def5678 100644 --- a/problem_035.rb +++ b/problem_035.rb @@ -0,0 +1,16 @@+require 'prime' + +# find all circular primes below a certain number +def p35(max) + (collection = []).tap do + Prime.each(max) do |p| + digits_array = p.to_s.chars.map(&:to_i) + tested_ok = (1..(p.to_s.length)).all? do |i| + digits_array.rotate(i).join.to_i.prime? + end + collection << p if tested_ok + end + end +end + +puts p35(1_000_000).size
Add solution to problem 35, circular primes.
diff --git a/lib/data_repository.rb b/lib/data_repository.rb index abc1234..def5678 100644 --- a/lib/data_repository.rb +++ b/lib/data_repository.rb @@ -9,7 +9,7 @@ end def read(name) - File.read("#{data_dir}/#{name}.json") + File.open("#{data_dir}/#{name}.json", "r:utf-8", &:read) end def data_dir
Tag read string correctly as UTF8
diff --git a/lib/how_bad/fetcher.rb b/lib/how_bad/fetcher.rb index abc1234..def5678 100644 --- a/lib/how_bad/fetcher.rb +++ b/lib/how_bad/fetcher.rb @@ -12,12 +12,12 @@ pulls = github.pulls.list user: user, repo: repo { - issues: to_array_of_hashes(issues), - pulls: to_array_of_hashes(pulls), + issues: obj_to_array_of_hashes(issues), + pulls: obj_to_array_of_hashes(pulls), } end - private def to_array_of_hashes(object) + private def obj_to_array_of_hashes(object) object.to_a.map(&:to_h) end end
Rename to_array_of_hashes so it's clearer how it works.
diff --git a/lib/http/redirector.rb b/lib/http/redirector.rb index abc1234..def5678 100644 --- a/lib/http/redirector.rb +++ b/lib/http/redirector.rb @@ -7,7 +7,7 @@ class EndlessRedirectError < TooManyRedirectsError; end # HTTP status codes which indicate redirects - REDIRECT_CODES = 301..303 + REDIRECT_CODES = [300, 301, 302, 303, 307].freeze # Last request attr_reader :request
Fix list of redirect codes we handle
diff --git a/spec/app/models/mdm/module_action_spec.rb b/spec/app/models/mdm/module_action_spec.rb index abc1234..def5678 100644 --- a/spec/app/models/mdm/module_action_spec.rb +++ b/spec/app/models/mdm/module_action_spec.rb @@ -27,6 +27,7 @@ end context 'mass assignment security' do + it { should_not allow_mass_assignment_of(:module_detail_id) } it { should allow_mass_assignment_of(:name) } end
Add missing negative mass assignment spec [#47720609] Mdm::ModuleAction's spec was missing that it should NOT allow mass assignment of module_detail_id, which all the other Mdm::Module* specs did have.
diff --git a/lib/policies/policy.rb b/lib/policies/policy.rb index abc1234..def5678 100644 --- a/lib/policies/policy.rb +++ b/lib/policies/policy.rb @@ -1,9 +1,9 @@ class Policy - attr_reader :user, :role + attr_reader :current_user, :current_role - def initialize(user, role, object) - @user = user - @role = role + def initialize(current_user, current_role, object) + @current_user = current_user + @current_role = current_role unless object.is_a?(Symbol) instance_variable_set('@' + object.class.to_s.underscore, object)
Change user to current_user and role to current_role
diff --git a/lib/rip/environment.rb b/lib/rip/environment.rb index abc1234..def5678 100644 --- a/lib/rip/environment.rb +++ b/lib/rip/environment.rb @@ -1,7 +1,7 @@ module Rip class Package < OpenStruct def to_s - "#{source} (#{version})" + "#{name} (#{version})" end def name @@ -10,6 +10,10 @@ else source end + end + + def dependencies + Array(super).map { |dep| self.class.new(dep) } end end @@ -22,7 +26,7 @@ def packages Rip::Parser.parse(File.read(@path), @path).map do |hash| - Package.new(hash) + package_and_dependencies Package.new(hash) end.flatten end
Fix last failing test, Package knows its dependencies
diff --git a/lib/identificamex/nombre/mayusculas.rb b/lib/identificamex/nombre/mayusculas.rb index abc1234..def5678 100644 --- a/lib/identificamex/nombre/mayusculas.rb +++ b/lib/identificamex/nombre/mayusculas.rb @@ -1,5 +1,6 @@ module Identificamex module Nombre + module Mayusculas def mayusculas(str) return if str.nil? @@ -8,8 +9,10 @@ .upcase .gsub(/ñ/, 'Ñ') .gsub(/,/, '') - .gsub(/\./, '') .gsub(/'/, '') + .gsub(/\./, ' ') + .squeeze(' ') + .strip end def hash_vocales @@ -27,5 +30,6 @@ 'Ü' => 'U'} end end + end end
Replace dots with spaces and squeeze and strip the string.
diff --git a/lib/harness/railtie.rb b/lib/harness/railtie.rb index abc1234..def5678 100644 --- a/lib/harness/railtie.rb +++ b/lib/harness/railtie.rb @@ -37,7 +37,7 @@ require 'harness/queues/sidekiq_queue' Harness.config.queue = :sidekiq else - Harness.config.queue = :syncronous + Harness.config.queue = Harness::SyncronousQueue end end end
Set queue explicity since weird thing with AS
diff --git a/lib/how_bad/fetcher.rb b/lib/how_bad/fetcher.rb index abc1234..def5678 100644 --- a/lib/how_bad/fetcher.rb +++ b/lib/how_bad/fetcher.rb @@ -24,7 +24,7 @@ end - Contract String, C::Optional[C::RespondTo[:issues, :pulls]] => Results + Contract String, C::RespondTo[:issues, :pulls] => Results def call(repository, github = Github.new(auto_pagination: true)) user, repo = repository.split('/', 2)
Remove unnecessary and nonfunctional C::Optional.
diff --git a/core/class.rb b/core/class.rb index abc1234..def5678 100644 --- a/core/class.rb +++ b/core/class.rb @@ -8,7 +8,11 @@ #{sup.inherited `klass`}; - return block !== nil ? block.call(klass, null) : klass; + if (block !== nil) { + block.call(klass, null); + } + + return klass; } end
Fix bug in Class.new when taking a block
diff --git a/lib/rack/body_proxy.rb b/lib/rack/body_proxy.rb index abc1234..def5678 100644 --- a/lib/rack/body_proxy.rb +++ b/lib/rack/body_proxy.rb @@ -1,7 +1,9 @@ module Rack class BodyProxy def initialize(body, &block) - @body, @block, @closed = body, block, false + @body = body + @block = block + @closed = false end def respond_to?(method_name, include_all=false)
Expand initialize ivars instead of using 1 line Flattening the ivars here causes them to be allocated as an array. This commit expands them to avoid these extra allocations. Total allocations before: 2913000 Total allocations after: 2892000
diff --git a/lib/rack/serverinfo.rb b/lib/rack/serverinfo.rb index abc1234..def5678 100644 --- a/lib/rack/serverinfo.rb +++ b/lib/rack/serverinfo.rb @@ -6,7 +6,7 @@ class Serverinfo < Plastic def change_nokogiri_doc(doc) - return request.xhr? + return doc if request.xhr? badge = doc.create_element 'div', style: style
Return the doc when it is a xhr request.
diff --git a/lib/twain/describer.rb b/lib/twain/describer.rb index abc1234..def5678 100644 --- a/lib/twain/describer.rb +++ b/lib/twain/describer.rb @@ -25,10 +25,12 @@ @view_template end + def __output + @__output ||= Liquid::Template.parse(text).render(Proxy.new(self)) + end + def compile(text) - template = Liquid::Template.parse(text) - output = template.render(Proxy.new(self)) - output.gsub("\n",'').squeeze(" ").strip # NOTE: Clean up + __output.gsub("\n",'').squeeze(" ").strip # NOTE: Clean up end end
Split compile into two methods
diff --git a/lib/web_game_engine.rb b/lib/web_game_engine.rb index abc1234..def5678 100644 --- a/lib/web_game_engine.rb +++ b/lib/web_game_engine.rb @@ -12,5 +12,17 @@ @rules = args.fetch(:rules, nil) end + def versus_user(current_board, player, user_input) + if current_board.valid_move?(user_input) + current_board = player.user_move(current_board, user_input) + end + end + + def versus_comp(current_board, rules, player_1, player_1_input, player_2) + if current_board.valid_move?(player_1_input) + current_board = player_1.user_move(current_board, player_1_input) + current_board = player_2.ai_move(current_board, rules) + end + end end
Create methods for game enginer for vs user and vs computer
diff --git a/app/decorators/generic_object_definition_decorator.rb b/app/decorators/generic_object_definition_decorator.rb index abc1234..def5678 100644 --- a/app/decorators/generic_object_definition_decorator.rb +++ b/app/decorators/generic_object_definition_decorator.rb @@ -6,4 +6,11 @@ def fileicon try(:picture) ? "/pictures/#{picture.basename}" : nil end + + def quadicon + { + :fileicon => fileicon, + :fonticon => fileicon ? nil : fonticon + } + end end
Add missing quadicon definition for generic object definitions Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1650146
diff --git a/examples/multi/custom_indent_opts.rb b/examples/multi/custom_indent_opts.rb index abc1234..def5678 100644 --- a/examples/multi/custom_indent_opts.rb +++ b/examples/multi/custom_indent_opts.rb @@ -3,11 +3,10 @@ require 'tty-spinner' opts = { - indent: 4, style: { top: ". ", - middle: "|--", - bottom: "|__", + middle: "|-> ", + bottom: "|__ ", } } spinners = TTY::Spinner::Multi.new("[:spinner] Top level spinner", opts)
Change :style values in the example
diff --git a/lib/ruco/file_store.rb b/lib/ruco/file_store.rb index abc1234..def5678 100644 --- a/lib/ruco/file_store.rb +++ b/lib/ruco/file_store.rb @@ -1,4 +1,5 @@ require "digest/md5" +require "fileutils.rb" module Ruco class FileStore @@ -8,7 +9,7 @@ end def set(key, value) - `mkdir -p #{@folder}` unless File.exist? @folder + FileUtils.mkdir_p @folder unless File.exist? @folder File.write(file(key), serialize(value)) cleanup end
Fix an error on quitting ruco. Windows full paths have a colon, and those were not being passed to the system correctly.
diff --git a/test/test_lxc_class_methods.rb b/test/test_lxc_class_methods.rb index abc1234..def5678 100644 --- a/test/test_lxc_class_methods.rb +++ b/test/test_lxc_class_methods.rb @@ -0,0 +1,25 @@+$:.unshift File.expand_path(File.join(File.dirname(__FILE__), 'lib')) + +require 'test/unit' +require 'lxc' +require 'timeout' + +class TestLXCClassMethods < Test::Unit::TestCase + def setup + if Process::Sys::geteuid != 0 + raise 'This test must be ran as root' + end + @name = 'test' + @container = LXC::Container.new(@name) + @container.create('ubuntu') unless @container.defined? + end + + def test_list_containers + assert_equal([@name], LXC.list_containers) + end + + def test_arch_to_personality + assert_equal(:linux32, LXC.arch_to_personality('x86')) + assert_equal(:linux, LXC.arch_to_personality('x86_64')) + end +end
Add a few specs against LXC singleton methods
diff --git a/lib/set/rainbow_set.rb b/lib/set/rainbow_set.rb index abc1234..def5678 100644 --- a/lib/set/rainbow_set.rb +++ b/lib/set/rainbow_set.rb @@ -26,12 +26,13 @@ set end - def pixel(number, frame = @frame_count) + def pixel(number) number = @length - number if number >= @length + x = @frequency*(number+@frame_count) Color.new( - (Math.sin(@frequency*(number+frame) + 0)**2 * 127), - (Math.sin(@frequency*(number+frame) + 2.0*Math::PI/3.0)**2 * 127), - (Math.sin(@frequency*(number+frame) + 4.0*Math::PI/3.0)**2 * 127) + (Math.sin(x)**2 * 127), + (Math.sin(x + 2.0*Math::PI/3.0)**2 * 127), + (Math.sin(x + 4.0*Math::PI/3.0)**2 * 127) ) end
[REFACTORING] Remove obsolete frame parameter, calculate x only once
diff --git a/db/migrate/20130917164747_add_header_color_and_short_title_to_app_content_set.rb b/db/migrate/20130917164747_add_header_color_and_short_title_to_app_content_set.rb index abc1234..def5678 100644 --- a/db/migrate/20130917164747_add_header_color_and_short_title_to_app_content_set.rb +++ b/db/migrate/20130917164747_add_header_color_and_short_title_to_app_content_set.rb @@ -0,0 +1,6 @@+class AddHeaderColorAndShortTitleToAppContentSet < ActiveRecord::Migration + def change + add_column :app_content_sets, :header_color, :string + add_column :app_content_sets, :short_title, :string + end +end
Add migration for header_color and short_title
diff --git a/cf_spec/spec_helper.rb b/cf_spec/spec_helper.rb index abc1234..def5678 100644 --- a/cf_spec/spec_helper.rb +++ b/cf_spec/spec_helper.rb @@ -2,4 +2,8 @@ require 'machete' `mkdir -p log` -Machete.logger = Machete::Logger.new("log/integration.log")+Machete.logger = Machete::Logger.new("log/integration.log") + +RSpec.configure do |c| + c.treat_symbols_as_metadata_keys_with_true_values = true +end
Change rspec runner to not use BuildpackUploader Relies on shell script in shared ~/.aliases instead.
diff --git a/lib/sunspot/mongoid.rb b/lib/sunspot/mongoid.rb index abc1234..def5678 100644 --- a/lib/sunspot/mongoid.rb +++ b/lib/sunspot/mongoid.rb @@ -32,7 +32,7 @@ class DataAccessor < Sunspot::Adapters::DataAccessor def load(id) - @clazz.find(id) rescue nil + @clazz.find(BSON::ObjectID.from_string(id)) rescue nil end def load_all(ids)
Convert id to BSON before loading
diff --git a/core/config/initializers/deprecation_checker.rb b/core/config/initializers/deprecation_checker.rb index abc1234..def5678 100644 --- a/core/config/initializers/deprecation_checker.rb +++ b/core/config/initializers/deprecation_checker.rb @@ -4,7 +4,4 @@ if File.exist?(Rails.root.join("public/assets/products")) || File.exist?(Rails.root.join("public/assets/taxons")) puts %q{[DEPRECATION] Your applications public directory contains an assets/products and/or assets/taxons subdirectory. Run `rake spree:assets:relocate_images` to relocate the images.} -elsif File.exist? Rails.root.join("public/assets") - puts %q{[DEPRECATION] Your applications public directory contains assets subdirectory. - You should remove the public/assets directory to prevent conflicts with the Rails 3.1 asset pipeline} end
Remove deprecation check for 'public/assets' as that's we're precompiled assets get created.
diff --git a/features/support/capybara_screenshot.rb b/features/support/capybara_screenshot.rb index abc1234..def5678 100644 --- a/features/support/capybara_screenshot.rb +++ b/features/support/capybara_screenshot.rb @@ -1 +1,3 @@ require 'capybara-screenshot/cucumber' +Capybara.save_path = File.join( ::Rails.root, 'tmp/capybara' ) +Capybara::Screenshot.prune_strategy = { keep: 5 }
Configure capybara screenshot to use correct directory and prune excess screenshots.
diff --git a/stacked_config.gemspec b/stacked_config.gemspec index abc1234..def5678 100644 --- a/stacked_config.gemspec +++ b/stacked_config.gemspec @@ -23,7 +23,7 @@ spec.add_development_dependency 'pry' spec.add_development_dependency 'rspec', '~> 3.0' - spec.add_dependency 'super_stack', '~> 0.2', '>= 0.2.5' + spec.add_dependency 'super_stack', '~> 0.2', '>= 0.2.5', '< 0.4' spec.add_dependency 'slop', '~> 3.0' end
Fix to avoid dependency upon broken super_stack (0.4)
diff --git a/railsthemes.gemspec b/railsthemes.gemspec index abc1234..def5678 100644 --- a/railsthemes.gemspec +++ b/railsthemes.gemspec @@ -17,4 +17,5 @@ gem.add_dependency "thor" gem.add_dependency "rest-client" + gem.add_dependency "launchy" end
Add launchy as a dependency.
diff --git a/test/sample_config.rb b/test/sample_config.rb index abc1234..def5678 100644 --- a/test/sample_config.rb +++ b/test/sample_config.rb @@ -0,0 +1,21 @@+require "schema/field_definitions" +require "schema/document_types" + +def schema_dir + File.expand_path('../config/schema', File.dirname(__FILE__)) +end + +def sample_field_definitions(fields=nil) + @sample_field_definitions ||= FieldDefinitionParser.new(schema_dir).parse + if fields.nil? + @sample_field_definitions + else + @sample_field_definitions.select { |field, _| + fields.include?(field) + } + end +end + +def sample_document_types + @sample_document_types ||= DocumentTypesParser.new(schema_dir, sample_field_definitions).parse +end
Add helper to get sample schemas for use in tests The schemas provided by these helpers are based on the "real" schema in config. This is more like the normal pattern of an app testing against the database models it's actually using, rather than abstract potential models. I want to move rummager's tests in this direction in general, since they're often testing for more generic support for things that we're not actually using. We'll then be able to remove code from rummager that is only being run by tests, not by production systems. Two helpers are provided: - `sample_field_definitions`: returns a hash from field_name to FieldDefinition. Can be parameterised to specify a subset of fields to return. - `sample_document_types`: returns a hash from document type name to DocumentType.
diff --git a/test/unit/url_test.rb b/test/unit/url_test.rb index abc1234..def5678 100644 --- a/test/unit/url_test.rb +++ b/test/unit/url_test.rb @@ -8,6 +8,7 @@ should "return false for a invalid url" do refute Twingly::URL.validate("http://"), "Should not be valid" + refute Twingly::URL.validate("feedville.com,2007-06-19:/blends/16171"), "Should not be valid" end end end
Test another type of invalid URL Close #7.
diff --git a/config/deploy/local.rb b/config/deploy/local.rb index abc1234..def5678 100644 --- a/config/deploy/local.rb +++ b/config/deploy/local.rb @@ -1,6 +1,5 @@ set :stage, :local set :rails_env, :production -set :branch, :http_proxy role :app, %w{deploy@localhost} role :web, %w{deploy@localhost}
Revert part of last commit
diff --git a/lib/fastlane/plugin/slack_train/actions/slack_train_action.rb b/lib/fastlane/plugin/slack_train/actions/slack_train_action.rb index abc1234..def5678 100644 --- a/lib/fastlane/plugin/slack_train/actions/slack_train_action.rb +++ b/lib/fastlane/plugin/slack_train/actions/slack_train_action.rb @@ -7,6 +7,9 @@ total_distance = lane_context[SharedValues::SLACK_TRAIN_DISTANCE] current_position = lane_context[SharedValues::SLACK_TRAIN_CURRENT_TRAIN_POSITION] speed = lane_context[SharedValues::SLACK_TRAIN_DIRECTION] + + UI.user_error!("train drove too far") if current_position < 0 + UI.user_error!("train drove too far") if total_distance == current_position before = rail_emoji * current_position after = rail_emoji * (total_distance - current_position - 1)
Fix crash for out of bounds
diff --git a/lib/octocatalog-diff/catalog-diff/filter/single_item_array.rb b/lib/octocatalog-diff/catalog-diff/filter/single_item_array.rb index abc1234..def5678 100644 --- a/lib/octocatalog-diff/catalog-diff/filter/single_item_array.rb +++ b/lib/octocatalog-diff/catalog-diff/filter/single_item_array.rb @@ -7,8 +7,8 @@ module OctocatalogDiff module CatalogDiff class Filter - # Filter out changes in parameters when one catalog has a parameter that's a string and - # the other catalog has that same parameter as an array containing the same string. + # Filter out changes in parameters when one catalog has a parameter that's an object and + # the other catalog has that same parameter as an array containing the same object. # For example, under this filter, the following is not a change: # catalog1: notify => "Service[foo]" # catalog2: notify => ["Service[foo]"] @@ -18,9 +18,27 @@ # # @param diff [OctocatalogDiff::API::V1::Diff] Difference # @param _options [Hash] Additional options (there are none for this filter) - # @return [Boolean] true if this difference is a YAML file with identical objects, false otherwise - def filtered?(_diff, _options = {}) - false + # @return [Boolean] true if this should be filtered out, false otherwise + def filtered?(diff, _options = {}) + # Skip additions or removals - focus only on changes + return false unless diff.change? + old_value = diff.old_value + new_value = diff.new_value + + # Skip unless there is a single-item array under consideration + return false unless + (old_value.is_a?(Array) && old_value.size == 1) || + (new_value.is_a?(Array) && new_value.size == 1) + + # Skip if both the old value and new value are arrays + return false if old_value.is_a?(Array) && new_value.is_a?(Array) + + # Do comparison + if old_value.is_a?(Array) + old_value.first == new_value + else + new_value.first == old_value + end end end end
Create single item array filter code
diff --git a/db/migrate/20141121161704_add_identity_table.rb b/db/migrate/20141121161704_add_identity_table.rb index abc1234..def5678 100644 --- a/db/migrate/20141121161704_add_identity_table.rb +++ b/db/migrate/20141121161704_add_identity_table.rb @@ -14,7 +14,10 @@ WHERE provider IS NOT NULL eos - remove_index :users, ["extern_uid", "provider"] + if index_exists?(:users, ["extern_uid", "provider"]) + remove_index :users, ["extern_uid", "provider"] + end + remove_column :users, :extern_uid remove_column :users, :provider end @@ -35,6 +38,9 @@ end drop_table :identities - add_index "users", ["extern_uid", "provider"], name: "index_users_on_extern_uid_and_provider", unique: true, using: :btree + + unless index_exists?(:users, ["extern_uid", "provider"]) + add_index "users", ["extern_uid", "provider"], name: "index_users_on_extern_uid_and_provider", unique: true, using: :btree + end end end
Remove index only if exists Signed-off-by: Dmitriy Zaporozhets <be23d75b156792e5acab51b196a2deb155d35d6a@gmail.com>
diff --git a/freecodecampruby/seek_and_destroy.rb b/freecodecampruby/seek_and_destroy.rb index abc1234..def5678 100644 --- a/freecodecampruby/seek_and_destroy.rb +++ b/freecodecampruby/seek_and_destroy.rb @@ -0,0 +1,34 @@+# Pseudocode +=begin +INPUT: Obtain an array and duplicate_values +Create a empty array called dup_values +Iterate through the array object +Iterate through the duplicate_values object +IF value from array == value from duplicate_values THEN + delete value from array + return array with remaining unique values +END IF + + +OUTPUT: Return an array with all unique values + +=end + +#Initial Solution +#def destroyer(array, *duplicate_values) +# array.each do |item| +# if duplicate_values.include?(item) +# array.delete(item) +# end +# end +#end + +def destroyer(array, *duplicate_values) + array.reject! { |item| duplicate_values.include?(item) } +end + +p destroyer([1, 2, 3, 1, 2, 3], 2, 3) +p destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3) +p destroyer([3, 5, 1, 2, 2], 2, 3, 5) +p destroyer([2, 3, 2, 3], 2, 3) +p destroyer(["tree", "hamburger", 53], "tree", 53)
Create method that removes all dup values from array
diff --git a/spec/dummy/application.rb b/spec/dummy/application.rb index abc1234..def5678 100644 --- a/spec/dummy/application.rb +++ b/spec/dummy/application.rb @@ -14,28 +14,21 @@ provider :developer, name: 'admin' end - module Actions - class << self - def index - lambda do |env| - [200, {'Content-Type' => 'text/html'}, ['Home']] - end - end - - def protected - lambda do |env| - [200, {'Content-Type' => 'text/html'}, ['Admin']] - end - end - end - end - routes.draw do - get '/' => Dummy::Actions.index + get '/' => 'dummy#index' constraints SimpleAdminAuth::Authenticate do - get '/protected/test' => Dummy::Actions.protected + get '/protected/test' => 'dummy#protected' end end end +class DummyController < ActionController::Base + def index + render text: 'Home' + end + + def protected + render text: 'Admin' + end +end
Use a Rails controller for integration tests.
diff --git a/core/spec/models/spree/app_configuration_spec.rb b/core/spec/models/spree/app_configuration_spec.rb index abc1234..def5678 100644 --- a/core/spec/models/spree/app_configuration_spec.rb +++ b/core/spec/models/spree/app_configuration_spec.rb @@ -5,13 +5,13 @@ let (:prefs) { Rails.application.config.spree.preferences } it "should be available from the environment" do - prefs.site_name = "TEST SITE NAME" - prefs.site_name.should eq "TEST SITE NAME" + prefs.layout = "my/layout" + prefs.layout.should eq "my/layout" end it "should be available as Spree::Config for legacy access" do - Spree::Config.site_name = "Spree::Config TEST SITE NAME" - Spree::Config.site_name.should eq "Spree::Config TEST SITE NAME" + Spree::Config.layout = "my/layout" + Spree::Config.layout.should eq "my/layout" end it "uses base searcher class by default" do
Switch app config test to move off of site_name Related to #4415
diff --git a/test/test_tori_file.rb b/test/test_tori_file.rb index abc1234..def5678 100644 --- a/test/test_tori_file.rb +++ b/test/test_tori_file.rb @@ -25,8 +25,8 @@ assert_instance_of Tori::File, Tori::File.new(nil, from: nil) end - test "#to_s" do - assert { "test" == Tori::File.new("test").to_s } + test "#name" do + assert { "test" == Tori::File.new("test").name } end test "#exist?" do
Use name instead of to_s
diff --git a/schema.gemspec b/schema.gemspec index abc1234..def5678 100644 --- a/schema.gemspec +++ b/schema.gemspec @@ -2,7 +2,7 @@ Gem::Specification.new do |s| s.name = 'schema' s.summary = "Primitives for schema and structure" - s.version = '0.3.0.0' + s.version = '0.4.0.0' s.description = ' ' s.authors = ['The Eventide Project']
Package version is increased from 0.3.0.0 to 0.4.0.0
diff --git a/schema.gemspec b/schema.gemspec index abc1234..def5678 100644 --- a/schema.gemspec +++ b/schema.gemspec @@ -2,7 +2,7 @@ Gem::Specification.new do |s| s.name = 'evt-schema' s.summary = "Primitives for schema and data structure" - s.version = '2.2.8.0' + s.version = '2.3.0.0' s.description = ' ' s.authors = ['The Eventide Project']
Package version is increased from 2.2.8.0 to 2.3.0.0
diff --git a/lib/thredded_create_app/tasks/setup_database.rb b/lib/thredded_create_app/tasks/setup_database.rb index abc1234..def5678 100644 --- a/lib/thredded_create_app/tasks/setup_database.rb +++ b/lib/thredded_create_app/tasks/setup_database.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true require 'thredded_create_app/tasks/base' -require 'securerandom' module ThreddedCreateApp module Tasks class SetupDatabase < Base @@ -33,7 +32,8 @@ end def dev_user_password - @dev_user_password ||= SecureRandom.urlsafe_base64(20) + # Use a fixed password so that multiple runs of thredded_create_app don't fail. + @dev_user_password ||= app_name end end end
Use fixed DB password so that multiple runs succeed
diff --git a/manifests/milky_way.rb b/manifests/milky_way.rb index abc1234..def5678 100644 --- a/manifests/milky_way.rb +++ b/manifests/milky_way.rb @@ -10,7 +10,7 @@ coords = file_name.match(/\w*?([\d\.]+)((\-|\+)[\d\.]+)\w*?/)[1..2].collect &:to_f group name: group_name - subject location: url_of(file), coords: coords, metadata: { size: size, file_name: file_name } + subject group_name: group_name, location: url_of(file.gsub('+', '%2B')), coords: coords, metadata: { size: size, file_name: file_name } end end end
Set group names on MWP subjects
diff --git a/fluent-plugin-graylog.gemspec b/fluent-plugin-graylog.gemspec index abc1234..def5678 100644 --- a/fluent-plugin-graylog.gemspec +++ b/fluent-plugin-graylog.gemspec @@ -21,7 +21,7 @@ spec.add_runtime_dependency 'fluentd', '~> 0.12.36' - spec.add_development_dependency 'rake', '~> 10.0' + spec.add_development_dependency 'rake', '~> 12.1' spec.add_development_dependency 'rspec', '~> 3.3' spec.add_development_dependency 'test-unit', '~> 3.1' spec.add_development_dependency 'pry', '~> 0.10'
Update rake requirement to ~> 12.1 Updates the requirements on [rake](https://github.com/ruby/rake) to permit the latest version. - [Changelog](https://github.com/ruby/rake/blob/master/History.rdoc)
diff --git a/lib/stackato-lkg/amazon/support/rate_limit_handler.rb b/lib/stackato-lkg/amazon/support/rate_limit_handler.rb index abc1234..def5678 100644 --- a/lib/stackato-lkg/amazon/support/rate_limit_handler.rb +++ b/lib/stackato-lkg/amazon/support/rate_limit_handler.rb @@ -0,0 +1,33 @@+require 'aws-sdk' +require 'contracts' +require 'retries' + +module StackatoLKG + module Amazon + module Support + module RateLimitHandler + include ::Contracts::Core + include ::Contracts::Builtin + + Contract None => Proc + def request_limit_exceeded_handler + Proc.new do |exception, attempt, seconds| + STDERR.puts "Encountered a #{exception.class}. DON'T PANIC. Waiting and trying again works (usually). Let's do that! (this was attempt #{attempt} after #{seconds} seconds)" + end + end + + Contract Symbol, Args[Any] => Any + def call_api(method, *args) + with_retries( + rescue: Aws::EC2::Errors::RequestLimitExceeded, + handler: request_limit_exceeded_handler, + base_sleep_seconds: 1.0, + max_sleep_seconds: 8.0 + ) do + api.method(method).call(*args) + end + end + end + end + end +end
Add handler for AWS RateLimitExceeded errors
diff --git a/setler.gemspec b/setler.gemspec index abc1234..def5678 100644 --- a/setler.gemspec +++ b/setler.gemspec @@ -7,7 +7,7 @@ s.version = Setler::VERSION s.authors = ["Chris Kelly"] s.email = ["ckdake@ckdake.com"] - s.homepage = "" + s.homepage = "https://github.com/ckdake/setler" s.summary = %q{Settler lets you use the 'Feature Flags' pettern or add settings to models.} s.description = %q{Setler is a Gem that lets one easily implement the "Feature Flags" pattern, or add settings to individual models. This is a cleanroom implementation of what the 'rails-settings' gem does. It's been forked all over the place, and my favorite version of it doesn't have any tests and doesn't work with settings associated with models.}
Add homepage link to gemspec
diff --git a/web/plugins/pagetoc.rb b/web/plugins/pagetoc.rb index abc1234..def5678 100644 --- a/web/plugins/pagetoc.rb +++ b/web/plugins/pagetoc.rb @@ -0,0 +1,39 @@+# Copyright 2015 Google Inc. All rights reserved. +# +# Use of this source code is governed by The MIT License. +# See the LICENSE file for details. + +# Jekyll plugin to build a page table of contents using Redcarpet's TOC data. +# +# Author:: nicksay@google.com (Alex Nicksay) + + +require 'redcarpet' + + +module Jekyll + + + class Page + + def render_and_generate_toc(payload, layouts) + # Generate the page TOC. + if @content + toc_renderer = Redcarpet::Render::HTML_TOC.new + toc = Redcarpet::Markdown.new(toc_renderer, {}).render(@content) + # Work around a Redcarpet bug + toc = toc.gsub('&lt;em&gt;', '<em>') + toc = toc.gsub('&lt;/em&gt;', '</em>') + @data['toc'] = toc + end + # Then call the default render method. + _render(payload, layouts) + end + + alias_method :_render, :render + alias_method :render, :render_and_generate_toc + + end + + +end
Web: Create Jekyll plugin to generate in-page TOC data Progress on #344
diff --git a/spec/views/images/show.html.erb_spec.rb b/spec/views/images/show.html.erb_spec.rb index abc1234..def5678 100644 --- a/spec/views/images/show.html.erb_spec.rb +++ b/spec/views/images/show.html.erb_spec.rb @@ -12,8 +12,13 @@ it 'shows the user that uploaded this image' do uploader = create(:user) + path_to_uploader = + Rails.application.routes.url_helpers.user_path(uploader) + @image.user = uploader + render rendered.should have_text(uploader.username) + rendered.should have_tag('a', :href => path_to_uploader) end end
Test if page has a link back to uploader
diff --git a/app/models/activity.rb b/app/models/activity.rb index abc1234..def5678 100644 --- a/app/models/activity.rb +++ b/app/models/activity.rb @@ -1,4 +1,6 @@ class Activity < ApplicationRecord + HIGH_PRIORITY_ACTIVITY_CLASS_NAMES = %w(DropActivity).freeze + belongs_to :appointment belongs_to :user belongs_to :owner, class_name: User @@ -8,6 +10,7 @@ scope :resolved, -> { where.not(resolved_at: nil) } scope :unresolved, -> { where(resolved_at: nil) } + scope :high_priority, -> { where(type: HIGH_PRIORITY_ACTIVITY_CLASS_NAMES) } def self.from(audit, appointment) if audit.action == 'create' @@ -38,4 +41,8 @@ def resolved? resolved_at? end + + def high_priority? + HIGH_PRIORITY_ACTIVITY_CLASS_NAMES.include?(self.class.to_s) + end end
Add way to classify activities as high priority
diff --git a/app/models/incident.rb b/app/models/incident.rb index abc1234..def5678 100644 --- a/app/models/incident.rb +++ b/app/models/incident.rb @@ -5,5 +5,8 @@ # https://github.com/collectiveidea/audited # audited - attr_accessible :body, :name + attr_accessible :body, :name, :monitoring_id + + # Validators + validates_presence_of :name, :body end
Add validators on Incident Model
diff --git a/lib/apivore/rspec_matchers.rb b/lib/apivore/rspec_matchers.rb index abc1234..def5678 100644 --- a/lib/apivore/rspec_matchers.rb +++ b/lib/apivore/rspec_matchers.rb @@ -37,7 +37,7 @@ matcher :conform_to_the_documented_model_for do |swagger, fragment| match do |body| body = JSON.parse(body) - @errors = JSON::Validator.fully_validate(swagger, body, fragment: fragment, strict: true) + @errors = JSON::Validator.fully_validate(swagger, body, fragment: fragment, strict: false) @errors.empty? end
Disable strict mode of JSON::Validator Strict mode treats all properties as required, and ignores the `required` attribute specified in the schema. This behaviour makes it impossible to have optional fields in the schema. Using the `required` property in the schema allows you to specify which other properties are required and which are optional.
diff --git a/warden-rails.gemspec b/warden-rails.gemspec index abc1234..def5678 100644 --- a/warden-rails.gemspec +++ b/warden-rails.gemspec @@ -6,12 +6,12 @@ s.version = Warden::Rails::VERSION s.authors = ["Adrià Planas"] s.email = ["adriaplanas@liquidcodeworks.com"] - s.summary = "Thin wrapper around Warden for Rails 3" + s.summary = "Thin wrapper around Warden for Rails 3.2+" s.files = Dir["lib/**/*"] + ["LICENSE", "Rakefile", "README.md"] s.test_files = Dir["test/**/*"] - s.add_dependency "rails", "~> 3.2.12" + s.add_dependency "railties", ">= 3.2" s.add_dependency "warden", "~> 1.2.1" s.add_development_dependency "mocha"
Replace rails dependency with railties >= 3.2
diff --git a/lib/cangaroo/logger_helper.rb b/lib/cangaroo/logger_helper.rb index abc1234..def5678 100644 --- a/lib/cangaroo/logger_helper.rb +++ b/lib/cangaroo/logger_helper.rb @@ -0,0 +1,13 @@+require 'active_support/concern' + +module Cangaroo + module LoggerHelper + extend ActiveSupport::Concern + + def job_tags(tags = {}) + tags.merge!(job: self.class.to_s, + job_id: job_id, + connection: self.class.connection) + end + end +end
Add a logger helper module for jobs
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index abc1234..def5678 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,3 +1,17 @@ class ApplicationController < ActionController::Base protect_from_forgery with: :exception + + def check_for_mobile + session[:mobile_override] = params[:mobile] if params[:mobile] + end + + def mobile_device? + if session[:mobile_override] + session[:mobile_override] == "1" + else + request.user_agent =~ /Mobile|webOS/ + end + end end + +helper_method :mobile_device?
Add methods to APplication Controller
diff --git a/app/helpers/rails/add_ons/table_helper.rb b/app/helpers/rails/add_ons/table_helper.rb index abc1234..def5678 100644 --- a/app/helpers/rails/add_ons/table_helper.rb +++ b/app/helpers/rails/add_ons/table_helper.rb @@ -25,7 +25,7 @@ end @view_context = view_context - @column_name = column_name + @column_name = @options[:column_name] || column_name @title = title if h.params[:sort_direction].present? @@ -47,4 +47,4 @@ end end end -end+end
Add column_name options to sort in the collection table helper.
diff --git a/Casks/synology-cloud-station.rb b/Casks/synology-cloud-station.rb index abc1234..def5678 100644 --- a/Casks/synology-cloud-station.rb +++ b/Casks/synology-cloud-station.rb @@ -1,6 +1,6 @@ cask :v1 => 'synology-cloud-station' do - version '3317' - sha256 'd3305b5f2b4d47cf84e18cdbdb86a58578bff396fbe4664c4c778745098a362d' + version '3423' + sha256 'c800dca63285cc754b34806c4f0dde11fa1ca4d3d31aa8eeb8ca129555c094e2' url "https://global.download.synology.com/download/Tools/CloudStation/#{version}/Mac/synology-cloud-station-#{version}.dmg" homepage 'http://www.synology.com/'
Update Synology Cloud Client to version 3423
diff --git a/arbitrary_mock.gemspec b/arbitrary_mock.gemspec index abc1234..def5678 100644 --- a/arbitrary_mock.gemspec +++ b/arbitrary_mock.gemspec @@ -9,7 +9,7 @@ s.version = ArbitraryMock::VERSION s.authors = ["Robert White"] s.email = ["robert@terracoding.com"] - s.homepage = "TODO" + s.homepage = "https://github.com/Haar/arbitrary_mock" s.summary = "Basic object for asserting behaviour of classes upon their dependencies" s.description = "Basic series of objects designed to allow you to arbitrarily assign and access properties, for use in conjunction with typical isolated testing style."
Add GitHub homepage to gemspec
diff --git a/spec/github_spec.rb b/spec/github_spec.rb index abc1234..def5678 100644 --- a/spec/github_spec.rb +++ b/spec/github_spec.rb @@ -1,5 +1,93 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper') describe Github do - pending + + it "should respond to 'new' message" do + Github.should respond_to :new + end + + it "should receive 'new' and initialize Github::Client instance" do + Github.new.should be_a Github::Client + end + + it "should respond to 'configure' message" do + Github.should respond_to :configure + end + + describe "setting configuration options" do + + it "should return default adapter" do + Github.adapter.should == Github::Configuration::DEFAULT_ADAPTER + end + + it "should allow to set adapter" do + Github.adapter = :typhoeus + Github.adapter.should == :typhoeus + end + + it "should return the default end point" do + Github.endpoint.should == Github::Configuration::DEFAULT_ENDPOINT + end + + it "should allow to set endpoint" do + Github.endpoint = 'http://linkedin.com' + Github.endpoint.should == 'http://linkedin.com' + end + + it "should return the default user agent" do + Github.user_agent.should == Github::Configuration::DEFAULT_USER_AGENT + end + + it "should allow to set new user agent" do + Github.user_agent = 'New User Agent' + Github.user_agent.should == 'New User Agent' + end + + it "should have not set oauth token" do + Github.oauth_token.should be_nil + end + + it "should allow to set oauth token" do + Github.oauth_token = '' + end + + it "should have not set default user" do + Github.user.should be_nil + end + + it "should allow to set new user" do + Github.user = 'github' + Github.user.should == 'github' + end + + it "should have not set default repository" do + Github.repo.should be_nil + end + + it "should allow to set new repository" do + Github.repo = 'github' + Github.repo.should == 'github' + end + + it "should have faraday options as hash" do + Github.faraday_options.should be_a Hash + end + + it "should initialize faraday options to empty hash" do + Github.faraday_options.should be_empty + end + + end + + describe ".configure" do + Github::Configuration::VALID_OPTIONS_KEYS.each do |key| + it "should set the #{key}" do + Github.configure do |config| + config.send("#{key}=", key) + Github.send(key).should == key + end + end + end + end + end
Add spec for main github client.
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 @@ -1,5 +1,3 @@-require 'linkedin2' - require 'rspec' require 'vcr' require 'pry' @@ -8,7 +6,10 @@ SimpleCov.start do add_group 'API', 'lib/linkedin/api' + add_filter 'spec' end + +require 'linkedin2' VCR.configure do |c| c.cassette_library_dir = 'spec/fixtures/requests'
Fix simplecov to cover the gem code, not the spec code
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 @@ -5,6 +5,9 @@ require 'cashier' require 'redis' require 'dalli' + +require 'pry' +require 'pry-nav' Combustion.initialize! :all @@ -21,4 +24,6 @@ Cashier::Adapters::RedisStore.redis.flushdb Rails.cache.clear end -end+end + +ApplicationController.perform_caching = true
Enable Rails perform_caching to fix upstream spec.
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 @@ -1,8 +1,8 @@-require 'codeclimate-test-reporter' -CodeClimate::TestReporter.start +require "simplecov" +SimpleCov.start -$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__) -require 'hashid/rails' +$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__) +require "hashid/rails" ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:" require_relative "support/schema"
Update simplecov with post 1.0 config
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 @@ -35,6 +35,10 @@ def with_headers(headers) proc { [200, {'Content-Type' => 'text/plain' }.merge(headers), ['ok']] } end + + def with_status(status=nil) + proc { [status || 200, {'Content-Type' => 'text/plain' }, ['ok']] } + end end RSpec.configure do |config|
Add helper for status setting.
diff --git a/spec/test_helper.rb b/spec/test_helper.rb index abc1234..def5678 100644 --- a/spec/test_helper.rb +++ b/spec/test_helper.rb @@ -7,13 +7,13 @@ original_stderr = $stderr original_stdout = $stdout - config.before(:all, silent_cli: true) do + config.before silent_cli: true do # Redirect stderr and stdout $stderr = File.open(File::NULL, "w") $stdout = File.open(File::NULL, "w") end - config.after(:all, silent_cli: true) do + config.after silent_cli: true do $stderr = original_stderr $stdout = original_stdout end
FIX remove :all options for specs silent CLI config
diff --git a/spec/tiddle_spec.rb b/spec/tiddle_spec.rb index abc1234..def5678 100644 --- a/spec/tiddle_spec.rb +++ b/spec/tiddle_spec.rb @@ -1,10 +1,10 @@ describe Tiddle do + before do + @user = User.create!(email: "test@example.com", password: "12345678") + end + describe "create_and_return_token" do - - before do - @user = User.create!(email: "test@example.com", password: "12345678") - end it "returns string with token" do result = Tiddle.create_and_return_token(@user) @@ -17,4 +17,18 @@ end.to change { @user.authentication_tokens.count }.by(1) end end + + describe "expire_token" do + + before do + @user.authentication_tokens.create!(body: "fireball") + @request = instance_double("request", headers: { "X-USER-TOKEN" => "fireball" }) + end + + it "deletes token from the database" do + expect do + Tiddle.expire_token(@user, @request) + end.to change { @user.authentication_tokens.count }.by(-1) + end + end end
Write spec for expire_token method
diff --git a/find_veterans.rb b/find_veterans.rb index abc1234..def5678 100644 --- a/find_veterans.rb +++ b/find_veterans.rb @@ -0,0 +1,38 @@+require 'httparty' + +class FindVeterans + include HTTParty + base_uri 'https://api.github.com' + + # Find the first 10 users on GitHub whose location starts with "New York" + def initialize + @top_ten = [] + new_yorkers = self.class.get("/search/users\?q\=type:user+location:New-York").parsed_response["items"] + new_yorkers.map.with_index { |user, i| @top_ten << [user["login"]] if i < 10 } + end + + def name_and_location + @top_ten.each do |user| + user_details = self.class.get("/users/#{user[0]}").parsed_response + user << user_details["name"] + user << user_details["location"] + end + end + + # Get a count of their public repositories created since the beginning of the day January 1 of 2015 (UTC) + def count_public_repos + @top_ten.each do |user| + public_repos = self.class.get("/users/#{user[0]}/repos?q=visibility:public+created:\>\=2015-01-01T00:00:00-07:00").parsed_response + user << public_repos.length + end + byebug + end + + # Generate a CSV file with the following headers: login, name, location, repo count + +end + +# Driver Code: +# test = FindVeterans.new +# test.name_and_location +# test.count_public_repos
Add FindVeterans class and GitHub API call methods
diff --git a/foreplay.gemspec b/foreplay.gemspec index abc1234..def5678 100644 --- a/foreplay.gemspec +++ b/foreplay.gemspec @@ -19,5 +19,5 @@ s.add_runtime_dependency 'foreman', '>= 0.76', '< 1.0' s.add_runtime_dependency 'ssh-shell', '>= 0.4', '< 1.0' - s.add_runtime_dependency 'activesupport', '>= 3.2.22', '< 5.0' + s.add_runtime_dependency 'activesupport', '>= 3.2.22' end
Allow Ruby 2.2.2+ to use ActiveSupport 5+
diff --git a/schema.gemspec b/schema.gemspec index abc1234..def5678 100644 --- a/schema.gemspec +++ b/schema.gemspec @@ -2,7 +2,7 @@ Gem::Specification.new do |s| s.name = 'evt-schema' s.summary = "Primitives for schema and data structure" - s.version = '0.7.1.2' + s.version = '0.7.1.3' s.description = ' ' s.authors = ['The Eventide Project']
Package version is increased from 0.7.1.2 to 0.7.1.3
diff --git a/app/helpers/georgia/meta_tags_helper.rb b/app/helpers/georgia/meta_tags_helper.rb index abc1234..def5678 100644 --- a/app/helpers/georgia/meta_tags_helper.rb +++ b/app/helpers/georgia/meta_tags_helper.rb @@ -3,7 +3,7 @@ def meta_title title site_title = "" - site_title << "#{title} | " if title + site_title << "#{title} | " unless title.blank? site_title << Georgia.title content_tag :title, site_title end
Fix | in title when no title
diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index abc1234..def5678 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -5,7 +5,7 @@ @appointment = Appointment.new @appointments_by_date = Appointment.upcoming_grouped_by_date(current_user) @date = Date.today - @contacts = Contact.all + @contacts = current_user.contacts @contact = Contact.new @assignments = current_user.get_recent_assignments @pending = current_user.get_pending_assignments
Modify dashboard index to show only curent users contacts
diff --git a/app/controllers/resources_controller.rb b/app/controllers/resources_controller.rb index abc1234..def5678 100644 --- a/app/controllers/resources_controller.rb +++ b/app/controllers/resources_controller.rb @@ -28,7 +28,6 @@ flash[:alert] = "You are not allowed to edit this resource!" redirect_to user_resource_path(@resource) end - @user = current_user end def update
Remove user variable from edit actions fo resources.
diff --git a/app/controllers/waypoints_controller.rb b/app/controllers/waypoints_controller.rb index abc1234..def5678 100644 --- a/app/controllers/waypoints_controller.rb +++ b/app/controllers/waypoints_controller.rb @@ -45,6 +45,6 @@ end def waypoint_params - params.require(:waypoint).permit(:name, :position, :image, :latitude, :longitude) + params.require(:waypoint).permit(:name, :description, :position, :image, :latitude, :longitude) end end
Allow description in waypoint parameters
diff --git a/app/helpers/multi_year_charts_helper.rb b/app/helpers/multi_year_charts_helper.rb index abc1234..def5678 100644 --- a/app/helpers/multi_year_charts_helper.rb +++ b/app/helpers/multi_year_charts_helper.rb @@ -5,8 +5,9 @@ # # Returns a string. def myc_url(multi_year_chart) - "#{Settings.multi_year_charts_url}/" \ - "#{multi_year_chart.redirect_slug}?locale=#{I18n.locale}" + "#{Settings.multi_year_charts_url}/#{multi_year_chart.redirect_slug}?" \ + "locale=#{I18n.locale}&" \ + "title=#{ERB::Util.url_encode(multi_year_chart.title)}" end def can_use_as_myc_scenario?(saved_scenario)
Send MYC session header to the application
diff --git a/lib/latent_object_detector.rb b/lib/latent_object_detector.rb index abc1234..def5678 100644 --- a/lib/latent_object_detector.rb +++ b/lib/latent_object_detector.rb @@ -13,18 +13,48 @@ end def suspicious_methods - explicit_instance_methods.select{|m| (words_in_method(m.to_s) & potential_objects).size > 0} + methods_owned_by_klass.select{ |m| (words_in_method(m.to_s) & potential_objects).size > 0 } end def potential_objects - words_hash = explicit_instance_methods.inject({}) {|h,m| h[m] = words_in_method(m); h} - hits = words_hash.values.flatten.inject({}){|h,w| h[w] ||= 0; h[w] += 1; h}.select{|k,v| v > 1}.keys - hits.select{|k| k.size > 2} + common_words = find_common_words_in(hash_of_words_used_in_methods) + words_used_more_than_twice(common_words) end private - def explicit_instance_methods - self.klass.instance_methods.select{|m| self.klass.new.method(m).owner == self.klass } + def words_used_more_than_twice(hash_of_words = {}) + hash_of_words.select{ |k| k.size > 2 } + end + + def hash_of_words_used_in_methods + methods_owned_by_klass.inject({}) do |hash, method| + hash[method] = words_in_method(method) + hash + end + end + + def find_common_words_in(hash_of_words = hash_of_words_used_in_methods) + count_word_frequency(hash_of_words).select{ |k,v| v > 1 }.keys + end + + def count_word_frequency(hash_of_words = {}) + hash_of_words.values.flatten.inject({}) do |hash, word| + hash[word] ||= 0 + hash[word] += 1 + hash + end + end + + def methods_owned_by_klass + all_instance_methods_of_klass.select{ |method| method_is_owned_by_klass? method } + end + + def method_is_owned_by_klass?(method) + self.klass.new.method(method).owner == self.klass + end + + def all_instance_methods_of_klass + self.klass.instance_methods end def words_in_method(name)
Simplify methods by decomposing them, and use really explicit method names
diff --git a/app/presenters/publication_presenter.rb b/app/presenters/publication_presenter.rb index abc1234..def5678 100644 --- a/app/presenters/publication_presenter.rb +++ b/app/presenters/publication_presenter.rb @@ -17,7 +17,7 @@ :body, :introduction, :expectations, :video_url, :alternative_title, :overview, :name, :video_summary, :continuation_link, :licence_overview, :link, :will_continue_on, :more_information, :minutes_to_complete, - :alternate_methods + :alternate_methods, :place_type ] PASS_THROUGH_KEYS.each do |key|
Fix place editions - displaying the results The JS which filled in the results was getting an error page instead of JSON, so would error.
diff --git a/flair.gemspec b/flair.gemspec index abc1234..def5678 100644 --- a/flair.gemspec +++ b/flair.gemspec @@ -13,7 +13,7 @@ s.summary = "TODO: Summary of Flair." s.description = "TODO: Description of Flair." - s.files = Dir["{app,config,db,lib}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.rdoc"] + s.files = Dir["{app,config,db,lib}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.md"] s.test_files = Dir["test/**/*"] s.add_dependency "rails", "~> 3.2.8"
Update gemspec to use README.md not README.rdoc
diff --git a/lib/specjour/socket_helper.rb b/lib/specjour/socket_helper.rb index abc1234..def5678 100644 --- a/lib/specjour/socket_helper.rb +++ b/lib/specjour/socket_helper.rb @@ -1,5 +1,7 @@ module Specjour module SocketHelper + Socket.do_not_reverse_lookup = true + def ip_from_hostname(hostname) Socket.getaddrinfo(hostname, nil, Socket::AF_INET, Socket::SOCK_STREAM).first.fetch(3) end
Disable reverse lookup, speed up linux; DUH!
diff --git a/libraries/port_reservation.rb b/libraries/port_reservation.rb index abc1234..def5678 100644 --- a/libraries/port_reservation.rb +++ b/libraries/port_reservation.rb @@ -1,9 +1,13 @@ module PortReservation extend Chef::DSL::DataQuery + class MissingReservation < StandardError; end + class << self def for(type) - reservations[type] + reservations[type].tap do |reservation| + raise MissingReservation.new("No port reservation found for #{type}") if reservation.nil? + end end def reservations
Raise if no reservation is configured in data bag
diff --git a/govuk_message_queue_consumer.gemspec b/govuk_message_queue_consumer.gemspec index abc1234..def5678 100644 --- a/govuk_message_queue_consumer.gemspec +++ b/govuk_message_queue_consumer.gemspec @@ -19,7 +19,7 @@ s.add_dependency 'bunny', '~> 2.11' s.add_development_dependency 'rspec', '~> 3.8.0' - s.add_development_dependency 'rake', '~> 12.3.2' + s.add_development_dependency 'rake', '~> 13.0.0' s.add_development_dependency 'yard' s.add_development_dependency 'bunny-mock' s.add_development_dependency 'pry-byebug'
Update rake requirement from ~> 12.3.2 to ~> 13.0.0 Updates the requirements on [rake](https://github.com/ruby/rake) to permit the latest version. - [Release notes](https://github.com/ruby/rake/releases) - [Changelog](https://github.com/ruby/rake/blob/master/History.rdoc) - [Commits](https://github.com/ruby/rake/compare/v12.3.2...v13.0.0) Signed-off-by: dependabot-preview[bot] <5bdcd3c0d4d24ae3e71b3b452a024c6324c7e4bb@dependabot.com>
diff --git a/spec/app_manager/api/version11_spec.rb b/spec/app_manager/api/version11_spec.rb index abc1234..def5678 100644 --- a/spec/app_manager/api/version11_spec.rb +++ b/spec/app_manager/api/version11_spec.rb @@ -0,0 +1,10 @@+require 'spec_helper' + +describe ManageEngine::AppManager::Api::Version11 do + subject { ManageEngine::AppManager::Api.new("11") } + + it "returns the connect_path" do + subject.should respond_to(:connect_path) + subject.connect_path.should be_instance_of(String) + end +end
Add Spec for Version11 Api Add a spec to test the Version11 Api.
diff --git a/spec/integration/multi_adapter_spec.rb b/spec/integration/multi_adapter_spec.rb index abc1234..def5678 100644 --- a/spec/integration/multi_adapter_spec.rb +++ b/spec/integration/multi_adapter_spec.rb @@ -0,0 +1,49 @@+RSpec.describe 'Repository with multi-adapters setup' do + include_context 'database' + + let(:rom) { ROM.env } + + let(:users) { rom.relation(:users) } + let(:tasks) { rom.relation(:tasks) } + + let(:repo) { Test::Repository.new(rom) } + + before do + ROM.setup( default: [:sql, 'postgres://localhost/rom'], memory: [:memory]) + + module Test + class Users < ROM::Relation[:sql] + end + + class Tasks < ROM::Relation[:memory] + use :view + + view(:for_users, [:user_id, :title]) do |users| + restrict(user_id: users.map { |u| u[:id] }) + end + end + + class Repository < ROM::Repository::Base + relations :users, :tasks + + def users_with_tasks + users.combine_children(many: tasks) + end + end + end + + ROM.finalize + + user_id = users.insert(name: 'Jane') + tasks.insert(user_id: user_id, title: 'Jane Task') + end + + specify 'ᕕ⁞ ᵒ̌ 〜 ᵒ̌ ⁞ᕗ' do + user = repo.users_with_tasks.one + + expect(user.name).to eql('Jane') + + expect(user.tasks[0].user_id).to eql(user.id) + expect(user.tasks[0].title).to eql('Jane Task') + end +end
Add a spec for multi-adapter repo :boom: :tada: :boom:
diff --git a/specs/spec_helper.rb b/specs/spec_helper.rb index abc1234..def5678 100644 --- a/specs/spec_helper.rb +++ b/specs/spec_helper.rb @@ -6,5 +6,25 @@ require "timecop" require "mocha/mini_test" require "webmock/minitest" +require 'stringio' alias :context :describe + +class FakeLogger + def initialize + @logger = StringIO.new + end + + def info(message) + @logger.write(message) + end + + def reset + @logger.string = "" + end + + def get + @logger.string + end +end +
Add FakeLogger to specs helper
diff --git a/spec/dummy/app/controllers/people_controller.rb b/spec/dummy/app/controllers/people_controller.rb index abc1234..def5678 100644 --- a/spec/dummy/app/controllers/people_controller.rb +++ b/spec/dummy/app/controllers/people_controller.rb @@ -1,4 +1,4 @@-class PeopleController < AuthorizedController +class PeopleController < HasAccountsController def index set_collection_ivar resource_class.search( params[:by_text],
Use HasAccountsController for People dummy spec controller.
diff --git a/spec/application_spec.rb b/spec/application_spec.rb index abc1234..def5678 100644 --- a/spec/application_spec.rb +++ b/spec/application_spec.rb @@ -1,12 +1,12 @@ require 'hyperloop' describe Hyperloop::Application do - before :all do + before :each do @root = 'spec/fixtures/simple/' + @app = Hyperloop::Application.new(@root) end it 'finds the index view' do - app = Hyperloop::Application.new(@root) - expect(app.views).to eql(['index.html']) + expect(@app.views).to eql(['index.html']) end end
Move app spec setup from before :all to :each
diff --git a/layer-custom/recipes/esmonit.rb b/layer-custom/recipes/esmonit.rb index abc1234..def5678 100644 --- a/layer-custom/recipes/esmonit.rb +++ b/layer-custom/recipes/esmonit.rb @@ -1,6 +1,6 @@-template "/etc/monit.d/elasticsearch-monit.conf" do +template "/etc/monit/monitrc.d/elasticsearch-monit.conf" do source "elasticsearch.monitrc.conf.erb" mode 0440 owner "root" group "root" -end+end
Use the updated monit conf directory
diff --git a/calculators/bsa/bsa.rb b/calculators/bsa/bsa.rb index abc1234..def5678 100644 --- a/calculators/bsa/bsa.rb +++ b/calculators/bsa/bsa.rb @@ -5,8 +5,8 @@ weight = get_field_as_float :weight_in_kg height = get_field_as_float :height_in_m - raise FieldError.new('weight', 'weight must be greater than zero') if weight <= 0 - raise FieldError.new('height', 'height must be greater than zero') if height <= 0 + raise FieldError.new('weight', 'must be greater than zero') if weight <= 0 + raise FieldError.new('height', 'must be greater than zero') if height <= 0 { value: ((weight * (height * 100)) / 3600) ** 0.5,
Remove redundant field name from error
diff --git a/lib/countries.rb b/lib/countries.rb index abc1234..def5678 100644 --- a/lib/countries.rb +++ b/lib/countries.rb @@ -5,6 +5,7 @@ class Country < ISO3166::Country def to_s + warn "[DEPRECATION] `Country` is deprecated. Please use `ISO3166::Country` instead." name end end
Add deprecation warning on country object.
diff --git a/lib/encryptor.rb b/lib/encryptor.rb index abc1234..def5678 100644 --- a/lib/encryptor.rb +++ b/lib/encryptor.rb @@ -14,6 +14,7 @@ begin return e.decrypt_and_verify(value) rescue Zlib::DataError + STATSD_CLIENT.increment('pvb.app.legacy_encryptor') next end end
Add a tracker for legacy encryption scheme.
diff --git a/Casks/daisydisk-beta.rb b/Casks/daisydisk-beta.rb index abc1234..def5678 100644 --- a/Casks/daisydisk-beta.rb +++ b/Casks/daisydisk-beta.rb @@ -0,0 +1,24 @@+cask :v1 => 'daisydisk-beta' do + version :latest + sha256 :no_check + + url 'http://daisydiskapp.com/downloads/DaisyDiskBeta.zip' + appcast 'http://www.daisydiskapp.com/downloads/appcastFeed.php' + name 'DaisyDisk' + homepage 'http://www.daisydiskapp.com' + license :freemium + + app 'DaisyDisk.app' + + depends_on :macos => '>= :yosemite' + conflicts_with :cask => 'daisydisk' + + postflight do + suppress_move_to_applications + end + + zap :delete => [ + '~/Library/Preferences/com.daisydiskapp.DaisyDiskStandAlone.plist', + '~/Library/Caches/com.daisydiskapp.DaisyDiskStandAlone', + ] +end
Add cask for Daisydisk Beta Closes #946.
diff --git a/Casks/pckeyboardhack.rb b/Casks/pckeyboardhack.rb index abc1234..def5678 100644 --- a/Casks/pckeyboardhack.rb +++ b/Casks/pckeyboardhack.rb @@ -1,7 +1,7 @@ class Pckeyboardhack < Cask - url 'https://pqrs.org/macosx/keyremap4macbook/files/PCKeyboardHack-10.0.0.dmg' + url 'https://pqrs.org/macosx/keyremap4macbook/files/PCKeyboardHack-10.2.0.dmg' homepage 'https://pqrs.org/macosx/keyremap4macbook/pckeyboardhack.html.en' - version '10.0.0' - sha1 'b9df8ba7e6417391394b6e086afeb5d0d25f07f5' + version '10.2.0' + sha1 'f37d06a84ec75adb45040a144067709a6beb64fd' install 'PCKeyboardHack.pkg' end
Update PCKeyboardHack to version 10.2.0
diff --git a/lib/content_manager/class_resolution.rb b/lib/content_manager/class_resolution.rb index abc1234..def5678 100644 --- a/lib/content_manager/class_resolution.rb +++ b/lib/content_manager/class_resolution.rb @@ -11,7 +11,7 @@ if Object.const_defined?(klass) return klass elsif file_path = rails_constant_file_path(class_name) - require file_path + require_relative file_path return klass else cm_class_name = "content_manager/#{class_name}".classify
Use require relative not require