diff
stringlengths
65
26.7k
message
stringlengths
7
9.92k
diff --git a/app/controllers/redirects_controller.rb b/app/controllers/redirects_controller.rb index abc1234..def5678 100644 --- a/app/controllers/redirects_controller.rb +++ b/app/controllers/redirects_controller.rb @@ -6,7 +6,7 @@ redirect.used! redirect_to redirect.destination_uri, status: redirect.status_code else - render text: 'No such redirect or disabled.', status: 404 + render plain: 'No such redirect or disabled.', status: 404 end end
Fix deprecation warning about using render: text
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 @@ -14,7 +14,7 @@ redirect_to root_path else flash[:error] = @resource.errors.full_messages - redirect_to new_resource_path + render new_resource_path end end @@ -29,7 +29,7 @@ redirect_to resource_path(@resource) else flash[:error] = @resource.errors.full_messages - redirect_to edit_resource_path(@resource) + render :edit end end @@ -46,7 +46,7 @@ def resource_params params.require(:resource).permit(:title, :url, :description, :language_id, - :user_id, :favorited, :course_ids => [], :topic_ids => [], + :user_id, :favorited, :course_ids => [], :topic_ids => [], :topics_attributes => [:name]) end
Change redirect to render for error message display in update and create.
diff --git a/config/application.rb b/config/application.rb index abc1234..def5678 100644 --- a/config/application.rb +++ b/config/application.rb @@ -23,6 +23,17 @@ # Application configuration can go into files in config/initializers # -- all .rb files in that directory are automatically loaded after loading # the framework and any gems in your application. + + config.action_mailer.smtp_settings = { + address: ENV['SMTP_HOSTNAME'], + port: ENV['SMTP_PORT'], + domain: ENV['SMTP_DOMAIN'], + user_name: ENV['SMTP_USERNAME'], + password: ENV['SMTP_PASSWORD'], + authentication: ENV['SMTP_AUTH_TYPE'], + enable_starttls_auto: true + } + end end
Configure SMTP via env vars
diff --git a/config/application.rb b/config/application.rb index abc1234..def5678 100644 --- a/config/application.rb +++ b/config/application.rb @@ -12,6 +12,9 @@ # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. + # add custom validators path + config.autoload_paths += %W["#{config.root}/app/validators/"] + # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. # config.time_zone = 'Central Time (US & Canada)'
Add validators folder to autoload paths.
diff --git a/config/application.rb b/config/application.rb index abc1234..def5678 100644 --- a/config/application.rb +++ b/config/application.rb @@ -11,5 +11,6 @@ # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. + config.autoload_paths << "#{Rails.root}/lib" end end
Add lib directory to auto_load path
diff --git a/test/cookbooks/test/recipes/kill.rb b/test/cookbooks/test/recipes/kill.rb index abc1234..def5678 100644 --- a/test/cookbooks/test/recipes/kill.rb +++ b/test/cookbooks/test/recipes/kill.rb @@ -1,5 +1,5 @@ chef_client_updater "Install Chef #{node['chef_client_updater']['version']}" do channel 'current' - verison node['chef_client_updater']['version'] + version node['chef_client_updater']['version'] post_install_action 'kill' end
Fix a typo in the property name Signed-off-by: Tim Smith <764ef62106582a09ed09dfa0b6bff7c05fd7d1e4@chef.io>
diff --git a/tests/rip/parsers/construct_test.rb b/tests/rip/parsers/construct_test.rb index abc1234..def5678 100644 --- a/tests/rip/parsers/construct_test.rb +++ b/tests/rip/parsers/construct_test.rb @@ -17,4 +17,9 @@ unless_condition = parser.unless_condition.parse('unless (false)') assert_equal 'false', unless_condition[:binary_condition][:false] end + + def test_binary_condition + binary_condition = parser.binary_condition.parse('(:rip)') + assert_equal 'rip', binary_condition[:binary_condition][:string] + end end
Add test for arbitrary object in binary condition rule
diff --git a/core/app/classes/fact_url.rb b/core/app/classes/fact_url.rb index abc1234..def5678 100644 --- a/core/app/classes/fact_url.rb +++ b/core/app/classes/fact_url.rb @@ -23,11 +23,18 @@ return unless @fact.site_url proxy_url + "/?url=" + CGI.escape(@fact.site_url) + - "&factlink_id=" + URI.escape(@fact.id) + "&scrollto=" + URI.escape(@fact.id) + end + + def proxy_open_url + return unless @fact.site_url + + proxy_url + "/?url=" + CGI.escape(@fact.site_url) + + "&open_id=" + URI.escape(@fact.id) end def sharing_url - proxy_scroll_url || friendly_fact_url + proxy_open_url || friendly_fact_url end private
Use scrollto for scroll url, and open_id for sharing url
diff --git a/config/environment.rb b/config/environment.rb index abc1234..def5678 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -3,3 +3,4 @@ # Initialize the Rails application. Rails.application.initialize! +
Create .env file Create .gitignore file Add client id and secret to .env file
diff --git a/Formula/bartycrouch.rb b/Formula/bartycrouch.rb index abc1234..def5678 100644 --- a/Formula/bartycrouch.rb +++ b/Formula/bartycrouch.rb @@ -1,7 +1,7 @@ class Bartycrouch < Formula desc "Incrementally update/translate your Strings files" homepage "https://github.com/Flinesoft/BartyCrouch" - url "https://github.com/Flinesoft/BartyCrouch.git", :tag => "4.4.1", :revision => "d0ea3568044e2348e5fa87b9fdbc9254561039e2" + url "https://github.com/Flinesoft/BartyCrouch.git", :tag => "4.5.0", :revision => "34ca469548e5ed8c39ddc394683b5cfcd510d866" head "https://github.com/Flinesoft/BartyCrouch.git" depends_on :xcode => ["12.0", :build]
Update formula to version 4.5.0
diff --git a/spec/controllers/rpt/badge_reports_controller_spec.rb b/spec/controllers/rpt/badge_reports_controller_spec.rb index abc1234..def5678 100644 --- a/spec/controllers/rpt/badge_reports_controller_spec.rb +++ b/spec/controllers/rpt/badge_reports_controller_spec.rb @@ -0,0 +1,53 @@+require "rails_helper" +require "controllers/rpt/shared_examples_for_reports" + +RSpec.describe Rpt::BadgeReportsController, aga_td_list_mock: true, :type => :controller do + let(:staff) { create :staff } + + it_behaves_like "a report", %w[html csv] + + describe 'html format' do + it "assigns certain variables" do + sign_in staff + get :show, format: 'html', params: { year: staff.year } + expect(assigns(:attendees)).to_not be_nil + end + end + + describe 'csv format' do + it "succeeds, renders csv" do + sign_in staff + get :show, format: 'csv', params: { year: staff.year } + expect(response).to be_success + expect(response.content_type).to eq('text/csv') + end + + it "has one line for each active, planful attendee, plus a header" do + y = Time.current.year + 3.times { |i| + # Active attendees with plans + new_attendee = create :attendee + plan = create :plan + new_attendee.plans << plan + } + + 3.times { |i| + # No plans! + new_attendee = create :attendee + } + + 3.times { |i| + # Cancelled! + new_attendee = create :attendee, cancelled: true + plan = create :plan + new_attendee.plans << plan + } + + sign_in staff + get :show, format: 'csv', params: { year: y } + expect(response).to be_success + ary = CSV.parse response.body + expect(ary.size).to eq(4) + end + end +end
Add tests for badge report
diff --git a/spec/account_spec.rb b/spec/account_spec.rb index abc1234..def5678 100644 --- a/spec/account_spec.rb +++ b/spec/account_spec.rb @@ -29,6 +29,18 @@ Account.count.must_equal 5 end + it 'has the correct account type' do + Account.count.must_equal 0 + + %w{asset liability revenue expense equity}.each do |type| + Account.create(name: "Test #{type} Account", type: type) + end + + %w{asset liability revenue expense equity}.each do |type| + Account.first(name: "Test #{type} Account").type.must_equal type.to_sym + end + end + it 'cannot have account type other' do Account.count.must_equal 0
Add test to check account type
diff --git a/spec/slacken_spec.rb b/spec/slacken_spec.rb index abc1234..def5678 100644 --- a/spec/slacken_spec.rb +++ b/spec/slacken_spec.rb @@ -5,6 +5,9 @@ subject { described_class.translate(source) } let(:source) { fixture('example.html') } + # This test checks whether the behavior of this translation engine is unexpectedly broken. + # If you change the behavior, you should run `scripts/update_markup_fixture.rb` + # to update fixture file. it 'translates as expected' do expect(subject).to eq(fixture('markup_text.txt')) end
Add a description of `scripts/update_markup_fixture.rb`
diff --git a/spec/buckaroo_client/service/credit_management_spec.rb b/spec/buckaroo_client/service/credit_management_spec.rb index abc1234..def5678 100644 --- a/spec/buckaroo_client/service/credit_management_spec.rb +++ b/spec/buckaroo_client/service/credit_management_spec.rb @@ -9,7 +9,7 @@ end it 'raises error on invalid attributes' do - expect { described_class.new(invalid_name: 'Some Text') }.to raise_error + expect { described_class.new(invalid_name: 'Some Text') }.to raise_error(NoMethodError) end end
Fix spec error and deprecation warning
diff --git a/spec/features/embed_stats_spec.rb b/spec/features/embed_stats_spec.rb index abc1234..def5678 100644 --- a/spec/features/embed_stats_spec.rb +++ b/spec/features/embed_stats_spec.rb @@ -0,0 +1,12 @@+# frozen_string_literal: true + +require 'rails_helper' + +describe 'course stats embed page', type: :feature, js: true do + let(:course) { create(:course) } + + it 'returns does nothing if token is incorrect' do + visit "/embed/course_stats/#{course.slug}" + expect(page).to have_content 'Articles Edited' + end +end
Add spec for embedded course stats
diff --git a/sauce-connect.rb b/sauce-connect.rb index abc1234..def5678 100644 --- a/sauce-connect.rb +++ b/sauce-connect.rb @@ -3,8 +3,8 @@ class SauceConnect < Formula homepage "https://docs.saucelabs.com/reference/sauce-connect/" - url "https://saucelabs.com/downloads/sc-4.3.11-osx.zip" - sha1 "5d0aa851d21f3d4a21f298b6a921761c6aa15217" + url "https://saucelabs.com/downloads/sc-4.3.13-osx.zip" + sha1 "d29ce847880ece5ea8c7cfa94b0c89de5a4f328c" def install bin.install 'bin/sc' @@ -14,4 +14,4 @@ system "#{bin}/sc", "--version" end -end+end
Upgrade to Sauce Connect 4.3.13
diff --git a/PINRemoteImage.podspec b/PINRemoteImage.podspec index abc1234..def5678 100644 --- a/PINRemoteImage.podspec +++ b/PINRemoteImage.podspec @@ -9,12 +9,12 @@ Pod::Spec.new do |s| s.name = "PINRemoteImage" - s.version = "1.1.1" + s.version = "1.1.2" s.summary = "A thread safe, performant, feature rich image fetcher" s.homepage = "https://github.com/pinterest/PINRemoteImage" s.license = 'Apache 2.0' s.author = { "Garrett Moon" => "garrett@pinterest.com" } - s.source = { :git => "https://github.com/pinterest/PINRemoteImage.git", :tag => 1.1.1 } + s.source = { :git => "https://github.com/pinterest/PINRemoteImage.git", :tag => "1.1.2" } s.social_media_url = 'https://twitter.com/garrettmoon' s.platform = :ios, '6.0'
Update podspec for 1.1.2 release
diff --git a/spec/knapsack/task_loader_spec.rb b/spec/knapsack/task_loader_spec.rb index abc1234..def5678 100644 --- a/spec/knapsack/task_loader_spec.rb +++ b/spec/knapsack/task_loader_spec.rb @@ -2,11 +2,13 @@ describe '#load_tasks' do let(:rspec_rake_task_path) { "#{Knapsack.root}/lib/tasks/knapsack_rspec.rake" } let(:cucumber_rake_task_path) { "#{Knapsack.root}/lib/tasks/knapsack_cucumber.rake" } + let(:spinach_rake_task_path) { "#{Knapsack.root}/lib/tasks/knapsack_spinach.rake" } let(:minitest_rake_task_path) { "#{Knapsack.root}/lib/tasks/knapsack_minitest.rake" } it do expect(subject).to receive(:import).with(rspec_rake_task_path) expect(subject).to receive(:import).with(cucumber_rake_task_path) + expect(subject).to receive(:import).with(spinach_rake_task_path) expect(subject).to receive(:import).with(minitest_rake_task_path) subject.load_tasks end
Fix spec for task loader
diff --git a/spec/mobility/accumulator_spec.rb b/spec/mobility/accumulator_spec.rb index abc1234..def5678 100644 --- a/spec/mobility/accumulator_spec.rb +++ b/spec/mobility/accumulator_spec.rb @@ -23,13 +23,20 @@ end describe "#backends" do - it "returns backend class for given attribute name" do + before do attributes = Mobility::Attributes.new("foo", "bar", backend: :null) Class.new { include Mobility }.include(attributes) subject << attributes + end + it "returns backend class for given attribute name" do expect(subject.backends[:foo]).to be < Mobility::Backends::Null expect(subject.backends[:bar]).to be < Mobility::Backends::Null end + + it "raises KeyError for undefined backend" do + expect { subject.backends[:baz] }.to raise_error(KeyError, "no backend found with name: \"baz\"") + + end end end
Add spec checking KeyError on mobility.backends
diff --git a/SAMContentMode.podspec b/SAMContentMode.podspec index abc1234..def5678 100644 --- a/SAMContentMode.podspec +++ b/SAMContentMode.podspec @@ -1,14 +1,14 @@ Pod::Spec.new do |spec| spec.name = 'SAMContentMode' - spec.version = '0.1.1' + spec.version = '0.1.2' spec.authors = {'Sam Soffes' => 'sam@soff.es'} spec.homepage = 'https://github.com/soffes/SAMContentMode' spec.summary = 'Content mode calculations for CGRect.' spec.source = {:git => 'https://github.com/soffes/SAMContentMode.git', :tag => "v#{spec.version}"} spec.license = { :type => 'MIT', :file => 'LICENSE' } - spec.platform = :ios spec.requires_arc = true - spec.frameworks = 'UIKit', 'CoreGraphics' + spec.ios.frameworks = 'UIKit', 'CoreGraphics' + spec.osx.frameworks = 'CoreGraphics' spec.source_files = 'SAMContentMode' end
Support for Mac. Version 0.1.2
diff --git a/spec/unit/executable_file_spec.rb b/spec/unit/executable_file_spec.rb index abc1234..def5678 100644 --- a/spec/unit/executable_file_spec.rb +++ b/spec/unit/executable_file_spec.rb @@ -1,13 +1,19 @@ # frozen_string_literal: true -RSpec.describe TTY::Which, '#executable_file?' do - it "checks if file is executable" do - allow(::File).to receive(:join).with('/usr/local/bin', 'ruby'). - and_return('/usr/local/bin/ruby') +RSpec.describe TTY::Which, "#executable_file?" do + it "checks if file in directory is executable" do + path = "/usr/local/bin/ruby" + allow(::File).to receive(:join).with("/usr/local/bin", "ruby").and_return(path) + allow(::File).to receive(:file?).with(path).and_return(true) + allow(::File).to receive(:executable?).with(path).and_return(true) - allow(::File).to receive(:file?).and_return(true) - allow(::File).to receive(:executable?).with('/usr/local/bin/ruby').and_return(true) + expect(TTY::Which.executable_file?("ruby", "/usr/local/bin")).to eq(true) + end - expect(TTY::Which.executable_file?('ruby', '/usr/local/bin')).to eq(true) + it "checks if only a file is executable" do + allow(::File).to receive(:file?).with("ruby").and_return(true) + allow(::File).to receive(:executable?).with("ruby").and_return(true) + + expect(TTY::Which.executable_file?("ruby")).to eql(true) end end
Change to check global executable without directory parameter
diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb index abc1234..def5678 100644 --- a/config/initializers/secret_token.rb +++ b/config/initializers/secret_token.rb @@ -9,4 +9,4 @@ # Make sure your secret_key_base is kept private # if you're sharing your code publicly. -SoprPlatform::Application.config.secret_key_base = 'e8e6a874de38ce84f1946c25d275b3c2f1ad8476622fdac853bc3056bd14964b7d030cc71339030b030342d7de0334e8087853f91789564e0019857092bae88f' +SoprPlatform::Application.config.secret_key_base = ENV['SECRET_TOKEN'] || 'e8e6a874de38ce84f1946c25d275b3c2f1ad8476622fdac853bc3056bd14964b7d030cc71339030b030342d7de0334e8087853f91789564e0019857092bae88f'
Change to read secret_key from env. variable or fallback to current key
diff --git a/lib/aws/plugins/json_serializer.rb b/lib/aws/plugins/json_serializer.rb index abc1234..def5678 100644 --- a/lib/aws/plugins/json_serializer.rb +++ b/lib/aws/plugins/json_serializer.rb @@ -29,7 +29,9 @@ context.http_request.headers['X-Amz-Target'] = target super(context).on_complete do |response| - response.data = JSON.parse(response.context.http_response.body.read) + output = response.context.http_response.body.read + output = '{}' if output.empty? + response.data = JSON.parse(output) end end
Handle empty body for JSON parsing
diff --git a/lib/flail/rails/action_dispatch.rb b/lib/flail/rails/action_dispatch.rb index abc1234..def5678 100644 --- a/lib/flail/rails/action_dispatch.rb +++ b/lib/flail/rails/action_dispatch.rb @@ -8,8 +8,15 @@ end module InstanceMethods - def render_exception(env, exception) - Flail::Exception.new(env, exception).handle! + def render_exception(request_or_env, exception) + _env = if request_or_env.is_a?(::ActionDispatch::Request) + request_or_env.env + else + request_or_env + end + + Flail::Exception.new(_env, exception).handle! + super end end
Fix render_exception method signature for Rails 5
diff --git a/lib/junos-ez/facts/switch_style.rb b/lib/junos-ez/facts/switch_style.rb index abc1234..def5678 100644 --- a/lib/junos-ez/facts/switch_style.rb +++ b/lib/junos-ez/facts/switch_style.rb @@ -8,6 +8,12 @@ :NONE when /^(ex9)|(ex43)/i :VLAN_L2NG + when /^(qfx5)|(qfx3)/i + if facts[:version][0..3].to_f >= 13.2 + :VLAN_L2NG + else + :VLAN + end else :VLAN end
Fix for PR 945745. Update switch style value for QFX device based on Junos software version
diff --git a/lib/minitest-spec-rails/railtie.rb b/lib/minitest-spec-rails/railtie.rb index abc1234..def5678 100644 --- a/lib/minitest-spec-rails/railtie.rb +++ b/lib/minitest-spec-rails/railtie.rb @@ -5,25 +5,24 @@ config.minitest_spec_rails.mini_shoulda = false config.before_initialize do |app| - if Rails.env.test? - ActiveSupport.on_load(:action_view) do - require 'minitest-spec-rails/init/action_view' - end - ActiveSupport.on_load(:action_controller) do - require 'minitest-spec-rails/init/action_controller' - require 'minitest-spec-rails/init/action_dispatch' - end - ActiveSupport.on_load(:action_mailer) do - require 'minitest-spec-rails/init/action_mailer' - end + return unless Rails.env.test? + require 'active_support' + require 'minitest-spec-rails/init/active_support' + ActiveSupport.on_load(:action_view) do + require 'minitest-spec-rails/init/action_view' + end + ActiveSupport.on_load(:action_controller) do + require 'minitest-spec-rails/init/action_controller' + require 'minitest-spec-rails/init/action_dispatch' + end + ActiveSupport.on_load(:action_mailer) do + require 'minitest-spec-rails/init/action_mailer' end end - initializer 'minitest-spec-rails.after.load_active_support', :after => :load_active_support, :group => :all do |app| - if Rails.env.test? - require 'minitest-spec-rails/init/active_support' - require 'minitest-spec-rails/init/mini_shoulda' if app.config.minitest_spec_rails.mini_shoulda - end + initializer 'minitest-spec-rails.mini_shoulda', :group => :all do |app| + return unless Rails.env.test? + require 'minitest-spec-rails/init/mini_shoulda' if app.config.minitest_spec_rails.mini_shoulda end end
Change initializers around to always require ActiveSupport first.
diff --git a/test/factories/projects_factory.rb b/test/factories/projects_factory.rb index abc1234..def5678 100644 --- a/test/factories/projects_factory.rb +++ b/test/factories/projects_factory.rb @@ -2,6 +2,7 @@ factory :project do unit campus + user after(:build) do |project| project.tutorial = FactoryGirl.create(:tutorial, campus: project.campus, unit: project.unit)
ENHANCE: Add user to project factory
diff --git a/test/test_belongs_to_association.rb b/test/test_belongs_to_association.rb index abc1234..def5678 100644 --- a/test/test_belongs_to_association.rb +++ b/test/test_belongs_to_association.rb @@ -14,4 +14,16 @@ assert_equal 42, @other.account_id end + + def test_does_not_inherit_when_parent_not_present + @other = Other.create! + assert_nil @other.account_id + end + + def test_overwrites_value_on_child + @main = Main.create!(:account_id => 42) + @other = Other.create!(:main => @main, :account_id => 1337) + + assert_equal 42, @other.account_id + end end
Add a few more tests
diff --git a/db/fixtures/development/01_admin.rb b/db/fixtures/development/01_admin.rb index abc1234..def5678 100644 --- a/db/fixtures/development/01_admin.rb +++ b/db/fixtures/development/01_admin.rb @@ -3,6 +3,7 @@ s.id = 1 s.name = 'Administrator' s.email = 'admin@example.com' + s.notification_email = 'admin@example.com' s.username = 'root' s.password = '5iveL!fe' s.admin = true
Fix dev fixture for admin
diff --git a/week-9/ruby-review-1/ruby_review.rb b/week-9/ruby-review-1/ruby_review.rb index abc1234..def5678 100644 --- a/week-9/ruby-review-1/ruby_review.rb +++ b/week-9/ruby-review-1/ruby_review.rb @@ -0,0 +1,102 @@+# First Ruby Review + +# I worked on this challenge [with: Darius Atmar]. +# This challenge took me [1.5] hours. + +# Pseudocode +# INPUT a number +# OUTPUT True/False + +# define Fibonacci sequence function that takes in a number + +# 0 step: IF number == 1 number is in Fibonacci sequence +# 1 Start with two variables sum and next_number +# 2 variable first_number is zero +# 3 next_number equals 1 +# 4 sum = first_number + next_number +# 4.5 put sum into array called fibonacci_numbers +# 5 IF number == sum, then this is in Fibonacci sequence, +# ELSE move to step 6 +# 6 replace first_number with next_number, and next_number with sum +# 7 repeat steps 4 and 5 until number <= sum + + +# Initial Solution + +def is_fibonacci?(num) + first_number = 0 + next_number = 1 + sum = 0 + fibonacci_numbers = [] + + return true if num == 1 + + while sum < num do + sum = first_number + next_number + fibonacci_numbers << sum + first_number = next_number + next_number = sum + end + + if fibonacci_numbers[-1] == num + return true + else + return false + end +end + + +# Refactored Solution + +def is_fibonacci?(num) + return true if num == 0 || num == 1 + + first_number = 0 + next_number = 1 + sum = 0 + + while sum < num do + sum = first_number + next_number + first_number = next_number + next_number = sum + end + + return true if sum == num + + return false +end + + +# Refactored-again Solution (separated the methods) + +def fibonacci_sequencer(num) + return num if num == 0 || num == 1 + + first_number = 0 + next_number = 1 + sum = 0 + + while sum < num do + sum = first_number + next_number + first_number = next_number + next_number = sum + end + + sum +end + +def is_fibonacci?(num) + return true if fibonacci_sequencer(num) == num + + false +end + + +# Driver Tests +p is_fibonacci?(0) # should return true +p is_fibonacci?(1) # should return true +p is_fibonacci?(5) # should return true +p is_fibonacci?(33) # should return false +p is_fibonacci?(34) # should return true +p is_fibonacci?(50) # should return false +p is_fibonacci?(55) # should return true
Copy the code from coderpad and do another refactor.
diff --git a/spec/app_spec.rb b/spec/app_spec.rb index abc1234..def5678 100644 --- a/spec/app_spec.rb +++ b/spec/app_spec.rb @@ -32,6 +32,13 @@ log.should include("Run completed") end + it "should log to debug on the cleanup step" do + Example.logger.level = Logger::DEBUG + + @app.run + log.should include("Cleaning up...") + end + it "should log an error if ran on a :widget" do Example.logger.level = Logger::ERROR
Add additional spec to App to test debug output
diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index abc1234..def5678 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -1,5 +1,5 @@ class HomeController < ApplicationController def index - @studies = Study.order(:updated_at).page params[:page] + @studies = Study.order(updated_at: :desc).page(params[:page]).per(10) end end
Sort studies recently updated first, show 10 per page
diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index abc1234..def5678 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -1,5 +1,17 @@ class TagsController < ApplicationController + before_action :set_tag + def show - @tag = Tag.find_by(id: params[:id]) end + + def destroy + @tag.destroy + redirect_to root_path + end + + private + + def set_tag + @tag = Tag.find_by(id: params[:id]) + end end
Add destroy action to tags.
diff --git a/lib/folio/engine.rb b/lib/folio/engine.rb index abc1234..def5678 100644 --- a/lib/folio/engine.rb +++ b/lib/folio/engine.rb @@ -26,13 +26,10 @@ g.helper false end - begin - config.autoload_paths << self.root.join('lib') - config.eager_load_paths << self.root.join('lib') - config.assets.paths << self.root.join('app/cells') - config.assets.paths << self.root.join('vendor/assets/bower_components') - rescue RuntimeError - end + config.autoload_paths << self.root.join('lib') + config.eager_load_paths << self.root.join('lib') + config.assets.paths << self.root.join('app/cells') + config.assets.paths << self.root.join('vendor/assets/bower_components') initializer :append_migrations do |app| unless app.root.to_s.match root.to_s
Revert "fix duplicate loading of frozen config array" This reverts commit f3a14682df25caecf76a586afc6b1883f7d4cc6b.
diff --git a/app/controllers/books_controller.rb b/app/controllers/books_controller.rb index abc1234..def5678 100644 --- a/app/controllers/books_controller.rb +++ b/app/controllers/books_controller.rb @@ -1,8 +1,12 @@ class BooksController < ApplicationController get '/books' do - @user = User.find(session[:user_id]) - @books = @user.books - erb :'/books/books' + if session[:user_id] + @user = User.find(session[:user_id]) + @books = @user.books + erb :'/books/books' + else + redirect to '/login' + end end end
Add conditional to /books controller action so that only account holders can access book index
diff --git a/app/serializers/user_serializer.rb b/app/serializers/user_serializer.rb index abc1234..def5678 100644 --- a/app/serializers/user_serializer.rb +++ b/app/serializers/user_serializer.rb @@ -18,10 +18,4 @@ def last_online object.last_request_at.iso8601 if object.last_request_at? end - - cached - - def cache_key - [object] - end end
Remove caching from user serializer, last_request_at doesn't break the cache
diff --git a/lib/archiving.rb b/lib/archiving.rb index abc1234..def5678 100644 --- a/lib/archiving.rb +++ b/lib/archiving.rb @@ -6,17 +6,22 @@ t0 = date.to_datetime t1 = t0.next_day deliveries = Delivery.where(created_at: t0..t1).includes(:links, :click_events, :open_events, :address, :postfix_log_lines, {:email => [:from_address, :app]}) + if deliveries.empty? + puts "Nothing to archive for #{date}" + else + FileUtils.mkdir_p("db/archive") - FileUtils.mkdir_p("db/archive") - - # TODO bzip2 gives better compression but I had trouble with the Ruby gem for it - Zlib::GzipWriter.open("db/archive/#{date}.tar.gz") do |gzip| - Archive::Tar::Minitar::Writer.open(gzip) do |writer| - deliveries.find_each do |delivery| - content = ActionController::Base.new.render_to_string(partial: "deliveries/delivery.json.jbuilder", locals: {delivery: delivery}) - writer.add_file_simple("#{date}/#{delivery.id}.json", size: content.length, mode: 0600 ) {|f| f.write content} + # TODO bzip2 gives better compression but I had trouble with the Ruby gem for it + Zlib::GzipWriter.open("db/archive/#{date}.tar.gz") do |gzip| + Archive::Tar::Minitar::Writer.open(gzip) do |writer| + deliveries.find_each do |delivery| + content = ActionController::Base.new.render_to_string(partial: "deliveries/delivery.json.jbuilder", locals: {delivery: delivery}) + writer.add_file_simple("#{date}/#{delivery.id}.json", size: content.length, mode: 0600 ) {|f| f.write content} + end end end + # The scary bit + deliveries.destroy_all end end end
Delete archived emails and don't archive if no emails
diff --git a/app/models/repository/destroying.rb b/app/models/repository/destroying.rb index abc1234..def5678 100644 --- a/app/models/repository/destroying.rb +++ b/app/models/repository/destroying.rb @@ -1,5 +1,11 @@ module Repository::Destroying extend ActiveSupport::Concern + + included do + scope :destroying, ->() { unscoped.where(is_destroying: true) } + scope :active, ->() { where(is_destroying: false) } + default_scope ->() { active } + end # Only use `destroy_asynchronously` if you want to destroy a repository. # It prepares the deletion by setting a flag, which enables the deletion
Add scopes and default scope, adjust migrations.
diff --git a/app/models/spree/order_decorator.rb b/app/models/spree/order_decorator.rb index abc1234..def5678 100644 --- a/app/models/spree/order_decorator.rb +++ b/app/models/spree/order_decorator.rb @@ -1,5 +1,7 @@ Spree::Order.class_eval do include ActiveSupport::Callbacks + + after_update :destroy_empty_shipments! def electronic_shipments shipments.electronic @@ -18,6 +20,19 @@ electronic_shipment.inventory_units = inventory_units.electronically_delivered end + destroy_empty_shipments! + end + alias_method_chain :create_shipment!, :electronic_delivery + + def after_finalize! + electronic_shipments.each do |shipment| + shipment.delay.asynchronous_ship! if shipment.can_ship? + end + end + + private + + def destroy_empty_shipments! # destroy any physical shipments without inventory units if line_items.physically_delivered.empty? && physical_shipments.any? physical_shipments.destroy_all @@ -28,11 +43,4 @@ electronic_shipments.destroy_all end end - alias_method_chain :create_shipment!, :electronic_delivery - - def after_finalize! - electronic_shipments.each do |shipment| - shipment.delay.asynchronous_ship! if shipment.can_ship? - end - end end
Destroy empty shipments after updating
diff --git a/app/serializers/guide_serializer.rb b/app/serializers/guide_serializer.rb index abc1234..def5678 100644 --- a/app/serializers/guide_serializer.rb +++ b/app/serializers/guide_serializer.rb @@ -10,6 +10,7 @@ attribute :featured_image do if object.featured_image { + canopy_url: object.pictures[object.featured_image].attachment.url(:canopy), image_url: object.pictures[object.featured_image].attachment.url, thumbnail_url: object.pictures[object.featured_image].attachment.url(:small) }
Add canopy image guide serializer
diff --git a/dev_environment/roles/dev.rb b/dev_environment/roles/dev.rb index abc1234..def5678 100644 --- a/dev_environment/roles/dev.rb +++ b/dev_environment/roles/dev.rb @@ -9,5 +9,6 @@ "recipe[adam::apt-update]", "recipe[mongodb::default]", "recipe[rabbitmq]", + "recipe[rabbitmq::mgmt_console]", "recipe[ejabberd]", "recipe[adam]"
[DEV] Add the rabbitmq management plugin
diff --git a/lib/redfish/util.rb b/lib/redfish/util.rb index abc1234..def5678 100644 --- a/lib/redfish/util.rb +++ b/lib/redfish/util.rb @@ -17,7 +17,9 @@ class << self # Generate a random password with lowercase, uppercase and numeric values def generate_password(size = 10) - size.times.map { [*('0'..'9'), *('A'..'Z'), *('a'..'z')].sample }.join + set = (('0'..'9').to_a + ('A'..'Z').to_a + ('a'..'z').to_a) + set[rand(set.length)] + size.times.map { set[rand(set.length)] }.join end def is_buildr_present?
Update code so it runs in earlier version of jruby
diff --git a/lib/vpaid_parser.rb b/lib/vpaid_parser.rb index abc1234..def5678 100644 --- a/lib/vpaid_parser.rb +++ b/lib/vpaid_parser.rb @@ -1,5 +1,62 @@ require 'vpaid_parser/version' +require 'nokogiri' +require 'open-uri' class VpaidParser - # Your code goes here... + + def initialize(url) + begin + @vast = Nokogiri::HTML(open(url)) + unwrap unless @vast.xpath("//vastadtaguri").empty? + @mediafiles = @vast.xpath('//mediafile') + rescue + raise ArgumentError, "Invalid url" + end + end + + def categorize + if include_flash_vpaid? && include_js? + 'flash_js' + elsif include_flash_vpaid? + 'flash' + elsif include_js? + 'js' + else + 'neither' + end + end + + private + + def unwrap + begin + 5.times do + url = @vast.xpath("//vastadtaguri")[0].content + @vast = Nokogiri::HTML(open(url)) + break if @vast.xpath("//vastadtaguri").empty? + end + rescue + raise ArgumentError, "Invalid wrapper redirect url" + end + raise WrapperDepthError, "Wrapper depth exceeds five redirects" + end + + def include_flash_vpaid? + flash_vpaid = false + @mediafiles.each do |mediafile| + if ((mediafile.attr('apiframework') == 'VPAID') && (mediafile.attr('type') == 'application/x-shockwave-flash' || mediafile.attr('type') == 'video/x-flv')) + flash_vpaid = true + end + end + flash_vpaid + end + + def include_js? + js = false + @mediafiles.each do |mediafile| + js = true if ((mediafile.attr('type') == 'application/x-javascript') || (mediafile.attr('type') == 'application/javascript')) + end + js + end end +
Add classifying and unwrapping logic
diff --git a/activeresource.gemspec b/activeresource.gemspec index abc1234..def5678 100644 --- a/activeresource.gemspec +++ b/activeresource.gemspec @@ -1,4 +1,4 @@-version = File.read("../RAILS_VERSION").strip +version = File.read(File.expand_path("../../RAILS_VERSION", __FILE__)).strip Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY
Load RAILS_VERSION relative to the gemspec file.
diff --git a/lib/api-client/parser.rb b/lib/api-client/parser.rb index abc1234..def5678 100644 --- a/lib/api-client/parser.rb +++ b/lib/api-client/parser.rb @@ -1,3 +1,5 @@+require 'json' + # ApiClient::Parser provides a method to parse the request response. module ApiClient::Parser # Parse the JSON response. @@ -7,8 +9,8 @@ def self.response(response) raise_exception(response.code) begin - object = JSON.parse(response.body) - rescue JSON::ParserError, TypeError + object = ::JSON.parse(response.body) + rescue ::JSON::ParserError, TypeError object = {} end object
Fix for 'uninitialized constant JSON (NameError)'
diff --git a/app/models/notifier.rb b/app/models/notifier.rb index abc1234..def5678 100644 --- a/app/models/notifier.rb +++ b/app/models/notifier.rb @@ -10,7 +10,7 @@ end def occurence_report(user, occurence, sent_at = Time.now) - subject "[#{occurence.error.project.name}] An error occured" + subject "[#{occurence.error.project.name}] An error occured (@#{@occurence.error_id})" recipients user.email from 'donotreply@failtale.be' sent_on sent_at
Include the error id in the mail title
diff --git a/app/models/api_key.rb b/app/models/api_key.rb index abc1234..def5678 100644 --- a/app/models/api_key.rb +++ b/app/models/api_key.rb @@ -9,6 +9,7 @@ # class ApiKey < ActiveRecord::Base + attr_accessible :access_token before_create :generate_access_token private
Allow editing of api key access token
diff --git a/app/models/listing.rb b/app/models/listing.rb index abc1234..def5678 100644 --- a/app/models/listing.rb +++ b/app/models/listing.rb @@ -7,18 +7,10 @@ has_many :donation_applications, dependent: :destroy has_many :applicants, through: :donation_applications + validates_presence_of :title, :creator + def get_show_image self.image_url || 'http://placehold.it/400x300&text=[img]' - end - - def self.import(file) - CSV.foreach(file.path, headers: true) do |row| - logger.debug "ROW: #{row}" - listing = find_by_id(row['id']) || new - listing.attributes = row.to_hash - logger.debug "LISTING: #{listing}" - listing.save! - end end def requires_pdf_form?
Fix bug in Listing importer required headers Add validation to Listing so listings that don't include the required fields will not be saved.
diff --git a/lib/inch/rake/suggest.rb b/lib/inch/rake/suggest.rb index abc1234..def5678 100644 --- a/lib/inch/rake/suggest.rb +++ b/lib/inch/rake/suggest.rb @@ -2,6 +2,7 @@ require "rake" require "rake/tasklib" +require "inch/cli" module Inch # Holds all Rake tasks
Fix error in Rake task (thanks @tabolario) Inch::CLI needs to be required manually (see CHANGELOG for 0.4.7). Fixes #24
diff --git a/lib/parrot/file_cache.rb b/lib/parrot/file_cache.rb index abc1234..def5678 100644 --- a/lib/parrot/file_cache.rb +++ b/lib/parrot/file_cache.rb @@ -0,0 +1,27 @@+require 'digest' +require 'singleton' + +class FileCache + + include Singleton + + attr_accessor :cache + + def initialize + @cache = {} + end + + def fetch(path) + cache[path] + end + + def set(path) + cache[path] = Digest::SHA256.hexdigest(File.read(path)) + end + + def changed?(path) + return true unless cache.has_key?(path) + data = File.read(path) + !(cache[path] == Digest::SHA256.hexdigest(data)) + end +end
Add file cache for checking the content change
diff --git a/lib/resync/xml/parser.rb b/lib/resync/xml/parser.rb index abc1234..def5678 100644 --- a/lib/resync/xml/parser.rb +++ b/lib/resync/xml/parser.rb @@ -2,10 +2,7 @@ module Resync module XML - class Parser - - # ------------------------------ - # Public methods + module Parser # @return [Urlset, Sitemapindex] def self.parse(xml) @@ -30,6 +27,8 @@ end end + private_class_method :find_root + def self.get_parse_class(root) root_name = root.name case root_name.downcase
Change Parser from class to module
diff --git a/lib/rspec_sequel/base.rb b/lib/rspec_sequel/base.rb index abc1234..def5678 100644 --- a/lib/rspec_sequel/base.rb +++ b/lib/rspec_sequel/base.rb @@ -15,7 +15,7 @@ @prefix = "expected #{target.inspect} to" valid?(target.db, target, target.class, @attribute, @options) else - @prefix = "expected #{target.table_name.to_s.singularize.humanize} to" + @prefix = "expected #{target.table_name.to_s.classify} to" valid?(target.db, target.new, target, @attribute, @options) end end
Use .classify instead of .singularize.humanize
diff --git a/lib/w3clove/validator.rb b/lib/w3clove/validator.rb index abc1234..def5678 100644 --- a/lib/w3clove/validator.rb +++ b/lib/w3clove/validator.rb @@ -3,10 +3,12 @@ # for all pages on a sitemap and output the errors # module W3Clove - class Validator + module Validator + extend self + ## # Parses a remote xml sitemap and checks markup validation for each url within - def self.check(url) + def check(url) sitemap = W3Clove::Sitemap.new(url) sitemap.pages.each do |page|
Make Validator class a module as it doesn't need to be instantiated
diff --git a/lib/maskable_attribute/maskable_attribute.rb b/lib/maskable_attribute/maskable_attribute.rb index abc1234..def5678 100644 --- a/lib/maskable_attribute/maskable_attribute.rb +++ b/lib/maskable_attribute/maskable_attribute.rb @@ -16,7 +16,7 @@ value = unmasked if !value.blank? and value.match(/\{.*\}/) value.scan(/(?<={)[^}]+(?=})/).each do |mask| #mask: two_digit model_series - value = value.sub "{#{mask}}", @masks[mask].unmask(@object) unless @masks[mask].unmask(@object).nil? + value = value.sub "{#{mask}}", @masks[mask].unmask(@object).to_s unless @masks[mask].unmask(@object).nil? end end value
Fix Failing Number Mask Value Fix the Maskable Attribute to accommodate the failing test where the resulting value for a mask could end up being a number rather than a string.
diff --git a/lib/attr_deprecated.rb b/lib/attr_deprecated.rb index abc1234..def5678 100644 --- a/lib/attr_deprecated.rb +++ b/lib/attr_deprecated.rb @@ -1,22 +1,48 @@ require "attr_deprecated/version" require 'active_support' +require 'active_record' +require 'active_model' module AttrDeprecated - module Model + def self.included(base) + base.send :extend, ClassMethods + end - def self.included(base) - base.send :extend, ClassMethods - end + module ClassMethods + ## + # == attr_deprecated + # class macro definition to non-destructively mark an attribute as deprecated. + # + # The original method (i.e. the one marked as deprecated) is wrapped in an alias that dispatches the notification. + # (See the `around_alias` pattern. [Paolo Perotta. Metaprogramming Ruby, p. 121]) + # + # + def attr_deprecated(*attr_names) + attr_names.each do |attr_name| + original_getter = "_#{attr_name}_deprecated".to_sym + #original_setter = "_#{attr_name}_deprecated=".to_sym - module ClassMethods - def attr_deprecated(*attr_names) - # TODO + attr_name.to_sym + + # TODO: Use alias_attribute from ActiveSupport to handle both getter and setter + alias_method(original_getter, attr_name.to_sym) + + # The getter + define_method attr_name.to_sym, -> do + puts "WARNING: deprecated attribute #{original_getter} was called:" + puts Thread.current.backtrace.join("\n") + + method(original_getter).call() + end + + # TODO: The setter + end end end end ActiveSupport.on_load(:active_record) do - include AttrDeprecated::Model + include AttrDeprecated end
Define and test deprecation behavior for a getter method
diff --git a/lib/mongo_benchpress/mongo_ruby_driver_bp.rb b/lib/mongo_benchpress/mongo_ruby_driver_bp.rb index abc1234..def5678 100644 --- a/lib/mongo_benchpress/mongo_ruby_driver_bp.rb +++ b/lib/mongo_benchpress/mongo_ruby_driver_bp.rb @@ -11,7 +11,7 @@ }, :insert_batch => Proc.new { |coll, object, i| object['x'] = i - coll.insert(object * i) + coll.insert([object] * MongoRubyDriverBp.default_options[:batch_size]) }, :find_one => Proc.new { |coll, x, i| coll.find_one('x' => x)
Update batch insert to be identical to original ruby test
diff --git a/lib/rooftop/algolia_search/post_searching.rb b/lib/rooftop/algolia_search/post_searching.rb index abc1234..def5678 100644 --- a/lib/rooftop/algolia_search/post_searching.rb +++ b/lib/rooftop/algolia_search/post_searching.rb @@ -5,23 +5,13 @@ def self.included(base) base.extend ClassMethods - base.send :setup_index_name! end module ClassMethods - attr_reader :search_index_name - def search_index_name=(name) - @search_index_name = name - setup_index_name! - end - - def search_index - @search_index ||= Algolia::Index.new(@search_index_name) - end - - def perform_search(query) - search_index.search(query) + def search(query, opts = {}) + opts = opts.with_indifferent_access + search_index.search(query, opts).with_indifferent_access end end
Add a search class method
diff --git a/lib/route_translator/extensions/route_set.rb b/lib/route_translator/extensions/route_set.rb index abc1234..def5678 100644 --- a/lib/route_translator/extensions/route_set.rb +++ b/lib/route_translator/extensions/route_set.rb @@ -11,13 +11,23 @@ translated_path_ast = ::ActionDispatch::Journey::Parser.parse(translated_path) translated_mapping = ::ActionDispatch::Routing::Mapper::Mapping.build(scope, self, translated_path_ast, controller, default_action, to, via, formatted, translated_options_constraints, anchor, translated_options) - add_route translated_mapping, translated_path_ast, translated_name, anchor + add_route_to_set translated_mapping, translated_path_ast, translated_name, anchor end if RouteTranslator.config.generate_unnamed_unlocalized_routes - add_route mapping, path_ast, nil, anchor + add_route_to_set mapping, path_ast, nil, anchor elsif RouteTranslator.config.generate_unlocalized_routes + add_route_to_set mapping, path_ast, name, anchor + end + end + + private + + def add_route_to_set(mapping, path_ast, name, anchor) + if method(:add_route).arity == 4 add_route mapping, path_ast, name, anchor + else + add_route mapping, name end end end
Add support for Rails 5.1.0.rc1 An internal change in actionpack removed a couple of unused parameters from the add_route method signature. This commit reflect that change. Close: #163 Ref: ccfa785535d912c3529b0562d9f2e7a2dc4b7ed7@6ddd65c9f366c5bca70cfce770d144e2fca1e679
diff --git a/app/models/ontology.rb b/app/models/ontology.rb index abc1234..def5678 100644 --- a/app/models/ontology.rb +++ b/app/models/ontology.rb @@ -10,6 +10,8 @@ belongs_to :owner, :polymorphic => true has_many :versions, :class_name => 'OntologyVersion' + + attr_accessible :uri, :name, :description def to_s uri
Whitelist uri, name, description for mass-assignability on Ontology.
diff --git a/lib/templates/new_project/site/blog/_init.rb b/lib/templates/new_project/site/blog/_init.rb index abc1234..def5678 100644 --- a/lib/templates/new_project/site/blog/_init.rb +++ b/lib/templates/new_project/site/blog/_init.rb @@ -5,7 +5,7 @@ # In this simple example, we're simply adding some convenience methods to # all available blog posts for easier access to specific pieces of data. -on(:created, ->(n) { n.page? }) do |node| +on(:created, ->(n) { n.page? }) do |evt, node| node.extend PostExtension end
Fix new project template ;-)
diff --git a/lib/test_after_commit/database_statements.rb b/lib/test_after_commit/database_statements.rb index abc1234..def5678 100644 --- a/lib/test_after_commit/database_statements.rb +++ b/lib/test_after_commit/database_statements.rb @@ -9,9 +9,9 @@ @_current_transaction_records.push([]) if @_current_transaction_records.empty? end result = yield - rescue Exception => e + rescue Exception rolled_back = true - raise e + raise ensure begin @test_open_transactions -= 1
Raise an exception without a variable
diff --git a/lib/yard/generators/helpers/method_helper.rb b/lib/yard/generators/helpers/method_helper.rb index abc1234..def5678 100644 --- a/lib/yard/generators/helpers/method_helper.rb +++ b/lib/yard/generators/helpers/method_helper.rb @@ -0,0 +1,36 @@+module YARD + module Generators::Helpers + module MethodHelper + protected + + def format_def(object) + h(object.signature.gsub(/^def\s*(?:.+?(?:\.|::)\s*)?/, '')) + end + + def format_return_types(object) + typenames = "Object" + if object.has_tag?(:return) + types = object.tags(:return).map do |t| + t.types.map do |type| + type.gsub(/(^|[<>])\s*([^<>#]+)\s*(?=[<>]|$)/) {|m| $1 + linkify($2) } + end + end.flatten + typenames = types.size == 1 ? types.first : h("[#{types.join(", ")}]") + end + typenames + end + + def format_block(object) + if object.has_tag?(:yieldparam) + h "{|" + object.tags(:yieldparam).map {|t| t.name }.join(", ") + "| ... }" + else + "" + end + end + + def format_meth_name(object) + (object.scope == :instance ? '#' : '') + h(object.name.to_s) + end + end + end +end
Create MethodHelper for specific method formatting helper methods
diff --git a/lib/redshift_cursor.rb b/lib/redshift_cursor.rb index abc1234..def5678 100644 --- a/lib/redshift_cursor.rb +++ b/lib/redshift_cursor.rb @@ -1,8 +1,12 @@ require 'redshift_cursor/version' -require 'redshift_cursor/active_record/connection_adapters/redshift_type_map' -require 'postgresql_cursor' +require 'active_support' -require 'active_record' -require 'active_record/connection_adapters/redshift_adapter' -ActiveRecord::ConnectionAdapters::RedshiftAdapter.send(:include, RedshiftCursor::ActiveRecord::ConnectionAdapters::RedshiftTypeMap) +ActiveSupport.on_load :active_record do + require 'redshift_cursor/active_record/connection_adapters/redshift_type_map' + + require 'postgresql_cursor' + + require 'active_record/connection_adapters/redshift_adapter' + ActiveRecord::ConnectionAdapters::RedshiftAdapter.send(:include, RedshiftCursor::ActiveRecord::ConnectionAdapters::RedshiftTypeMap) +end
Use ActiveSupport.on_load hook instead of eagerly loading external dependencies
diff --git a/lib/salesforce_bulk.rb b/lib/salesforce_bulk.rb index abc1234..def5678 100644 --- a/lib/salesforce_bulk.rb +++ b/lib/salesforce_bulk.rb @@ -12,69 +12,4 @@ require 'salesforce_bulk/batch' require 'salesforce_bulk/batch_result' require 'salesforce_bulk/batch_result_collection' -require 'salesforce_bulk/query_result_collection' -require 'salesforce_bulk/connection' - -module SalesforceBulk - # Your code goes here... - class Api - - @@SALESFORCE_API_VERSION = '23.0' - - def initialize(username, password) - @connection = SalesforceBulk::Connection.new(username, password, @@SALESFORCE_API_VERSION) - end - - def upsert(sobject, records, external_field) - self.do_operation('upsert', sobject, records, external_field) - end - - def update(sobject, records) - self.do_operation('update', sobject, records, nil) - end - - def create(sobject, records) - self.do_operation('insert', sobject, records, nil) - end - - def delete(sobject, records) - self.do_operation('delete', sobject, records, nil) - end - - def query(sobject, query) - self.do_operation('query', sobject, query, nil) - end - - #private - - def do_operation(operation, sobject, records, external_field) - job = SalesforceBulk::Job.new(operation, sobject, records, external_field, @connection) - - # TODO: put this in one function - job_id = job.create_job() - if(operation == "query") - batch_id = job.add_query() - else - batch_id = job.add_batch() - end - job.close_job() - - while true - state = job.check_batch_status() - #puts "\nstate is #{state}\n" - if state != "Queued" && state != "InProgress" - break - end - sleep(2) # wait x seconds and check again - end - - if state == 'Completed' - job.get_batch_result() - else - return "error" - end - - end - - end # End class -end +require 'salesforce_bulk/query_result_collection'
Delete old Api class from root file as its been replaced by the new Client class. Researching other popular gems this file seems to be empty as a standard perhaps? Best practice?
diff --git a/lib/storey/migrator.rb b/lib/storey/migrator.rb index abc1234..def5678 100644 --- a/lib/storey/migrator.rb +++ b/lib/storey/migrator.rb @@ -14,6 +14,7 @@ def migrate(schema, options={}) Storey.switch schema do + puts "= Migrating #{schema}" ::ActiveRecord::Migrator.migrate(::ActiveRecord::Migrator.migrations_path, options[:version]) end
Add notice about which schema is being migrated
diff --git a/lib/tasks/install.rake b/lib/tasks/install.rake index abc1234..def5678 100644 --- a/lib/tasks/install.rake +++ b/lib/tasks/install.rake @@ -1,9 +1,8 @@ namespace :orientation do desc "Install a fresh new Orientation" task install: :environment do + cp '.env.example', '.env' cp 'config/database.yml.example', 'config/database.yml' - cp 'config/mandrill.yml.example', 'config/mandrill.yml' - cp '.env.example', '.env' puts "You should now configure .env with your local database settings..." puts "Once you're done, run `rake db:create db:setup`." end
Fix order dependency issue and unnecessary config in setup task
diff --git a/lib/trashed/railtie.rb b/lib/trashed/railtie.rb index abc1234..def5678 100644 --- a/lib/trashed/railtie.rb +++ b/lib/trashed/railtie.rb @@ -28,8 +28,8 @@ app.config.trashed.gauge_sample_rate ||= 0.05 app.config.trashed.logger ||= Rails.logger - app.middleware.insert_after 'Rack::Runtime', Trashed::Rack, app.config.trashed - app.middleware.insert_after 'Rails::Rack::Logger', ExposeLoggerTagsToRackEnv + app.middleware.insert_after Rack::Runtime, Trashed::Rack, app.config.trashed + app.middleware.insert_after Rails::Rack::Logger, ExposeLoggerTagsToRackEnv end end end
Fix deprecation warnings from Rails This commit fixes the deprecation warnings coming from inserting middleware. This just removes the quotes, per the deprecation warning: ``` DEPRECATION WARNING: Passing strings or symbols to the middleware builder is deprecated, please change them to actual class references. For example: "Rack::Runtime" => Rack::Runtime ```
diff --git a/Casks/firefoxdeveloperedition.rb b/Casks/firefoxdeveloperedition.rb index abc1234..def5678 100644 --- a/Casks/firefoxdeveloperedition.rb +++ b/Casks/firefoxdeveloperedition.rb @@ -5,6 +5,7 @@ url "https://download.mozilla.org/?product=firefox-aurora-latest-ssl&os=osx&lang=en-US" homepage 'https://www.mozilla.org/en-US/firefox/developer/' license :mpl + tags :vendor => 'Mozilla' app 'FirefoxDeveloperEdition.app' end
Add tag stanza to Firefox Developer Edition
diff --git a/app/concerns/authentication/api.rb b/app/concerns/authentication/api.rb index abc1234..def5678 100644 --- a/app/concerns/authentication/api.rb +++ b/app/concerns/authentication/api.rb @@ -37,11 +37,11 @@ rescue JWT::ExpiredSignature error = {message: "Authorization token has expired."} render json: {errors: [error]}, status: :unauthorized - return {} + {} rescue JWT::DecodeError error = {message: "Authorization token is not valid."} render json: {errors: [error]}, status: :unprocessable_entity - return {} + {} end end end
Fix Redundant Return issue with token decoding method
diff --git a/recipes/openstack-db.rb b/recipes/openstack-db.rb index abc1234..def5678 100644 --- a/recipes/openstack-db.rb +++ b/recipes/openstack-db.rb @@ -24,12 +24,12 @@ db_create_with_user( "identity", node["openstack"]["identity"]["db"]["username"], - db_password("keystone") + get_password "db", "keystone" ) db_create_with_user( "image", node["openstack"]["image"]["db"]["username"], - db_password("image") + get_password "db", "image" )
Move from db_password to get_password
diff --git a/scripts/users.rb b/scripts/users.rb index abc1234..def5678 100644 --- a/scripts/users.rb +++ b/scripts/users.rb @@ -1,4 +1,4 @@-require_relative '../lib/fogbugz/fogbugz' +require 'fogbugz' interface = Fogbugz::Interface.new(YAML.load_file('config.yml')[:fogbugz]) interface.authenticate
Update Users script to reflect Fogbugz extraction
diff --git a/spec/afip_bill/check_digit_spec.rb b/spec/afip_bill/check_digit_spec.rb index abc1234..def5678 100644 --- a/spec/afip_bill/check_digit_spec.rb +++ b/spec/afip_bill/check_digit_spec.rb @@ -0,0 +1,43 @@+require 'spec_helper' +require "afip_bill/check_digit" + +describe AfipBill::CheckDigit do + subject { described_class } + + describe "#generate" do + context "when the sum of code numbers is even" do + it "returns the expected checksum" do + code = "01234567890" + + checksum = subject.new(code).calculate + expect(checksum).to eq 5 + end + + it "returns the expected checksum" do + code = "111111111112233334444444444444455555555" + + checksum = subject.new(code).calculate + + expect(checksum).to eq 3 + end + end + + context "when the sum of code numbers is odd" do + it "returns the expected checksum" do + code = "01234567890" + + checksum = subject.new(code).calculate + + expect(checksum).to eq 5 + end + + it "returns the expected checksum" do + code = "111111111112233334444444444444455555555" + + checksum = subject.new(code).calculate + + expect(checksum).to eq 3 + end + end + end +end
Test coverage for CheckDigit class
diff --git a/spec/classes/trove_db_sync_spec.rb b/spec/classes/trove_db_sync_spec.rb index abc1234..def5678 100644 --- a/spec/classes/trove_db_sync_spec.rb +++ b/spec/classes/trove_db_sync_spec.rb @@ -0,0 +1,42 @@+require 'spec_helper' + +describe 'trove::db::sync' do + + shared_examples_for 'trove-dbsync' do + + it { is_expected.to contain_class('trove::deps') } + + it 'runs trove-db-sync' do + is_expected.to contain_exec('trove-manage db_sync').with( + :command => 'trove-manage db_sync', + :path => '/usr/bin', + :refreshonly => 'true', + :user => 'trove', + :try_sleep => 5, + :tries => 10, + :logoutput => 'on_failure', + :subscribe => ['Anchor[trove::install::end]', + 'Anchor[trove::config::end]', + 'Anchor[trove::dbsync::begin]'], + :notify => 'Anchor[trove::dbsync::end]', + ) + end + + end + + on_supported_os({ + :supported_os => OSDefaults.get_supported_os + }).each do |os,facts| + context "on #{os}" do + let (:facts) do + facts.merge(OSDefaults.get_facts({ + :os_workers => 8, + :concat_basedir => '/var/lib/puppet/concat' + })) + end + + it_configures 'trove-dbsync' + end + end + +end
Add unit test for sync.pp Change-Id: I9ac96d91693eaf066e4674a63199286063ef6f28 Closes-Bug: #1689241
diff --git a/config/initializers/check_submodules.rb b/config/initializers/check_submodules.rb index abc1234..def5678 100644 --- a/config/initializers/check_submodules.rb +++ b/config/initializers/check_submodules.rb @@ -0,0 +1,30 @@+# encoding: utf-8 +#-- +# Copyright (C) 2012 Gitorious AS +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +#++ +require "pathname" + +root = Pathname(__FILE__) + "../../../" +File.read(root + ".gitmodules").scan(/path = (.*)/).each do |s| + if !File.exist?(root + s.first) + $stderr.puts "Git submodule #{s.first} not present." + $stderr.puts "Did you initialize and update submodules?" + $stderr.puts "" + $stderr.puts " git submodule update --init --recursive" + $stderr.puts " bundle exec rake assets:clear" + exit 1 + end +end
Add initializer to notify users of missing submodules
diff --git a/spec/models/commit_request_spec.rb b/spec/models/commit_request_spec.rb index abc1234..def5678 100644 --- a/spec/models/commit_request_spec.rb +++ b/spec/models/commit_request_spec.rb @@ -14,7 +14,9 @@ }] } cr = CommitRequest.new(value) - cr.should be_valid + cr.should be_valid + cr.should_receive(:enqueue) + cr.save end it "can fail to validate a commitrequest" do @@ -31,6 +33,8 @@ } cr = CommitRequest.new(value) cr.should_not be_valid + cr.should_not_receive(:enqueue) + cr.save end end end
Add expectation of enqueue in commit request spec
diff --git a/spec/state_machine-mongoid_spec.rb b/spec/state_machine-mongoid_spec.rb index abc1234..def5678 100644 --- a/spec/state_machine-mongoid_spec.rb +++ b/spec/state_machine-mongoid_spec.rb @@ -13,35 +13,34 @@ context "new vehicle" do before(:each) do - @vehicle = Vehicle.new + @vehicle = Vehicle.create! end it "should be parked" do - @vehicle.parked?.should be_true + @vehicle.should be_parked @vehicle.state.should == "parked" end context "after igniting" do - before(:each) do - @vehicle.ignite - end it "should be ignited" do - @vehicle.idling?.should be_true + @vehicle.ignite! + @vehicle.should be_idling end end end context "read from database" do before(:each) do - @vehicle = Vehicle.find(Vehicle.create.id) + vehicle = Vehicle.create! + @vehicle = Vehicle.find(vehicle.id) end it "should has sate" do - @vehicle.state.should_not nil + @vehicle.state.should_not be_nil end it "should state transition" do @vehicle.ignite - @vehicle.idling?.should be_true + @vehicle.should be_idling end end end
Clear up the specs a tiny bit
diff --git a/testing/lib/refinerycms-testing.rb b/testing/lib/refinerycms-testing.rb index abc1234..def5678 100644 --- a/testing/lib/refinerycms-testing.rb +++ b/testing/lib/refinerycms-testing.rb @@ -1,5 +1,4 @@ require 'refinerycms-core' -require 'rspec-rails' require 'refinery/generators/testing_generator' module Refinery @@ -17,23 +16,6 @@ class Engine < ::Rails::Engine isolate_namespace ::Refinery - config.before_configuration do - ::Refinery::Application.module_eval do - def load_tasks - super - - # To get specs from all Refinery engines, not just those in Rails.root/spec/ - ::RSpec::Core::RakeTask.module_eval do - def pattern - [@pattern] | ::Refinery::Plugins.registered.pathnames.map{|p| - p.join('spec', '**', '*_spec.rb').to_s - } - end - end if defined?(::RSpec::Core::RakeTask) - end - end - end - config.after_initialize do ::Refinery::Plugin.register do |plugin| plugin.pathname = root
Remove initializer that loads refinery tests into rspec runlist We don't want users running Refinery's tests when they are just running rake rspec from within their application
diff --git a/canon-interpreter.rb b/canon-interpreter.rb index abc1234..def5678 100644 --- a/canon-interpreter.rb +++ b/canon-interpreter.rb @@ -25,11 +25,12 @@ puts "Warning: empty canon given." else num_beats = canon[0][0].length - for i in 0..voices - 1 - sleep i * num_beats + voices.times do + puts "new" in_thread do play_melody(canon) end + sleep num_beats end end end
Fix interpreter to have right number of voices.
diff --git a/app/models/tag_list.rb b/app/models/tag_list.rb index abc1234..def5678 100644 --- a/app/models/tag_list.rb +++ b/app/models/tag_list.rb @@ -1,5 +1,4 @@ # encoding: utf-8 -require 'shellwords' # The TagList class is used to convert a string to an array of tags. # @@ -10,19 +9,13 @@ # taglist = TagList.new("One Two Three") # taglist # => ["One", "Two", "Three"] def initialize(string) - add(string.shellsplit) + add string.split(/\s+/) end # Add tags to the tag_list. Duplicate or blank tags will be ignored. def add(names) concat(names) clean! - self - end - - # Remove specific tags from the tag_list. - def remove(names) - delete_if { |name| names.include?(name) } self end @@ -33,7 +26,7 @@ private - INVALID_CHARS = /\P{Word}/u + INVALID_CHARS = /[^\p{Word}'+-]/u # Keeps only letters and digits, and remove duplicates def clean!
Allow some more characters to tags
diff --git a/Lipstick.podspec b/Lipstick.podspec index abc1234..def5678 100644 --- a/Lipstick.podspec +++ b/Lipstick.podspec @@ -19,4 +19,5 @@ s.source_files = 'Source/**/*.swift' s.frameworks = 'UIKit' + s.dependency 'SwiftKitStaging' end
Add SwiftKitStaging as a dependency.
diff --git a/attributes/default.rb b/attributes/default.rb index abc1234..def5678 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -7,7 +7,7 @@ } node.default['bash_it']['custom_plugins'] = { - 'sprout-base' => %w( + 'sprout-bash-it' => %w( bash_it/custom/disable_ctrl-s_output_control.bash bash_it/custom/enable_ctrl-o_history_execution.bash bash_it/custom/ensure_usr_local_bin_first.bash
Install custom plugins from bash-it repository, not sprout-base. :)
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 @@ -13,8 +13,8 @@ config.cassette_library_dir = 'spec/vcr_cassettes' config.configure_rspec_metadata! config.filter_sensitive_data("library.edu") { "library.nyu.edu" } - config.filter_sensitive_data("BOR_ID") { ENV['BOR_ID'] } - config.filter_sensitive_data("VERIFICATION") { ENV['VERIFICATION'] } + config.filter_sensitive_data('BOR_ID') { ENV['BOR_ID'] } + config.filter_sensitive_data('VERIFICATION') { ENV['VERIFICATION'] } end Exlibris::Aleph.configure do |config|
Clean up spec helper for style
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index abc1234..def5678 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -7,7 +7,6 @@ require 'rubygems' require 'bundler/setup' -require 'right_on' if ENV['COVERAGE'] require 'simplecov' @@ -16,6 +15,8 @@ SimpleCov.start end +require 'right_on' + RSpec.configure do |config| config.treat_symbols_as_metadata_keys_with_true_values = true config.run_all_when_everything_filtered = true
Fix coverage task as it needs to load prior to library
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,7 +1,9 @@ require_relative '../lib/payment_processor' require_relative '../lib/payment_processor_connection' +require_relative '../lib/charge_response' require_relative '../lib/user' require 'uri' require 'net/http' require 'webmock/rspec' +require 'surrogate/rspec'
Add surrogate and charge response for surrogate example
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,6 +1,30 @@ # encoding: utf-8 + +require 'devtools/spec_helper' + +if ENV['COVERAGE'] == 'true' + require 'simplecov' + require 'coveralls' + + SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[ + SimpleCov::Formatter::HTMLFormatter, + Coveralls::SimpleCov::Formatter + ] + + SimpleCov.start do + command_name 'spec:unit' + add_filter 'config' + add_filter 'spec' + minimum_coverage 100 + end +end + require 'ice_nine' -require 'devtools/spec_helper' + +# require spec support files and shared behavior +Dir[File.expand_path('../{support,shared}/**/*.rb', __FILE__)].each do |file| + require file +end RSpec.configure do |config| end
Add simplecov and coveralls to ice_nine
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,27 +1,15 @@ require 'serverspec' -require 'net/ssh' - -include SpecInfra::Helper::DetectOS -include SpecInfra::Helper::Exec -include SpecInfra::Helper::Ssh if ENV['RAKE_ANSIBLE_USE_VAGRANT'] require 'lib/vagrant' - conn = Vagrant.new + c = Vagrant.new else require 'lib/docker' - conn = Docker.new + c = Docker.new end -RSpec.configure do |config| - config.before :all do - config.host = conn.ssh_host - opts = Net::SSH::Config.for(config.host) - opts[:port] = conn.ssh_port - opts[:keys] = conn.ssh_keys - opts[:auth_methods] = Net::SSH::Config.default_auth_methods - config.ssh = Net::SSH.start(conn.ssh_host, conn.ssh_user, opts) - end -end +set :backend, :ssh +set :host, c.ssh_host +set :ssh_options, :user => c.ssh_user, :port => c.ssh_port, :keys => c.ssh_keys
Update integration testing to work with Serverspec 2.N
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 @@ -18,7 +18,7 @@ end config.filter_run :focus - config.filter_run_excluding type: :feature unless ENV['S3_BUCKET_NAME'] + config.filter_run_excluding type: :feature unless ENV.key?('S3_BUCKET_NAME') config.run_all_when_everything_filtered = true config.order = :random
Check for presence of AWS_BUCKET key
diff --git a/week-9/ruby-review-2/ruby-review.rb b/week-9/ruby-review-2/ruby-review.rb index abc1234..def5678 100644 --- a/week-9/ruby-review-2/ruby-review.rb +++ b/week-9/ruby-review-2/ruby-review.rb @@ -0,0 +1,80 @@+# U2.W6: Testing Assert Statements + +# I worked on this challenge Kevin Corso. + + +# 2. Review the simple assert statement + +# def assert +# raise "Assertion failed!" unless yield +# end + +# name = "bettysue" +# assert { name == "bettysue" } +# assert { name == "billybob" } + +# 2. Pseudocode what happens when the code above runs +# In driver code, setting name equal to "bettysue" +# Both assert statements set up a block, which are called by yield in the code +# First assert passes because block is TRUE +# Second assert fails because block is FALSE + + +# 3. Copy your selected challenge here + +def separate_comma(num) + str_num = num.to_s.reverse + + if str_num.length < 4 + return str_num.reverse + else + i = 3 + while i < str_num.length + str_num.insert(i, ',') + i += 4 + end + end + return str_num.reverse +end + +# def separate_comma(integer) +# require "enumerator" +# integer.to_s.split(//).reverse.enum_for(:each_slice, 3).to_a.map(&:join).join(",").reverse +# end + +# 4. Convert your driver test code from that challenge into Assert Statements + +def assert + raise "Assertion failed!" unless yield +end + +test_1 = "1,204" +assert { test_1 == separate_comma(1204)} +test_2 = "1,456,789" +assert { test_2 == separate_comma(1456789)} +test_3 = "678" +assert { test_3 == separate_comma(678)} +test_4 = "1,234,546,879,654,321" +assert { test_4 == separate_comma(1234546879654321)} + +# 5. Reflection +=begin +What concepts did you review in this challenge? + +My partner and I learned about assert statements in this challenge. While +they're different from RSpec files, it did provide a good "kickstart" to the +idea of testing code (TDD). + +What is still confusing to you about Ruby? + +I still don't understand RSpec files. We weren't required to work with them +in this challenge, but I'm sure we will write them in Phases 1-3 of DBC, so +I'd like to start learning about them. + +What are you going to study to get more prepared for Phase 1? + +I will complete more ruby review files, especially the more advanced +applications. I may also try to understand things we haven't covered, +like RegEx and RSpec files. + +=end
Add ruby review pair file
diff --git a/lib/anvil/heroku/command/release.rb b/lib/anvil/heroku/command/release.rb index abc1234..def5678 100644 --- a/lib/anvil/heroku/command/release.rb +++ b/lib/anvil/heroku/command/release.rb @@ -12,7 +12,7 @@ error("Usage: heroku release SLUG_URL") unless slug_url = shift_argument validate_arguments! - action("Releasing to #{app}.#{heroku.host}") do + action("Releasing to #{app}.herokuapp.com") do release_options = { :slug_url => slug_url, :cloud => heroku.host
Fix hostname in "releasing to..." message Uses `heroku.host`, which is wrong - "herokuapp.com" is correct!
diff --git a/lib/iridium/commands/application.rb b/lib/iridium/commands/application.rb index abc1234..def5678 100644 --- a/lib/iridium/commands/application.rb +++ b/lib/iridium/commands/application.rb @@ -3,7 +3,7 @@ class Application < Thor include Thor::Actions - argument :app_path, :type => :string + attr_reader :app_path def self.source_root File.expand_path '../../../../generators/application', __FILE__ @@ -14,7 +14,9 @@ method_option :assetfile, :type => :boolean method_option :index, :type => :boolean method_option :envs, :type => :boolean - def application + def application(app_path) + @app_path = app_path + self.destination_root = File.expand_path app_path, destination_root directory "app"
Refactor away from declared arguments
diff --git a/lib/itamae/resource/http_request.rb b/lib/itamae/resource/http_request.rb index abc1234..def5678 100644 --- a/lib/itamae/resource/http_request.rb +++ b/lib/itamae/resource/http_request.rb @@ -7,13 +7,9 @@ UrlNotFoundError = Class.new(StandardError) define_attribute :headers, type: Hash, default: {} - define_attribute :url, type: String + define_attribute :url, type: String, required: true def pre_action - unless attributes.url - raise UrlNotFoundError, "url is not found" - end - attributes.content = open(attributes.url, attributes.headers).read super
Use 'required: true' on url attribute
diff --git a/lib/tasks/scheduled_publishing.rake b/lib/tasks/scheduled_publishing.rake index abc1234..def5678 100644 --- a/lib/tasks/scheduled_publishing.rake +++ b/lib/tasks/scheduled_publishing.rake @@ -29,6 +29,7 @@ begin ScheduledEditionsPublisher.publish_all_due_editions rescue ScheduledEditionsPublisher::PublishingFailure => exception + Airbrake.notify_or_ignore(exception, parameters: { unpublished_editions: exception.unpublished_edition_ids }) ExceptionNotifier::Notifier.background_exception_notification(exception, data: { unpublished_editions: exception.unpublished_edition_ids }) end end
Use Airbrake as well as ExceptionNotifier
diff --git a/spec/lib/child_benefit_tax_calculator_spec.rb b/spec/lib/child_benefit_tax_calculator_spec.rb index abc1234..def5678 100644 --- a/spec/lib/child_benefit_tax_calculator_spec.rb +++ b/spec/lib/child_benefit_tax_calculator_spec.rb @@ -14,7 +14,7 @@ :gross_pension_contributions => 10, :net_pension_contributions => 10, :trading_losses_self_employed => 10, - :gift_aid_donations => 10 + :gift_aid_donations => 10, :children_count => 1 }) calc.total_annual_income.should == 40
Fix syntax error in lib spec
diff --git a/spec/models/miq_worker/systemd_common_spec.rb b/spec/models/miq_worker/systemd_common_spec.rb index abc1234..def5678 100644 --- a/spec/models/miq_worker/systemd_common_spec.rb +++ b/spec/models/miq_worker/systemd_common_spec.rb @@ -0,0 +1,26 @@+RSpec.describe MiqWorker::SystemdCommon do + describe ".service_base_name" do + before { MiqWorkerType.seed } + + it "every worker has a matching systemd target and service file" do + all_systemd_units = (Vmdb::Plugins.systemd_units + Rails.root.join("systemd").glob("*.*")).map(&:basename).map(&:to_s) + + all_systemd_units.delete("manageiq.target") + + MiqWorkerType.worker_class_names.each do |klass_name| + klass = klass_name.constantize + service_base_name = klass.service_base_name + + service_file = "#{service_base_name}@.service" + target_file = "#{service_base_name}.target" + + expect(all_systemd_units).to include(service_file) + expect(all_systemd_units).to include(target_file) + + all_systemd_units -= [service_file, target_file] + end + + expect(all_systemd_units).to be_empty + end + end +end
Add spec test for workers <=> systemd units
diff --git a/lib/halite/converter/misc.rb b/lib/halite/converter/misc.rb index abc1234..def5678 100644 --- a/lib/halite/converter/misc.rb +++ b/lib/halite/converter/misc.rb @@ -31,7 +31,7 @@ # @param output_path [String] Output path for the cookbook. # @return [void] def self.write(gem_data, output_path) - %w{Readme License Copying Contributing}.each do |name| + %w{Readme License Copying Contributing Changelog}.each do |name| if path = gem_data.find_misc_path(name) # rubocop:disable Lint/AssignmentInCondition FileUtils.copy(path, File.join(output_path, File.basename(path)), preserve: true) end
Include the changelog too, if present.
diff --git a/lib/klarna_gateway/engine.rb b/lib/klarna_gateway/engine.rb index abc1234..def5678 100644 --- a/lib/klarna_gateway/engine.rb +++ b/lib/klarna_gateway/engine.rb @@ -7,17 +7,13 @@ end config.to_prepare do - require 'httplog' if Rails.env.development? Spree::PermittedAttributes.source_attributes << "authorization_token" - end - - config.after_initialize do if defined?(Spree::Admin) Spree::Admin::OrdersController.include(KlarnaGateway::Admin::OrdersController) Spree::Admin::PaymentsController.include(KlarnaGateway::Admin::PaymentsController) end Spree::CheckoutController.include(KlarnaGateway::SessionController) - Spree::CheckoutController.include(KlarnaGateway::CheckoutController) + Spree::CheckoutController.prepend(KlarnaGateway::CheckoutController) Spree::Order.include(KlarnaGateway::Order) Spree::Payment.include(KlarnaGateway::Payment) end
Fix the autoload issues in dev by using to_prepare
diff --git a/lib/registerable_calendar.rb b/lib/registerable_calendar.rb index abc1234..def5678 100644 --- a/lib/registerable_calendar.rb +++ b/lib/registerable_calendar.rb @@ -3,7 +3,7 @@ class RegisterableCalendar extend Forwardable - attr_accessor :calendar, :slug, :live + attr_accessor :calendar, :slug def_delegators :@calendar, :indexable_content, :content_id @@ -20,22 +20,4 @@ def description I18n.t(@calendar.description) end - - def state - 'live' - end - - def need_ids - [@calendar.need_id.to_s] - end - - # Sending an empty array for `paths` and `prefixes` will make sure we don't - # register routes in Panopticon. - def paths - [] - end - - def prefixes - [] - end end
Remove unused method from registerable calendar This class used to be used by both panopticon and rummager. Now that panopticon is removed as a dependency (https://github.com/alphagov/calendars/pull/135) these methods aren't necessary anymore.
diff --git a/gstreamer/sample/gst-gi.rb b/gstreamer/sample/gst-gi.rb index abc1234..def5678 100644 --- a/gstreamer/sample/gst-gi.rb +++ b/gstreamer/sample/gst-gi.rb @@ -0,0 +1,55 @@+# Copyright (C) 2013 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +require "gobject-introspection" + +base_dir = Pathname.new(__FILE__).dirname.dirname.dirname.expand_path +vendor_dir = base_dir + "vendor" + "local" +vendor_bin_dir = vendor_dir + "bin" +GLib.prepend_environment_path(vendor_bin_dir) + +module Gst + LOG_DOMAIN = "GStreamer" + GLib::Log.set_log_domain(LOG_DOMAIN) + + class << self + @initialized = false + def init(argv=ARGV) + return if @initialized + @initialized = true + loader = Loader.new(self, argv) + loader.load("Gst") + end + end + + class Loader < GObjectIntrospection::Loader + def initialize(base_module, init_arguments) + super(base_module) + @init_arguments = init_arguments + end + + private + def pre_load(repository, namespace) + init = repository.find(namespace, "init") + argc, argv = init.invoke(1 + @init_arguments.size, + [$0] + @init_arguments) + @init_arguments.replace(argv) + end + + def post_load(repository, namespace) + end + end +end
Add GObject Introspection based GStreamer binding as sample
diff --git a/lib/tasks/testing_tasks.rake b/lib/tasks/testing_tasks.rake index abc1234..def5678 100644 --- a/lib/tasks/testing_tasks.rake +++ b/lib/tasks/testing_tasks.rake @@ -1,5 +1,9 @@+Rails::TestTask.new :test do |t| + t.pattern = "test/**/*_test.rb" +end + namespace :test do - Rails::TestTask.new("lib") do |t| + Rails::TestTask.new "lib" do |t| t.pattern = "test/lib/**/*_test.rb" end end
Fix general rake test task
diff --git a/lib/sufia.rb b/lib/sufia.rb index abc1234..def5678 100644 --- a/lib/sufia.rb +++ b/lib/sufia.rb @@ -30,5 +30,9 @@ config.assets.paths << config.root.join('vendor', 'assets', 'fonts') config.assets.precompile << %r(vjs\.(?:eot|ttf|woff)$) + config.assets.precompile += %w( fontawesome-webfont.woff ) + config.assets.precompile += %w( fontawesome-webfont.ttf ) + config.assets.precompile += %w( fontawesome-webfont.svg ) + config.assets.precompile += %w( ZeroClipboard.swf ) end end
Make sure a few required assets are explicitly listed on the asset pipeline. This removes the runtime error that asks the developer to manually add them when running the application for the very first time.