diff
stringlengths
65
26.7k
message
stringlengths
7
9.92k
diff --git a/lib/generators/rafters/component/component_generator.rb b/lib/generators/rafters/component/component_generator.rb index abc1234..def5678 100644 --- a/lib/generators/rafters/component/component_generator.rb +++ b/lib/generators/rafters/component/component_generator.rb @@ -15,6 +15,8 @@ def create_gitkeeps create_file "#{base_directory}/assets/images/.gitkeep" + create_file "#{base_directory}/assets/stylesheets/.gitkeep" + create_file "#{base_directory}/assets/javascripts/.gitkeep" end def create_files
Add .gitkeeps for stylesheet and javascript directories
diff --git a/lib/generators/ruby_rabbitmq_janus/install_generator.rb b/lib/generators/ruby_rabbitmq_janus/install_generator.rb index abc1234..def5678 100644 --- a/lib/generators/ruby_rabbitmq_janus/install_generator.rb +++ b/lib/generators/ruby_rabbitmq_janus/install_generator.rb @@ -44,6 +44,9 @@ # Add initializer generate 'ruby_rabbitmq_janus:initializer' + + # Copy basic request + generate 'ruby_rabbitmq_janus:default_request' end end end
Add to install generators default_request action
diff --git a/action_args.gemspec b/action_args.gemspec index abc1234..def5678 100644 --- a/action_args.gemspec +++ b/action_args.gemspec @@ -18,7 +18,9 @@ s.summary = 'Controller action arguments parameterizer for Rails 4+ & Ruby 2.0+' s.description = 'Rails plugin gem that supports Merbish style controller action arguments.' - s.files = `git ls-files`.split("\n") + s.files = Dir.chdir(File.expand_path('..', __FILE__)) do + `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } + end s.require_paths = ["lib"] s.add_development_dependency 'bundler'
Exclude test files from the gem package
diff --git a/lib/chef_zero/solr/query/regexpable_query.rb b/lib/chef_zero/solr/query/regexpable_query.rb index abc1234..def5678 100644 --- a/lib/chef_zero/solr/query/regexpable_query.rb +++ b/lib/chef_zero/solr/query/regexpable_query.rb @@ -21,8 +21,8 @@ end DEFAULT_FIELD = "text" - WORD_CHARACTER = "[A-Za-z0-9@._':]" - NON_WORD_CHARACTER = "[^A-Za-z0-9@._':]" + WORD_CHARACTER = "[A-Za-z0-9@._':\-]" + NON_WORD_CHARACTER = "[^A-Za-z0-9@._':\-]" end end end
Fix scary search behavior on terms containing dash character
diff --git a/test/test_async.rb b/test/test_async.rb index abc1234..def5678 100644 --- a/test/test_async.rb +++ b/test/test_async.rb @@ -5,7 +5,7 @@ describe 'async operations' do it 'can runs queries async' do rows = [] - pool = 3.times.map.with_index {|n| Swift.setup n, Swift::DB::Postgres, db: 'swift' } + pool = 3.times.map.with_index {|n| Swift.setup n, Swift::DB::Postgres, db: 'swift_test' } Thread.new do pool[0].async_execute('select pg_sleep(0.3), 1 as query_id') {|row| rows << row[:query_id]}
Use the same db other tests use.
diff --git a/spec/flipper/adapters/active_record_spec.rb b/spec/flipper/adapters/active_record_spec.rb index abc1234..def5678 100644 --- a/spec/flipper/adapters/active_record_spec.rb +++ b/spec/flipper/adapters/active_record_spec.rb @@ -45,4 +45,16 @@ end it_should_behave_like 'a flipper adapter' + + describe '.get_all' do + it 'includes features in features table but not in gates table' do + flipper = Flipper.new(subject) + flipper.enable(:stats) + flipper.enable(:search) + flipper.disable(:search) + + result = subject.get_all + expect(result.keys.sort).to eq(%w(search stats)) + end + end end
Add spec to demonstrate that disabled features are not included in get_all
diff --git a/app/helpers/mapit_helper.rb b/app/helpers/mapit_helper.rb index abc1234..def5678 100644 --- a/app/helpers/mapit_helper.rb +++ b/app/helpers/mapit_helper.rb @@ -14,4 +14,8 @@ end end + def link_to_infowindow(text, url, id, options => {}) + link_to text, url, options.merge({:onclick => "infoWindow_#{id}(); return false;"}) + end + end
Add a link_to_infowindow helper method
diff --git a/spec/db_spec_helper.rb b/spec/db_spec_helper.rb index abc1234..def5678 100644 --- a/spec/db_spec_helper.rb +++ b/spec/db_spec_helper.rb @@ -6,6 +6,10 @@ ActiveRecord::Base.logger = Logger.new(logfile) if defined?(ActiveRecord::Base) db_config = YAML.load_file('config/database.yml')['test'] + +host = db_config['host'] +fail("Can't run destructive tests against non-local database #{host}") unless host == 'localhost' + ActiveRecord::Base.establish_connection(db_config) ActiveRecord::Migration.verbose = false ActiveRecord::Migrator.up 'db/migrate'
Check before accidentally blowing away a shared database
diff --git a/spec/features/admin/products/search_for_product_spec.rb b/spec/features/admin/products/search_for_product_spec.rb index abc1234..def5678 100644 --- a/spec/features/admin/products/search_for_product_spec.rb +++ b/spec/features/admin/products/search_for_product_spec.rb @@ -20,7 +20,6 @@ end def and_i_search_for query - save_and_open_page fill_in 'query', with: query click_button 'Search' end
Remove debugging code in failing spec
diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index abc1234..def5678 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -1,4 +1,5 @@ class PostsController < ApplicationController + before_action :redirect, only: [:edit, :destroy] def index end @@ -12,6 +13,8 @@ def create @post = Post.new(post_params) + + end def edit @@ -24,4 +27,7 @@ def post_params params.require(:post).permit(:title, :body) end + + def redirect + end end
Work on Posts controller--protections and new posts
diff --git a/app/services/review_deck.rb b/app/services/review_deck.rb index abc1234..def5678 100644 --- a/app/services/review_deck.rb +++ b/app/services/review_deck.rb @@ -2,7 +2,7 @@ def initialize(user, session) @session = session @user = user - unless session.has_key?(:review) || session[:review].empty? + unless (session.has_key?(:review) || !session[:review].empty?) session[:review] = user.words.review.map(&:id) end end
Fix for empty review set in session.
diff --git a/app/services/weather_man.rb b/app/services/weather_man.rb index abc1234..def5678 100644 --- a/app/services/weather_man.rb +++ b/app/services/weather_man.rb @@ -16,7 +16,7 @@ observationHash = @w_api.history_for(time, zip_code) if observationHash - observations = ['history']['observations'] + observations = observationHash['history']['observations'] observations.each do |o| if o['date']['hour'] == time.hour.to_s return o['tempi'].to_i
Access hash properly for wunderground api response
diff --git a/app/controllers/docs_controller.rb b/app/controllers/docs_controller.rb index abc1234..def5678 100644 --- a/app/controllers/docs_controller.rb +++ b/app/controllers/docs_controller.rb @@ -2,7 +2,7 @@ before_action :find_doc, only: [:show, :edit, :update, :destroy] def index - @docs = Doc.all.order("created_at DESC") + @docs = Doc.where(user_id: current_user) end def show
Change index to show current user docs
diff --git a/test/integration/elasticsearch_indexing_test.rb b/test/integration/elasticsearch_indexing_test.rb index abc1234..def5678 100644 --- a/test/integration/elasticsearch_indexing_test.rb +++ b/test/integration/elasticsearch_indexing_test.rb @@ -38,21 +38,4 @@ assert_document_is_in_rummager(@sample_document) end - - def test_can_index_fields_of_type_opaque_object - create_test_indexes - - document = { - "format" => "statistics_announcemnt", - "link" => "/a-link", - "metadata" => { - "confirmed" => true, - "display_date" => "27 August 2014 9:30am", - }, - } - - post "/documents", document.to_json - - assert_document_is_in_rummager(document) - end end
Remove redundant test for indexing This test was added when migrating to a new elasticsearch version. It no longer tests something valuable.
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 @@ -34,6 +34,7 @@ notes = notes .order(show_id: :desc) .offset((page-1) * PAGE_SIZE) + .select(:show_id, :title, :topic, :text) .first(PAGE_SIZE) render json: {
Select only the fields needed to render the json
diff --git a/app/presenters/signup_presenter.rb b/app/presenters/signup_presenter.rb index abc1234..def5678 100644 --- a/app/presenters/signup_presenter.rb +++ b/app/presenters/signup_presenter.rb @@ -12,7 +12,7 @@ end def body - artefact.description + artefact.details["description"] end def target
Use description from details hash
diff --git a/app/helpers/article_helper.rb b/app/helpers/article_helper.rb index abc1234..def5678 100644 --- a/app/helpers/article_helper.rb +++ b/app/helpers/article_helper.rb @@ -1,14 +1,29 @@ require 'bing-search' + +# def find_articles +# BingSearch.account_key = 'l1VfVxiJeygTtAUbcXL8O7A5Wpt3bmvH3+Z0eqX6HOE' +# results = [] +# yoga_results = [] +# shopping_results = [] +# yoga_results << BingSearch.web('yoga') +# # results << (BingSearch.web('travel'))[rand(10)] +# # results << (BingSearch.web('cats'))[rand(10)] +# shopping_results << BingSearch.web('shopping') +# # results << (BingSearch.web('meditation'))[rand(10)] +# results << yoga_results[rand(10)] +# results << yoga_results[rand(10)] +# results << shopping_results[rand(10)] +# results << shopping_results[rand(10)] +# results.shuffle +# end def find_articles BingSearch.account_key = 'l1VfVxiJeygTtAUbcXL8O7A5Wpt3bmvH3+Z0eqX6HOE' results = [] - results << (BingSearch.web('yoga'))[rand(10)] - results << (BingSearch.web('travel'))[rand(10)] - results << (BingSearch.web('cats'))[rand(10)] - results << (BingSearch.web('shopping'))[rand(10)] - results << (BingSearch.web('meditation'))[rand(10)] + results << (BingSearch.web('yoga', limit: 1)).pop + results << (BingSearch.web('travel', limit: 1)).pop + results << (BingSearch.web('cats', limit: 1)).pop + results << (BingSearch.web('shopping', limit: 1)).pop + results << (BingSearch.web('meditation', limit: 1)).pop results.shuffle end - -p find_articles
Speed up the loading of the links
diff --git a/app/queries/project_filter_query.rb b/app/queries/project_filter_query.rb index abc1234..def5678 100644 --- a/app/queries/project_filter_query.rb +++ b/app/queries/project_filter_query.rb @@ -29,7 +29,7 @@ when FILTER_TODO items = items .todo - .order(id: :asc) # Retain the spreadsheet order + .reorder(id: :asc) # Retain the spreadsheet order when FILTER_FLAGGED items = items.flagged when FILTER_DONE
Fix reordering of project items Just calling order doesn't work, reorder needs to be used.
diff --git a/src/vsphere_cpi/spec/unit/cloud/vsphere/soap_stub_spec.rb b/src/vsphere_cpi/spec/unit/cloud/vsphere/soap_stub_spec.rb index abc1234..def5678 100644 --- a/src/vsphere_cpi/spec/unit/cloud/vsphere/soap_stub_spec.rb +++ b/src/vsphere_cpi/spec/unit/cloud/vsphere/soap_stub_spec.rb @@ -12,7 +12,7 @@ expect(VimSdk::Soap::StubAdapter).to receive(:new) .with( 'https://some-host/sdk/vimService', - 'vim.version.version9', + 'vim.version.version12', http_client, ) .and_return(base_adapter)
Update vim version in soap_stub_adapter test
diff --git a/app/models/concerns/geo_works/external_metadata_file_behavior.rb b/app/models/concerns/geo_works/external_metadata_file_behavior.rb index abc1234..def5678 100644 --- a/app/models/concerns/geo_works/external_metadata_file_behavior.rb +++ b/app/models/concerns/geo_works/external_metadata_file_behavior.rb @@ -25,7 +25,7 @@ end def schema - (MetadataFormatService.label(geo_mime_type) || '').parameterize('_') + (MetadataFormatService.label(geo_mime_type) || '').parameterize(separator: '_') end end end
Fix parameterize separator deprecation warning
diff --git a/app/views/course/lesson_plan/milestones/_milestone.json.jbuilder b/app/views/course/lesson_plan/milestones/_milestone.json.jbuilder index abc1234..def5678 100644 --- a/app/views/course/lesson_plan/milestones/_milestone.json.jbuilder +++ b/app/views/course/lesson_plan/milestones/_milestone.json.jbuilder @@ -1,2 +1,3 @@ # frozen_string_literal: true -json.(milestone, :id, :title, :description, :start_at) +json.(milestone, :id, :title, :description) +json.(milestone.time_for(current_course_user), :start_at)
Read off personal time for milestones
diff --git a/lib/persistence/active_record_persistence.rb b/lib/persistence/active_record_persistence.rb index abc1234..def5678 100644 --- a/lib/persistence/active_record_persistence.rb +++ b/lib/persistence/active_record_persistence.rb @@ -5,6 +5,10 @@ base.extend AASM::Persistence::ActiveRecordPersistence::ClassMethods base.send(:include, AASM::Persistence::ActiveRecordPersistence::WriteState) unless base.method_defined?(:aasm_write_state) base.send(:include, AASM::Persistence::ActiveRecordPersistence::ReadState) unless base.method_defined?(:aasm_read_state) + + base.before_save do |record| + record.send("#{record.class.aasm_column}=", record.aasm_current_state.to_s) + end end module ClassMethods @@ -12,23 +16,20 @@ if column_name @aasm_column = column_name.to_sym else - @aasm_column + @aasm_column ||= :aasm_state end end end module WriteState def aasm_write_state(state) - @aasm_column ||= :aasm_state - - update_attribute(@aasm_column, state.to_s) + update_attribute(self.class.aasm_column, state.to_s) end end module ReadState def aasm_read_state - @aasm_column ||= :aasm_state - send(@aasm_column).to_sym + new_record? ? self.class.aasm_initial_state : send(self.class.aasm_column).to_sym end end end
Fix AR persistence so new records have their state set. [Joao Paulo Lins] Ensure that a state is written for a new record even if aasm_current_state or {state}= are never called.
diff --git a/windows/cookbooks/packer/recipes/disable_hibernation.rb b/windows/cookbooks/packer/recipes/disable_hibernation.rb index abc1234..def5678 100644 --- a/windows/cookbooks/packer/recipes/disable_hibernation.rb +++ b/windows/cookbooks/packer/recipes/disable_hibernation.rb @@ -0,0 +1,6 @@+registry_key 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power' do + values [{ name: 'HiberFileSizePercent', type: :dword, data: 0 }, + { name: 'HibernateEnabled', type: :dword, data: 0 }, + ] + action :create +end
Add a recipe for disabling hibernation on WIndows No need to have this in a vagrant box Signed-off-by: Tim Smith <764ef62106582a09ed09dfa0b6bff7c05fd7d1e4@chef.io>
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index abc1234..def5678 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -10,7 +10,7 @@ end it "is invalid without an email" do - expect(User.new(email: nil)).to have(1).errors_on(:email) + expect(User.new(email: nil)).to have(2).errors_on(:email) end it "is invalid with a duplicate email" do
Update user model test to reflect additional email validation.
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index abc1234..def5678 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -27,5 +27,15 @@ bad_guy = User.new(@attr.merge(:name => "")) bad_guy.should_not be_valid end + + it "devrait exige une adresse email" do + no_email_user = User.new(@attr.merge(:email => "")) + no_email_user.should_not be_valid + end + +# it "devrait valider unicite de email" do +# no_email_user = User.new(@attr.merge(:email => "user@example.com")) +# no_email_user.should_not be_valid +# end end end
Add Unit test validation User
diff --git a/config/initializers/patch_for_action_controller_test_response.rb b/config/initializers/patch_for_action_controller_test_response.rb index abc1234..def5678 100644 --- a/config/initializers/patch_for_action_controller_test_response.rb +++ b/config/initializers/patch_for_action_controller_test_response.rb @@ -0,0 +1,14 @@+if RUBY_VERSION>='2.6.0' + if Rails.version < '5' + class ActionController::TestResponse < ActionDispatch::TestResponse + def recycle! + # hack to avoid MonitorMixin double-initialize error: + @mon_mutex_owner_object_id = nil + @mon_mutex = nil + initialize + end + end + else + puts "Monkeypatch for ActionController::TestResponse no longer needed" + end +end
Add monkeypatch for Ruby 2.6
diff --git a/plugins/ftp/check-ftp.rb b/plugins/ftp/check-ftp.rb index abc1234..def5678 100644 --- a/plugins/ftp/check-ftp.rb +++ b/plugins/ftp/check-ftp.rb @@ -0,0 +1,88 @@+#!/usr/bin/env ruby +# check-ftp.rb +# === +# Uses either net/ftp or optionally double-bag-ftps ruby gem to check for +# connectivity to an FTP or FTPS server +# +# Author: S. Zachariah Sprackett <zac@sprackett.com> +# +# Released under the same terms as Sensu (the MIT license); see LICENSE +# for details. + +require 'rubygems' if RUBY_VERSION < '1.9.0' +require 'sensu-plugin/check/cli' +require 'net/http' + +class CheckFTP < Sensu::Plugin::Check::CLI + option :host, + :short => '-h HOST', + :default => 'localhost' + option :tls, + :short => '-s', + :boolean => true, + :default => false + option :noverify, + :short => '-n', + :boolean => true, + :default => false + option :user, + :short => '-u', + :long => '--username USER', + :default => 'anonymous' + option :pass, + :short => '-p', + :long => '--password PASS' + option :timeout, + :short => '-t SECS', + :proc => proc { |a| a.to_i }, + :default => 15 + + def run + begin + timeout(config[:timeout]) do + if config[:tls] + ftps_login + else + ftp_login + end + end + rescue Timeout::Error + critical "Connection timed out" + rescue => e + critical "Connection error: #{e.message}" + end + ok + end + + def ftps_login + require 'double_bag_ftps' + verify = OpenSSL::SSL::VERIFY_PEER + if config[:noverify] + verify = OpenSSL::SSL::VERIFY_NONE + end + + begin + ftps = DoubleBagFTPS.new + ftps.ssl_context = DoubleBagFTPS.create_ssl_context( + :verify_mode => verify + ) + ftps.connect(config[:host]) + ftps.login(config[:user], config[:pass]) + ftps.quit + rescue => e + critical "Failed to log in (#{e.to_s.chomp})" + end + end + + def ftp_login + require 'net/ftp' + begin + ftp = Net::FTP.new(config[:host]) + ftp.debug_mode = true + ftp.login(config[:user], config[:pass]) + ftp.quit + rescue => e + critical "Failed to log in (#{e.to_s.chomp})" + end + end +end
Add FTP / FTPS check
diff --git a/app/models/wafflemix/asset.rb b/app/models/wafflemix/asset.rb index abc1234..def5678 100644 --- a/app/models/wafflemix/asset.rb +++ b/app/models/wafflemix/asset.rb @@ -9,8 +9,8 @@ private def store_image_info if self.asset_origin - self.asset_mime_type = remote_asset.mime_type - self.asset_size = remote_asset.size + self.asset_mime_type = self.asset.mime_type + self.asset_size = self.asset.size self.save end end
Use dragonfly for these attributes.
diff --git a/app/lib/services.rb b/app/lib/services.rb index abc1234..def5678 100644 --- a/app/lib/services.rb +++ b/app/lib/services.rb @@ -9,7 +9,9 @@ def self.cached_content_item(base_path) Rails.cache.fetch("finder-frontend_content_items#{base_path}", expires_in: 5.minutes) do - content_store.content_item(base_path).to_h + GovukStatsd.time("content_store.fetch_request_time") do + content_store.content_item(base_path).to_h + end end end
Add timer to content item requests This adds tracking to the content item requests. This will be available in Graphite at stats.timers.finder-frontend.content_store.fetch_request_time
diff --git a/routes/player_counts.rb b/routes/player_counts.rb index abc1234..def5678 100644 --- a/routes/player_counts.rb +++ b/routes/player_counts.rb @@ -40,6 +40,18 @@ result.to_json end + + app.get '/player_counts-latest.json' do + result = [] + + servers = %w[Darktide Frostfell Harvestgain Leafcull Morningthaw Thistledown Solclaim Verdantine WintersEbb] + servers.each do |server| + latest = PlayerCount.where(server: server).desc(:created_at).limit(1) + result << { 'server' => server, 'count' => latest.to_a.first['c'] } + end + + result.to_json + end end end end
Add latest player counts JSON route
diff --git a/app/models/image.rb b/app/models/image.rb index abc1234..def5678 100644 --- a/app/models/image.rb +++ b/app/models/image.rb @@ -11,7 +11,7 @@ on: :create before_validation :set_md5 - after_create :async_set_thumbnails + after_commit :async_set_thumbnails, on: :create before_create :set_store_dir private
Use after commit instead of after create.
diff --git a/scrolls/shellycloud.rb b/scrolls/shellycloud.rb index abc1234..def5678 100644 --- a/scrolls/shellycloud.rb +++ b/scrolls/shellycloud.rb @@ -0,0 +1,82 @@+@name = File.basename(File.expand_path(".")) + +gem_group :development do + gem 'shelly', '>= 0.0.62' +end + +# check if user has account on shelly +`shelly list` +if $? != 0 + say_custom "shellycloud", "Please log in or register with Shelly Cloud." + say_custom "shellycloud", "You can do that by running `shelly login` or `shelly register`" + exit 1 +end + +required_dbs = %w[postgresql mongodb redis] +required_app_servers = %w[thin] + +selected_db = required_dbs.find { |db| scroll? db } +unless selected_db + say_custom "shellycloud", "Please include a DB choice from: #{required_dbs.join ", "}" + exit_now = true +end + +selected_app_server = required_app_servers.find { |app| scroll? app } +unless selected_app_server + say_custom "shellycloud", "Please include an App Server choice from: #{required_app_servers.join ", "}" + exit_now = true +end + +exit 1 if exit_now + +after_everything do + framework_env = multiple_choice "Which framework environment?", [ + ['Production', 'production'], + ['Staging', 'staging'] + ] + + app_name = (@repo_name && @repo_name.size > 0) ? @repo_name : @name + app_name.gsub!(/\W/, '') # only letters and numbers + app_name.gsub!("_", "-") + + instance_size = "large" + if framework_env == "production" + say_custom "shellycloud", "Using large instances for production environment" + else + say_custom "shellycloud", "Using small instances for staging environment" + instance_size = "small" + end + + code_name = "#{app_name}-#{framework_env}" + + name = File.basename(".") + command = "bundle exec shelly add --code_name #{code_name} " + command += "--databases=#{selected_db} " if selected_db + command += "--size=#{instance_size}" + + run command + + say_custom "shellycloud", "Adding Cloudfile to your repo" + run "git add Cloudfile" + run "git commit -m 'Added Cloudfile'" + + say_custom "shellycloud", "Pushing code to Shelly Cloud" + sleep(5) # sleep for ssh key to generate on shelly + run "git push #{code_name} master" + + say_custom "shellycloud", "Your application in now configured for Shelly Cloud" + say_custom "shellycloud", "You can start it by running `shelly start`." + say_custom "shellycloud", "For more information, check https://shellycloud.com/documentation" +end + +__END__ + +name: Shelly Cloud +description: Ruby Cloud Hosting in Europe +author: grk + +category: deployment +exclusive: deployment + +requires: [compile_assets, serve_static_assets, git, thin] +run_after: [git]
Add a scroll for deployment with AppScrolls [#27824317] depends on drnic/appscrolls#14 drnic/appscrolls#12
diff --git a/lib/krypt/hmac.rb b/lib/krypt/hmac.rb index abc1234..def5678 100644 --- a/lib/krypt/hmac.rb +++ b/lib/krypt/hmac.rb @@ -1,6 +1,5 @@ module Krypt class HMAC - include Krypt::Helper::XOR def initialize(digest, key) @digest = digest
Include is not necessary here
diff --git a/lib/active_record_lite/mass_object.rb b/lib/active_record_lite/mass_object.rb index abc1234..def5678 100644 --- a/lib/active_record_lite/mass_object.rb +++ b/lib/active_record_lite/mass_object.rb @@ -1,13 +1,25 @@ class MassObject def self.my_attr_accessible(*attributes) + attributes.each do |attribute| + attr_accessor attribute + self.attributes << attribute.to_s + end end def self.attributes + @attributes ||= [] end def self.parse_all(results) end def initialize(params = {}) + params.each do |attribute, value| + if self.class.attributes.include?(attribute) + self.send("#{attribute}=", value) + else + raise "mass assignment to unregistered attribute #{attribute}" + end + end end -end+end
Add basic mass assignment checking
diff --git a/lib/approvals/extensions/rspec/dsl.rb b/lib/approvals/extensions/rspec/dsl.rb index abc1234..def5678 100644 --- a/lib/approvals/extensions/rspec/dsl.rb +++ b/lib/approvals/extensions/rspec/dsl.rb @@ -10,7 +10,10 @@ def verify(options = {}, &block) group = eval "self", block.binding namer = ::RSpec.configuration.approvals_namer_class.new(group.example) - Approvals.verify(block.call, options.merge(:namer => namer)) + defaults = { + :namer => namer + } + Approvals.verify(block.call, defaults.merge(options)) rescue ApprovalError => e if diff_on_approval_failure? ::RSpec::Expectations.fail_with(e.message, e.approved_text, e.received_text)
Make it possible to override the defaults
diff --git a/pronto-scss.gemspec b/pronto-scss.gemspec index abc1234..def5678 100644 --- a/pronto-scss.gemspec +++ b/pronto-scss.gemspec @@ -1,7 +1,8 @@ # -*- encoding: utf-8 -*- + $LOAD_PATH.push File.expand_path('../lib', __FILE__) - require 'pronto/scss/version' +require 'English' Gem::Specification.new do |s| s.name = 'pronto-scss' @@ -14,11 +15,23 @@ Pronto runner for SCSS-Lint, tool to help keep your SCSS clean and readable EOF - s.required_rubygems_version = '>= 1.3.6' - s.license = 'MIT' + s.licenses = ['MIT'] + s.required_ruby_version = '>= 1.9.3' + s.rubygems_version = '1.8.23' - s.files = Dir.glob('{lib}/**/*') + %w(LICENSE README.md) - s.test_files = `git ls-files -- {spec}/*`.split("\n") + s.files = `git ls-files`.split($RS).reject do |file| + file =~ %r{^(?: + spec/.* + |Gemfile + |Rakefile + |\.rspec + |\.gitignore + |\.rubocop.yml + |\.travis.yml + )$}x + end + s.test_files = [] + s.extra_rdoc_files = ['LICENSE', 'README.md'] s.require_paths = ['lib'] s.add_runtime_dependency 'scss_lint', '~> 0.41.0'
Reduce size of the gem by only including the necessary files via gemspec
diff --git a/lib/caprese/controller/concerns/typing.rb b/lib/caprese/controller/concerns/typing.rb index abc1234..def5678 100644 --- a/lib/caprese/controller/concerns/typing.rb +++ b/lib/caprese/controller/concerns/typing.rb @@ -16,7 +16,15 @@ # @param [Symbol] type the record type to get the class for # @return [Class] the class for a given record type def record_class(type) - type.to_s.classify.constantize + begin + type.to_s.classify.constantize + rescue NameError + if type = resource_type_aliases[type] + record_class(type) + else + raise "Could not find type alias for #{type}." + end + end end # Gets the record class for the current controller
Implement type aliasing in record_class
diff --git a/config/initializers/mailboxer.rb b/config/initializers/mailboxer.rb index abc1234..def5678 100644 --- a/config/initializers/mailboxer.rb +++ b/config/initializers/mailboxer.rb @@ -20,19 +20,13 @@ messageable = Object.const_get(id_parts[0]).find(id_parts[1]) Mailboxer::Mailbox.new(messageable, id_parts[2]) end - - def drafts - Mailboxer::Conversation.draft(messageable) - end end Mailboxer::Receipt.class_eval do - scope :draft, lambda { where(is_draft: true) } + belongs_to :message, class_name: "Mailboxer::Message", foreign_key: "notification_id", required: false, counter_cache: true end - Mailboxer::Conversation.class_eval do - scope :draft, lambda { |participant| - participant(participant).merge(Mailboxer::Receipt.draft) - } + Mailboxer::Message.class_eval do + belongs_to :conversation, validate: true, autosave: true, counter_cache: true end end
Add counter cache option to belongs to
diff --git a/config/initializers/mongo.rb b/config/initializers/mongo.rb index abc1234..def5678 100644 --- a/config/initializers/mongo.rb +++ b/config/initializers/mongo.rb @@ -28,7 +28,6 @@ hosts: [ "#{settings.host}:#{settings.port}" ] } }, - options: { allow_dynamic_fields: false, use_activesupport_time_zone: true, identity_map_enabled: true } } if settings.user && settings.password @@ -39,3 +38,7 @@ config.load_configuration(hash) end end + +Mongoid.allow_dynamic_fields = false +Mongoid.use_activesupport_time_zone = true +Mongoid.identity_map_enabled = true
Define some Mongoid option mandatory by define if there are ENV configuration or not Revert in commit [f021f13444f727888986ea79fad36b77ca0f6ae7]
diff --git a/app/controllers/spree/admin/variants_controller_decorator.rb b/app/controllers/spree/admin/variants_controller_decorator.rb index abc1234..def5678 100644 --- a/app/controllers/spree/admin/variants_controller_decorator.rb +++ b/app/controllers/spree/admin/variants_controller_decorator.rb @@ -12,6 +12,7 @@ def volume_prices @product = @variant.product + @variant.volume_prices.build end def location_after_save
Build a volume price so table is populated
diff --git a/app/helpers/application_helper/button/transform_vm_button.rb b/app/helpers/application_helper/button/transform_vm_button.rb index abc1234..def5678 100644 --- a/app/helpers/application_helper/button/transform_vm_button.rb +++ b/app/helpers/application_helper/button/transform_vm_button.rb @@ -6,7 +6,22 @@ end def disabled? + @error_message = _('No suitable target infra provider exists') unless destination_exists? + @error_message = _('Can only transform VMs in down state') unless vm_down? + @error_message = _('Cannot transform VMs with snapshots') if vm_has_snapshots? + @error_message.present? + end + + def destination_exists? # Is there a provider that supports import? - EmsInfra.all.select(&:validate_import_vm).empty? + !EmsInfra.all.select(&:validate_import_vm).empty? + end + + def vm_down? + @record.state == 'off' + end + + def vm_has_snapshots? + !@record.snapshots.empty? end end
v2v: Disable VM transform button when op not possible Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1473180
diff --git a/lib/docs/scrapers/jquery/jquery_ui.rb b/lib/docs/scrapers/jquery/jquery_ui.rb index abc1234..def5678 100644 --- a/lib/docs/scrapers/jquery/jquery_ui.rb +++ b/lib/docs/scrapers/jquery/jquery_ui.rb @@ -2,7 +2,7 @@ class JqueryUi < Jquery self.name = 'jQuery UI' self.slug = 'jqueryui' - self.release = '1.12.0' + self.release = '1.12.1' self.base_url = 'https://api.jqueryui.com' self.root_path = '/category/all'
Update jQuery UI documentation (1.12.1)
diff --git a/lib/sass/rails.rb b/lib/sass/rails.rb index abc1234..def5678 100644 --- a/lib/sass/rails.rb +++ b/lib/sass/rails.rb @@ -1,16 +1,12 @@ module Sass - autoload :Script, 'sass/rails/helpers' - module Rails - autoload :CssCompressor, 'sass/rails/compressor' - autoload :Importer, 'sass/rails/importer' - autoload :Logger, 'sass/rails/logger' - autoload :Resolver, 'sass/rails/template_handlers' - autoload :SassTemplate, 'sass/rails/template_handlers' - autoload :ScssTemplate, 'sass/rails/template_handlers' end end +require 'sass/rails/compressor' +require 'sass/rails/logger' +require 'sass/rails/railtie' +require 'sass/rails/helpers' +require 'sass/rails/importer' +require 'sass/rails/template_handlers' require 'sass/rails/version' -require 'sass/rails/helpers' -require 'sass/rails/railtie'
Disable autoloading for dev performance.
diff --git a/lib/greenhorn/craft/category_group.rb b/lib/greenhorn/craft/category_group.rb index abc1234..def5678 100644 --- a/lib/greenhorn/craft/category_group.rb +++ b/lib/greenhorn/craft/category_group.rb @@ -28,6 +28,10 @@ update(group_locales: group_locales) end + def ordered_categories + categories.joins(:structure_element).order('craft_structureelements.lft') + end + def initialize(attrs) attrs[:hasUrls] = false if attrs[:hasUrls].nil? super(attrs)
Add support for ordering categories by their structure order
diff --git a/lib/tasks/db.rake b/lib/tasks/db.rake index abc1234..def5678 100644 --- a/lib/tasks/db.rake +++ b/lib/tasks/db.rake @@ -5,5 +5,10 @@ task :votes => :environment do Vote.destroy_all end + + desc 'Remove all representatives' + task :representatives => :environment do + Representative.destroy_all + end end end
Add task to remove all representatives.
diff --git a/app/controllers/backend/users_controller.rb b/app/controllers/backend/users_controller.rb index abc1234..def5678 100644 --- a/app/controllers/backend/users_controller.rb +++ b/app/controllers/backend/users_controller.rb @@ -1,7 +1,7 @@ class Backend::UsersController < Backend::BaseController include Concerns::PaginationController - before_action :find_user, only: [:show, :edit, :update, :destroy] + before_action :find_model, only: [:show, :edit, :update, :destroy] before_action -> { breadcrumb.add t('b.users'), backend_users_path } def index @@ -42,7 +42,7 @@ private - def find_user + def find_model @user = User.find params[:id] end
Rename find_user to find_model for the users controller.
diff --git a/lib/devise_cas_authenticatable/railtie.rb b/lib/devise_cas_authenticatable/railtie.rb index abc1234..def5678 100644 --- a/lib/devise_cas_authenticatable/railtie.rb +++ b/lib/devise_cas_authenticatable/railtie.rb @@ -4,7 +4,11 @@ module DeviseCasAuthenticatable class Railtie < ::Rails::Railtie initializer "devise_cas_authenticatable.use_rack_middleware" do |app| - app.config.middleware.use "DeviseCasAuthenticatable::SingleSignOut::StoreSessionId" + if Rails::VERSION::MAJOR < 5 + app.config.middleware.use "DeviseCasAuthenticatable::SingleSignOut::StoreSessionId" + else + app.config.middleware.use DeviseCasAuthenticatable::SingleSignOut::StoreSessionId + end end end end
Fix for deprecation message when trying to pass a string an not a class to the middleware builder for Rails 5
diff --git a/lib/the_merger.rb b/lib/the_merger.rb index abc1234..def5678 100644 --- a/lib/the_merger.rb +++ b/lib/the_merger.rb @@ -1,12 +1,20 @@ require "the_merger/version" module TheMerger + # + # Default settings for TheMerger + # + # merge_model: User + # + def self.merger puts 'Mail Merge test' end def self.merge_fields(original_body, *fields) - + self.parse_config + puts @merge_model + User.all.each do |user| puts "User: #{user.firstname}" @@ -19,5 +27,16 @@ end end - + private + + def self.parse_config + path = "#{Rails.root}/config/the_merger.yml" + + if File.exists?(path) + conf=YAML::load(IO.read(path)) + @merge_model = conf["merge_model"] + else + @merge_model = "User" + end + end end
Read a variable from a yaml file
diff --git a/app/controllers/storytime/subscriptions_controller.rb b/app/controllers/storytime/subscriptions_controller.rb index abc1234..def5678 100644 --- a/app/controllers/storytime/subscriptions_controller.rb +++ b/app/controllers/storytime/subscriptions_controller.rb @@ -14,7 +14,11 @@ flash[:error] = I18n.t('flash.subscriptions.create.fail') end - redirect_to :back + if respond_to?(:redirect_back) + redirect_back(fallback_location: "/") + else + redirect_to :back + end end def destroy
Fix redirect back since rails 5 changed signature for this
diff --git a/lib/rails-footnotes/notes/log_note.rb b/lib/rails-footnotes/notes/log_note.rb index abc1234..def5678 100644 --- a/lib/rails-footnotes/notes/log_note.rb +++ b/lib/rails-footnotes/notes/log_note.rb @@ -12,7 +12,12 @@ self.original_logger = Rails.logger note_logger = NoteLogger.new(self.logs) note_logger.level = self.original_logger.level - note_logger.formatter = self.original_logger.kind_of?(Logger) ? self.original_logger.formatter : ActiveSupport::Logger::SimpleFormatter.new + note_logger.formatter = + if self.original_logger.kind_of?(Logger) + self.original_logger.formatter + else + defined?(ActiveSupport::Logger) ? ActiveSupport::Logger::SimpleFormatter.new : Logger::SimpleFormatter.new + end # Rails 3 don't have ActiveSupport::Logger#broadcast so we backported it extend_module = defined?(ActiveSupport::Logger) ? ActiveSupport::Logger.broadcast(note_logger) : NoteLogger.broadcast(note_logger) Rails.logger = self.original_logger.dup.extend(extend_module)
Remove the error occurred by `Footnotes::Notes::LogNote.start!` on Rails 3 On Rails 3, `Rails.logger` is not kind of `Logger`, and `ActiveSupport::Logger::SimpleFormatter` is not defined. Therefore, this line is output to Rails log. ``` Footnotes Log Exception: uninitialized constant ActiveSupport::Logger ``` Use `Logger::SimpleFormatter` as it is the class correspond to `ActiveSupport::Logger::SimpleFormatter`.
diff --git a/lib/rapns/daemon/feedback_receiver.rb b/lib/rapns/daemon/feedback_receiver.rb index abc1234..def5678 100644 --- a/lib/rapns/daemon/feedback_receiver.rb +++ b/lib/rapns/daemon/feedback_receiver.rb @@ -8,7 +8,7 @@ loop do break if @stop check_for_feedback - sleep 60 + sleep Rapns::Daemon.configuration.feedback.poll end end end
Use feedback poll config option
diff --git a/lib/fog/storage/requests/hp/put_object.rb b/lib/fog/storage/requests/hp/put_object.rb index abc1234..def5678 100644 --- a/lib/fog/storage/requests/hp/put_object.rb +++ b/lib/fog/storage/requests/hp/put_object.rb @@ -11,6 +11,9 @@ def put_object(container, object, data, options = {}) data = Fog::Storage.parse_data(data) headers = data[:headers].merge!(options) + if headers.has_key?('Transfer-Encoding') + headers.delete('Content-Length') + end response = request( :body => data[:body], :expects => 201,
Remove Content-Length header incase Transfer-Encoding header is present. This was done to get the streaming for PUT working.
diff --git a/lib/rack_after_reply/adapter/passenger.rb b/lib/rack_after_reply/adapter/passenger.rb index abc1234..def5678 100644 --- a/lib/rack_after_reply/adapter/passenger.rb +++ b/lib/rack_after_reply/adapter/passenger.rb @@ -12,8 +12,9 @@ RackAfterReply.freedom_patch self, :initialize def accept_and_process_next_request_with_rack_after_reply(socket_wrapper, channel, buffer) - accept_and_process_next_request_without_rack_after_reply(socket_wrapper, channel, buffer) - fire_rack_after_reply + returning accept_and_process_next_request_without_rack_after_reply(socket_wrapper, channel, buffer) do + fire_rack_after_reply + end end RackAfterReply.freedom_patch self, :accept_and_process_next_request end
Fix patch to Passenger's `accept_and_process_next_request`
diff --git a/core/binding/eval_spec.rb b/core/binding/eval_spec.rb index abc1234..def5678 100644 --- a/core/binding/eval_spec.rb +++ b/core/binding/eval_spec.rb @@ -14,6 +14,18 @@ bind.eval("Inside.name").should == "BindingSpecs::Demo::Inside" end + describe "with a file given" do + + it "does not store the filename permanently" do + obj = BindingSpecs::Demo.new(1) + bind = obj.get_binding + + bind.eval("__FILE__", "test.rb").should == "test.rb" + bind.eval("__FILE__").should_not == "test.rb" + end + + end + it "needs to be completed" end end
Add spec for using eval with different filenames on a binding
diff --git a/CUtil.podspec b/CUtil.podspec index abc1234..def5678 100644 --- a/CUtil.podspec +++ b/CUtil.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "CUtil" - s.version = "0.1.20" + s.version = "0.1.21" s.summary = "CUtil is a common utilities collection. It is designed as a tool-box for iOS development." s.author = { "Acttos" => "acttosma@gmail.com", "Jason" => "majinshou@gmail.com" } s.social_media_url = "https://twitter.com/hulu0319"
Add a new version 0.1.21 for CocoaPods.
diff --git a/Cedar.podspec b/Cedar.podspec index abc1234..def5678 100644 --- a/Cedar.podspec +++ b/Cedar.podspec @@ -19,7 +19,8 @@ # https://github.com/pivotal/cedar/issues/47 s.xcconfig = { 'CLANG_CXX_LANGUAGE_STANDARD' => 'c++0x', - 'CLANG_CXX_LIBRARY' => 'libc++' + 'CLANG_CXX_LIBRARY' => 'libc++', + 'OTHER_CFLAGS' => '-DDEVELOPER_BIN_DIR=@\"${DEVELOPER_BIN_DIR}\"' } s.libraries = 'c++' s.requires_arc = false
Update podspec to produce the DEVELOPER_BIN_DIR preprocessor macro
diff --git a/cardgate-rails.gemspec b/cardgate-rails.gemspec index abc1234..def5678 100644 --- a/cardgate-rails.gemspec +++ b/cardgate-rails.gemspec @@ -22,6 +22,6 @@ spec.add_development_dependency "rake" spec.add_development_dependency "mocha" - spec.add_dependency "faraday", "0.8.9" - spec.add_dependency "faraday_middleware", "0.9.0" + spec.add_dependency "faraday", "~> 0.8.9" + spec.add_dependency "faraday_middleware", "~> 0.9.0" end
Allow minor versions up for faraday gems.
diff --git a/week-5/nums-commas/my_solution.rb b/week-5/nums-commas/my_solution.rb index abc1234..def5678 100644 --- a/week-5/nums-commas/my_solution.rb +++ b/week-5/nums-commas/my_solution.rb @@ -8,9 +8,46 @@ # 0. Pseudocode +=begin # What is the input? +# Input: positive integer + # What is the output? (i.e. What should the code return?) +# Output: String-version of input, + but the numbers are separated by commas. + # What are the steps needed to solve the problem? +# Steps to solve the problem: + +VERSION 1: +Step 1: Get user input (integer called "number"). +Step 2: Make a variable to hold result -- "comma-ized". +Step 3: Transform integer into comma-ized version of input. + How? + Step 3.1: Split the String into individual digits (characters). + How? + Step 3.1.a: Convert "number" into a String. + Step 3.2.b: Split this String-ified "number" into an Array. + Step 3.2: Starting at the end of the individual characters, + FOR each set of 3 digits copy those digits and put a comma, + UNTIL no more digits are left. +Step 4: return the comma-ized version of input. + +VERSION 2: +Step 1: Get user input (integer called "number"). +Step 2: Make a variable to hold result -- "comma-ized". +Step 3: Transform integer into comma-ized version of input. + How? + Step 3.1: Split the String into individual digits (characters). + How? + Step 3.1.a: Convert "number" into a String. + Step 3.2.b: Split this String-ified "number" into an Array. + Step 3.2: Count the number of elements in this Array. + IF a position is a multiple of 3: + add a comma to that set of digits, + Repeat UNTIL no more digits are left. +Step 4: return the comma-ized version of input. +=end # 1. Initial Solution
Add pseudocode of separate_comma method.
diff --git a/graph.rb b/graph.rb index abc1234..def5678 100644 --- a/graph.rb +++ b/graph.rb @@ -1,5 +1,7 @@ class Graph - def new(graph_info, directed) + attr_reader :edges + + def initialize(graph_info, directed) @edges = {} @directed = directed make_edges(graph_info) @@ -11,21 +13,22 @@ end end - def add_edge(x, y, pair_processed?) - @edges[x] + def add_edge(x, y, pair_processed) + if @edges[x] @edges[x] << y else @edges[x] = [y] end - add_edge(y, x, true) unless pair_processed? + add_edge(y, x, true) unless pair_processed end end class EdgeNode - def new() + def initialize() end end -graph_info = [[1, 2], [1, 3], [1, 4], [3, 4], [4, 5], [2,7], [5,6]]; +graph_info = [[1, 2], [1, 3], [1, 4], [3, 4], [4, 5], [2,7], [5,6]] graph = Graph.new(graph_info, false) +puts graph.edges
Correct ruby initialize method name
diff --git a/config.ru b/config.ru index abc1234..def5678 100644 --- a/config.ru +++ b/config.ru @@ -20,6 +20,6 @@ end run Rack::Cascade.new([ - Api::App, - rails_app + rails_app, + Api::App ])
Change order of rack cascade
diff --git a/spec/file_info_spec.rb b/spec/file_info_spec.rb index abc1234..def5678 100644 --- a/spec/file_info_spec.rb +++ b/spec/file_info_spec.rb @@ -1,37 +1,44 @@ RSpec.describe(Jekyll::Compose::FileInfo) do - let(:open_and_closing_tag) { "---\n" } - let(:layout_content) { "post\n" } - describe '#content' do context 'with a title of only words' do - let(:expected_title) { "A test arg parser\n" } - subject { described_class.new Jekyll::Compose::ArgParser.new( + let(:expected_result) {<<-CONTENT.gsub(/^\s+/, '') + --- + layout: post + title: A test arg parser + --- + CONTENT + } + + let(:parsed_args) { Jekyll::Compose::ArgParser.new( ['A test arg parser'], {} ) } it 'does not wrap the title in quotes' do - expect(subject.content).to start_with(open_and_closing_tag) - expect(subject.content).to end_with(open_and_closing_tag) - expect(subject.content).to match(layout_content) - expect(subject.content).to match(expected_title) + file_info = described_class.new parsed_args + expect(file_info.content).to eq(expected_result) end end context 'with a title that includes a colon' do - let(:expected_title) { "'A test: arg parser'\n" } - subject { described_class.new Jekyll::Compose::ArgParser.new( + let(:expected_result) {<<-CONTENT.gsub(/^\s+/, '') + --- + layout: post + title: 'A test: arg parser' + --- + CONTENT + } + + let(:parsed_args) { Jekyll::Compose::ArgParser.new( ['A test: arg parser'], {} ) } it 'does wrap the title in quotes' do - expect(subject.content).to start_with(open_and_closing_tag) - expect(subject.content).to end_with(open_and_closing_tag) - expect(subject.content).to match(layout_content) - expect(subject.content).to match(expected_title) + file_info = described_class.new parsed_args + expect(file_info.content).to eq(expected_result) end end end
Revert "Update tests to work for ruby 1.9" This reverts commit 553dbbbd1d56752ded289a8b1ad0e7496ff96afa.
diff --git a/db/seeds/tags.rb b/db/seeds/tags.rb index abc1234..def5678 100644 --- a/db/seeds/tags.rb +++ b/db/seeds/tags.rb @@ -6,11 +6,3 @@ TagRepository.put(:tag_id => 'businesslink', :title => 'Business Link', :tag_type => 'legacy_source') TagRepository.put(:tag_id => 'directgov', :title => 'Directgov', :tag_type => 'legacy_source') - -TagRepository.put(tag_type: "section", tag_id: "disabilities", title: "Disabled people", description: "Includes your rights, benefits, carers and the Equality Act") -parent = Tag.where(tag_id: "disabilities").first -TagRepository.put(tag_type: "section", parent_id: parent.tag_id, tag_id: "disabilities/benefits", title: "Benefits and financial help", description: "Includes Disability Living Allowance, Employment and Support Allowance and Attendance Allowance") -TagRepository.put(tag_type: "section", parent_id: parent.tag_id, tag_id: "disabilities/carers", title: "Carers", description: "Includes Carer's Allowance, disabled children and disability day care centres") -TagRepository.put(tag_type: "section", parent_id: parent.tag_id, tag_id: "disabilities/rights", title: "Disability rights", description: "Disability rights under the Equality Act 2010") -TagRepository.put(tag_type: "section", parent_id: parent.tag_id, tag_id: "disabilities/work", title: "Work and disabled people", description: "Includes recruitment and disabled people, reasonable adjustments at work and Access to Work") -TagRepository.put(tag_type: "section", parent_id: parent.tag_id, tag_id: "disabilities/equipment", title: "Disability equipment and transport", description: "Includes Disabled Students Allowances, Blue Badge and disabled access")
Remove old Section seeds to avoid overwriting them This has been deployed now. There's a secret UI for editing these and they are subject to change, so let's not trash those changes on every deploy.
diff --git a/config/environments/development.rb b/config/environments/development.rb index abc1234..def5678 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -35,5 +35,5 @@ # Expands the lines which load the assets config.assets.debug = true - config.i18n.fallbacks = true + config.i18n.fallbacks = false end
Disable fallback locales from dev env
diff --git a/delayed_job_mongo_mapper.gemspec b/delayed_job_mongo_mapper.gemspec index abc1234..def5678 100644 --- a/delayed_job_mongo_mapper.gemspec +++ b/delayed_job_mongo_mapper.gemspec @@ -5,7 +5,6 @@ s.summary = "MongoMapper backend for delayed_job" s.version = '1.0.0' s.authors = 'Andrew Timberlake' - s.date = Date.today.to_s s.email = 'andrew@andrewtimberlake.com' s.extra_rdoc_files = ["LICENSE", "README.md"] s.files = Dir.glob("{lib,spec}/**/*") + %w[LICENSE README.md]
Remove date.today specifier in gemspec
diff --git a/spec/support/helper.rb b/spec/support/helper.rb index abc1234..def5678 100644 --- a/spec/support/helper.rb +++ b/spec/support/helper.rb @@ -2,17 +2,33 @@ module SpecHelper - def mock_model(*attributes) - Class.new { + def mock_model(*attributes, &block) + model = Class.new { include Equalizer.new(*attributes) - attributes.each { |attribute| attr_accessor attribute } + const_set(:ATTRIBUTES, attributes) + + attributes.each { |name| attr_accessor name } def initialize(attrs = {}, &block) attrs.each { |name, value| send("#{name}=", value) } instance_eval(&block) if block end + + def update(tuple) + self.class.new(to_h.update(tuple)) + end + + def attribute_names + self.class.const_get(:ATTRIBUTES) + end + + def to_h + attribute_names.each_with_object({}) { |name, h| h[name] = send(name) } + end } + model.class_eval(&block) if block + model end end
Add support for immutable objects to session
diff --git a/lib/technoweenie/attachment_fu/backends/db_file_backend.rb b/lib/technoweenie/attachment_fu/backends/db_file_backend.rb index abc1234..def5678 100644 --- a/lib/technoweenie/attachment_fu/backends/db_file_backend.rb +++ b/lib/technoweenie/attachment_fu/backends/db_file_backend.rb @@ -29,11 +29,12 @@ if save_attachment? (db_file || build_db_file).data = temp_data db_file.save! - self.class.update_all ['db_file_id = ?', self.db_file_id = db_file.id], ['id = ?', id] + self.db_file_id = db_file.id + self.class.where(id: id).update_all(db_file_id: db_file.id) end true end end end end -end+end
Refactor DbFileBackend for Rails 4 AREL conformity ActiveRecord#update_all was deprecated in Rails 2.3.8 and has since been replaced by ActiveRecord::Relation#update_all. With this change the method signature (accepted parameters) and usage have also changed requiring the refactoring.
diff --git a/spec/hash_object_spec.rb b/spec/hash_object_spec.rb index abc1234..def5678 100644 --- a/spec/hash_object_spec.rb +++ b/spec/hash_object_spec.rb @@ -3,18 +3,18 @@ # Test support object describe HashObject do - subject { HashObject.new(hash) } - let(:hash) do - { - :name => 'Steve', - :address => {:street => 'Mainstreet'}, - :posts => [ - {:title => 'It is christmas'}, - {:title => 'NOT'} - ] - } - end - + subject { HashObject.new(hash) } + let(:hash) do + { + :name => 'Steve', + :address => {:street => 'Mainstreet'}, + :posts => [ + {:title => 'It is christmas'}, + {:title => 'NOT'} + ] + } + end + it 'maps an intergalactic hash' do assert_equal hash[:name], subject.name assert_equal hash[:address][:street], subject.address.street
Fix code identation in HashObject spec.
diff --git a/spec/lib/webhook_spec.rb b/spec/lib/webhook_spec.rb index abc1234..def5678 100644 --- a/spec/lib/webhook_spec.rb +++ b/spec/lib/webhook_spec.rb @@ -5,6 +5,10 @@ describe 'Webhook' do it 'does only block for a very short time' do + # Set up webhook directory. + # + Webhook.directory = '.' + # Run webhooks in a child. # pid = fork do
[Webhook] Use . as directory when testing to make Travis happy.
diff --git a/manticore.gemspec b/manticore.gemspec index abc1234..def5678 100644 --- a/manticore.gemspec +++ b/manticore.gemspec @@ -19,8 +19,11 @@ spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] - spec.signing_key = File.expand_path("~/.gemcert/gem-private_key.pem") - spec.cert_chain = ['gem-public_cert.pem'] + private_key = File.expand_path("~/.gemcert/gem-private_key.pem") + if File.exists? private_key + spec.signing_key = private_key + spec.cert_chain = ['gem-public_cert.pem'] + end spec.add_dependency "addressable", "~> 2.3" spec.add_development_dependency "bundler", "~> 1.3"
Make signing conditional for building the gem, so that external systems such as Travis may build it without needing to have a private key present
diff --git a/cookbooks/util/libraries/cflags.rb b/cookbooks/util/libraries/cflags.rb index abc1234..def5678 100644 --- a/cookbooks/util/libraries/cflags.rb +++ b/cookbooks/util/libraries/cflags.rb @@ -2,7 +2,7 @@ def cflags flags = { "LDFLAGS" => "-I#{embedded_dir}/include -L#{embedded_dir}/lib", - "CLFAGS" => "-I#{embedded_dir}/include -L#{embedded_dir}/lib" + "CFLAGS" => "-I#{embedded_dir}/include -L#{embedded_dir}/lib" } if platform?("windows") @@ -13,6 +13,10 @@ elsif platform?("mac_os_x") # Actually not quite sure if I need this... yet flags["LDFLAGS"] += " -R#{embedded_dir}/lib" + + # Build down to Mac OS X 10.5 + flags["LDFLAGS"] += " -mmacosx-version-min=10.5" + flags["CFLAGS"] += " -mmacosx-version-min=10.5" end return flags
Mac: Support down to Mac OS X 10.5
diff --git a/spec/models/task_spec.rb b/spec/models/task_spec.rb index abc1234..def5678 100644 --- a/spec/models/task_spec.rb +++ b/spec/models/task_spec.rb @@ -3,14 +3,9 @@ describe Task do context "for three sample tasks in a list" do let(:list) { create(:task_list) } - let(:task1) { create(:task, list: list) } - let(:task2) { create(:task, list: list) } - let(:task3) { create(:task, list: list) } - - before do - # Force creation in proper order. - task3; task2; task1 - end + let!(:task3) { create(:task, list: list) } + let!(:task2) { create(:task, list: list) } + let!(:task1) { create(:task, list: list) } it "should reorder other tasks in the list when target_priority is set" do expect {
Use let! instead of let+before hack.
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index abc1234..def5678 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' describe User do - pending "add some examples to (or delete) #{__FILE__}" +# TODO: Write some tests +# pending "add some examples to (or delete) #{__FILE__}" end
Disable "pending" test for now
diff --git a/helpspot-sso/lib/opscode/helpspot_sso.rb b/helpspot-sso/lib/opscode/helpspot_sso.rb index abc1234..def5678 100644 --- a/helpspot-sso/lib/opscode/helpspot_sso.rb +++ b/helpspot-sso/lib/opscode/helpspot_sso.rb @@ -11,7 +11,7 @@ def create_helpspot_user(email) return 0 unless DATABASE_URI portal_users = helpspot_db[:HS_Portal_Login] - portal_users.on_duplicate_key_update(:sPassword).insert(:sEmail => email, :sPassword => '') + portal_users.on_duplicate_key_update(:sPasswordHash).insert(:sEmail => email, :sPasswordHash => '') portal_users.select(:xLogin).where(:sEmail => email).first end
Update column names for new helpspot version.
diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb index abc1234..def5678 100644 --- a/spec/support/helpers.rb +++ b/spec/support/helpers.rb @@ -14,6 +14,11 @@ it 'inflects through module method' do assert { RussianInflect.inflect(answers[0], inflection_case) == answers[index] } end + + it 'inflects with force_downcase equals true' do + inflected = inflector.to_case(inflection_case, force_downcase: true) + assert { inflected == UnicodeUtils.downcase(answers[index]) } + end end end end
Add force_downcase: true inflect test assertion
diff --git a/lib/ld4l_browser_data/utilities/file_systems/mysql_zip_fs.rb b/lib/ld4l_browser_data/utilities/file_systems/mysql_zip_fs.rb index abc1234..def5678 100644 --- a/lib/ld4l_browser_data/utilities/file_systems/mysql_zip_fs.rb +++ b/lib/ld4l_browser_data/utilities/file_systems/mysql_zip_fs.rb @@ -4,62 +4,12 @@ module Ld4lBrowserData module Utilities module FileSystems - class MySqlZipFS - DEFAULT_PARAMS = { - :host => 'localhost', - :username => 'SUPPLY_USERNAME', - :password => 'SUPPLY_PASSWORD', - :database => 'ld4l', - } - - def initialize(params) - @settings = DEFAULT_PARAMS.merge(params) - @client = Mysql2::Client.new(@settings) - @read_statement = @client.prepare('SELECT rdf FROM lod WHERE uri = ?') - @insert_statement = @client.prepare('INSERT INTO lod SET uri = ?, rdf = ?') - @update_statement = @client.prepare('INSERT INTO lod SET uri = ?, rdf = ? ON DUPLICATE KEY UPDATE rdf = ?') - end - - def get_bookmark(key) - result = @read_statement.execute('bookmark_' + key) - row = result.first - if row && row['rdf'] - bkmk = JSON.parse(row['rdf'], :symbolize_names => true) - bkmk - else - nil - end - end - - def set_bookmark(key, contents) - insert('bookmark_' + key, JSON.generate(contents)) - end - - def acceptable?(uri) - true - end - + class MySqlZipFS < MySqlFS def write(uri, contents) bogus("Size of RDF is %d for %s" % [contents.size, uri]) if contents.size >= 2**16 zipped = Zlib.deflate(contents) insert(uri, zipped) end - - def set_void(filename, contents) - bogus "set_void(#{filename})" - end - - def insert(uri, rdf) - begin - @insert_statement.execute(uri, rdf) - rescue - @update_statement.execute(uri, rdf, rdf) - end - end - - def close() - @client.close - end end end end
Make MySqlZipFS an extension of MySqlFS
diff --git a/lib/metamorpher/builders/ruby/uppercase_constant_rewriter.rb b/lib/metamorpher/builders/ruby/uppercase_constant_rewriter.rb index abc1234..def5678 100644 --- a/lib/metamorpher/builders/ruby/uppercase_constant_rewriter.rb +++ b/lib/metamorpher/builders/ruby/uppercase_constant_rewriter.rb @@ -1,29 +1,15 @@ require "metamorpher/builders/ast" +require "metamorpher/builders/ruby/uppercase_rewriter" module Metamorpher module Builders module Ruby - class UppercaseConstantRewriter + class UppercaseConstantRewriter < UppercaseRewriter include Metamorpher::Rewriter include Metamorpher::Builders::AST def pattern - builder.const( - builder.literal!(nil), - builder.VARIABLE_TO_BE { |v| v.name && v.name.to_s[/^[A-Z_]*$/] } - ) - end - - def replacement - builder.derivation!(:variable_to_be) do |variable_to_be, builder| - name = variable_to_be.name.to_s - - if name.end_with?("_") - builder.greedy_variable! name.chomp("_").downcase.to_sym - else - builder.variable! name.downcase.to_sym - end - end + builder.const(builder.literal!(nil), super) end end end
Reduce duplication in Ruby builder code.
diff --git a/lib/doorkeeper/request.rb b/lib/doorkeeper/request.rb index abc1234..def5678 100644 --- a/lib/doorkeeper/request.rb +++ b/lib/doorkeeper/request.rb @@ -9,22 +9,22 @@ module Request module_function - def authorization_strategy(strategy) - get_strategy strategy, Doorkeeper.configuration.authorization_response_types + def authorization_strategy(response_type) + get_strategy response_type, Doorkeeper.configuration.authorization_response_types rescue NameError raise Errors::InvalidAuthorizationStrategy end - def token_strategy(strategy) - get_strategy strategy, Doorkeeper.configuration.token_grant_types + def token_strategy(grant_type) + get_strategy grant_type, Doorkeeper.configuration.token_grant_types rescue NameError raise Errors::InvalidTokenStrategy end - def get_strategy(strategy, available) - fail Errors::MissingRequestStrategy unless strategy.present? - fail NameError unless available.include?(strategy.to_s) - "Doorkeeper::Request::#{strategy.to_s.camelize}".constantize + def get_strategy(grant_or_request_type, available) + fail Errors::MissingRequestStrategy unless grant_or_request_type.present? + fail NameError unless available.include?(grant_or_request_type.to_s) + "Doorkeeper::Request::#{grant_or_request_type.to_s.camelize}".constantize end end end
Rename Doorkeeper::Request method params for clarity The arguments are strings from the `request_type` and `grant_type` parameters, not strategies.
diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index abc1234..def5678 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -1,7 +1,7 @@ class PagesController < ActionController::Base before_filter :update_page_resolver - append_view_path Page::Resolver.instance + prepend_view_path Page::Resolver.instance helper_method :is_editing?
Prepend view templates to view context.
diff --git a/core/db/migrate/20140309024355_create_spree_stores.rb b/core/db/migrate/20140309024355_create_spree_stores.rb index abc1234..def5678 100644 --- a/core/db/migrate/20140309024355_create_spree_stores.rb +++ b/core/db/migrate/20140309024355_create_spree_stores.rb @@ -1,17 +1,25 @@ class CreateSpreeStores < ActiveRecord::Migration def change - create_table :spree_stores do |t| - t.string :name - t.string :url - t.text :meta_description - t.text :meta_keywords - t.string :seo_title - t.string :mail_from_address - t.string :default_currency - t.string :code - t.boolean :default, default: false, null: false + if table_exists?(:spree_stores) + rename_column :spree_stores, :domains, :url + rename_column :spree_stores, :email, :mail_from_address + add_column :spree_stores, :meta_description, :text + add_column :spree_stores, :meta_keywords, :text + add_column :spree_stores, :seo_title, :string + else + create_table :spree_stores do |t| + t.string :name + t.string :url + t.text :meta_description + t.text :meta_keywords + t.string :seo_title + t.string :mail_from_address + t.string :default_currency + t.string :code + t.boolean :default, default: false, null: false - t.timestamps + t.timestamps + end end end end
Update store migration for when apps already were using spree-multi-domain.
diff --git a/app/controllers/votes_controller.rb b/app/controllers/votes_controller.rb index abc1234..def5678 100644 --- a/app/controllers/votes_controller.rb +++ b/app/controllers/votes_controller.rb @@ -11,11 +11,17 @@ @prev_winner_ranking = rankings[@prev_winner.id] @prev_loser_ranking = rankings[@prev_loser.id] end - @option1 = Artist.get_random_artist - @option2 = Artist.get_random_artist - until @option1 != @option2 - @option2 = Artist.get_random_artist + + if !session[:next_pairs] #first visit + pair = Artist.get_artist_pair + @option1 = pair[0] + @option2 = pair[1] + else #other visits + @option1 = Artist.find(session[:next_pairs][0]) + @option2 = Artist.find(session[:next_pairs][1]) end + session_pair = Artist.get_artist_pair + session[:next_pairs] = [session_pair[0].id, session_pair[1].id] @vote = Vote.new() end
Add logic to find next pair of votes
diff --git a/app/decorators/storage_decorator.rb b/app/decorators/storage_decorator.rb index abc1234..def5678 100644 --- a/app/decorators/storage_decorator.rb +++ b/app/decorators/storage_decorator.rb @@ -6,9 +6,8 @@ def quadicon { :top_left => { - :fileicon => store_type_icon, :tooltip => store_type.to_s - }, + }.merge(store_type_icon), :top_right => {:text => v_total_vms}, :bottom_left => {:text => v_total_hosts}, :bottom_right => { @@ -30,6 +29,25 @@ end def store_type_icon - "100/storagetype-#{store_type.nil? ? "unknown" : ERB::Util.h(store_type.to_s.downcase)}.png" + case store_type.try(:downcase) + when 'cinder' + {:fileicon => 'svg/vendor-cinder.svg'} + when 'glance' + {:fileicon => 'svg/vendor-openstack.svg'} + when 'gluster' + {:fileicon => 'svg/vendor-gluster.svg'} + when 'vmfs' + {:fileicon => 'svg/vendor-vmware.svg'} + when 'nfs', 'nfs41' + {:fonticon => 'ff ff-network-interface fa-rotate-180', :color => '#0099cc'} + when 'fcp' + {:fonticon => 'ff ff-network-interface fa-rotate-180', :color => '#0099cc'} + when 'iscsi' + {:fonticon => 'ff ff-network-interface fa-rotate-180', :color => '#0099cc'} + when 'glusterfs' + {:fileicon => 'svg/vendor-gluster.svg'} + else + {:fonticon => 'pficon pficon-unknown'} + end end end
Use svg/fonticons for store types in the storage decorator
diff --git a/app/helpers/georgia/users_helper.rb b/app/helpers/georgia/users_helper.rb index abc1234..def5678 100644 --- a/app/helpers/georgia/users_helper.rb +++ b/app/helpers/georgia/users_helper.rb @@ -9,5 +9,9 @@ PermissionTablePresenter.new(self, section, actions).to_s end + def georgia_roles_collection + @georgia_role_collection ||= Georgia::Role.pluck(:name, :id).map{|name, id| [name.titleize, id]} + end + end end
Add georgia_roles_collection for users form
diff --git a/app/models/repository_text_value.rb b/app/models/repository_text_value.rb index abc1234..def5678 100644 --- a/app/models/repository_text_value.rb +++ b/app/models/repository_text_value.rb @@ -3,4 +3,7 @@ accepts_nested_attributes_for :repository_cell validates :repository_cell, presence: true + validates :value, + presence: true, + length: { maximum: Constants::TEXT_MAX_LENGTH } end
Add validation of text_value length [SCI-1267]
diff --git a/lib/link_shrink/config.rb b/lib/link_shrink/config.rb index abc1234..def5678 100644 --- a/lib/link_shrink/config.rb +++ b/lib/link_shrink/config.rb @@ -1,8 +1,11 @@ module LinkShrink module Config + # @author Jonah Ruiz <jonah@pixelhipsters.com> + # Configurable module for integrating with other URL APIs extend self attr_accessor :api_key + def api=(api) @api = api.new
Add documentation for Config module
diff --git a/Formula/ruby-enterprise-edition.rb b/Formula/ruby-enterprise-edition.rb index abc1234..def5678 100644 --- a/Formula/ruby-enterprise-edition.rb +++ b/Formula/ruby-enterprise-edition.rb @@ -11,6 +11,23 @@ def install ENV.gcc_4_2 # fails with LLVM - system "./installer --auto #{prefix} --no-tcmalloc" + args = ['./installer', "--auto #{prefix}", '--no-tcmalloc'] + args.push('-c --enable-shared') if ARGV.include?('--enable-shared') + system *args + end + + def caveats; <<-EOS +By default we don't compile REE as a shared library. From their documentation: + + Please note that enabling --enable-shared will make the Ruby interpreter + about 20% slower. + +For desktop environments (particularly ones requiring RubyCocoa) this is +acceptable and even desirable. + +If you need REE to be compiled as a shared library, you can re-compile like so: + + brew install ruby-enterprise-edition --force --enable-shared + EOS end end
Allow REE to be built shared
diff --git a/lib/tasks/ci_monitor.rake b/lib/tasks/ci_monitor.rake index abc1234..def5678 100644 --- a/lib/tasks/ci_monitor.rake +++ b/lib/tasks/ci_monitor.rake @@ -1,11 +1,13 @@ namespace :cimonitor do desc "Update the status for each active project" task :fetch_statuses => :environment do - StatusFetcher.new.fetch_all + if !JobManager.jobs_exist?('project_status') + StatusFetcher.new.fetch_all + end end desc "Send an email notification including any projects that have been red for over one day" task :red_over_one_day_notification => :environment do CiMonitorNotifier.send_red_over_one_day_notifications end -end+end
Fix up ci monitor rake task to use delayed_job
diff --git a/app/models/admin.rb b/app/models/admin.rb index abc1234..def5678 100644 --- a/app/models/admin.rb +++ b/app/models/admin.rb @@ -1,6 +1,5 @@ class Admin < ActiveRecord::Base # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable and :omniauthable - devise :database_authenticatable, :registerable, - :recoverable, :rememberable, :trackable, :validatable + devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable end
Remove sign_up path from devise
diff --git a/app/models/skill.rb b/app/models/skill.rb index abc1234..def5678 100644 --- a/app/models/skill.rb +++ b/app/models/skill.rb @@ -3,4 +3,6 @@ belongs_to :user acts_as_tenant(:user) + + validates_uniqueness_of :name end
Add AR uniquness validator on name Signed-off-by: Max Fierke <0706025b2bbcec1ed8d64822f4eccd96314938d0@maxfierke.com>
diff --git a/app/models/tweet.rb b/app/models/tweet.rb index abc1234..def5678 100644 --- a/app/models/tweet.rb +++ b/app/models/tweet.rb @@ -1,5 +1,5 @@ class Tweet < ActiveRecord::Base - default_scope order("created_at desc") + default_scope order("published_at desc") mount_uploader :image, ImageUploader
Sort desc by Twitter's timestamp
diff --git a/kiwi/app/controllers/votes_controller.rb b/kiwi/app/controllers/votes_controller.rb index abc1234..def5678 100644 --- a/kiwi/app/controllers/votes_controller.rb +++ b/kiwi/app/controllers/votes_controller.rb @@ -1,5 +1,5 @@ class VotesController < ApplicationController - before_action :load_votable + before_action :vote_type def create @vote = current_user.votes.new(vote_params) @@ -23,10 +23,13 @@ params.require(:vote).permit(:direction,:user_id) end -def load_votable - # binding.pry - resource, id = request.path.split('/')[1,2] - @votable = resource.singularize.classify.constantize.find(id) +def vote_type + + + + + + end
Make changes to votable_type assignment
diff --git a/spec/rspec/rails/matchers/be_valid_spec.rb b/spec/rspec/rails/matchers/be_valid_spec.rb index abc1234..def5678 100644 --- a/spec/rspec/rails/matchers/be_valid_spec.rb +++ b/spec/rspec/rails/matchers/be_valid_spec.rb @@ -10,19 +10,12 @@ validates_presence_of :something end + let(:matcher) { be_valid } subject { TestModel.new } - it "passes the matcher when valid" do - subject.something = "something" + it "includes validation errors by default" do + matcher.matches? subject - subject.should be_valid - expect(subject).to be_valid - end - - it "fails the matcher when not valid" do - subject.something = nil - - subject.should_not be_valid - expect(subject).to_not be_valid + matcher.failure_message_for_should.should =~ /is blank/ end end
Test for matcher error text instead
diff --git a/ruboty-sloc.gemspec b/ruboty-sloc.gemspec index abc1234..def5678 100644 --- a/ruboty-sloc.gemspec +++ b/ruboty-sloc.gemspec @@ -20,6 +20,7 @@ spec.require_paths = ["lib"] spec.add_dependency "ruboty" + spec.add_dependency "sloc" spec.add_development_dependency "bundler", "~> 1.8" spec.add_development_dependency "rake", "~> 10.0" end
Add sloc as runtime dependency
diff --git a/ruby-dtrace.gemspec b/ruby-dtrace.gemspec index abc1234..def5678 100644 --- a/ruby-dtrace.gemspec +++ b/ruby-dtrace.gemspec @@ -1,3 +1,6 @@+$:<<'./lib' +require 'dtrace' + Gem::Specification.new do |s| s.name = 'ruby-dtrace'
Fix gemspec - must include dtrace.rb
diff --git a/blimp.gemspec b/blimp.gemspec index abc1234..def5678 100644 --- a/blimp.gemspec +++ b/blimp.gemspec @@ -6,7 +6,7 @@ Gem::Specification.new do |gem| gem.name = "blimp" gem.version = Blimp::VERSION - gem.authors = ["Blake Williams"] + gem.authors = ["Blake Williams", "Sixteen Eighty"] gem.email = ["blake@blakewilliams.me"] gem.description = %q{Ruby gem that implements the Blimp Public API http://dev.getblimp.com/} gem.summary = %q{Ruby bindings to the Blimp API}
Add Sixteen Eighty as an author
diff --git a/db/migrate/20150123013225_add_parsed_user_agent_to_open_events.rb b/db/migrate/20150123013225_add_parsed_user_agent_to_open_events.rb index abc1234..def5678 100644 --- a/db/migrate/20150123013225_add_parsed_user_agent_to_open_events.rb +++ b/db/migrate/20150123013225_add_parsed_user_agent_to_open_events.rb @@ -9,23 +9,25 @@ OpenEvent.reset_column_information # Resaving open events so that the user agent parsing happens count = 0 - OpenEvent.find_each do |open_event| - parsed_user_agent = parser.parse(open_event.user_agent) + ActiveRecord::Base.uncached do + OpenEvent.find_each do |open_event| + parsed_user_agent = parser.parse(open_event.user_agent) - calculate_ua_family = parsed_user_agent.family - calculate_ua_version = parsed_user_agent.version.to_s if parsed_user_agent.version - calculate_os_family = parsed_user_agent.os.family - calculate_os_version = parsed_user_agent.os.version.to_s if parsed_user_agent.os.version + calculate_ua_family = parsed_user_agent.family + calculate_ua_version = parsed_user_agent.version.to_s if parsed_user_agent.version + calculate_os_family = parsed_user_agent.os.family + calculate_os_version = parsed_user_agent.os.version.to_s if parsed_user_agent.os.version - open_event.update_attributes( + open_event.update_attributes( ua_family: calculate_ua_family, ua_version: calculate_ua_version, os_family: calculate_os_family, os_version: calculate_os_version - ) + ) - count += 1 - p count if count % 100 == 0 + count += 1 + p count if count % 100 == 0 + end end end end
Use uncached. to try to cut down on runaway memory See http://stackoverflow.com/questions/6668875/ruby-on-rails-memory-leak-when-looping-through-large-number-of-records-find-eac
diff --git a/spec/lib/angellist_api/configuration_spec.rb b/spec/lib/angellist_api/configuration_spec.rb index abc1234..def5678 100644 --- a/spec/lib/angellist_api/configuration_spec.rb +++ b/spec/lib/angellist_api/configuration_spec.rb @@ -0,0 +1,52 @@+require 'spec_helper' + +describe AngellistApi::Configuration do + class ExtendedClass; extend AngellistApi::Configuration; end + class IncludedClass; include AngellistApi::Configuration; end + + describe "#extended" do + it "should have all configuration variables set to the default values by default" do + AngellistApi::Configuration::VALID_OPTIONS_KEYS.each do |key| + ExtendedClass.send(key).should == AngellistApi::Configuration.const_get("DEFAULT_#{key.upcase}") + end + end + end + + describe "#configure" do + it "should allow configuration variables to be set in a block" do + object = IncludedClass.new + object.configure do |o| + o.oauth_token = "my oauth token" + o.oauth_token_secret = "some super secret token" + end + object.oauth_token.should == "my oauth token" + object.oauth_token_secret.should == "some super secret token" + end + end + + describe "#options" do + it "should return a hash of all configuration options" do + object = IncludedClass.new + config = { :oauth_token => "123-token", :oauth_token_secret => "345-secret" } + config.each { |k,v| object.send("#{k.to_s}=", v) } + + config.each { |k,v| object.options[k].should == v } + end + end + + describe "#reset" do + it "should set all config variables to the defaults" do + object = IncludedClass.new + AngellistApi::Configuration::VALID_OPTIONS_KEYS.each_with_index do |key, i| + object.send("#{key}=", i) + object.send(key).should == i + end + + object.reset + + AngellistApi::Configuration::VALID_OPTIONS_KEYS.each_with_index do |key, i| + object.send(key).should == AngellistApi::Configuration.const_get("DEFAULT_#{key.upcase}") + end + end + end +end
Write tests for AngellistApi::Configuration module
diff --git a/lib/locotimezone/active_record_helper.rb b/lib/locotimezone/active_record_helper.rb index abc1234..def5678 100644 --- a/lib/locotimezone/active_record_helper.rb +++ b/lib/locotimezone/active_record_helper.rb @@ -1,33 +1,21 @@ module Locotimezone module ActiveRecordHelper + def locotime(options = {}) + data = Locotimezone.locotime(options) + attr_writers = Locotimezone.configuration.attr_writers - def locotime(options = {}) - Locotimezone.locotime(options) - end + unless data[:geo].nil? || data[:geo].empty? + data[:geo][:location].each do |key, value| + attr_key = (key == :lat ? :latitude : :longitude) - # def locotime(options = {}) - # data = Locotimezone.locotime(options) - # geolocation_attributes data[:geo] unless data[:geo].nil? - # timezone_attribute data[:timezone] unless data[:timezone].nil? - # end + next unless respond_to?(attr_writers[attr_key]) + send(attr_writers[attr_key], value) + end + end - def geolocation_attributes(geolocation_data) - return nil if geolocation_data.empty? - geolocation_data[:location].each do |key, value| - attribute = :latitude - attribute = :longitude if key == :lng - save_attribute(attribute, value) - end - end - - def timezone_attribute(timezone_data) - return nil if timezone_data.empty? - save_attribute(:timezone_id, timezone_data[:timezone_id]) - end - - def save_attribute(attribute, value) - if respond_to? attr_writers[attribute] - send attr_writers[attribute], value + unless data[:timezone].nil? || data[:timezone].empty? + tz_writer = attr_writers[:timezone_id] + send(tz_writer, data[:timezone][:timezone_id]) if respond_to?(tz_writer) end end end
Simplify helper to single method
diff --git a/lib/sandthorn/aggregate_root_snapshot.rb b/lib/sandthorn/aggregate_root_snapshot.rb index abc1234..def5678 100644 --- a/lib/sandthorn/aggregate_root_snapshot.rb +++ b/lib/sandthorn/aggregate_root_snapshot.rb @@ -10,7 +10,7 @@ def aggregate_snapshot! if @aggregate_events.count > 0 - raise Errors::SnapshotError.new, + raise Errors::SnapshotError, "Can't take snapshot on object with unsaved events" end @@ -23,7 +23,7 @@ def save_snapshot unless aggregate_snapshot - raise Errors::SnapshotError.new "No snapshot has been created!" + raise Errors::SnapshotError, "No snapshot has been created!" end @aggregate_snapshot[:event_data] = Sandthorn
Correct raise statements to not use new.
diff --git a/lib/scanny/checks/http_redirect_check.rb b/lib/scanny/checks/http_redirect_check.rb index abc1234..def5678 100644 --- a/lib/scanny/checks/http_redirect_check.rb +++ b/lib/scanny/checks/http_redirect_check.rb @@ -36,7 +36,16 @@ # require 'open-uri' def pattern_open_uri - "StringLiteral<string = 'open-uri'>" + <<-EOT + SendWithArguments< + arguments = ActualArguments< + array = [ + StringLiteral<string = 'open-uri'> + ] + >, + name = :require + > + EOT end # OpenStruct.new(key: value)
Update pattern to more specific (call require method)
diff --git a/lib/templates/rspec/scaffold/new_spec.rb b/lib/templates/rspec/scaffold/new_spec.rb index abc1234..def5678 100644 --- a/lib/templates/rspec/scaffold/new_spec.rb +++ b/lib/templates/rspec/scaffold/new_spec.rb @@ -3,8 +3,9 @@ <% output_attributes = model.columns.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%> RSpec.describe '<%= ns_table_name %>/new', <%= type_metatag(:view) %> do <%= model.factory_girl_let_definitions %> + <%= model.factory_girl_let_definition(action: :build) %> before(:each) do - assign(:<%= ns_file_name %>, <%= model.factory_girl_to :build %>) + assign(:<%= model.full_resource_name %>, <%= model.full_resource_name %>) end it 'renders new <%= ns_file_name %> form' do
Use let definition for assigned variable