diff
stringlengths
65
26.7k
message
stringlengths
7
9.92k
diff --git a/spec/java_spec.rb b/spec/java_spec.rb index abc1234..def5678 100644 --- a/spec/java_spec.rb +++ b/spec/java_spec.rb @@ -6,19 +6,16 @@ set_java_version(app.directory, jdk_version) app.setup! app.set_config("JVM_COMMON_BUILDPACK" => "https://github.com/heroku/heroku-buildpack-jvm-common/tarball/#{`git rev-parse HEAD`}") - app.heroku.put_stack(app.name, "cedar-14") end ["1.7", "1.8"].each do |version| context "on jdk-#{version}" do - let(:app) { Hatchet::Runner.new("java-servlets-sample") } + let(:app) { Hatchet::Runner.new("java-servlets-sample", + :buildpack_url => "https://github.com/heroku/heroku-buildpack-java") } let(:jdk_version) { version } - it "should not install settings.xml" do - app.set_config("BUILDPACK_URL" => "https://github.com/heroku/heroku-buildpack-java#upgrade-jvm-common") + it "should deploy a simple java app" do app.deploy do |app| expect(app.output).to include("Installing OpenJDK #{jdk_version}") - expect(successful_body(app)).to eq("Hello from Java!") - expect(app.output).not_to include("Installing Maven") expect(app.output).to include("BUILD SUCCESS") expect(successful_body(app)).to eq("Hello from Java!") end
Set the default buildpack url for the java sample to the master branch of the java buildpack repo
diff --git a/spec/support/all/bad_tests.rb b/spec/support/all/bad_tests.rb index abc1234..def5678 100644 --- a/spec/support/all/bad_tests.rb +++ b/spec/support/all/bad_tests.rb @@ -4,7 +4,6 @@ next if file.closed? next if file.path == '/dev/null' next if file.path.end_with? '.pry_history' - next if file.path.end_with? 'zxcvbn.js' next if file.path =~ /^#{Rails.root.join('log')}.*.log/ next if file.path =~ /^#{Rails.root.join('app')}.*/
Stop checking for open zxcvbn.js files in specs
diff --git a/lib/keep_track/creation.rb b/lib/keep_track/creation.rb index abc1234..def5678 100644 --- a/lib/keep_track/creation.rb +++ b/lib/keep_track/creation.rb @@ -4,17 +4,19 @@ included do after_create do - user = nil - if not self.activity_user.nil? + if self.activity_user user = self.activity_user else - if self.class.activity_user_global.is_a?(Symbol) or self.class.activity_user_global.is_a?(String) - user = self[self.class.activity_user_global] - end + case self.activity_user_global + when Symbol, String + user = self[self.class.activity_user_global] + when Proc + user = self.class.activity_user_global.call + end end + self.activities.create(:key => self.class.name.downcase+".create", :user_id => user, :parameters => self.activity_params) end - end - + end end end
Clean up the code and allow tracked :user to be Proc or a Symbol/String, setting activity_user on a tracked object takes priority over :user attribute in model definition
diff --git a/RxKeyboard.podspec b/RxKeyboard.podspec index abc1234..def5678 100644 --- a/RxKeyboard.podspec +++ b/RxKeyboard.podspec @@ -11,8 +11,8 @@ s.frameworks = 'UIKit', 'Foundation' s.requires_arc = true - s.dependency 'RxSwift', '>= 4.1.2' - s.dependency 'RxCocoa', '>= 4.1.2' + s.dependency 'RxSwift', '>= 4.0.0' + s.dependency 'RxCocoa', '>= 4.0.0' s.ios.deployment_target = '8.0' end
Fix supported Swift version to 4.0.0
diff --git a/lib/travis/builder/base.rb b/lib/travis/builder/base.rb index abc1234..def5678 100644 --- a/lib/travis/builder/base.rb +++ b/lib/travis/builder/base.rb @@ -18,7 +18,7 @@ def buildable @buildable ||= Travis::Buildable.new( - :script => 'bundle exec rake', + :script => 'rake', :commit => build['commit'], :config => build['config'], :url => repository['url'] || "https://github.com/#{repository['slug']}"
Revert "Shouldn't we use bundle exec rake?" This reverts commit 13ebda7a9eb2cb70ddd197d91108a5c814544299.
diff --git a/config/initializers/transam_transit_extensions.rb b/config/initializers/transam_transit_extensions.rb index abc1234..def5678 100644 --- a/config/initializers/transam_transit_extensions.rb +++ b/config/initializers/transam_transit_extensions.rb @@ -1,8 +1,5 @@ # Technique caged from http://stackoverflow.com/questions/4460800/how-to-monkey-patch-code-that-gets-auto-loaded-in-rails Rails.configuration.to_prepare do - Asset.class_eval do - include TransamTransitAsset - end PolicyAssetSubtypeRule.class_eval do include TransamTransitPolicyAssetSubtypeRule end
Fix double loading of asset extensions for transit asset classes
diff --git a/ab.gemspec b/ab.gemspec index abc1234..def5678 100644 --- a/ab.gemspec +++ b/ab.gemspec @@ -19,10 +19,8 @@ spec.test_files = `git ls-files -- {spec}/*`.split("\n") spec.require_paths = ['lib'] - spec.add_development_dependency 'rake', '~> 10.3' + spec.add_development_dependency 'rake', '~> 11.0' spec.add_development_dependency 'rspec', '~> 3.0' spec.add_development_dependency 'rspec-its', '~> 1.0' spec.add_development_dependency 'json-schema', '~> 2.2.2', '>= 2.2.2' - spec.add_development_dependency 'ruby-prof', '~> 0.15.0', '>= 0.15.0' - spec.add_development_dependency 'pry', '~> 0.10.0', '>= 0.10.0' end
Update gemspec with newer gem versions
diff --git a/aggregate.gemspec b/aggregate.gemspec index abc1234..def5678 100644 --- a/aggregate.gemspec +++ b/aggregate.gemspec @@ -15,7 +15,7 @@ "LICENSE", "README.textile" ] - s.files = `git ls-files -z`.split("\x0") + s.files = Dir.glob("**/*") s.homepage = %q{http://github.com/josephruscio/aggregate} s.rdoc_options = ["--charset=UTF-8"] s.require_paths = ["lib"]
Use Dir.glob instead of git ls-files
diff --git a/db/migrate/20131203025507_question_translation.rb b/db/migrate/20131203025507_question_translation.rb index abc1234..def5678 100644 --- a/db/migrate/20131203025507_question_translation.rb +++ b/db/migrate/20131203025507_question_translation.rb @@ -1,4 +1,4 @@-class QuestionTranslation < ActiveRecord::Migration +class CreateQuestionTranslation < ActiveRecord::Migration def change create_table :question_translations do |t| t.integer :question_id
Fix name conflict in migration
diff --git a/lib/arug/trader/money.rb b/lib/arug/trader/money.rb index abc1234..def5678 100644 --- a/lib/arug/trader/money.rb +++ b/lib/arug/trader/money.rb @@ -8,15 +8,6 @@ def initialize(amount, currency) @amount = BigDecimal.new(amount.to_s) @currency = currency.upcase - end - - def +(other) - unless self.class === other && currency == other.currency - raise ArgumentError, "Currency mismatch" - end - - sum = amount + other.amount - self.class.new(sum, currency) end def +(other)
Remove superfluous addition definition on Money.
diff --git a/tests/spec/features/highlighting_error_output_spec.rb b/tests/spec/features/highlighting_error_output_spec.rb index abc1234..def5678 100644 --- a/tests/spec/features/highlighting_error_output_spec.rb +++ b/tests/spec/features/highlighting_error_output_spec.rb @@ -12,7 +12,7 @@ within('.output-stderr') do expect(page).to have_css '.error', text: 'wrong number of type arguments' expect(page).to have_css '.error', text: 'aborting due to 2 previous errors' - expect(page).to have_css '.error', text: 'Could not compile `playground`' + expect(page).to have_css '.error', text: /Could not compile `playground`/i end end
Update regex for failing to compile
diff --git a/omf_common/omf_common.gemspec b/omf_common/omf_common.gemspec index abc1234..def5678 100644 --- a/omf_common/omf_common.gemspec +++ b/omf_common/omf_common.gemspec @@ -20,6 +20,7 @@ # specify any dependencies here; for example: s.add_development_dependency "minitest", "~> 3.2" + s.add_development_dependency "em-minitest-spec", "~> 1.1.1" s.add_development_dependency "simplecov" s.add_runtime_dependency "blather", "~> 0.8.0" s.add_runtime_dependency "logging", "~> 1.7.1"
Include EM minispec in required dev gems
diff --git a/lib/couch_blog/engine.rb b/lib/couch_blog/engine.rb index abc1234..def5678 100644 --- a/lib/couch_blog/engine.rb +++ b/lib/couch_blog/engine.rb @@ -6,8 +6,7 @@ require 'cmtool' Cmtool::Menu.register do append_to :publications do - resource_link CouchBlog::Post, scope: CouchBlog::Admin, engine: CouchBlog::Engine - + resource_link CouchBlog::Post, scope: CouchBlog::Admin, engine: CouchBlog::Engine, label: :couch_blog_posts end end CouchBlog::Post.has_and_belongs_to_many :keywords, storing_keys: true, class_name: 'Cmtool::Keyword'
Add label to cmtool menu item
diff --git a/Ruby/lib/rack-mini-profiler.rb b/Ruby/lib/rack-mini-profiler.rb index abc1234..def5678 100644 --- a/Ruby/lib/rack-mini-profiler.rb +++ b/Ruby/lib/rack-mini-profiler.rb @@ -1,6 +1,6 @@ require 'mini_profiler/profiler' require 'patches/sql_patches' -if defined?(::Rails) && ::Rails::VERSION::MAJOR.to_i == 3 +if defined?(::Rails) && ::Rails::VERSION::MAJOR.to_i >= 3 require 'mini_profiler_rails/railtie' end
Load railtie under Rails 4.x
diff --git a/lib/ephemeral/app/api.rb b/lib/ephemeral/app/api.rb index abc1234..def5678 100644 --- a/lib/ephemeral/app/api.rb +++ b/lib/ephemeral/app/api.rb @@ -11,5 +11,6 @@ format :json group(:builds) { mount Ephemeral::Resources::Build } + group(:files) { mount Ephemeral::Resources::File } end end
Add files group to API
diff --git a/git_pissed.gemspec b/git_pissed.gemspec index abc1234..def5678 100644 --- a/git_pissed.gemspec +++ b/git_pissed.gemspec @@ -7,9 +7,9 @@ spec.name = 'git_pissed' spec.version = GitPissed::VERSION spec.authors = ['Chris Hunt'] - spec.email = ['chrishunt@github.com'] - spec.description = %q{TODO: Write a gem description} - spec.summary = %q{TODO: Write a gem summary} + spec.email = ['c@chrishunt.co'] + spec.description = %q{Track words over time in your git repository} + spec.summary = %q{Track words over time in your git repository} spec.homepage = '' spec.license = 'MIT'
Add description and summary to gemspec
diff --git a/lib/merb_activerecord.rb b/lib/merb_activerecord.rb index abc1234..def5678 100644 --- a/lib/merb_activerecord.rb +++ b/lib/merb_activerecord.rb @@ -1,10 +1,17 @@-if defined?(Merb::Plugins) +if defined?(Merb::Plugins) dependency "activerecord" require File.join(File.dirname(__FILE__) / "merb" / "orms" / "active_record" / "connection") Merb::Plugins.add_rakefiles(File.join(File.dirname(__FILE__) / "active_record" / "merbtasks")) + + class Merb::Orms::ActiveRecord::Connect < Merb::BootLoader - Merb::BootLoader.before_app_loads do - Merb::Orms::ActiveRecord.connect - Merb::Orms::ActiveRecord.register_session_type + after BeforeAppLoads + + def self.run + Merb::Orms::ActiveRecord.connect + Merb::Orms::ActiveRecord.register_session_type + end + end -end + +end
Revert "Use simple before_app_loads hook instead of bootloader subclass." This reverts commit a15f43ae003cc68c671ab325586fa026f5673373.
diff --git a/lib/mumukit/auth/user.rb b/lib/mumukit/auth/user.rb index abc1234..def5678 100644 --- a/lib/mumukit/auth/user.rb +++ b/lib/mumukit/auth/user.rb @@ -2,23 +2,29 @@ class Mumukit::Auth::User - attr_accessor :social_id, :user + attr_accessor :social_id, :user, :metadata def initialize(social_id) @social_id = social_id @user = client.user @social_id + @metadata = get_metadata || {} end - def update_metadata(data) - client.update_user_metadata social_id, metadata.merge(data) + def update_permissions(key, permission) + client.update_user_metadata social_id, add_permission(key, permission) end - def metadata - metadata = {} - apps.each do |app| - metadata[app] = @user[app] if @user[app].present? + def get_metadata + apps.select { |app| @user[app].present? }.map { |app| { "#{app}" => @user[app] } }.reduce({}, :merge) + end + + def add_permission(key, permission) + if @metadata[key].present? + @metadata[key]['permissions'] += ":#{permission}" + else + @metadata.merge!("#{key}" => { 'permissions' => permission }) end - metadata + @metadata end def apps
Refactor to support when no permissions
diff --git a/lib/number_recognizer.rb b/lib/number_recognizer.rb index abc1234..def5678 100644 --- a/lib/number_recognizer.rb +++ b/lib/number_recognizer.rb @@ -1,4 +1,10 @@ class NumberRecognizer + KNOWN_FORMATS = { + 'Dutch mobile' => [316, 8], + 'Belgian mobile' => [324, 8], + 'Suriname' => [597,7], + 'Antilles' => [599,7] + } attr_accessor :number def initialize(number) @@ -6,22 +12,10 @@ end def valid? - valid_dutch_mobile? or valid_belgian_mobile? or valid_suriname? or valid_antilles? - end - - def valid_dutch_mobile? - number =~ /^00316\d{8,8}$/ - end - - def valid_belgian_mobile? - number =~ /^00324\d{8,8}$/ - end - - def valid_suriname? - number =~ /^00597\d{7,7}/ - end - - def valid_antilles? - number =~ /^00599\d{7,7}/ + if match = KNOWN_FORMATS.find {|name, pattern| number =~ /^0{0,2}#{pattern.first}\d{#{pattern.last},#{pattern.last}}$/} + match + else + false + end end end
Use a lookup table instead of hand-crafted method to match a number
diff --git a/upstreamer.gemspec b/upstreamer.gemspec index abc1234..def5678 100644 --- a/upstreamer.gemspec +++ b/upstreamer.gemspec @@ -23,6 +23,7 @@ spec.require_paths = ["lib"] spec.add_runtime_dependency "octokit" + spec.add_runtime_dependency "rugged" spec.add_development_dependency "bundler", "~> 1.7" spec.add_development_dependency "rake", "~> 10.0" end
Add rugged as runtime dependency
diff --git a/lib/spotify/api/inbox.rb b/lib/spotify/api/inbox.rb index abc1234..def5678 100644 --- a/lib/spotify/api/inbox.rb +++ b/lib/spotify/api/inbox.rb @@ -1,8 +1,32 @@ module Spotify class API # @!group Inbox + + # Post an array of tracks to a Spotify user's inbox. + # + # @example + # tracks = [track_one, track_two] + # tracks_pointer = FFI::MemoryPointer.new(Spotify::Track, tracks.length) + # tracks_pointer.write_array_of_pointer(tracks) + # callback = proc do |inbox| + # puts "Message posted." + # end + # inbox = Spotify.inbox_post_tracks(session, "burgestrand", tracks_pointer, tracks.length, "You must listen to these!", callback, nil) + # + # @param [Session] session + # @param [String] username canonical username of recipient + # @param [FFI::Pointer<Track>] tracks_pointer pointer to array of tracks + # @param [Integer] tracks_pointer_count number of tracks in tracks_pointer + # @param [String] message message to attach to post + # @param [Proc<Inbox, FFI::Pointer] callback to call on completion + # @param [FFI::Pointer] userdata + # @return [Inbox] attach_function :inbox_post_tracks, [ Session, UTF8String, :array, :int, UTF8String, :inboxpost_complete_cb, :userdata ], Inbox + + # @param [Inbox] inbox + # @return [Symbol] error status of inbox post attach_function :inbox_error, [ Inbox ], :error + attach_function :inbox_add_ref, [ Inbox ], :error attach_function :inbox_release, [ Inbox ], :error end
Add documentation for Inbox subsystem
diff --git a/app/models/hint.rb b/app/models/hint.rb index abc1234..def5678 100644 --- a/app/models/hint.rb +++ b/app/models/hint.rb @@ -1,7 +1,7 @@ class Hint < ActiveRecord::Base validates :hint, presence: true, length: { maximum: 500 } validates :priority, presence: true, numericality: true - validates :points, presence: true, inclusion: { in: 0..1000 } + validates :points, presence: true, numericality: { only_integer: true, greater_than: 0 } def decrement_pointer_counter if self.pointer_counter <= 1
Remove limit in point value and fix error messages
diff --git a/lib/tasks/aggregate.rake b/lib/tasks/aggregate.rake index abc1234..def5678 100644 --- a/lib/tasks/aggregate.rake +++ b/lib/tasks/aggregate.rake @@ -0,0 +1,37 @@+namespace :aggregate do + namespace :hourly do + desc "Aggregate hourly impressions for every impression every recorded." + task all: :environment do + Rails.logger.level = :info + current = Impression.first.created_at.to_date + while current <= Date.today + Rails.logger.info "Aggregating Hourly Impressions for #{current}" + UpdateHourlyAggregations.call(date: current) + current = current + 1.day + end + end + + desc "Aggregate hourly impressions for every impression in the given year and month." + task :for_month, [:year, :month] => :environment do |t, args| + Rails.logger.level = :info + year = args[:year].to_i + month = args[:month].to_i + current = Date.new(year, month, 1) + while current <= Date.new(year, month).end_of_month + Rails.logger.info "Aggregating Hourly Impressions for #{current}" + UpdateHourlyAggregations.call(date: current) + current = current + 1.day + end + end + + desc "Aggregate hourly impressions for all of todays impressions." + task today: :environment do + UpdateHourlyAggregations.call(date: Date.today) + end + + desc "Aggregate hourly impressions for all of yesterdays impressions." + task yesterday: :environment do + UpdateHourlyAggregations.call(date: Date.yesterday) + end + end +end
Add tasks to generate hourly aggregations.
diff --git a/app/models/page.rb b/app/models/page.rb index abc1234..def5678 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -4,7 +4,6 @@ class Page < ActiveRecord::Base validates :url, presence: true, url: true - after_save :populate_content attr_accessible :content, :url
Remove after_save callback which seemed to be causing infinite loop
diff --git a/lib/punchblock/dsl.rb b/lib/punchblock/dsl.rb index abc1234..def5678 100644 --- a/lib/punchblock/dsl.rb +++ b/lib/punchblock/dsl.rb @@ -20,12 +20,12 @@ write @protocol::Hangup.new end - def reject(reason = :declined) # :nodoc: - write @protocol::Reject.new(reason) + def reject(reason = nil) # :nodoc: + write @protocol::Reject.new(:reason => reason) end def redirect(dest) # :nodoc: - write @protocol::Redirect.new(dest) + write @protocol::Redirect.new(:to => dest) end def say(string, type = :text) # :nodoc:
Update DSL for options hash requirement
diff --git a/spec/bundler/installer/gem_installer_spec.rb b/spec/bundler/installer/gem_installer_spec.rb index abc1234..def5678 100644 --- a/spec/bundler/installer/gem_installer_spec.rb +++ b/spec/bundler/installer/gem_installer_spec.rb @@ -20,6 +20,7 @@ it "invokes install method with build_args", :rubygems => ">= 2" do allow(Bundler.settings).to receive(:[]).with(:bin) allow(Bundler.settings).to receive(:[]).with(:inline) + allow(Bundler.settings).to receive(:[]).with(:forget_cli_options) allow(Bundler.settings).to receive(:[]).with("build.dummy").and_return("--with-dummy-config=dummy") expect(spec_source).to receive(:install).with(spec, :force => false, :ensure_builtin_gems_cached => false, :build_args => ["--with-dummy-config=dummy"]) subject.install_from_spec
Remove several CLI flags that need to be set via config in Bundler 2
diff --git a/Casks/qlstephen.rb b/Casks/qlstephen.rb index abc1234..def5678 100644 --- a/Casks/qlstephen.rb +++ b/Casks/qlstephen.rb @@ -2,7 +2,7 @@ version '1.4.3' sha256 '73f9a467ba2eb4244ffe1dbf9be435d3481a438c8ec64d2bd9bb1ba60d576a66' - # github.com/downloads/whomwah/qlstephen was verified as official when first introduced to the cask + # github.com/whomwah/qlstephen was verified as official when first introduced to the cask url "https://github.com/whomwah/qlstephen/releases/download/#{version}/QLStephen.qlgenerator.#{version}.zip" appcast 'https://github.com/whomwah/qlstephen/releases.atom', checkpoint: '6cf8bb2decd2e475f96e024cdd7c265266361417b4d30520def92c31eb951c3b'
Fix `url` stanza comment for QLStephen.
diff --git a/Casks/tangerine.rb b/Casks/tangerine.rb index abc1234..def5678 100644 --- a/Casks/tangerine.rb +++ b/Casks/tangerine.rb @@ -9,6 +9,8 @@ homepage 'https://www.karelia.com/products/tangerine/' license :commercial + auto_updates true + app 'Tangerine!.app' postflight do
Add auto_updates flag to Tangerine!
diff --git a/lib/yubioath/reset.rb b/lib/yubioath/reset.rb index abc1234..def5678 100644 --- a/lib/yubioath/reset.rb +++ b/lib/yubioath/reset.rb @@ -0,0 +1,17 @@+require 'yubioath' +require 'bindata' + +module YubiOATH + class Reset + def self.send(to:) + ::YubiOATH::Response.read(to.transmit(Request.new.to_binary_s)) + end + + class Request < BinData::Record + uint8 :cla, value: CLA + uint8 :ins, value: 0x04 + uint8 :p1, value: 0xDE + uint8 :p2, value: 0xAD + end + end +end
Implement the 'Reset' instruction, but don't expose it via the CLI
diff --git a/db/seeds.rb b/db/seeds.rb index abc1234..def5678 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -6,8 +6,6 @@ # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) # Mayor.create(name: 'Emanuel', city: cities.first) -Page.create(title: 'Home', content: 'home', published: true, url: 'home') - [['Diaspora blog', 'http://blog.diasporafoundation.org/feed/atom']].each do |title, url| Planet::Models::Feed.create! title: title, url: url end
Fix uninitialized constant during db setup Fixes #92
diff --git a/api/config/initializers/cors.rb b/api/config/initializers/cors.rb index abc1234..def5678 100644 --- a/api/config/initializers/cors.rb +++ b/api/config/initializers/cors.rb @@ -13,7 +13,7 @@ 'https://lachlan.hackclub.com', 'http://lachlan.hackclub.com', 'https://hackclub.com', - 'http://hackclub.com' + 'http://hackclub.com', 'localhost'].freeze allow do
Fix typo in CORS initializer
diff --git a/config/initializers/rails_admin.rb b/config/initializers/rails_admin.rb index abc1234..def5678 100644 --- a/config/initializers/rails_admin.rb +++ b/config/initializers/rails_admin.rb @@ -45,4 +45,13 @@ end end + config.model 'Document' do + list do + field :id + field :name + field :created_at + field :updated_at + end + end + end
Remove Data form admin view of Documents Data is generally large and it is not useful to load it. Increases page load time and transfers a lot of data to browser
diff --git a/lib/app/routes/exercises.rb b/lib/app/routes/exercises.rb index abc1234..def5678 100644 --- a/lib/app/routes/exercises.rb +++ b/lib/app/routes/exercises.rb @@ -1,19 +1,21 @@ module Xapi module Routes class Exercises < Core + helpers do + def require_key + unless params[:key] + halt 401, {error: "Please provide your Exercism.io API key"}.to_json + end + end + end + get '/exercises' do - unless params[:key] - halt 401, {error: "Please provide your Exercism.io API key"}.to_json - end - + require_key pg :exercises, locals: {exercises: Xapi::UserHomework.exercises_for(params[:key])} end get '/exercises/restore' do - unless params[:key] - halt 401, {error: "Please provide your Exercism.io API key"}.to_json - end - + require_key pg :exercises, locals: {exercises: Xapi::UserHomework.restore(params[:key])} end
Move guard into helper method
diff --git a/lib/bench_press/runnable.rb b/lib/bench_press/runnable.rb index abc1234..def5678 100644 --- a/lib/bench_press/runnable.rb +++ b/lib/bench_press/runnable.rb @@ -25,6 +25,7 @@ def run r,w = IO.pipe fork do + GC.disable run_it time = Benchmark.realtime do run_it
Disable garbage collector when benchmarking
diff --git a/lib/bundler/cli/platform.rb b/lib/bundler/cli/platform.rb index abc1234..def5678 100644 --- a/lib/bundler/cli/platform.rb +++ b/lib/bundler/cli/platform.rb @@ -9,7 +9,7 @@ def run platforms, ruby_version = Bundler.ui.silence do [Bundler.definition.platforms.map {|p| "* #{p}" }, - Bundler.definition.ruby_version] + (Bundler.locked_gems && Bundler.locked_gems.ruby_version) || Bundler.definition.ruby_version] end output = []
[Platform] Print out an exact version from the lockfile
diff --git a/lib/chart/receivers/line.rb b/lib/chart/receivers/line.rb index abc1234..def5678 100644 --- a/lib/chart/receivers/line.rb +++ b/lib/chart/receivers/line.rb @@ -1,3 +1,5 @@+require 'chart/topic' + module Chart module Receivers class Line @@ -12,15 +14,7 @@ def guess_config_for(topic) data = data_for(topic) - dimensions = data.first.map do |field| - case field - when /^\d+$/ then "i" - when /^\d+\.\d+$/ then "d" - when /^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.\d+)?(?:Z|[+-]\d\d:\d\d)$/ then "t" - else "s" - end - end - {"dimensions" => dimensions} + Topic.guess_config_for(data) end def data_for(topic, new_data = nil)
Make config guessing the same on the client as the server
diff --git a/spec/features/thredded/user_tracks_read_topics_and_posts_spec.rb b/spec/features/thredded/user_tracks_read_topics_and_posts_spec.rb index abc1234..def5678 100644 --- a/spec/features/thredded/user_tracks_read_topics_and_posts_spec.rb +++ b/spec/features/thredded/user_tracks_read_topics_and_posts_spec.rb @@ -29,7 +29,7 @@ topic.view_read_topic - travel_to 1.minute.from_now do + travel_to 1.day.from_now do topic.someone_updates_topic end topic.visit_index
Work around mysterious test failure
diff --git a/spec_support.gemspec b/spec_support.gemspec index abc1234..def5678 100644 --- a/spec_support.gemspec +++ b/spec_support.gemspec @@ -18,4 +18,5 @@ s.test_files = Dir["spec/**/*"] s.add_development_dependency "rspec" + s.add_dependency "jruby-openssl" end
Add jruby-openssl as a dependency for jruby in the gemspec
diff --git a/app/mailers/georgia/notifier.rb b/app/mailers/georgia/notifier.rb index abc1234..def5678 100644 --- a/app/mailers/georgia/notifier.rb +++ b/app/mailers/georgia/notifier.rb @@ -13,7 +13,6 @@ end def notify_admins(message, url) - return if Rails.env.development? or Rails.env.test? @message = message @url = url domain_name = Rails.application.config.action_mailer.smtp_settings[:domain] @@ -28,7 +27,6 @@ end def notify_editors(message, url) - return if Rails.env.development? or Rails.env.test? @message = message @url = url domain_name = Rails.application.config.action_mailer.smtp_settings[:domain]
Send emails in dev too, use letter_opener in main app
diff --git a/app/models/build/bower_error.rb b/app/models/build/bower_error.rb index abc1234..def5678 100644 --- a/app/models/build/bower_error.rb +++ b/app/models/build/bower_error.rb @@ -2,16 +2,17 @@ # Encapsulate Bower errors # parsed from Bower JSON output class BowerError < BuildError - attr_reader :path, :command, :details, :code + attr_reader :path, :command, :details, :code, :stacktrace ENOTFOUND = 'ENOTFOUND'.freeze EINVALID = 'EINVALID'.freeze - def initialize(message, details, path = nil, command = nil, code = nil) + def initialize(message, details, path = nil, command = nil, code = nil, stacktrace = nil) @details = details @path = path @command = command @code = code + @stacktrace = stacktrace super(message) end @@ -26,8 +27,12 @@ def self.from_shell_error(e) parsed_json = JSON.parse(e.message) error = parsed_json.find { |h| h['level'] == 'error' } - BowerError.new(error['message'], error['details'], - e.path, e.command, error['code']) + BowerError.new(error['message'], + error['details'], + e.path, + e.command, + error['code'], + error['stacktrace']) end end end
Add a stacktrace if present from Bower
diff --git a/approvals.gemspec b/approvals.gemspec index abc1234..def5678 100644 --- a/approvals.gemspec +++ b/approvals.gemspec @@ -23,7 +23,12 @@ s.add_development_dependency 'rspec', '~> 3.1' s.add_dependency 'thor', '~> 0.18' - s.add_dependency 'nokogiri', '~> 1.6' + + if RUBY_VERSION < "2.1" + s.add_dependency 'nokogiri', '~> 1.6.8' + else + s.add_dependency 'nokogiri', '~> 1.8' + end # We also depend on the json gem, but the version we need is # Ruby-version-specific. See `ext/mkrf_conf.rb`. end
:open_hands: Support EOL Ruby versions by locking Nokogiri to pre v1.7
diff --git a/erm.gemspec b/erm.gemspec index abc1234..def5678 100644 --- a/erm.gemspec +++ b/erm.gemspec @@ -1,6 +1,6 @@ require "rubygems" -$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib]) +$:.unshift File.join(File.dirname(__FILE__), "lib") require "erm/version" Gem::Specification.new do |s|
Fix gem spec lib path
diff --git a/app/mailers/adhoc_mailer.rb b/app/mailers/adhoc_mailer.rb index abc1234..def5678 100644 --- a/app/mailers/adhoc_mailer.rb +++ b/app/mailers/adhoc_mailer.rb @@ -3,7 +3,7 @@ default from: ENV.fetch('FROM_EMAIL') def send_adhoc_email(subject, body, user_ids) - users = User.where("id IN (?)", user_ids) + users = User.where(id: user_ids) users.each do |user| mail(to: user.email, subject: subject, body: body)
Use hash condition in where.
diff --git a/lib/geocoder/models/base.rb b/lib/geocoder/models/base.rb index abc1234..def5678 100644 --- a/lib/geocoder/models/base.rb +++ b/lib/geocoder/models/base.rb @@ -28,7 +28,7 @@ private # ---------------------------------------------------------------- def geocoder_init(options) - unless geocoder_initialized? + unless @geocoder_options @geocoder_options = {} require "geocoder/stores/#{geocoder_file_name}" include eval("Geocoder::Store::" + geocoder_module_name)
Fix for geocoding with STI models
diff --git a/lib/gitlab/client/groups.rb b/lib/gitlab/client/groups.rb index abc1234..def5678 100644 --- a/lib/gitlab/client/groups.rb +++ b/lib/gitlab/client/groups.rb @@ -1,8 +1,18 @@ class Gitlab::Client # Defines methods related to groups. module Groups - def groups - get("/groups") + + # Gets a list of groups. + # + # @example + # Gitlab.groups + # + # @param [Hash] options A customizable set of options. + # @option options [Integer] :page The page number. + # @option options [Integer] :per_page The number of results per page. + # @return [Array<Gitlab::ObjectifiedHash>] + def groups(options={}) + get("/groups", :query => options) end def group(group_id)
Add ability for group api to page results
diff --git a/app/models/topic_section.rb b/app/models/topic_section.rb index abc1234..def5678 100644 --- a/app/models/topic_section.rb +++ b/app/models/topic_section.rb @@ -4,8 +4,4 @@ has_many :topic_section_guides, -> { order(position: :asc) }, dependent: :destroy accepts_nested_attributes_for :topic_section_guides - - scope :belonging_to_topic, ->(topic_id) { - where(topic_id: topic_id) - } end
Remove unused topic section scope
diff --git a/lib/news/news_controller.rb b/lib/news/news_controller.rb index abc1234..def5678 100644 --- a/lib/news/news_controller.rb +++ b/lib/news/news_controller.rb @@ -1,6 +1,5 @@ require_relative 'news_service' require_relative 'news_repository' -require_relative 'relevance/relevance_command' class NewsController
Remove require "relevance functionality" from news controller
diff --git a/msfl_visitors.gemspec b/msfl_visitors.gemspec index abc1234..def5678 100644 --- a/msfl_visitors.gemspec +++ b/msfl_visitors.gemspec @@ -1,7 +1,7 @@ Gem::Specification.new do |s| s.name = 'msfl_visitors' - s.version = '0.1.0.rc0' - s.date = '2015-05-06' + s.version = '0.1.0.rc1' + s.date = '2015-05-08' s.summary = "Convert MSFL to other forms" s.description = "Visitor pattern approach to converting MSFL to other forms." s.authors = ["Courtland Caldwell"]
Update gem version now that all comparison fields and AND are parseable
diff --git a/app/uploaders/image_uploader.rb b/app/uploaders/image_uploader.rb index abc1234..def5678 100644 --- a/app/uploaders/image_uploader.rb +++ b/app/uploaders/image_uploader.rb @@ -7,8 +7,28 @@ process :set_content_type - version :thumb do + version :huge do + process resize_to_fit: [1024, 1024] + end + + version :large do + process resize_to_fit: [640, 640] + end + + version :medium do + process resize_to_fit: [320, 320] + end + + version :small do + process resize_to_fit: [160, 160] + end + + version :large_square do process resize_to_fill: [200, 200] + end + + version :small_square do + process resize_to_fill: [100, 100] end def store_dir @@ -22,4 +42,4 @@ def extension_white_list %w(jpg jpeg gif png) end -end +end
Add various version sizes similar to imgur.
diff --git a/absorb_api.gemspec b/absorb_api.gemspec index abc1234..def5678 100644 --- a/absorb_api.gemspec +++ b/absorb_api.gemspec @@ -6,11 +6,11 @@ Gem::Specification.new do |spec| spec.name = "absorb_api" spec.version = AbsorbApi::VERSION - spec.authors = ["npezza93"] + spec.authors = ["npezza"] spec.email = ["npezza93@gmail.com"] spec.summary = "API wrapper for Absorb LMS" - spec.description = "\"Absorb LMS is a powerful, flexible, and visually stunning software platform teamed with expert implementation and support to help you build the training programs your business needs. Whether your old LMS is slowing you down or you’ve outgrown your current training model, Absorb can help. + spec.description = "\"Absorb API is a ruby wrapper for Absorb's LMS. \n\n Absorb LMS is a powerful, flexible, and visually stunning software platform teamed with expert implementation and support to help you build the training programs your business needs. Whether your old LMS is slowing you down or you’ve outgrown your current training model, Absorb can help. \"" spec.homepage = "https://github.com/npezza93/absorb_api" spec.license = "MIT"
Update gemspec to publish gem
diff --git a/manifests/cf-manifest/spec/manifest/oauth_spec.rb b/manifests/cf-manifest/spec/manifest/oauth_spec.rb index abc1234..def5678 100644 --- a/manifests/cf-manifest/spec/manifest/oauth_spec.rb +++ b/manifests/cf-manifest/spec/manifest/oauth_spec.rb @@ -1,11 +1,32 @@-RSpec.describe "Google OAuth" do +RSpec.describe "OAuth" do let(:properties) { manifest.fetch("instance_groups.uaa.jobs.uaa.properties") } describe "by default" do let(:manifest) { manifest_with_defaults } + it "enables the Google OAuth provider in UAA" do providers = properties.fetch("login").fetch("oauth").fetch("providers") expect(providers).to have_key 'google' end + + it "enables the Microsoft OAuth provider in UAA" do + providers = properties.fetch("login").fetch("oauth").fetch("providers") + expect(providers).to have_key 'microsoft' + end + + it "enables a Google OAuth provider for administators in UAA" do + providers = properties.fetch("login").fetch("oauth").fetch("providers") + expect(providers).to have_key 'admin-google' + end + + it "ensures unique username attr mappings to ensure unique usernames" do + providers = properties.fetch("login").fetch("oauth").fetch("providers") + + mappings = providers + .values + .map { |p| p.dig('attributeMappings', 'user_name') } + + expect(mappings).to eq(mappings.uniq) + end end end
Add some tests for cf-manifest oauth Signed-off-by: Toby Lorne <527052641d65eef236eeef9545b2acac74c35d57@digital.cabinet-office.gov.uk>
diff --git a/app/models/renalware/patients/practice_search_query.rb b/app/models/renalware/patients/practice_search_query.rb index abc1234..def5678 100644 --- a/app/models/renalware/patients/practice_search_query.rb +++ b/app/models/renalware/patients/practice_search_query.rb @@ -12,7 +12,7 @@ term = "%#{search_term}%" Practice.select(:id, :name) - .joins(:address) + .left_outer_joins(:address) .where("patient_practices.name ILIKE ? OR addresses.postcode ILIKE ?", term, term) # .select("patient_practices.id", "patient_practices.name") end
Use outer join onto addresses when searcing for practice Otherwise a pratice with no address will not show up. Unlikely to have that I know, but useful for testing.
diff --git a/app/abilities/owner_ability.rb b/app/abilities/owner_ability.rb index abc1234..def5678 100644 --- a/app/abilities/owner_ability.rb +++ b/app/abilities/owner_ability.rb @@ -26,7 +26,6 @@ # Everyone can show and watch anyone can :show, Owner - # TODO: Don't like the use of persisted? here. Refactor. can :watch, Owner unless user.nil? || SiteSetting.read_only_mode end end
Remove out of date comment
diff --git a/app/models/installer_report.rb b/app/models/installer_report.rb index abc1234..def5678 100644 --- a/app/models/installer_report.rb +++ b/app/models/installer_report.rb @@ -17,6 +17,13 @@ find(/^Writing to a (temp directory)!$/) == "temp directory" end + def learner + learner_id = find(/^Not found URL: .*\/portal\/learners\/(\d+).jnlp.*$/) + l = nil + l = Portal::Learner.find(learner_id.to_i) + return l + end + # expects a regular expression with at least one capture group. # if more than one capture group is present, only the first group value will be reported def find(regexp)
Add learner method to InstallerReports
diff --git a/lib/suspenders/generators/stylelint_generator.rb b/lib/suspenders/generators/stylelint_generator.rb index abc1234..def5678 100644 --- a/lib/suspenders/generators/stylelint_generator.rb +++ b/lib/suspenders/generators/stylelint_generator.rb @@ -3,11 +3,13 @@ module Suspenders class StylelintGenerator < Generators::Base def install_stylelint - dependencies = ["stylelint@10", # FIXME: config-recommened is not ready for stylelint 11 yet - "stylelint-config-recommended", - "stylelint-order", - "stylelint-declaration-block-no-ignored-properties", - "stylelint-scss"] + dependencies = [ + { name: "stylelint", version: '10' }, # FIXME: config-recommened is not ready for stylelint 11 yet + { name: "stylelint-config-recommended" }, + { name: "stylelint-order" }, + { name: "stylelint-declaration-block-no-ignored-properties" }, + { name: "stylelint-scss" } + ] action YarnInstall.new(self, dependencies, "--dev") end @@ -18,17 +20,18 @@ class YarnInstall def initialize(base, dependencies, flags) @base = base - @dependencies = dependencies.join(" ") + @dependencies = dependencies @flags = flags end def invoke! - @base.run "bin/yarn add #{@dependencies} #{@flags}" + dependencies_with_versions = @dependencies.map { |d| d[:version] ? "#{d[:name]}@#{d[:version]}" : d[:name] }.join(' ') + @base.run "bin/yarn add #{dependencies_with_versions} #{@flags}" end def revoke! @base.behavior = :invoke - @base.run "bin/yarn remove #{@dependencies}" + @base.run "bin/yarn remove #{@dependencies.map { |d| d[:name] }.join(' ')}" ensure @base.behavior = :revoke end
Fix style lint destroying action
diff --git a/Casks/yourkit-java-profiler.rb b/Casks/yourkit-java-profiler.rb index abc1234..def5678 100644 --- a/Casks/yourkit-java-profiler.rb +++ b/Casks/yourkit-java-profiler.rb @@ -1,6 +1,6 @@ cask :v1 => 'yourkit-java-profiler' do - version '2015-build-15044' - sha256 '4a1ccfe84645026701dd45414e53ddfb948b2dd0fa88aaf5dece2fcd0c244037' + version '2015-build-15050' + sha256 'e090896ca3dc57f05221b662b7fce74fc75edfcc24aaf3a06c098f2c1dc2db8a' url "http://www.yourkit.com/download/yjp-#{version}-mac.zip" name 'YourKit Java Profiler'
Update Yourkit Java Profiler to 2015-build-15050
diff --git a/lib/action_dispatch/exception_wrapper.rb b/lib/action_dispatch/exception_wrapper.rb index abc1234..def5678 100644 --- a/lib/action_dispatch/exception_wrapper.rb +++ b/lib/action_dispatch/exception_wrapper.rb @@ -5,7 +5,7 @@ file, line = trace.split(":") line_number = line.to_i { - code: source_fragment(file, line_number), + code: source_fragment(file, line_number) || {}, file: file, line_number: line_number }
Make sure code extract is always a hash
diff --git a/lib/rubocop/formatter/junit_formatter.rb b/lib/rubocop/formatter/junit_formatter.rb index abc1234..def5678 100644 --- a/lib/rubocop/formatter/junit_formatter.rb +++ b/lib/rubocop/formatter/junit_formatter.rb @@ -3,6 +3,11 @@ module RuboCop module Formatter class JUnitFormatter < BaseFormatter + + # This gives all cops - we really want all _enabled_ cops, but + # that is difficult to obtain - no access to config object here. + COPS = Cop::Cop.all + def started(target_file) @document = REXML::Document.new.tap do |d| d << REXML::XMLDecl.new @@ -16,14 +21,17 @@ def file_finished(file, offences) return if offences.empty? - offences.group_by(&:cop_name).each do |cop, cop_offences| + # One test case per cop per file + COPS.each do |cop| REXML::Element.new('testcase', @testsuite).tap do |f| f.attributes['classname'] = file.gsub(/\.rb\Z/, '').gsub("#{Dir.pwd}/", '').gsub('/', '.') - f.attributes['name'] = cop - - cop_offences.each do |offence| + f.attributes['name'] = cop.cop_name + + # One failure per offence. Zero failures is a passing test case, + # for most surefire/nUnit parsers. + offences.select {|offence| offence.cop_name == cop.cop_name}.each do |offence| REXML::Element.new('failure', f).tap do |e| - e.attributes['type'] = cop + e.attributes['type'] = cop.cop_name e.attributes['message'] = offence.message e.add_text offence.location.to_s end
Include test cases for all cops, and then emit failure tags only for those with offences
diff --git a/tty-file.gemspec b/tty-file.gemspec index abc1234..def5678 100644 --- a/tty-file.gemspec +++ b/tty-file.gemspec @@ -9,8 +9,8 @@ spec.authors = ["Piotr Murach"] spec.email = [""] - spec.summary = %q{File manipulation utility methods} - spec.description = %q{File manipulation utility methods} + spec.summary = %q{File manipulation utility methods.} + spec.description = %q{File manipulation utility methods.} spec.homepage = "https://piotrmurach.github.io/tty" spec.license = "MIT" @@ -19,8 +19,10 @@ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - spec.add_dependency 'pastel', '~> 0.7.1' - spec.add_dependency 'tty-prompt', '~> 0.13.2' + spec.required_ruby_version = '>= 2.0.0' + + spec.add_dependency 'pastel', '~> 0.7.2' + spec.add_dependency 'tty-prompt', '~> 0.14.0' spec.add_dependency 'diff-lcs', '~> 1.3.0' spec.add_development_dependency 'bundler', '~> 1.5'
Change to update dependencies and lock ruby version
diff --git a/lib/transactional_factories/test_case.rb b/lib/transactional_factories/test_case.rb index abc1234..def5678 100644 --- a/lib/transactional_factories/test_case.rb +++ b/lib/transactional_factories/test_case.rb @@ -1,21 +1,25 @@ module TransactionalFactories module ClassMethods def suite_with_transactions - method_names = public_instance_methods(true) - tests = method_names.delete_if {|method_name| method_name !~ /^test./} - suite = TransactionalFactories::TestSuite.new(name) - tests.sort.each do - |test| - catch(:invalid_test) do - suite << new(test) + if use_transactional_factories.is_a?(FalseClass) + suite_without_transactions + else + method_names = public_instance_methods(true) + tests = method_names.delete_if {|method_name| method_name !~ /^test./} + suite = TransactionalFactories::TestSuite.new(name) + tests.sort.each do + |test| + catch(:invalid_test) do + suite << new(test) + end end + if (suite.empty?) + catch(:invalid_test) do + suite << new("default_test") + end + end + return suite end - if (suite.empty?) - catch(:invalid_test) do - suite << new("default_test") - end - end - return suite end end @@ -23,6 +27,7 @@ class << klass include ClassMethods alias_method_chain 'suite', 'transactions' + cattr_accessor :use_transactional_factories end end end
Add a way to disable transactional factories for a single test.
diff --git a/spec/core/float/divmod_spec.rb b/spec/core/float/divmod_spec.rb index abc1234..def5678 100644 --- a/spec/core/float/divmod_spec.rb +++ b/spec/core/float/divmod_spec.rb @@ -2,9 +2,15 @@ describe "Float#divmod" do it "returns an [quotient, modulus] from dividing self by other" do - 3.14.divmod(2).inspect.should == "[1, 1.14]" - 2.8284.divmod(3.1415).inspect.should == "[0, 2.8284]" - -1.0.divmod(0xffffffff).inspect.should == "[-1, 4294967294.0]" + values = 3.14.divmod(2) + values[0].should == 1 + values[1].should be_close(1.14, TOLERANCE) + values = 2.8284.divmod(3.1415) + values[0].should == 0 + values[1].should be_close(2.8284, TOLERANCE) + values = -1.0.divmod(0xffffffff) + values[0].should == -1 + values[1].should be_close(4294967294.0, TOLERANCE) end platform :version => '1.8.5'..'1.8.6' do
Expand Float divmod array equality comparisons to use be_close with a default tolerance.
diff --git a/files/aerobase-cookbooks/aerobase/recipes/java-home.rb b/files/aerobase-cookbooks/aerobase/recipes/java-home.rb index abc1234..def5678 100644 --- a/files/aerobase-cookbooks/aerobase/recipes/java-home.rb +++ b/files/aerobase-cookbooks/aerobase/recipes/java-home.rb @@ -18,7 +18,7 @@ cmd_helper = CmdHelper.new(node) powershell_script "set-java-home" do - code "#{install_dir}/embedded/bin/find-java.ps1 -SetSystem" + code "#{install_dir}/embedded/bin/find-java.ps1 -SetSystem -SetSession" flags "-NonInteractive" ignore_failure true end
Add java_home to current session
diff --git a/test/integration/post_show_test.rb b/test/integration/post_show_test.rb index abc1234..def5678 100644 --- a/test/integration/post_show_test.rb +++ b/test/integration/post_show_test.rb @@ -3,8 +3,18 @@ class PostShowTest < ActionDispatch::IntegrationTest setup do @post = create(:post, :whatever, :with_credit, body: <<~EOS.encode(crlf_newline: true)) - <h1> hi </h1> + # hi + contents + + <!--nextpage--> + + ## hi hi + + contents + contents + contents + EOS switch_domain(@post.site.fqdn) @@ -27,4 +37,13 @@ assert page.has_selector?('section.credits') end end + + test "page 2 should not display credits" do + visit "/#{@post.public_id}?page=2" + + within '.post__body' do + assert page.has_selector?('h2', text: 'hi hi') + assert page.has_no_selector?('section.credits') + end + end end
Add test for displaying credits in page 2
diff --git a/test/error_handling_test.rb b/test/error_handling_test.rb index abc1234..def5678 100644 --- a/test/error_handling_test.rb +++ b/test/error_handling_test.rb @@ -19,13 +19,23 @@ def test_always_raise_timeout_error Geocoder::Configuration.always_raise = [TimeoutError] - assert_raise(TimeoutError) { Geocoder.search("timeout") } + all_lookups.each do |l| + lookup = Geocoder.send(:get_lookup, l) + assert_raises TimeoutError do + lookup.send(:results, "timeout") + end + end Geocoder::Configuration.always_raise = [] end def test_always_raise_socket_error Geocoder::Configuration.always_raise = [SocketError] - assert_raise(SocketError) { Geocoder.search("socket_error") } + all_lookups.each do |l| + lookup = Geocoder.send(:get_lookup, l) + assert_raises SocketError do + lookup.send(:results, "socket_error") + end + end Geocoder::Configuration.always_raise = [] end end
Test exceptions with all lookups.
diff --git a/lib/fit_commit/cli.rb b/lib/fit_commit/cli.rb index abc1234..def5678 100644 --- a/lib/fit_commit/cli.rb +++ b/lib/fit_commit/cli.rb @@ -12,26 +12,37 @@ end def execute - action_name = args.shift - case action_name - when "install" - FitCommit::Installer.new.install - EXIT_CODE_SUCCESS - when "uninstall" - FitCommit::Installer.new.uninstall - EXIT_CODE_SUCCESS - else - print_help - EXIT_CODE_FAILURE - end + action_name = in_git_repo? ? args.shift : :fail_git_repo + action_name = :help unless respond_to?(action_name, :include_private) + send(action_name) end private - def print_help - warn "fit-commit v#{FitCommit::VERSION}" - warn "Usage: fit-commit install" - warn "Usage: fit-commit uninstall" + def help + $stderr.puts "fit-commit v#{FitCommit::VERSION}" + $stderr.puts "Usage: fit-commit install" + $stderr.puts "Usage: fit-commit uninstall" + EXIT_CODE_FAILURE + end + + def install + FitCommit::Installer.new.install + EXIT_CODE_SUCCESS + end + + def uninstall + FitCommit::Installer.new.uninstall + EXIT_CODE_SUCCESS + end + + def in_git_repo? + File.exist?(".git") + end + + def fail_git_repo + $stderr.puts "fit-commit: .git directory not found. Please run from your Git repository root." + EXIT_CODE_FAILURE end end end
Print error if binary not run from git repo
diff --git a/lib/jekyll/version.rb b/lib/jekyll/version.rb index abc1234..def5678 100644 --- a/lib/jekyll/version.rb +++ b/lib/jekyll/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Jekyll - VERSION = "4.3.0" + VERSION = "5.0.0.dev" end
Mark initiation of v5.0 development To prevent users from pointing their Gemfile to the repository and breaking their site.
diff --git a/app/helpers/application_helper/toolbar/ansible_credential_center.rb b/app/helpers/application_helper/toolbar/ansible_credential_center.rb index abc1234..def5678 100644 --- a/app/helpers/application_helper/toolbar/ansible_credential_center.rb +++ b/app/helpers/application_helper/toolbar/ansible_credential_center.rb @@ -24,4 +24,20 @@ ] ), ]) + button_group('embedded_ansible_credentials_policy', [ + select( + :embedded_ansible_credentials_policy_choice, + 'fa fa-shield fa-lg', + t = N_('Policy'), + t, + :items => [ + button( + :ansible_credential_tag, + 'pficon pficon-edit fa-lg', + N_('Edit Tags for the selected Ansible Credentials'), + N_('Edit Tags'), + ), + ] + ) + ]) end
Add Policy button to enable tagging of Ansible Credential Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1526219 Add Policy toolbar button to enable tagging of any Ansible Credential from its summary page.
diff --git a/config/routes.rb b/config/routes.rb index abc1234..def5678 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -7,6 +7,8 @@ namespace :admin do root 'dashboard#index' - resources :sites + constraints ->(_req) { Apartment::Tenant.current == 'public' } do + resources :sites + end end end
Add constraint for system only resources in admin
diff --git a/db/migrate/20200511153912_change_column_type_control_on_sample.rb b/db/migrate/20200511153912_change_column_type_control_on_sample.rb index abc1234..def5678 100644 --- a/db/migrate/20200511153912_change_column_type_control_on_sample.rb +++ b/db/migrate/20200511153912_change_column_type_control_on_sample.rb @@ -0,0 +1,41 @@+class ChangeColumnTypeControlOnSample < ActiveRecord::Migration + CONTROL_DATA_MAPPING_UP = { + '0' => 'no_control', + '1' => 'control' + } + + CONTROL_DATA_MAPPING_DOWN = { + 'no_control' => '0', + 'control' => '1', + 'positive_control' => '1', # there shouldn't be any of these, but if there are then they should map to control rather than not control + 'negative_control' => '1' # there shouldn't be any of these, but if there are then they should map to control rather than not control + } + + def up + puts "Changing column type from boolean to string..." + change_column :sample, :control, :string + + puts "Migrating data..." + ActiveRecord::Base.transaction do + Sample.all.each do |sample| + sample.update!(control: CONTROL_DATA_MAPPING_UP[sample.control]) + end + end + + puts "Done" + end + + def down + puts "Migrating data back..." + ActiveRecord::Base.transaction do + Sample.all.each do |sample| + sample.update!(control: CONTROL_DATA_MAPPING_DOWN[sample.control]) + end + end + + puts "Reverting column type from string to boolean..." + change_column :sample, :control, :boolean + + puts "Done" + end +end
Add migration - schema to come, after upgrading mysql to try to get rid of all the trivial changes
diff --git a/app/controllers/spree/admin/overview_controller_decorator.rb b/app/controllers/spree/admin/overview_controller_decorator.rb index abc1234..def5678 100644 --- a/app/controllers/spree/admin/overview_controller_decorator.rb +++ b/app/controllers/spree/admin/overview_controller_decorator.rb @@ -5,7 +5,7 @@ @product_count = Spree::Product.active.managed_by(spree_current_user).count @order_cycle_count = OrderCycle.active.managed_by(spree_current_user).count - if OpenFoodNetwork::Permissions.new(spree_current_user).manages_one_enterprise? + if OpenFoodNetwork::Permissions.new(spree_current_user).manages_one_enterprise? && !spree_current_user.admin? @enterprise = @enterprises.first if @enterprise.sells == "unspecified" render "welcome", layout: "spree/layouts/bare_admin"
Make admins get multi enterprise dashboard
diff --git a/lib/walkman/player.rb b/lib/walkman/player.rb index abc1234..def5678 100644 --- a/lib/walkman/player.rb +++ b/lib/walkman/player.rb @@ -1,11 +1,11 @@ require "singleton" require "forwardable" - -SERVICES = [Walkman::Service::Rdio] module Walkman class Player include Singleton + + SERVICES = [Walkman::Service::Rdio] def services @services ||= begin
Move SERVICES within the class
diff --git a/test/integration/api_operations/list_test.rb b/test/integration/api_operations/list_test.rb index abc1234..def5678 100644 --- a/test/integration/api_operations/list_test.rb +++ b/test/integration/api_operations/list_test.rb @@ -7,14 +7,18 @@ should "retrieve districts" do VCR.use_cassette("districts") do - Clever::District.all + @districts = Clever::District.all end + + @districts.count.must_equal 1 end should "retrieve schools" do VCR.use_cassette("schools") do - Clever::School.all + @schools = Clever::School.all end + + @schools.count.must_equal 4 end should "retrieve students" do @@ -22,13 +26,15 @@ @students = Clever::Student.all end - student = @students[0] + @students.count.must_equal 100 end should "retrieve sections" do VCR.use_cassette("sections") do - Clever::Section.all + @sections = Clever::Section.all end + + @sections.count.must_equal 44 end should "retrieve teachers" do
Add some explicit assertions to list tests
diff --git a/config/deploy/production.rb b/config/deploy/production.rb index abc1234..def5678 100644 --- a/config/deploy/production.rb +++ b/config/deploy/production.rb @@ -13,7 +13,6 @@ server 'dash15.code.org', :app, :web server 'dash16.code.org', :app, :web server 'dash17.code.org', :app, :web -server 'dash18.code.org', :app, :web server 'dash19.code.org', :app, :web server 'dash20.code.org', :app, :web server 'dash23.code.org', :app, :web
Remove dash18, which is becoming the new archive machine
diff --git a/tablerize.gemspec b/tablerize.gemspec index abc1234..def5678 100644 --- a/tablerize.gemspec +++ b/tablerize.gemspec @@ -2,10 +2,10 @@ Gem::Specification.new do |gem| gem.name = 'tablerize' - gem.summary = 'Convert YAML to HTML tables.' + gem.summary = 'Say goodbye to aligning tables in Markdown.' gem.description = <<-END - Tablerize converts YAML to HTML tables. Say goodbye to aligning tables - in Markdown. + Tablerize is a format for writing tables using YAML/JSON-compatible data + structures, and Ruby code to convert it to HTML. END gem.version = Tablerize::VERSION
Make gemspec text consistent with repo text
diff --git a/catalinker/lib/server.rb b/catalinker/lib/server.rb index abc1234..def5678 100644 --- a/catalinker/lib/server.rb +++ b/catalinker/lib/server.rb @@ -5,6 +5,7 @@ require_relative './RESTService.rb' set :bind, '0.0.0.0' +enable :static get '/' do "Catalinker"
Enable (explicitly) static file access
diff --git a/app/controllers/relationships_controller.rb b/app/controllers/relationships_controller.rb index abc1234..def5678 100644 --- a/app/controllers/relationships_controller.rb +++ b/app/controllers/relationships_controller.rb @@ -2,15 +2,11 @@ before_filter :authenticate_user! #TODO: Use ajax? + #TODO: Add conditional to make sure a contact cannot be requestd twice def create - relationship = Relationship.new(status: "pending") - - student = Student.find(params[:student_id]) - relationship.student = student - relationship.partner_id = current_user.partner_id - relationship.save - - flash[:notice] = "You successfully requested contact with #{student.name}." + Relationship.pending!(current_user.partner.id, params[:student_id]) + flash[:notice] = "You successfully requested contact with #{Student.find(params[:student_id]).name}." redirect_to students_path end + end
Refactor controller to include new connection creating methods
diff --git a/lib/miq_automation_engine/service_models/miq_ae_service_manageiq-providers-ansible_tower-configuration_manager-job.rb b/lib/miq_automation_engine/service_models/miq_ae_service_manageiq-providers-ansible_tower-configuration_manager-job.rb index abc1234..def5678 100644 --- a/lib/miq_automation_engine/service_models/miq_ae_service_manageiq-providers-ansible_tower-configuration_manager-job.rb +++ b/lib/miq_automation_engine/service_models/miq_ae_service_manageiq-providers-ansible_tower-configuration_manager-job.rb @@ -0,0 +1,12 @@+module MiqAeMethodService + class MiqAeServiceManageIQ_Providers_AnsibleTower_ConfigurationManager_Job < MiqAeServiceOrchestrationStack + expose :job_template, :association => true + expose :refresh_ems + + def self.create_job(template, args = {}) + template_object = ConfigurationScript.find_by(:id => template.id) + klass = ManageIQ::Providers::AnsibleTower::ConfigurationManager::Job + wrap_results(klass.create_job(template_object, args)) + end + end +end
Introduce AnsibleTower's Job subclassed from OrchestrationStack (transferred from ManageIQ/manageiq@2cfe41f01bb6120f4f6f8c50a0e3a4762c415ec5)
diff --git a/app/validators/panopticon_slug_validator.rb b/app/validators/panopticon_slug_validator.rb index abc1234..def5678 100644 --- a/app/validators/panopticon_slug_validator.rb +++ b/app/validators/panopticon_slug_validator.rb @@ -1,3 +1,5 @@+require 'net/http' + class PanopticonSlugValidator < ActiveModel::EachValidator def claim_slug(endpoint_url, attributes_to_send) uri = URI.parse(endpoint_url)
Add net/http to panopticon slug validator so that we can create things again net/http must have been required in some of the frontend code that we've now removed
diff --git a/test/models/unit_test.rb b/test/models/unit_test.rb index abc1234..def5678 100644 --- a/test/models/unit_test.rb +++ b/test/models/unit_test.rb @@ -0,0 +1,15 @@+require 'test_helper' + +class UnitTest < ActiveSupport::TestCase + test 'ensure valid response from unit ilo data' do + unit = Unit.first + details = unit.ilo_progress_class_details + + assert details.key?('all'), 'contains all key' + + unit.tutorials.each do |tute| + assert details.key?(tute.id), 'contains tutorial keys' + end + + end +end
TEST: Add test for unit ilo progress
diff --git a/spec/models/game_spec.rb b/spec/models/game_spec.rb index abc1234..def5678 100644 --- a/spec/models/game_spec.rb +++ b/spec/models/game_spec.rb @@ -1,5 +1,15 @@ require 'rails_helper' RSpec.describe Game, type: :model do - pending "add some examples to (or delete) #{__FILE__}" + describe "#deal" do + subject(:game) { Game.new } + + specify do + HAND_SIZE = 10 + + game.deal + + expect(game.south_hand).to have_exactly(HAND_SIZE).items + end + end end
Create unit test for Game.deal
diff --git a/spec/numeric_ext_spec.rb b/spec/numeric_ext_spec.rb index abc1234..def5678 100644 --- a/spec/numeric_ext_spec.rb +++ b/spec/numeric_ext_spec.rb @@ -14,12 +14,28 @@ end end + shared_context 'having correct precision' do |n| + it 'sets default precision without an argument' do + expect(n.inches).to have_precision(Dims::DEFAULT_PRECISION) + end + + it 'sets the supplied precision' do + expect(n.inches(2)).to have_precision(2) + end + end + context 'with integer value' do - include_context 'returning expected', 42 + n = 42 + + include_context 'returning expected', n + include_context 'having correct precision', n end context 'with float value' do - include_context 'returning expected', 3.14 + n = Math::PI + + include_context 'returning expected', n + include_context 'having correct precision', n end end end
Add examples for testing precision is set
diff --git a/spec/support/postgres.rb b/spec/support/postgres.rb index abc1234..def5678 100644 --- a/spec/support/postgres.rb +++ b/spec/support/postgres.rb @@ -10,7 +10,7 @@ DEFAULT_TEST_DATABASE = 'postgres:///rspec-sequel-test' def self.connect_to_postgres - test_database = unless ENV['TEST_DATABASE'] + test_database = ENV['TEST_DATABASE'] || begin STDERR.puts "TEST_DATABASE environment variable not found, defaulting to #{DEFAULT_TEST_DATABASE}" DEFAULT_TEST_DATABASE end
Fix test database connection string setup
diff --git a/sli/admin-tools/admin-rails/app/models/user_account_validation.rb b/sli/admin-tools/admin-rails/app/models/user_account_validation.rb index abc1234..def5678 100644 --- a/sli/admin-tools/admin-rails/app/models/user_account_validation.rb +++ b/sli/admin-tools/admin-rails/app/models/user_account_validation.rb @@ -30,7 +30,7 @@ rescue => e Rails.logger.error "VERIFICATION ERROR: #{e}" # TODO have approval engine raise exceptions or check approval state instead of matching msg strings - if e.to_s == "Current status 'approved' does not allow transition 'verify_email'." + if e.to_s =~ /^Current status '\w+' does not allow transition 'verify_email'\.$/ return ACCOUNT_PREVIOUSLY_VERIFIED elsif e.to_s == "Could not find user for email id #{emailToken}." return INVALID_VERIFICATION_CODE
Fix error message for duplicate email validation attempts
diff --git a/tools/run_old_experiment.rb b/tools/run_old_experiment.rb index abc1234..def5678 100644 --- a/tools/run_old_experiment.rb +++ b/tools/run_old_experiment.rb @@ -28,6 +28,9 @@ # remove them ourselves. Dir.glob('**/*pyc').each { |f| File.delete(f) } +# Also make sure that hassel has been compiled. +system "./tools/clean.sh" + experiment_dir = File.dirname(options[:config_path]) repo_orchestrator = RepositoryOrchestrator.new
Make sure hassel has been compiled
diff --git a/tests/test_command_matcher_move.rb b/tests/test_command_matcher_move.rb index abc1234..def5678 100644 --- a/tests/test_command_matcher_move.rb +++ b/tests/test_command_matcher_move.rb @@ -0,0 +1,35 @@+require './lib/toy_robot_simulator/command/matcher/base' +require 'minitest/autorun' + +class CommandMatcherMoveTest < MiniTest::Unit::TestCase + def setup + @move_matcher = Command::Matcher::Move + @valid_str = 'MOVE' + end + + def test_respond_to_public_interface + assert_respond_to @move_matcher, :build_with_match + end + + def test_that_it_matches_move + assert @move_matcher.build_with_match(@valid_str) + end + + def test_that_it_ignores_others + refute @move_matcher.build_with_match('MOVE ') + end + + def test_that_response_knows_token + assert_equal Command::Token::MOVE, + @move_matcher.build_with_match(@valid_str).token + end + + def test_that_response_knows_args + assert_equal @move_matcher.send(:extract_args, @valid_str), + @move_matcher.build_with_match(@valid_str).args + end + + def test_that_response_is_nil + assert_equal nil, @move_matcher.build_with_match('f34j89f34f893h') + end +end
Implement CommandMatcherMoveTest to guide design This class is intended to test and document the development of a command matching object, which understands the 'MOVE' command.
diff --git a/db/migrate/20161125172005_add_braintree_configuration_to_stores.rb b/db/migrate/20161125172005_add_braintree_configuration_to_stores.rb index abc1234..def5678 100644 --- a/db/migrate/20161125172005_add_braintree_configuration_to_stores.rb +++ b/db/migrate/20161125172005_add_braintree_configuration_to_stores.rb @@ -0,0 +1,9 @@+class AddBraintreeConfigurationToStores < ActiveRecord::Migration + def up + Spree::Store.all.each(&:create_braintree_configuration) + end + + def down + SolidusPaypalBraintree::Configuration.joins(:store).destroy_all + end +end
Add default configuration to stores in a migration
diff --git a/plugins/disk_stats.rb b/plugins/disk_stats.rb index abc1234..def5678 100644 --- a/plugins/disk_stats.rb +++ b/plugins/disk_stats.rb @@ -2,7 +2,7 @@ provides 'disk_stats' collect_data(:linux) do disk_stats Mash.new - so = shell_out("iostat -d") + so = shell_out("iostat -d -k") parsing_dev = false so.stdout.lines do |line| next if line == "\n"
Use -k option on iostat: Display statistics in kilobytes per second instead of blocks per second
diff --git a/app/models/item.rb b/app/models/item.rb index abc1234..def5678 100644 --- a/app/models/item.rb +++ b/app/models/item.rb @@ -1,5 +1,4 @@ class Item < ApplicationRecord - attr_accessor :category_id validates :name, presence: { message: "Name field can't be left blank"}, length: { in: 3..64, message: "Name must be between 3 and 64 characters in length" } validates :description, presence: { message: "Description field can't be left blank" }, length: { in: 3..3000, message: "Description must be between 3 and 3,000 characters" }
Remove the attr_accessor, which was preventing me from updating changes when saving the database
diff --git a/app/models/user.rb b/app/models/user.rb index abc1234..def5678 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -6,8 +6,8 @@ has_many :participations has_many :challenges, through: :participations - validates :username, presence: true - validates :email, presence: true + validates :username, presence: true, uniqueness: true + validates :email, presence: true, uniqueness: true has_secure_password has_attached_file :image, :styles => {:medium => "200x200", :large => "500x500"}
Add uniqueness validation to User model
diff --git a/color-scheme-validator.gemspec b/color-scheme-validator.gemspec index abc1234..def5678 100644 --- a/color-scheme-validator.gemspec +++ b/color-scheme-validator.gemspec @@ -4,7 +4,7 @@ Gem::Specification.new do |spec| spec.name = "color-scheme-validator" - spec.version = "0.3.0" + spec.version = "0.4.0" spec.authors = ["ka"] spec.email = ["ka.kaosf@gmail.com"] @@ -18,7 +18,7 @@ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - spec.add_dependency("activemodel", "~> 4.0") + spec.add_dependency("activemodel", "~> 5.0") spec.add_development_dependency "bundler", "~> 1.10" spec.add_development_dependency "rake", "~> 11.3"
Upgrade activemodel version from 4.x to 5.x
diff --git a/spec/lib/action_subscriber/configuration_spec.rb b/spec/lib/action_subscriber/configuration_spec.rb index abc1234..def5678 100644 --- a/spec/lib/action_subscriber/configuration_spec.rb +++ b/spec/lib/action_subscriber/configuration_spec.rb @@ -2,9 +2,15 @@ describe "default values" do specify { expect(subject.allow_low_priority_methods).to eq(false) } specify { expect(subject.default_exchange).to eq("events") } + specify { expect(subject.heartbeat).to eq(5) } specify { expect(subject.host).to eq("localhost") } + specify { expect(subject.mode).to eq('subscribe') } + specify { expect(subject.pop_interval).to eq(100) } specify { expect(subject.port).to eq(5672) } + specify { expect(subject.prefetch).to eq(200) } specify { expect(subject.threadpool_size).to eq(8) } + specify { expect(subject.timeout).to eq(1) } + specify { expect(subject.times_to_pop).to eq(8) } end describe "add_decoder" do
Add specs for default settings
diff --git a/spec/models/questions_spec.rb b/spec/models/questions_spec.rb index abc1234..def5678 100644 --- a/spec/models/questions_spec.rb +++ b/spec/models/questions_spec.rb @@ -5,4 +5,8 @@ it "has a valid factory" do expect(build(:question)).to be_valid end + + it "is invalid without a title" do + expect(build(:question, title: nil).valid?).to eq false + end end
Test for question title validation
diff --git a/config/environments/staging.rb b/config/environments/staging.rb index abc1234..def5678 100644 --- a/config/environments/staging.rb +++ b/config/environments/staging.rb @@ -28,5 +28,5 @@ # Expands the lines which load the assets config.assets.debug = true - config.middleware.insert 0, Slimmer::App, :template_host => "/data/vhost/static.#{Rails.env}.alphagov.co.uk/current/public/templates" + config.middleware.use Slimmer::App, :template_host => "/data/vhost/static.#{Rails.env}.alphagov.co.uk/current/public/templates" end
Switch slimmer middleware insertion to be less specific about placement
diff --git a/config/software/loom-server.rb b/config/software/loom-server.rb index abc1234..def5678 100644 --- a/config/software/loom-server.rb +++ b/config/software/loom-server.rb @@ -8,8 +8,8 @@ mkdir "#{install_dir}/bin" copy "#{project_dir}/server/bin/*", "#{install_dir}/bin" command "cp -fpPR #{project_dir}/docs/licenses #{project_dir}/config #{install_dir}" - mkdir "#{install_dir}/etc/logrotate.d" - copy "#{project_dir}/server/distribution/etc/logrotate.d/loom-server", "#{install_dir}/etc/logrotate.d" + mkdir "#{install_dir}/distribution/etc/logrotate.d" + copy "#{project_dir}/server/distribution/etc/logrotate.d/loom-server", "#{install_dir}/distribution/etc/logrotate.d" mkdir "#{install_dir}/conf" copy "#{project_dir}/server/distribution/etc/loom/conf.dist/*", "#{install_dir}/conf" # command "sed -e 's/APP_NAME/loom-server/g' -e 's/SVC_NAME/server/g' bin/loom-service > #{install_dir}/server/bin/init-loom-server"
Install logrotate file into correct location
diff --git a/app/serializers/api/v1/update_serializer.rb b/app/serializers/api/v1/update_serializer.rb index abc1234..def5678 100644 --- a/app/serializers/api/v1/update_serializer.rb +++ b/app/serializers/api/v1/update_serializer.rb @@ -7,7 +7,7 @@ attribute :updated_at, key: :date def updated_at - object.updated_at.strftime('%d %B %Y') + object.updated_at.strftime('%d %b %Y') end end end
Format date to give month in short form
diff --git a/rack-secure-upload.gemspec b/rack-secure-upload.gemspec index abc1234..def5678 100644 --- a/rack-secure-upload.gemspec +++ b/rack-secure-upload.gemspec @@ -16,6 +16,8 @@ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } gem.require_paths = ['lib'] + gem.required_ruby_version = ['>= 1.9', '< 2.6'] + gem.add_dependency 'logger', '>= 1.2' gem.add_dependency "rack", ">= 1.3" gem.add_dependency "terrapin"
Add required ruby version in gemspec
diff --git a/lib/boson/libraries/gem_library.rb b/lib/boson/libraries/gem_library.rb index abc1234..def5678 100644 --- a/lib/boson/libraries/gem_library.rb +++ b/lib/boson/libraries/gem_library.rb @@ -10,7 +10,7 @@ class GemLibrary < Library #:stopdoc: def self.is_a_gem?(name) - Object.const_defined?(:Gem) && Gem.searcher.find(name).is_a?(Gem::Specification) + Object.const_defined?(:Gem) && Gem::Specification.find_by_name(name).is_a?(Gem::Specification) end handles {|source| is_a_gem?(source.to_s) }
Update for new version of RubyGems Changed Gem.searcher.find to Gem::Specification.find_by_name
diff --git a/lib/coding_test_dg/rule/product.rb b/lib/coding_test_dg/rule/product.rb index abc1234..def5678 100644 --- a/lib/coding_test_dg/rule/product.rb +++ b/lib/coding_test_dg/rule/product.rb @@ -7,7 +7,7 @@ def apply(checkout) ft_products = checkout.cart.select(&:product_code).select{|p| p.product_code == @rule.fetch(:product_code)} - free_products = ft_products.each_slice(2).select{|p| p.size == 2}.count + free_products = ft_products.each_slice(@rule.fetch(:qty)).select{|p| p.size == 2}.count @rule.fetch(:price) * free_products end end
Make slice each value configurable to accommodate 3 for 1
diff --git a/lib/ey-core/models/server_usage.rb b/lib/ey-core/models/server_usage.rb index abc1234..def5678 100644 --- a/lib/ey-core/models/server_usage.rb +++ b/lib/ey-core/models/server_usage.rb @@ -8,6 +8,7 @@ attribute :dedicated attribute :location attribute :deis + attribute :provisioned_id has_one :environment has_one :provider
Add provisioned_id attribute to ServerUsage
diff --git a/lib/learn_web/response_parsable.rb b/lib/learn_web/response_parsable.rb index abc1234..def5678 100644 --- a/lib/learn_web/response_parsable.rb +++ b/lib/learn_web/response_parsable.rb @@ -1,5 +1,5 @@ module LearnWeb - module AttributePopulatable + module ResponseParsable def self.included(base) base.class_eval do def parse!
Fix bad copy paste job