diff
stringlengths
65
26.7k
message
stringlengths
7
9.92k
diff --git a/lib/mongoid-app_settings.rb b/lib/mongoid-app_settings.rb index abc1234..def5678 100644 --- a/lib/mongoid-app_settings.rb +++ b/lib/mongoid-app_settings.rb @@ -3,6 +3,10 @@ module Mongoid module AppSettings extend ActiveSupport::Concern + + included do |base| + @base = base + end class Record #:nodoc: include Mongoid::Document @@ -23,6 +27,16 @@ # end def setting(name, options = {}) settings[name.to_s] = options + + @base.class.class_eval do + define_method(name.to_s) do + @base[name.to_s] + end + + define_method(name.to_s + "=") do |value| + @base[name.to_s] = value + end + end end # Force a reload from the database @@ -31,16 +45,6 @@ end protected - - def method_missing(name, *args, &block) # :nodoc: - if name.to_s =~ /^(.*)=$/ and setting_defined?($1) - self[$1] = args[0] - elsif setting_defined?(name.to_s) - self[name.to_s] - else - super - end - end def settings # :nodoc: @settings ||= {}
Remove method_missing and dynamically create methods
diff --git a/lib/tasks/gitlab/setup.rake b/lib/tasks/gitlab/setup.rake index abc1234..def5678 100644 --- a/lib/tasks/gitlab/setup.rake +++ b/lib/tasks/gitlab/setup.rake @@ -16,7 +16,7 @@ Rake::Task["db:setup"].invoke - config = YAML.load_file(File.join(Rails.root,'config','database.yml'))[Rails.env] + config = YAML.load(ERB.new(File.read(File.join(Rails.root, "config","database.yml"))).result) success = case config["adapter"] when /^mysql/ then Rake::Task["add_limits_mysql"].invoke
Allow to parse heroku-generated database.yml config file.
diff --git a/spec/factories/user_factory.rb b/spec/factories/user_factory.rb index abc1234..def5678 100644 --- a/spec/factories/user_factory.rb +++ b/spec/factories/user_factory.rb @@ -3,6 +3,8 @@ name 'User' email 'email@test.com' login 'user' + password 'coolness' + password_confirmation { password } factory :admin do name 'Admin'
Add password and password_confirmation attrs to UserFactory
diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index abc1234..def5678 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -3,6 +3,12 @@ hosts.each do |host| on host, install_puppet end + +zookeeper_pp = <<-EOS +class { 'zookeeper': + client_ip => $::ipaddress_lo +} +EOS RSpec.configure do |c| module_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) @@ -17,6 +23,10 @@ puppet_module_install(:source => module_root, :module_name => module_name) hosts.each do |host| on host, puppet('module', 'install', 'puppetlabs/stdlib'), { :acceptable_exit_codes => [0,1] } + on host, puppet('module', 'install', 'deric/zookeeper'), { :acceptable_exit_codes => [0,1] } + + # Make sure a working instance of zookeeper is running + apply_manifest(zookeeper_pp) end end end
Add deric-zookeeper module setup to acceptance spec helper. The acceptance test for the running druid services need a working instance of zookeeper to connect to. The deric-zookeeper module is used to accomplish this and its utilization has been added to spec_helper_acceptance.rb to initialize the test VM.
diff --git a/lib/webdriver_utils/page.rb b/lib/webdriver_utils/page.rb index abc1234..def5678 100644 --- a/lib/webdriver_utils/page.rb +++ b/lib/webdriver_utils/page.rb @@ -8,7 +8,7 @@ def define_page_methods opts={} page_module = opts[:page_module] || raise('must set page_module') target_class = opts[:target_class] || raise('must set target_class') - driver_object = opts[:driver] || raise('must set driver') + driver_object = opts[:watir] || opts[:driver] || raise('must set driver') page_module.constants.each do |page_class| # ButtonsPage => buttons_page # https://github.com/rails/rails/blob/daaa21bc7d20f2e4ff451637423a25ff2d5e75c7/activesupport/lib/active_support/inflector/methods.rb#L96
Add watir alias for driver opt
diff --git a/Casks/macupdate-desktop.rb b/Casks/macupdate-desktop.rb index abc1234..def5678 100644 --- a/Casks/macupdate-desktop.rb +++ b/Casks/macupdate-desktop.rb @@ -1,8 +1,8 @@ cask :v1 => 'macupdate-desktop' do - version '6.0.2' - sha256 '1aa04e0bec920f28af5417a2b875e40af832d5303a29dca27e527e30c4db42f5' + version '6.0.6' + sha256 '3f9a7fbbf19458912609723a181c608b6f335645d94c94bb8e635d928bd650a2' - url "http://dl.macupdate.com/MacUpdateDesktop#{version}.zip" + url "http://cdn.macupdate.com/MacUpdateDesktop#{version}.zip" appcast 'http://www.macupdate.com/desktop/updates.xml', :sha256 => 'f34602a28e842a77a7159342463747c05d783d44613feed26bbf742d88e3607f' name 'MacUpdate Desktop'
Upgrade MacUpdate Desktop.app to v6.0.6
diff --git a/Casks/omnipresence-beta.rb b/Casks/omnipresence-beta.rb index abc1234..def5678 100644 --- a/Casks/omnipresence-beta.rb +++ b/Casks/omnipresence-beta.rb @@ -1,6 +1,6 @@ cask :v1 => 'omnipresence-beta' do - version '1.4.x-r232733' - sha256 'c21289a7a90b4efc8f0eb9cf3775bb4bb19145688229cd886718881b2c34377a' + version '1.4.x-r233232' + sha256 '2366e49d19d9e9d53967f18c6ab0781d5478db24c883921300f62040dd14f119' url "http://omnistaging.omnigroup.com/omnipresence/releases/OmniPresence-#{version}-Test.dmg" name 'OmniPresence Beta'
Update Omnipresence Beta to version 1.4.x-r233232 This commit updates the version and sha256 stanzas.
diff --git a/test/test_helper.rb b/test/test_helper.rb index abc1234..def5678 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,7 +1,6 @@ require File.expand_path('../../lib/colirby.rb', __FILE__) - require 'minitest/autorun' -require 'minitest/pride' +require 'turn' require 'webmock/minitest' require 'vcr'
Use turn instead of pride to print test output
diff --git a/test/unit/deletion_test.rb b/test/unit/deletion_test.rb index abc1234..def5678 100644 --- a/test/unit/deletion_test.rb +++ b/test/unit/deletion_test.rb @@ -3,9 +3,7 @@ class DeletionTest < ActiveSupport::TestCase self.use_transactional_fixtures = false # Disabled to test after_commit - def setup - super - + setup do @user = create(:user) Pusher.new(@user, gem_file).process @version = Version.last @@ -43,8 +41,7 @@ assert_nil RubygemFs.instance.get("gems/#{@version.full_name}.gem"), "Rubygem still exists!" end - def teardown - super + teardown do # This is necessary due to after_commit not cleaning up for us [Rubygem, Version, User, Deletion].each(&:delete_all) end
Use setup helper with block instead of overriding it
diff --git a/lib/email_address/active_record_validator.rb b/lib/email_address/active_record_validator.rb index abc1234..def5678 100644 --- a/lib/email_address/active_record_validator.rb +++ b/lib/email_address/active_record_validator.rb @@ -38,7 +38,7 @@ e = Address.new(r[f]) unless e.valid? error_message = @opt[:message] || - Config.error_messages[:invalid_address] || + Config.error_message(:invalid_address, I18n.locale.to_s) || "Invalid Email Address" r.errors.add(f, error_message) end
Use I18n strings if available Like #67 but I18n is used on Rails' side
diff --git a/core/app/controllers/admin/global_feature_toggles_controller.rb b/core/app/controllers/admin/global_feature_toggles_controller.rb index abc1234..def5678 100644 --- a/core/app/controllers/admin/global_feature_toggles_controller.rb +++ b/core/app/controllers/admin/global_feature_toggles_controller.rb @@ -7,7 +7,7 @@ end def update - @global_features = params[:features].andand.keys + @global_features = params[:features].andand.keys || [] interactor :'global_features/set', @global_features render :show end
Allow setting to the empty global feature toggle list.
diff --git a/db/migrate/20131118115555_add_customer_number.rb b/db/migrate/20131118115555_add_customer_number.rb index abc1234..def5678 100644 --- a/db/migrate/20131118115555_add_customer_number.rb +++ b/db/migrate/20131118115555_add_customer_number.rb @@ -2,10 +2,24 @@ def up rename_column :customers, :id, :number add_column :customers, :id, :primary_key + fix_customer_references(Project, :number, :id) + fix_customer_references(Activity, :number, :id) end def down + fix_customer_references(Project, :id, :number) + fix_customer_references(Activity, :id, :number) remove_column :customers, :id rename_column :customers, :number, :id end + + private + def fix_customer_references(model, source_id_name, target_id_name) + model.all.each do |item| + next if item.customer_id.nil? + customer = Customer.where(source_id_name => item.customer_id).last + item.customer_id = customer.send(target_id_name) + item.save!(validate: false) + end + end end
Fix migration of customer number
diff --git a/db/migrate/20110509092008_add_neutral_feedback_to_reputation.rb b/db/migrate/20110509092008_add_neutral_feedback_to_reputation.rb index abc1234..def5678 100644 --- a/db/migrate/20110509092008_add_neutral_feedback_to_reputation.rb +++ b/db/migrate/20110509092008_add_neutral_feedback_to_reputation.rb @@ -0,0 +1,9 @@+class AddNeutralFeedbackToReputation < ActiveRecord::Migration + def self.up + add_column :reputation_ratings, :neutral_feedback, :string + end + + def self.down + remove_column :reputation_ratings, :neutral_feedback + end +end
Add neutral feedback to reputation
diff --git a/custom_counter_cache.gemspec b/custom_counter_cache.gemspec index abc1234..def5678 100644 --- a/custom_counter_cache.gemspec +++ b/custom_counter_cache.gemspec @@ -13,7 +13,7 @@ s.require_paths = ['lib'] s.files = Dir['lib/**/*.rb'] s.required_rubygems_version = '>= 1.3.6' - s.add_dependency('rails', Gem::Platform::RUBY < '1.9.2' ? '~> 3.1' : '>= 3.1') + s.add_dependency('rails', Gem::Platform::RUBY < '1.9.3' ? '~> 3.1' : '>= 3.1') s.add_development_dependency('sqlite3') s.test_files = Dir['test/**/*.rb'] s.rubyforge_project = 'custom_counter_cache'
Fix version ternary for Travis.
diff --git a/app.rb b/app.rb index abc1234..def5678 100644 --- a/app.rb +++ b/app.rb @@ -19,10 +19,12 @@ end post '/upload' do - File.open('uploads/' + params['birthdayFile'][:filename], "w") do |f| + filename = 'uploads/' + params['birthdayFile'][:filename] + + File.open(filename, "w") do |f| f.write(params['birthdayFile'][:tempfile].read) end - filename = 'uploads/' + params['birthdayFile'][:filename] + if filename =~ /xlsx$/ excel = Roo::Excelx.new(filename)
Change duplicate data with a variable
diff --git a/app.rb b/app.rb index abc1234..def5678 100644 --- a/app.rb +++ b/app.rb @@ -7,5 +7,8 @@ get '/echofile' do halt 404 if params[:content].nil? or params[:file].nil? content_type "text/x-shellscript" - "echo \"#{params[:content]}\" > #{params[:file]}" -end+ <<-eos + #!/bin/sh + echo "#{params[:content]}" > #{params[:file]} + eos +end
Write out directive as first line of script file
diff --git a/test/node_test.rb b/test/node_test.rb index abc1234..def5678 100644 --- a/test/node_test.rb +++ b/test/node_test.rb @@ -32,4 +32,16 @@ empty_node.size.zero? end end + + group '.new' do + assert 'given a block, evaluates it in the context of the object' do + node_with_method = Node.new do + def returns_puppies + :puppies + end + end + + node_with_method.returns_puppies == :puppies + end + end end
Test initializing Node with block
diff --git a/db/migrate/20160511145349_update_format_to_dual_specialist_publisher.rb b/db/migrate/20160511145349_update_format_to_dual_specialist_publisher.rb index abc1234..def5678 100644 --- a/db/migrate/20160511145349_update_format_to_dual_specialist_publisher.rb +++ b/db/migrate/20160511145349_update_format_to_dual_specialist_publisher.rb @@ -0,0 +1,6 @@+class UpdateFormatToDualSpecialistPublisher < ActiveRecord::Migration + def change + ContentItem.where(document_type: ['specialist_document', 'placeholder_specialist_document']) + .update_all("document_type = (details #>> '{metadata,document_type}')") + end +end
Set document_type of specialist documents to be more specific Specialist publisher has a separate document_type from schema name. Currently, these are set to the same thing. This migration sets the document_type from details.metadata.document_type
diff --git a/extras/sanitizable_attributes.rb b/extras/sanitizable_attributes.rb index abc1234..def5678 100644 --- a/extras/sanitizable_attributes.rb +++ b/extras/sanitizable_attributes.rb @@ -31,7 +31,8 @@ module ClassMethods def sanitize_attributes(*attr_names) cattr_accessor :sanitizable_attributes - self.sanitizable_attributes = attr_names + self.sanitizable_attributes ||= [] + self.sanitizable_attributes += attr_names.to_a before_validation :sanitize! end
Support multiple calls to sanitize_attributes in same model. Implement formatable descriptions [story: #40582233]
diff --git a/lib/happy-helpers/helpers/numbers.rb b/lib/happy-helpers/helpers/numbers.rb index abc1234..def5678 100644 --- a/lib/happy-helpers/helpers/numbers.rb +++ b/lib/happy-helpers/helpers/numbers.rb @@ -1,6 +1,6 @@ # -*- encoding: utf-8 -*- - require 'i18n' +require 'money' module HappyHelpers module Helpers
Make sure 'money' is required
diff --git a/lib/infoblox/resource/roaminghost.rb b/lib/infoblox/resource/roaminghost.rb index abc1234..def5678 100644 --- a/lib/infoblox/resource/roaminghost.rb +++ b/lib/infoblox/resource/roaminghost.rb @@ -0,0 +1,18 @@+module Infoblox + # minimum WAPI version: 1.1 + class RoamingHost < Resource + remote_attr_accessor :extattrs, + :mac, + :bootfile, + :use_bootfile, + :nextserver, + :use_nextserver, + :name, + :network_view, + :options, + :match_client, + :comment + + wapi_object 'roaminghost' + end +end
Add Roaming host entry for Infoblox This allows specifying DHCP options for MAC addresses without explicitly locking them to a fixed address.
diff --git a/app/models/blueprint.rb b/app/models/blueprint.rb index abc1234..def5678 100644 --- a/app/models/blueprint.rb +++ b/app/models/blueprint.rb @@ -7,10 +7,13 @@ validates :name, uniqueness: true validate do - patterns.each(&:set_metadata_from_repository) - - unless patterns.any? { |pattern| pattern.type == 'platform' } - errors.add(:patterns, 'don\'t contain platform pattern') + begin + patterns.each(&:set_metadata_from_repository) + unless patterns.any? { |pattern| pattern.type == 'platform' } + errors.add(:patterns, 'don\'t contain platform pattern') + end + rescue => e + errors.add(:patterns, "is invalid(#{e.message})") end end
Return error response when pattern is invalid
diff --git a/app/models/excursion.rb b/app/models/excursion.rb index abc1234..def5678 100644 --- a/app/models/excursion.rb +++ b/app/models/excursion.rb @@ -17,7 +17,7 @@ private def parse_for_meta - parsed_json = ActiveSupport::JSON.decode(json) + parsed_json = JSON(json) activity_object.title = parsed_json["name"] activity_object.description = parsed_json["description"] activity_object.save!
Use more efficient JSON parser
diff --git a/app/models/micropost.rb b/app/models/micropost.rb index abc1234..def5678 100644 --- a/app/models/micropost.rb +++ b/app/models/micropost.rb @@ -12,6 +12,7 @@ private def picture_size - erros.add(:picture, 'should be less than 5MB') if picture.size > 5.megabytes + errors.add(:picture, 'should be less than 5MB') if picture.size > + 5.megabytes end end
Fix bug not to add error
diff --git a/lib/language_pack/helpers/nodebin.rb b/lib/language_pack/helpers/nodebin.rb index abc1234..def5678 100644 --- a/lib/language_pack/helpers/nodebin.rb +++ b/lib/language_pack/helpers/nodebin.rb @@ -19,7 +19,7 @@ end def self.hardcoded_yarn - version = "1.5.1" + version = "1.12.3" { "number" => version, "url" => "https://s3.amazonaws.com/heroku-nodejs-bins/yarn/release/yarn-v#{version}.tar.gz"
Update included Yarn to latest 1.x version
diff --git a/lib/plugins/graphite/graphite_api.rb b/lib/plugins/graphite/graphite_api.rb index abc1234..def5678 100644 --- a/lib/plugins/graphite/graphite_api.rb +++ b/lib/plugins/graphite/graphite_api.rb @@ -0,0 +1,27 @@+require 'net/http' +require 'json' + +class GraphiteAPI + def initialize(host, port) + @uri = URI.parse("https://#{host}:#{port}") + @graphite = Net::HTTP.new(@uri.host, @uri.port) + end + + def expand(query) + get("metrics/expand", {:query => query})["results"] + end + + private + def get(endpoint, data) + request_uri = @uri.merge(endpoint) + request_uri.query = URI.encode_www_form(data) + + request = Net::HTTP::Get.new(request_uri) + + get_json_from request + end + + def get_json_from(request) + JSON.parse(@graphite.request(request).body) + end +end
Create a wrapper around the graphite api
diff --git a/travis-saucelabs-api.gemspec b/travis-saucelabs-api.gemspec index abc1234..def5678 100644 --- a/travis-saucelabs-api.gemspec +++ b/travis-saucelabs-api.gemspec @@ -19,5 +19,5 @@ gem.add_runtime_dependency('faraday', '~> 0.7') gem.add_runtime_dependency('faraday_middleware', '~> 0.9') - gem.add_runtime_dependency('thor', '~> 0.17') + gem.add_runtime_dependency('thor', '~> 0.14') end
Downgrade the necessary thor version
diff --git a/providers/configure_init_scripts.rb b/providers/configure_init_scripts.rb index abc1234..def5678 100644 --- a/providers/configure_init_scripts.rb +++ b/providers/configure_init_scripts.rb @@ -22,7 +22,7 @@ path "#{new_resource.installer_prefix_dir}/dynatrace/init.d/#{script}" owner new_resource.dynatrace_owner group new_resource.dynatrace_group - mode '0744' + mode '0755' variables({ :linux_service_start_runlevels => linux_service_start_runlevels, :linux_service_stop_runlevels => linux_service_stop_runlevels,
Make init scripts be 0755.
diff --git a/config/deploy.rb b/config/deploy.rb index abc1234..def5678 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -20,7 +20,7 @@ desc 'Pull in local OBRA code' task :after_update_code do - sudo "svn co svn+ssh://sw@butlerpress.com/var/repos/obra /srv/www/rails/#{application}/local" + sudo "svn co --password Merckx svn+ssh://sw@butlerpress.com/var/repos/obra /srv/www/rails/#{application}/local" end desc "Set file permissions for Rails app"
Add SVN password to deplloy file!
diff --git a/config/routes.rb b/config/routes.rb index abc1234..def5678 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -7,9 +7,9 @@ end Guides::Application.routes.draw do - authenticate :user do + # authenticate :user do match '/preview/:edition_id' => GuidesFrontEnd::Preview, :anchor => false, :as => :preview_edition_prefix - end + # end namespace :admin do resources :transactions do
Disable requirement that you log in to preview as that was causing problems
diff --git a/config/routes.rb b/config/routes.rb index abc1234..def5678 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -14,7 +14,7 @@ resources :link_categories resources :partners resources :events, :path => 'eventos' do - post :register, on: :member + post :register, on: :member collection do post 'register' end @@ -26,6 +26,7 @@ get "/paginas/:pagina" => "paginas#show" root "paginas#show", pagina: "home" get 'contact', to: 'messages#new', as: 'contact' + post 'messages/subscribe', to: 'messages#subscribe' post 'contact', to: 'messages#create' match "/404" => "errors#error404", via: [ :get, :post, :patch, :delete ] match "/422" => "errors#error422", via: [ :get, :post, :patch, :delete ]
Add rota para post de subscribe
diff --git a/config/routes.rb b/config/routes.rb index abc1234..def5678 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -35,4 +35,7 @@ match '/about', :to => 'static_pages#about' root :to => 'static_pages#home' + unless Rails.application.config.consider_all_requests_local + match '*not_found', to: 'static_pages#error_404' + end end
Add missing route for error pages
diff --git a/config/routes.rb b/config/routes.rb index abc1234..def5678 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,6 @@ Rails.application.routes.draw do + + get 'faqs/:id' => 'faqs#show_with_token' devise_for :users devise_scope :user do @@ -17,9 +19,7 @@ resources :comments resources :ratings - - root to: "users#show" + end - - end + root to: "users#show" end
Add route to fetch FAQs based on id and token Also move the `root` directive out of the `devise_scope`.
diff --git a/config/routes.rb b/config/routes.rb index abc1234..def5678 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,7 +1,11 @@ Rails.application.routes.draw do devise_for :users get 'welcome/index' - root 'welcome#index' + resources :docs - resources :docs + authenticated :user do + root "docs#index", as: "authenticated_root" + end + + root 'welcome#index' end
Change root of application for authenticated user
diff --git a/config/routes.rb b/config/routes.rb index abc1234..def5678 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,56 +1,3 @@ Rails.application.routes.draw do - # The priority is based upon order of creation: first created -> highest priority. - # See how all your routes lay out with "rake routes". - - # You can have the root of your site routed with "root" - # root 'welcome#index' - - # Example of regular route: - # get 'products/:id' => 'catalog#view' - - # Example of named route that can be invoked with purchase_url(id: product.id) - # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase - - # Example resource route (maps HTTP verbs to controller actions automatically): - # resources :products - - # Example resource route with options: - # resources :products do - # member do - # get 'short' - # post 'toggle' - # end - # - # collection do - # get 'sold' - # end - # end - - # Example resource route with sub-resources: - # resources :products do - # resources :comments, :sales - # resource :seller - # end - - # Example resource route with more complex sub-resources: - # resources :products do - # resources :comments - # resources :sales do - # get 'recent', on: :collection - # end - # end - - # Example resource route with concerns: - # concern :toggleable do - # post 'toggle' - # end - # resources :posts, concerns: :toggleable - # resources :photos, concerns: :toggleable - - # Example resource route within a namespace: - # namespace :admin do - # # Directs /admin/products/* to Admin::ProductsController - # # (app/controllers/admin/products_controller.rb) - # resources :products - # end -end + resources :articles +end
Create articles as a resource
diff --git a/spec/features/subapps_spec.rb b/spec/features/subapps_spec.rb index abc1234..def5678 100644 --- a/spec/features/subapps_spec.rb +++ b/spec/features/subapps_spec.rb @@ -10,6 +10,12 @@ response.send("logged in as #{request.params[:username]}") end cannon_app.mount(admin_app, at: '/admin') + + resources_app = Cannon::App.new(binding) + resources_app.get('/') do |request, response| + response.send('resources admin') + end + admin_app.mount(resources_app, at: '/resources') cannon_app.get('/info') do |request, response| response.send('Main Info') @@ -38,4 +44,9 @@ get '/admin/info' expect(response.body).to eq('Admin Info') end + + it 'allows mounting of apps within apps' do + get '/admin/resources/' + expect(response.body).to eq('resources admin') + end end
Add spec for confirming sub app mounting within app works
diff --git a/redis-rails-instrumentation.gemspec b/redis-rails-instrumentation.gemspec index abc1234..def5678 100644 --- a/redis-rails-instrumentation.gemspec +++ b/redis-rails-instrumentation.gemspec @@ -24,4 +24,5 @@ spec.add_development_dependency 'bundler', '~> 1.6' spec.add_development_dependency 'rake' spec.add_development_dependency 'rspec', '~> 3.0' + spec.required_ruby_version = '>= 2.0.0' end
Define 2.0.0 as minimum Ruby version
diff --git a/phantomjs.gemspec b/phantomjs.gemspec index abc1234..def5678 100644 --- a/phantomjs.gemspec +++ b/phantomjs.gemspec @@ -14,6 +14,9 @@ gem.add_development_dependency 'rspec', "~> 2.99" gem.add_development_dependency 'simplecov' gem.add_development_dependency 'rake' + if RUBY_VERSION < '2' + gem.add_development_dependency "mime-types", "~> 2.6" + end gem.files = `git ls-files`.split($\) gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
Fix Travis builds on Ruby 1.9 The mime-types gem versions 3+ no longer supports Ruby < 2.0. This sets a version constraint for Ruby versions less than 2.
diff --git a/app/models/item_default.rb b/app/models/item_default.rb index abc1234..def5678 100644 --- a/app/models/item_default.rb +++ b/app/models/item_default.rb @@ -1,6 +1,6 @@ class ItemDefault < ActiveRecord::Base include AuthUtilities - + acts_as_authorization_object has_one :playlist_item, :as => :resource_item
Fix for default item model git-svn-id: 40f48ef6be603b97d118b87e4ef5b23ea6e9fa7c@199 ac1452a4-9358-4c15-a3b0-de1119e254d8
diff --git a/files/private-chef-cookbooks/private-chef/recipes/add_ons_remote.rb b/files/private-chef-cookbooks/private-chef/recipes/add_ons_remote.rb index abc1234..def5678 100644 --- a/files/private-chef-cookbooks/private-chef/recipes/add_ons_remote.rb +++ b/files/private-chef-cookbooks/private-chef/recipes/add_ons_remote.rb @@ -7,6 +7,8 @@ case node['platform_family'] when 'debian' + + package "apt-transport-https" apt_repository 'chef-stable' do uri "https://packagecloud.io/chef/stable/ubuntu/"
Fix for missing apt-transport-http package under ubuntu
diff --git a/lib/miq_automation_engine/service_models/miq_ae_service_manageiq-providers-storage_manager-swift_manager.rb b/lib/miq_automation_engine/service_models/miq_ae_service_manageiq-providers-storage_manager-swift_manager.rb index abc1234..def5678 100644 --- a/lib/miq_automation_engine/service_models/miq_ae_service_manageiq-providers-storage_manager-swift_manager.rb +++ b/lib/miq_automation_engine/service_models/miq_ae_service_manageiq-providers-storage_manager-swift_manager.rb @@ -0,0 +1,7 @@+module MiqAeMethodService + class MiqAeServiceManageIQ_Providers_StorageManager_SwiftManager < MiqAeServiceManageIQ_Providers_StorageManager + expose :parent_manager, :association => true + expose :cloud_object_store_containers, :association => true + expose :cloud_object_store_objects, :association => true + end +end
Add automation engine service model for SwiftManager Omitted from prior commits. (transferred from ManageIQ/manageiq@14399372b77ba247d65d4d1800473ba09562e121)
diff --git a/provisioner/daemon/plugins/automators/chef_automator/chef_automator/cookbooks/loom_hosts/recipes/default.rb b/provisioner/daemon/plugins/automators/chef_automator/chef_automator/cookbooks/loom_hosts/recipes/default.rb index abc1234..def5678 100644 --- a/provisioner/daemon/plugins/automators/chef_automator/chef_automator/cookbooks/loom_hosts/recipes/default.rb +++ b/provisioner/daemon/plugins/automators/chef_automator/chef_automator/cookbooks/loom_hosts/recipes/default.rb @@ -1,8 +1,8 @@ # -# Cookbook Name:: hosts +# Cookbook Name:: loom_hosts # Recipe:: default # -# Copyright 2013, Continuuity, Inc. +# Copyright 2013-2014, Continuuity, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -18,9 +18,10 @@ # node['loom']['cluster']['nodes'].each do |n, v| + short_host = v.hostname.split('.').first hostsfile_entry v.ipaddress do hostname v.hostname - aliases [ v.hostname.gsub('.local','') ] + aliases [ short_host ] unique true action :create end
Fix aliases in /etc/hosts for machines using a DNS suffix other than '.local'
diff --git a/Casks/beersmith2.rb b/Casks/beersmith2.rb index abc1234..def5678 100644 --- a/Casks/beersmith2.rb +++ b/Casks/beersmith2.rb @@ -2,6 +2,7 @@ version '2.2.12' sha256 'e4aa64af9e9c65e0cfe132de67ab580d0c3b2f527d598fcda0d9b2cc84b74da6' + # amazonaws.com/BeerSmith2-2 was verified as official when first introduced to the cask url "https://s3.amazonaws.com/BeerSmith2-2/BeerSmith#{version.gsub('.', '_')}_64.dmg" name 'BeerSmith2' homepage 'http://beersmith.com'
Fix `url` stanza comment for BeerSmith2.
diff --git a/Casks/opera-beta.rb b/Casks/opera-beta.rb index abc1234..def5678 100644 --- a/Casks/opera-beta.rb +++ b/Casks/opera-beta.rb @@ -1,6 +1,6 @@ cask :v1 => 'opera-beta' do - version '29.0.1795.30' - sha256 '6ef44a4236ad4f29bfc2c66bc8b542fb583fb50fb7c267fbd4777ccaca59adcb' + version '29.0.1795.35' + sha256 '0b6ee1cad2b335bd95c1c77c24e13fabad80419f430a91e10ea62a4574064cac' url "http://get.geo.opera.com/pub/opera-beta/#{version}/mac/Opera_beta_#{version}_Setup.dmg" homepage 'http://www.opera.com/computer/beta'
Upgrade Opera Beta.app to v29.0.1795.35
diff --git a/publify_core/app/controllers/theme_controller.rb b/publify_core/app/controllers/theme_controller.rb index abc1234..def5678 100644 --- a/publify_core/app/controllers/theme_controller.rb +++ b/publify_core/app/controllers/theme_controller.rb @@ -32,8 +32,6 @@ src = this_blog.current_theme.path + "/#{type}/#{file}" return (render plain: 'Not Found', status: 404) unless File.exist? src - cache_page File.read(src) if perform_caching - send_file(src, type: mime, disposition: 'inline', stream: true) end
Remove last remaining page cache
diff --git a/db/data_migrations/20190122153116_add_filterable_class_name_to_audits.rb b/db/data_migrations/20190122153116_add_filterable_class_name_to_audits.rb index abc1234..def5678 100644 --- a/db/data_migrations/20190122153116_add_filterable_class_name_to_audits.rb +++ b/db/data_migrations/20190122153116_add_filterable_class_name_to_audits.rb @@ -0,0 +1,10 @@+class AddFilterableClassNameToAudits < ActiveRecord::DataMigration + def up + if SystemConfig.transam_module_loaded? :audit + Audit.where(class_name: "AssetAuditor").each do |audit| + audit.filterable_class_name = "FtaAssetCategory" + audit.save + end + end + end +end
[TTPLAT-633] Add data migration for filterable class name in audits.
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index abc1234..def5678 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -2,5 +2,10 @@ include Authenticatable include ErrorHandler - protect_from_forgery with: :null_session + protect_from_forgery with: :null_session unless Rails.env.development? + after_filter :set_csrf_cookie + + def set_csrf_cookie + cookies['CSRF-Token'] = form_authenticity_token if protect_against_forgery? + end end
Add csrf protection to API endpoints
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index abc1234..def5678 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -3,13 +3,16 @@ # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. protect_from_forgery with: :exception + helper_method :current_user + + rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized def current_user if cookies[:auth_token] return @current_user ||= User.find_by_auth_token!(cookies[:auth_token]) else - return false + return NullUser.new end end @@ -36,4 +39,8 @@ @session.persist(cookies) end + def user_not_authorized + flash[:alert] = "You are not authorized to perform this action." + redirect_to(login_path) + end end
Add Pundit Exception rescue to ApplicationController Updates the application controller to rescue pundit expections and redirects the user to the login page. We'll refactor this soon to make the redirects more relevant to where they originated.
diff --git a/app/controllers/contractors_controller.rb b/app/controllers/contractors_controller.rb index abc1234..def5678 100644 --- a/app/controllers/contractors_controller.rb +++ b/app/controllers/contractors_controller.rb @@ -1,8 +1,8 @@ class ContractorsController < ApplicationController def index @contractors = Contractor.all.sort { |a, b| b.total_est_contract_value <=> a.total_est_contract_value } - @contractor_history = PaperTrail::Version.where("created_at > ? and item_type = ? and event = ?", 2.week.ago, "Contractor", "create") - @contract_history = PaperTrail::Version.where("created_at > ? and item_type = ? and event = ?", 2.week.ago, "Contract", "create") + @contractor_history = PaperTrail::Version.where("item_type = ? and event = ?", "Contractor", "create") + @contract_history = PaperTrail::Version.where("item_type = ? and event = ?", "Contract", "create") @days_with_changes = PaperTrail::Version.group_by_day(:created_at).keys.map{|k| k.to_date}.reverse end end
Remove date query from version collections
diff --git a/app/controllers/derivatives_controller.rb b/app/controllers/derivatives_controller.rb index abc1234..def5678 100644 --- a/app/controllers/derivatives_controller.rb +++ b/app/controllers/derivatives_controller.rb @@ -33,6 +33,8 @@ derivative.masterfile = masterfile masterfile.save derivative.save + + render :nothing => true end end
Fix MH postback of rtmp url in a production environment
diff --git a/app/controllers/json/status_controller.rb b/app/controllers/json/status_controller.rb index abc1234..def5678 100644 --- a/app/controllers/json/status_controller.rb +++ b/app/controllers/json/status_controller.rb @@ -14,8 +14,8 @@ res_body = http_get_response_body("http://#{server}/status-json.xsl") rescue nil next if res_body.nil? icecast_status = JSON.parse(res_body) - icecast_source = icecast_status['icestats']['source'] - listeners = icecast_source ? icecast_source['listeners'].to_i : 0 + icecast_sources = icecast_status['icestats']['source'] + listeners = Array(icecast_sources).map { |source| source['listeners'] }.inject(0, :+) total_listeners += listeners end items[:date] = Time.now.utc
Fix online listeners calculation formula
diff --git a/spec/support/examples_group/shared_examples_for_column_migration.rb b/spec/support/examples_group/shared_examples_for_column_migration.rb index abc1234..def5678 100644 --- a/spec/support/examples_group/shared_examples_for_column_migration.rb +++ b/spec/support/examples_group/shared_examples_for_column_migration.rb @@ -0,0 +1,17 @@+# it tests data migration for one column +# Example: +# include_examples "column migration", :type, :ExtManagementSystem, ["Old Data Field", "New Data Field"] +shared_examples_for "column migration" do |column, klass, data_to_convert| + let(:stub) { migration_stub(klass) } + let(:old_data_field) { data_to_convert.first } + let(:new_data_field) { data_to_convert.second } + + it "migrates column #{column} of #{klass}" do + rec = stub.create!(column => old_data_field) + + migrate + + column_value = rec.reload.send(column) + expect(column_value).to eq(new_data_field) + end +end
Add spec for data migration of one column to shared examples
diff --git a/spec/features/user_views_solicitors_list_spec.rb b/spec/features/user_views_solicitors_list_spec.rb index abc1234..def5678 100644 --- a/spec/features/user_views_solicitors_list_spec.rb +++ b/spec/features/user_views_solicitors_list_spec.rb @@ -1,8 +1,15 @@ require "rails_helper" RSpec.feature "User views a list of solicitors" do + def sign_in_using_dsds_auth + visit root_path + end + scenario "on their dashboard" do expected_solicitor_names = "Bob Smith", "Andy Brown" + + mock_token + mock_profile sign_in_using_dsds_auth
Update test to use new sign in helpers
diff --git a/feedzirra.gemspec b/feedzirra.gemspec index abc1234..def5678 100644 --- a/feedzirra.gemspec +++ b/feedzirra.gemspec @@ -16,6 +16,8 @@ s.files = Dir['{lib/spec}/**/*.rb'] + %w[README.textile Rakefile .rspec] s.test_files = Dir['spec/**/*.rb'] + s.platform = Gem::Platform::RUBY + s.add_runtime_dependency 'nokogiri', ['> 0.0.0'] s.add_runtime_dependency 'sax-machine', ['>= 0.0.12'] s.add_runtime_dependency 'curb', ['>= 0.2.3']
Add missing platform setting in gemspec
diff --git a/spec/support/define_rails_classes.rb b/spec/support/define_rails_classes.rb index abc1234..def5678 100644 --- a/spec/support/define_rails_classes.rb +++ b/spec/support/define_rails_classes.rb @@ -13,9 +13,9 @@ FATAL = 4 attr_accessor :level - def initialize(device) - @logdev = MyLogDevice.new(device) - @level = WARN + def initialize(logdev, *_) + @logdev = logdev + self.level = WARN end def info(*_); end @@ -23,7 +23,7 @@ module MyClass def logger - @logger ||= MyDefaultLogger.new(STDOUT) + @logger ||= MyDefaultLogger.new(MyLogDevice.new(STDOUT)) end def logger=(value)
Make fake logger class more like Rails
diff --git a/test/filters/test_rdiscount.rb b/test/filters/test_rdiscount.rb index abc1234..def5678 100644 --- a/test/filters/test_rdiscount.rb +++ b/test/filters/test_rdiscount.rb @@ -14,16 +14,17 @@ end end - def test_with_extensions - if_have 'rdiscount' do - # Create filter - filter = ::Nanoc::Filters::RDiscount.new - - # Run filter - input = "The quotation 'marks' sure make this look sarcastic!" - output_expected = /The quotation &lsquo;marks&rsquo; sure make this look sarcastic!/ - output_actual = filter.setup_and_run(input, extensions: [:smart]) - assert_match(output_expected, output_actual) - end - end + # FIXME: Re-enable this test (flaky; quotation marks are not transformed consistently) + # def test_with_extensions + # if_have 'rdiscount' do + # # Create filter + # filter = ::Nanoc::Filters::RDiscount.new + # + # # Run filter + # input = "The quotation 'marks' sure make this look sarcastic!" + # output_expected = /The quotation &lsquo;marks&rsquo; sure make this look sarcastic!/ + # output_actual = filter.setup_and_run(input, extensions: [:smart]) + # assert_match(output_expected, output_actual) + # end + # end end
Revert "Re-enable rdiscount extensions test" This reverts commit 0bb17fff6bd1197909f1e49bceba91d84529f03a. Still flaky?!
diff --git a/spec/replication/util/migration_order_spec.rb b/spec/replication/util/migration_order_spec.rb index abc1234..def5678 100644 --- a/spec/replication/util/migration_order_spec.rb +++ b/spec/replication/util/migration_order_spec.rb @@ -17,22 +17,29 @@ current_release_migrations.last end + def invalid_migrations_message(incorrect_migration_time_stamps, last_released_migration) + <<-EOS +The following migration timestamps are too early to be included in the next release: + +#{incorrect_migration_time_stamps.join("\n")} + +These migrations must be regenerated so that they will run after the latest +released migration, #{last_released_migration}. + +This is done to prevent schema differences between migrated databases and +newly created ones where all the migrations are run in timestamp order. +EOS + end + it "is correct" do incorrect_migration_time_stamps = [] new_migrations.each do |m| incorrect_migration_time_stamps << m if m < last_released_migration end - expect(incorrect_migration_time_stamps).to be_empty, <<-EOS.gsub!(/^ +/, "") - The following migration timestamps are too early to be included in the next release: - - #{incorrect_migration_time_stamps.join("\n")} - - These migrations must be regenerated so that they will run after the latest - released migration, #{last_released_migration}. - - This is done to prevent schema differences between migrated databases and - newly created ones where all the migrations are run in timestamp order. - EOS + expect(incorrect_migration_time_stamps).to( + be_empty, + invalid_migrations_message(incorrect_migration_time_stamps, last_released_migration) + ) end end
Change the invalid migration message to live in a method The reasoning for this is that RSpec spits out the failing line in addition to the message. Since the long string is part of the line, it appears "twice" in the RSpec message which is confusing. By moving it into a method, then the output won't contain the first of the 2 messages.
diff --git a/spec/cucumber/world/pending_spec.rb b/spec/cucumber/world/pending_spec.rb index abc1234..def5678 100644 --- a/spec/cucumber/world/pending_spec.rb +++ b/spec/cucumber/world/pending_spec.rb @@ -29,7 +29,7 @@ @world.pending "TODO" do m = double('thing') m.should_receive(:foo) - m.rspec_verify + RSpec::Mocks.verify end }.should raise_error(Cucumber::Pending, /TODO/) end
Fix spec change due to RSpec update. RSpec mocks interface has changed - rspec_verify removed.
diff --git a/roles/lysator.rb b/roles/lysator.rb index abc1234..def5678 100644 --- a/roles/lysator.rb +++ b/roles/lysator.rb @@ -11,7 +11,7 @@ :hosted_by => "Lysator", :location => "Linköping, Sweden", :networking => { - :nameservers => ["130.236.254.225", "2001:6b0:17:f0a0::e1"], + :nameservers => ["130.236.254.225", "2001:6b0:17:f0a0::e1", "130.236.254.4"], :roles => { :external => { :zone => "osm"
Add an extra resolve for nidhogg
diff --git a/rsscache.gemspec b/rsscache.gemspec index abc1234..def5678 100644 --- a/rsscache.gemspec +++ b/rsscache.gemspec @@ -18,11 +18,11 @@ spec.test_files = spec.files.grep('^(test|spec|features)/') spec.require_paths = ['lib'] - spec.add_dependency 'simple-rss' + spec.add_dependency 'simple-rss', '~> 1.3.1' spec.add_development_dependency 'bundler', '~> 1.5' - spec.add_development_dependency 'fakeweb' - spec.add_development_dependency 'rake' - spec.add_development_dependency 'rspec' - spec.add_development_dependency 'rubocop' + spec.add_development_dependency 'fakeweb', '~> 1.3.0' + spec.add_development_dependency 'rake', '~> 10.3.2' + spec.add_development_dependency 'rspec', '~> 3.0.0' + spec.add_development_dependency 'rubocop', '~> 0.24.1' end
Add version constraints to dependencies
diff --git a/spec/classes/mailman_spec.rb b/spec/classes/mailman_spec.rb index abc1234..def5678 100644 --- a/spec/classes/mailman_spec.rb +++ b/spec/classes/mailman_spec.rb @@ -0,0 +1,25 @@+require 'spec_helper' + +describe 'mailman' do + + let :params do + { :password => 'password', :admin_email => 'admin@email.com' } + end + + it 'installs mailman' do + is_expected.to contain_class('mailman::install') + end + + it 'configures mailman' do + is_expected.to contain_class('mailman::config') + end + + it 'runs the mailman service' do + is_expected.to contain_class('mailman::service') + end + + it 'creates the mailman mailing lists' do + is_expected.to contain_class('mailman::lists') + end + +end
unit-test: Add test for mailman class
diff --git a/spec/helpers/locales_helper_spec.rb b/spec/helpers/locales_helper_spec.rb index abc1234..def5678 100644 --- a/spec/helpers/locales_helper_spec.rb +++ b/spec/helpers/locales_helper_spec.rb @@ -13,6 +13,7 @@ after do I18n.backend.reload! I18n.enforce_available_locales = default_enforce + I18n.backend.send(:init_translations) end it "returns the language name in i18n.language.name translation" do @@ -29,4 +30,4 @@ end end -end+end
Fix flaky spec for translations This spec was causing a side effect on another spec[2], making it fail 😌 I think it was because no translation had been called yet, in the failing spec, and so the the i18n backend translations had not been initialized, and was always returning empty translations for any locale. This might have been due to tampering with translations in the this newly introduced spec. By forcing translations to load after this new spec, the other spec passes again [2] https://github.com/AyuntamientoMadrid/consul/blob/master/spec/features/localization_spec.rb#L20
diff --git a/roles/datahata.rb b/roles/datahata.rb index abc1234..def5678 100644 --- a/roles/datahata.rb +++ b/roles/datahata.rb @@ -2,6 +2,11 @@ description "Role applied to all servers at DataHata" default_attributes( + :accounts => { + :users => { + :kom => { :status => :administrator } + } + }, :networking => { :nameservers => [ "31.130.200.2"
Make komzpa an admin on cmok
diff --git a/resources/chef-repo/site-cookbooks/mysql_part/recipes/create_database.rb b/resources/chef-repo/site-cookbooks/mysql_part/recipes/create_database.rb index abc1234..def5678 100644 --- a/resources/chef-repo/site-cookbooks/mysql_part/recipes/create_database.rb +++ b/resources/chef-repo/site-cookbooks/mysql_part/recipes/create_database.rb @@ -32,7 +32,7 @@ mysql_database_user node['mysql_part']['app']['username'] do connection mysql_connection_info database_name node['mysql_part']['app']['database'] - host '127.0.0.1' + host '%' privileges node['mysql_part']['app']['privileges'] require_ssl node['mysql_part']['app']['require_ssl'] action :grant
Allow access to mysql from other instances
diff --git a/lib/chef-api/resources/search.rb b/lib/chef-api/resources/search.rb index abc1234..def5678 100644 --- a/lib/chef-api/resources/search.rb +++ b/lib/chef-api/resources/search.rb @@ -10,7 +10,7 @@ class << self # - # About search : http://docs.opscode.com/essentials_search.html + # About search : https://docs.chef.io/chef_search.html # # @param [String] index # the name of the index to search
Change Search docs URI to docs.chef.io
diff --git a/lib/deep_cover/node/arguments.rb b/lib/deep_cover/node/arguments.rb index abc1234..def5678 100644 --- a/lib/deep_cover/node/arguments.rb +++ b/lib/deep_cover/node/arguments.rb @@ -38,6 +38,9 @@ class Args < Node has_child arguments: [Arg, Optarg, Restarg, Kwarg, Kwoptarg, Kwrestarg, Blockarg], rest: true + def executable? + false + end end end end
Mark args as non executable
diff --git a/lib/inuit-rails/rails/version.rb b/lib/inuit-rails/rails/version.rb index abc1234..def5678 100644 --- a/lib/inuit-rails/rails/version.rb +++ b/lib/inuit-rails/rails/version.rb @@ -1,5 +1,5 @@ module Inuit module Rails - VERSION = "6.0.0.beta.5" + VERSION = "6.0.0.beta.6" end end
Tweak to generator output file
diff --git a/activesupport-db-cache.gemspec b/activesupport-db-cache.gemspec index abc1234..def5678 100644 --- a/activesupport-db-cache.gemspec +++ b/activesupport-db-cache.gemspec @@ -1,6 +1,6 @@ # -*- encoding: utf-8 -*- $:.push File.expand_path("../lib", __FILE__) -require File.expand_path('../lib/activesupport-db-cache', __FILE__) +require 'activesupport-db-cache' Gem::Specification.new do |gem| gem.authors = ["Sergei O. Udalov"]
Correct the require not to use relative path
diff --git a/lib/rambo/raml_models/headers.rb b/lib/rambo/raml_models/headers.rb index abc1234..def5678 100644 --- a/lib/rambo/raml_models/headers.rb +++ b/lib/rambo/raml_models/headers.rb @@ -17,17 +17,14 @@ end def pretty - beginning, ending = "{\n", "}" + beginning = "{\n" + ending = "}" - contents = headers.to_a.each_with_index.map {|pair| - if headers.to_a.index(pair) == headers.length - 1 - "\t\"#{pair.first}\" => \"#{pair.last}\"\n" # No comma after last item - else - "\t\"#{pair.first}\" => \"#{pair.last}\"\n" - end + contents = headers.to_a.map {|pair| + "\t\"#{pair.first}\" => \"#{pair.last}\"\n" } - "#{beginning}#{contents.join}#{ending}" + "#{beginning}#{contents.join("")}#{ending}" end end end
Mark test as pending :/
diff --git a/app/models/parted.rb b/app/models/parted.rb index abc1234..def5678 100644 --- a/app/models/parted.rb +++ b/app/models/parted.rb @@ -13,7 +13,7 @@ output = super return output unless latest_edition output['additional_links'] = [] - latest_edition.parts.each do |part| + latest_edition.parts.each_with_index do |part, index| if _type.downcase == 'programme' && part.slug != 'further-information' link = "/#{slug}\##{part.slug}" else @@ -21,7 +21,8 @@ end output['additional_links'] << { 'title' => part.title, - 'link' => link + 'link' => link, + 'link_order' => index } end output
Add the link order to additional links
diff --git a/app/models/school.rb b/app/models/school.rb index abc1234..def5678 100644 --- a/app/models/school.rb +++ b/app/models/school.rb @@ -1,3 +1,7 @@ class School < ActiveRecord::Base + include PgSearch + has_many :programs + multisearchable :against => [:school_name, :school_type] + end
Change pg_search from pg_search_scope to multisearchable against
diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb index abc1234..def5678 100644 --- a/spec/controllers/sessions_controller_spec.rb +++ b/spec/controllers/sessions_controller_spec.rb @@ -0,0 +1,60 @@+require 'rails_helper' + +RSpec.describe SessionsController, type: :controller do + let!(:user) { build(:user) } + + context "GET #new)" do + it "responds successfully with an HTTP 200 status code" do + get :new + expect(response).to be_success + expect(response).to have_http_status(200) + end + + it "renders the login template" do + get :new + expect(response).to render_template("new") + end + end + + context "POST #create" do + before(:each) { user.save } + context "with valid attributes" do + it "logs the user in" do + post :create, params: { email: user.email, password: user.password } + expect(session['user_id']).to eq user.id + end + + it "redirects to the current user" do + post :create, params: { email: user.email, password: user.password } + expect(response).to redirect_to user + end + end + + context "with invalid attributes" do + before(:each) { user.save } + it "does not log the user in" do + post :create, params: { email: "tj@momicello.com", password: user.password } + expect(session['user_id']).to be nil + end + + it "re-renders the new template" do + post :create, params: { email: user.email, password: "1253sir3" } + expect(response).to redirect_to '/login' + end + end + end + + context "DELETE #destroy)" do + before(:each) { user.save } + + it "redirects to /login" do + delete :destroy + expect(response).to redirect_to login_path + end + + it "empties the sessions hash" do + delete :destroy + expect(session['user_id']).to be nil + end + end +end
Add tests for sessions controller; all tests pass
diff --git a/lib/tasks/move_to_paperclip.rake b/lib/tasks/move_to_paperclip.rake index abc1234..def5678 100644 --- a/lib/tasks/move_to_paperclip.rake +++ b/lib/tasks/move_to_paperclip.rake @@ -0,0 +1,50 @@+namespace :onebody do + + desc 'Move existing pictures and files to new locations for OneBody 2.0.0.' + task :move_to_paperclip => :environment do + require 'fileutils' + paths = Dir[DB_PHOTO_PATH.join('**/*')].to_a + \ + Dir[DB_ATTACHMENTS_PATH.join('**/*')].to_a + paths.each_with_index do |path, index| + if path =~ %r{db/photos} + _, collection, id, _, env, size = path.match(%r{db/photos/(.+)/(\d+)(\.(test|development))?\.(tn|small|medium|large|full)\.jpg}).to_a + next if size != 'full' + attribute = 'photo' + else + _, collection, id, _, env, extension = path.match(%r{db/(.+)/(\d+)(\.(test|development))?\.(.+)$}).to_a + attribute = 'file' + end + next if collection.nil? + next if collection == 'recipes' + klass = Object.const_get(collection.singularize.capitalize) + env = 'production' if env.nil? + next if Rails.env.to_s != env + begin + object = klass.unscoped { klass.find(id) } + rescue ActiveRecord::RecordNotFound + puts "Warning: #{klass.name} with id #{id} was not found." + puts " This file/photo was not copied: #{path}" + else + object.send("#{attribute}=", File.open(path)) + #klass.skip_callback :save do + #object.save(:validate => false) + #end + #object.save_attached_files + # manually update db so as to not trigger any callbacks + Person.connection.execute("UPDATE #{collection} SET #{attribute}_updated_at='#{Time.now.utc}', #{attribute}_fingerprint='#{object.attributes[attribute + '_fingerprint']}', #{attribute}_file_size=#{object.attributes[attribute + '_file_size']}, #{attribute}_content_type='#{object.attributes[attribute + '_content_type']}', #{attribute}_file_name='#{object.attributes[attribute + '_file_name']}' WHERE id=#{object.id}") + puts "Copied #{path} =>\n #{object.send(attribute).path}" + end + puts " #{index+1}/#{paths.length} complete." + end + if paths.any? + puts + puts "============================================================================" + puts "Operation complete." + puts "Please check that all photos and files are in place in public/system." + puts "Then you can delete the db/photos and db/attachments dirs." + puts "============================================================================" + puts + end + end + +end
Put back rake task that was used in migration. Oops.
diff --git a/spec/coverage.rb b/spec/coverage.rb index abc1234..def5678 100644 --- a/spec/coverage.rb +++ b/spec/coverage.rb @@ -7,5 +7,5 @@ formatters << Coveralls::SimpleCov::Formatter end -SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[*formatters] +SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(formatters) SimpleCov.start
Fix test suite for Ruby 2.4 compatibility.
diff --git a/spec/support/uses_tmp_dir.rb b/spec/support/uses_tmp_dir.rb index abc1234..def5678 100644 --- a/spec/support/uses_tmp_dir.rb +++ b/spec/support/uses_tmp_dir.rb @@ -0,0 +1,12 @@+require 'tmpdir' + +shared_context :uses_tmp_dir do + around do |example| + Dir.mktmpdir('yacs-rspec-') do |dir| + @tmp_dir = dir + example.run + end + end + + attr_reader :tmp_dir +end
yacs: Add helper to create tmp dirs in rspec
diff --git a/services/prowl.rb b/services/prowl.rb index abc1234..def5678 100644 --- a/services/prowl.rb +++ b/services/prowl.rb @@ -1,14 +1,15 @@ service :prowl do |data, payload| url = URI.parse('https://prowl.weks.net/publicapi/add') repository = payload['repository']['url'].split("/") - application = repository[-2], "/", repository[-1] + event = repository[-2], "/", repository[-1] + application = "GitHub" description = "#{payload['commits'].length} commits pushed to #{application} (#{payload['commits'][-1]['id'][0..7]}..#{payload['commits'][0]['id'][0..7]}) Latest Commit by #{payload['commits'][-1]['author']['name']} #{payload['commits'][-1]['id'][0..7]} #{payload['commits'][-1]['message']}" req = Net::HTTP::Post.new(url.path) - req.set_form_data('apikey' => data['apikey'], 'application' => application, 'description' => description) + req.set_form_data('apikey' => data['apikey'], 'application' => application, 'event' => event, 'description' => description) http = Net::HTTP.new(url.host, url.port) http.use_ssl = true if url.port == 443 || url.instance_of?(URI::HTTPS)
Move repo name into 'event' field, use generic 'GitHub' for application name. Potentially helpful for easy redirection to iOctocat (possibly also to the specific repo in the future).
diff --git a/definitions/user_ulimit.rb b/definitions/user_ulimit.rb index abc1234..def5678 100644 --- a/definitions/user_ulimit.rb +++ b/definitions/user_ulimit.rb @@ -9,8 +9,15 @@ # memory_limit 1024 # end -define :user_ulimit, :filehandle_limit => nil, :process_limit => nil, :memory_limit => nil, :stack_soft_limit => nil, :stack_hard_limit => nil do - template "/etc/security/limits.d/#{params[:name]}_limits.conf" do +define :user_ulimit, :filehandle_limit => nil, :process_limit => nil, :memory_limit => nil, :stack_soft_limit => nil, :stack_hard_limit => nil, :filename => nil do + + if params[:filename].nil? + filename = "/etc/security/limits.d/#{params[:name]}_limits.conf" + else + filename = "/etc/security/limits.d/#{params[:filename]}.conf" + end + + template filename do source "ulimit.erb" cookbook "ulimit" owner "root"
Allow passing a param to change the filename of the conf file.
diff --git a/db/migrate/20190806071559_remove_epic_issues_default_relative_position.rb b/db/migrate/20190806071559_remove_epic_issues_default_relative_position.rb index abc1234..def5678 100644 --- a/db/migrate/20190806071559_remove_epic_issues_default_relative_position.rb +++ b/db/migrate/20190806071559_remove_epic_issues_default_relative_position.rb @@ -3,8 +3,23 @@ class RemoveEpicIssuesDefaultRelativePosition < ActiveRecord::Migration[5.2] DOWNTIME = false - def change - change_column_null :epic_issues, :relative_position, true - change_column_default :epic_issues, :relative_position, from: 1073741823, to: nil + include Gitlab::Database::MigrationHelpers + + disable_ddl_transaction! + + def up + # The column won't exist if someone installed EE, downgraded to CE + # before it was added in EE, then tries to upgrade CE. + if column_exists?(:epic_issues, :relative_position) + change_column_null :epic_issues, :relative_position, true + change_column_default :epic_issues, :relative_position, from: 1073741823, to: nil + else + add_column_with_default(:epic_issues, :relative_position, :integer, default: nil, allow_null: true) + end + end + + def down + change_column_default :epic_issues, :relative_position, from: nil, to: 1073741823 + change_column_null :epic_issues, :relative_position, false end end
Make epic_issues relative_position migration more robust If someone installed EE, then downgraded to CE before this column was added, upgrading to the latest version of CE will fail: 1. We have a backport migration for the entire EE schema but the table `epic_issues` exists, just not the `relative_position` column. 2. The migration that changes the default (quite reasonably) didn't check if the column exists. If the column doesn't exist, we can just create it with the correct default.
diff --git a/spec/helpers/application_helper/buttons/generic_feature_button_with_disable_spec.rb b/spec/helpers/application_helper/buttons/generic_feature_button_with_disable_spec.rb index abc1234..def5678 100644 --- a/spec/helpers/application_helper/buttons/generic_feature_button_with_disable_spec.rb +++ b/spec/helpers/application_helper/buttons/generic_feature_button_with_disable_spec.rb @@ -5,5 +5,16 @@ let(:props) { {:options => {:feature => feature}} } let(:button) { described_class.new(view_context, {}, {'record' => record}, props) } - it_behaves_like 'a generic feature button with disabled' + context 'the feature is unavailable' do + let(:supports_feature) { false } + + it 'the button is visible' do + expect(button.visible?).to be_truthy + end + + it 'the button has error message in the title' do + button.calculate_properties + expect(button[:title]).not_to be(nil) + end + end end
Fix failing spec for generic feature button with disable
diff --git a/test/setup.rb b/test/setup.rb index abc1234..def5678 100644 --- a/test/setup.rb +++ b/test/setup.rb @@ -1,3 +1,4 @@ require 'xpool' require 'minitest/mock' require 'test/unit' +XPool.debug = ENV.has_key? "DEBUG"
Add debug switch to test environment.
diff --git a/app/controllers/application.rb b/app/controllers/application.rb index abc1234..def5678 100644 --- a/app/controllers/application.rb +++ b/app/controllers/application.rb @@ -22,4 +22,11 @@ end helper_method :space, :space! + + before_filter :not_activated_warning + def not_activated_warning + if authenticated? && ! current_agent.active? + flash[:notice] = "Your account isn't activated. Please, check your email to activate it." + end + end end
Add before filter to warn users that are not already authenticated
diff --git a/app/helpers/sessions_helper.rb b/app/helpers/sessions_helper.rb index abc1234..def5678 100644 --- a/app/helpers/sessions_helper.rb +++ b/app/helpers/sessions_helper.rb @@ -1,2 +1,13 @@ module SessionsHelper + + def sign_in(user) + remember_token = User.new_remember_token + cookies.permanent[remember_token] = remember_token + user.update_attribute(:remember_token, User.digest(remember_token)) + self.current_user = user + end + + def current_user=(user) + @current_user = user + end end
Create a sign-in action with a token
diff --git a/test/functional/admin/base_controller_test.rb b/test/functional/admin/base_controller_test.rb index abc1234..def5678 100644 --- a/test/functional/admin/base_controller_test.rb +++ b/test/functional/admin/base_controller_test.rb @@ -0,0 +1,41 @@+require "test_helper" + +=begin + + What's being tested here? + + - Access to user_guide. + - ... + +=end + +class Admin::BaseControllerTest < ActionController::TestCase + + context "non-authenticated" do + + should "not be able to get the user_guide" do + get :user_guide + assert_response :redirect + assert_redirected_to new_admin_session_path(:back_to => '/admin/user_guide') + end + + end + + context "authenticated" do + + setup do + @request.session[:typus_user_id] = Factory(:typus_user).id + end + + teardown do + @request.session[:typus_user_id] = nil + end + + should "be able to get the user_guide" do + get :user_guide + assert_response :success + end + + end + +end
Make sure user_guide is only accessible to authenticated users
diff --git a/examples/firehose-consumer.rb b/examples/firehose-consumer.rb index abc1234..def5678 100644 --- a/examples/firehose-consumer.rb +++ b/examples/firehose-consumer.rb @@ -0,0 +1,57 @@+$LOAD_PATH.unshift(File.expand_path("../../lib", __FILE__)) + +require "kafka" + +KAFKA_CLIENT_CERT = ENV.fetch("KAFKA_CLIENT_CERT") +KAFKA_CLIENT_CERT_KEY = ENV.fetch("KAFKA_CLIENT_CERT_KEY") +KAFKA_SERVER_CERT = ENV.fetch("KAFKA_SERVER_CERT") +KAFKA_URL = ENV.fetch("KAFKA_URL") +KAFKA_BROKERS = KAFKA_URL.gsub("kafka+ssl://", "").split(",") +KAFKA_TOPIC = "test-messages" + +NUM_THREADS = 4 + +queue = Queue.new + +threads = NUM_THREADS.times.map do + Thread.new do + logger = Logger.new($stderr) + logger.level = Logger::INFO + + kafka = Kafka.new( + seed_brokers: KAFKA_BROKERS, + logger: logger, + connect_timeout: 30, + socket_timeout: 30, + ssl_client_cert: KAFKA_CLIENT_CERT, + ssl_client_cert_key: KAFKA_CLIENT_CERT_KEY, + ssl_ca_cert: KAFKA_SERVER_CERT, + ) + + consumer = kafka.consumer(group_id: "firehose") + consumer.subscribe(KAFKA_TOPIC) + + begin + i = 0 + consumer.each_message do |message| + i += 1 + + if i % 100 == 0 + queue << i + i = 0 + end + end + ensure + consumer.shutdown + end + end +end + +threads.each {|t| t.abort_on_exception = true } + +received_messages = 0 + +loop do + received_messages += queue.pop + puts "===> Received #{received_messages} messages" +end
Add a balanced consumer example
diff --git a/app/helpers/session_helper.rb b/app/helpers/session_helper.rb index abc1234..def5678 100644 --- a/app/helpers/session_helper.rb +++ b/app/helpers/session_helper.rb @@ -1,5 +1,5 @@ module SessionHelper - def find_question(recent_question, id) + def find_question(recent_questions, id) recent_questions.each do |question| if question.questionId == id return question
Add sorted question link details
diff --git a/lib/ahoy_matey.rb b/lib/ahoy_matey.rb index abc1234..def5678 100644 --- a/lib/ahoy_matey.rb +++ b/lib/ahoy_matey.rb @@ -11,7 +11,11 @@ module Ahoy def self.visit_model - ::Visit + @visit_model || ::Visit + end + + def self.visit_model=(visit_model) + @visit_model = visit_model end # TODO private @@ -26,7 +30,7 @@ ActiveRecord::Base.send(:extend, Ahoy::Model) if defined?(ActiveRecord) if defined?(Warden) - Warden::Manager.after_authentication do |user, auth, opts| + Warden::Manager.after_set_user except: :fetch do |user, auth, opts| request = Rack::Request.new(auth.env) if request.cookies["ahoy_visit"] visit = Ahoy.visit_model.where(visit_token: request.cookies["ahoy_visit"]).first
Attach user on devise sign up and added ability to specify visit model
diff --git a/spec/test_node.rb b/spec/test_node.rb index abc1234..def5678 100644 --- a/spec/test_node.rb +++ b/spec/test_node.rb @@ -25,9 +25,9 @@ end end -class TestApplication < Celluloid::Application - supervise DCell::Application +class TestGroup < Celluloid::Group + supervise DCell::Group supervise TestActor, :as => :test_actor end -TestApplication.run +TestGroup.run
Use Celluloid::Group for defining the test node
diff --git a/core/db/migrate/20170323151450_add_missing_unique_indexes_for_unique_attributes.rb b/core/db/migrate/20170323151450_add_missing_unique_indexes_for_unique_attributes.rb index abc1234..def5678 100644 --- a/core/db/migrate/20170323151450_add_missing_unique_indexes_for_unique_attributes.rb +++ b/core/db/migrate/20170323151450_add_missing_unique_indexes_for_unique_attributes.rb @@ -0,0 +1,28 @@+class AddMissingUniqueIndexesForUniqueAttributes < ActiveRecord::Migration[5.0] + def change + tables = { + spree_countries: [:name, :iso_name], + spree_option_types: [:name], + spree_option_values: [:name], + spree_promotions: [:path], + spree_refund_reasons: [:name], + spree_reimbursement_types: [:name], + spree_return_authorization_reasons: [:name], + spree_roles: [:name], + spree_shipping_categories: [:name], + spree_stores: [:code], + spree_tax_categories: [:name], + spree_trackers: [:analytics_id], + spree_zones: [:name] + } + + tables.each do |table, columns| + columns.each do |column| + unless index_exists?(table, column, unique: true) + remove_index table, column if index_exists?(table, column) + add_index table, column, unique: true + end + end + end + end +end
Add indexes for unique attributes
diff --git a/lib/backup-gitbucket/tools.rb b/lib/backup-gitbucket/tools.rb index abc1234..def5678 100644 --- a/lib/backup-gitbucket/tools.rb +++ b/lib/backup-gitbucket/tools.rb @@ -2,6 +2,18 @@ require 'json' module BackupGitBucket + + class HTTPInstrumentor + class << self + attr_accessor :events + + def instrument(name, params = {}, &block) + puts "#{name} just happened: #{params.inspect}" + yield if block_given? + end + end + end + module HTTPTools def basic_auth(username, password) credentials = Base64.encode64("#{username}:#{password}").strip
Add instrumentor to debug BitBucket issues.
diff --git a/lib/can_haz_poster/grabber.rb b/lib/can_haz_poster/grabber.rb index abc1234..def5678 100644 --- a/lib/can_haz_poster/grabber.rb +++ b/lib/can_haz_poster/grabber.rb @@ -25,7 +25,8 @@ def parse_movie_url(page, year) doc = Nokogiri::HTML(page) cell = doc.css('.content td:nth-child(2)').find do |cell| - cell.css('span b').first.content == year.to_s + year_span = cell.css('span b').first + year_span && year_span.content == year.to_s end raise MovieNotFoundError if cell.nil?
Add a nil-check when fetching a year Some of the movies on the site may have no year specified. Check is required to not fail on these.
diff --git a/week-6/nested_data_solution.rb b/week-6/nested_data_solution.rb index abc1234..def5678 100644 --- a/week-6/nested_data_solution.rb +++ b/week-6/nested_data_solution.rb @@ -7,7 +7,7 @@ # attempts: # ============================================================ - +p array[1][1][2][0] # ============================================================ @@ -19,7 +19,7 @@ # attempts: # ============================================================ - +p hash[:outer][:inner]["almost"][3] # ============================================================ @@ -32,7 +32,7 @@ # attempts: # ============================================================ - +p nested_data[:array][1][:hash] # ============================================================ @@ -40,8 +40,28 @@ number_array = [5, [10, 15], [20,25,30], 35] +number_array.map! do |x| + x.is_a?(Integer) ? x*5 : x.map! {|y| y * 5} +end +p number_array # Bonus: -startup_names = ["bit", ["find", "fast", ["optimize", "scope"]]]+startup_names = ["bit", ["find", "fast", ["optimize", "scope"]]] + +startup_names.map! do |x| + if x.is_a?(Array) + x.map! do |y| + if y.is_a?(Array) + y.map! do |b| + b + "ly" + end + else y + "ly" + end + end + else x + "ly" + end +end + +p startup_names
Complete nested data solution pair challenge
diff --git a/lib/ktutils/os.rb b/lib/ktutils/os.rb index abc1234..def5678 100644 --- a/lib/ktutils/os.rb +++ b/lib/ktutils/os.rb @@ -10,13 +10,16 @@ module Ktutils # Sourced from # http://stackoverflow.com/questions/170956/how-can-i-find-which-operating-system-my-ruby-program-is-running-on/171011#171011 + # NOTE: When running on jruby, "arch" returns universal-java1.7 (or similar) + # Use "host_os" instead. + # module OS def OS.windows? - (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RbConfig::CONFIG["arch"]) != nil + (/mswin|mingw|bccwin|wince|emx/ =~ RbConfig::CONFIG["host_os"]) != nil end def OS.mac? - (/darwin/ =~ RbConfig::CONFIG["arch"]) != nil + (/darwin|mac/ =~ RbConfig::CONFIG["host_os"]) != nil end def OS.unix?
Change how OS is detected * Use host_os instead of arch
diff --git a/lib/pay/engine.rb b/lib/pay/engine.rb index abc1234..def5678 100644 --- a/lib/pay/engine.rb +++ b/lib/pay/engine.rb @@ -4,31 +4,32 @@ config.autoload_paths += Dir["#{config.root}/lib/**/"] + initializer 'pay.processors' do + ActiveSupport::Reloader.to_prepare do + # Include processor backends + if defined? Stripe + Dir[File.join(__dir__, 'pay/stripe', '**', '*.rb')].each { |file| require file } - initializer 'pay.processors' do - # Include processor backends - if defined? Stripe - Dir[File.join(__dir__, 'pay/stripe', '**', '*.rb')].each { |file| require file } + Pay.charge_model.include Pay::Stripe::Charge + Pay.subscription_model.include Pay::Stripe::Subscription + Pay.user_model.include Pay::Stripe::Billable - Pay.charge_model.include Pay::Stripe::Charge - Pay.subscription_model.include Pay::Stripe::Subscription - Pay.user_model.include Pay::Stripe::Billable + Pay::Stripe::Api.set_api_keys + end - Pay::Stripe::Api.set_api_keys - end + if defined? Braintree + Dir[File.join(__dir__, 'pay/braintree', '**', '*.rb')].each { |file| require file } - if defined? Braintree - Dir[File.join(__dir__, 'pay/braintree', '**', '*.rb')].each { |file| require file } + Pay.charge_model.include Pay::Braintree::Charge + Pay.subscription_model.include Pay::Braintree::Subscription + Pay.user_model.include Pay::Braintree::Billable - Pay.charge_model.include Pay::Braintree::Charge - Pay.subscription_model.include Pay::Braintree::Subscription - Pay.user_model.include Pay::Braintree::Billable + Pay::Braintree::Api.set_api_keys + end - Pay::Braintree::Api.set_api_keys - end - - if defined?(Receipts::Receipt) - Pay.charge_model.include Pay::Receipts + if defined?(Receipts::Receipt) + Pay.charge_model.include Pay::Receipts + end end end end
Use ActiveSupport Reloader to continuously include modules on reloads
diff --git a/lib/rubycritic.rb b/lib/rubycritic.rb index abc1234..def5678 100644 --- a/lib/rubycritic.rb +++ b/lib/rubycritic.rb @@ -14,18 +14,13 @@ end def critique - smell_adapters = AnalysersRunner.new(@source.paths).run - smelly_pathnames = SmellsAggregator.new(smell_adapters).smelly_pathnames - Reporter.new(@source.pathnames, smelly_pathnames).generate_report - end - - def compare if @source_control_system.has_revision? smelly_pathnames = RevisionComparator.new(@source.paths, @source_control_system).compare - Reporter.new(@source.pathnames, smelly_pathnames).generate_report else - critique + smell_adapters = AnalysersRunner.new(@source.paths).run + smelly_pathnames = SmellsAggregator.new(smell_adapters).smelly_pathnames end + Reporter.new(@source.pathnames, smelly_pathnames).generate_report end end
Use the compare method by default The compare method is better than critique, so let's merge the two and use the compare logic whenever possible.
diff --git a/lib/token_auth.rb b/lib/token_auth.rb index abc1234..def5678 100644 --- a/lib/token_auth.rb +++ b/lib/token_auth.rb @@ -1,4 +1,6 @@ module TokenAuthentication + + class Unauthorized < StandardError; end module ActsAsTokenAuthenticatable extend ActiveSupport::Concern @@ -40,17 +42,13 @@ end def authenticate_by_token! - authenticate || render_unauthorized + authenticate || (raise Unauthorized) end def authenticate @current_user = authenticate_with_http_token do |token, options| @@entity.find_by_authentication_token(token) end - end - - def render_unauthorized - render status: :unauthorized, json: { error: 'Unauthorized' } end module ClassMethods
Raise Unauthorized if authentication fail
diff --git a/lib/turbograft.rb b/lib/turbograft.rb index abc1234..def5678 100644 --- a/lib/turbograft.rb +++ b/lib/turbograft.rb @@ -14,16 +14,20 @@ self.controllers = ["ActionController::Base"] end + def self.included(controller) + controller.class_eval do + include XHRHeaders, Cookies, XDomainBlocker, Redirection + before_action :set_xhr_redirected_to, :set_request_method_cookie + after_action :abort_xdomain_redirect + end + end + class Engine < ::Rails::Engine initializer :turbograft do |config| ActiveSupport.on_load(:action_controller) do - Config.controllers.each do |klass| - klass.constantize.class_eval do - include XHRHeaders, Cookies, XDomainBlocker, Redirection - before_action :set_xhr_redirected_to, :set_request_method_cookie - after_action :abort_xdomain_redirect - end + Config.controllers.each do |class_name| + class_name.constantize.include(::TurboGraft) end ActionDispatch::Request.class_eval do
Allow to configure Turbogradft in a way that doesn't compromise lazy loading
diff --git a/lib/money-rails/active_record/migration_extensions/table_pg_rails4.rb b/lib/money-rails/active_record/migration_extensions/table_pg_rails4.rb index abc1234..def5678 100644 --- a/lib/money-rails/active_record/migration_extensions/table_pg_rails4.rb +++ b/lib/money-rails/active_record/migration_extensions/table_pg_rails4.rb @@ -5,8 +5,12 @@ def monetize(accessor, options={}) [:amount, :currency].each do |attribute| column_present, _, *opts = OptionsExtractor.extract attribute, :no_table, accessor, options - constraints = opts.pop - column(*opts, **constraints) if column_present + if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3') + constraints = opts.pop + column(*opts, **constraints) if column_present + else + column(*opts) if column_present + end end end
Support both 1.9.3 and 3.0.0 Added RVM GPG to download ruby 3.0.0 correctly in Travis
diff --git a/libs/ldap_auth.rb b/libs/ldap_auth.rb index abc1234..def5678 100644 --- a/libs/ldap_auth.rb +++ b/libs/ldap_auth.rb @@ -1,6 +1,10 @@ def ldap_authenticate(username, password) name, domain = username.split('@') auth_conf = get_conf[:authentication][param_to_sym(domain)] + + if name == '' or password == '' + return {status: 'failed'} + end if auth_conf if auth_conf[:type] == 'ldap'
Fix LDAP Auth bug: Allows anyone to login w/o password
diff --git a/lib/active_pivot/activity.rb b/lib/active_pivot/activity.rb index abc1234..def5678 100644 --- a/lib/active_pivot/activity.rb +++ b/lib/active_pivot/activity.rb @@ -49,7 +49,12 @@ end def new_values - remote_activity.changes[0]['new_values'] + remote_activity.changes.each do |change| + if change['new_values'] && change['new_values']['current_state'] + return change['new_values'] + end + end + return nil end end end
Fix Story start date detection
diff --git a/lib/emque/consuming/router.rb b/lib/emque/consuming/router.rb index abc1234..def5678 100644 --- a/lib/emque/consuming/router.rb +++ b/lib/emque/consuming/router.rb @@ -56,11 +56,11 @@ end def map(map) - mapping.merge!(map.symbolize_keys) + mapping.merge!(map) end def route(type) - mapping[type.to_sym] + mapping[type] end private
Use strings as keys to remove dependency on ActiveSupport