diff
stringlengths
65
26.7k
message
stringlengths
7
9.92k
diff --git a/lib/celluloid/proxy/abstract.rb b/lib/celluloid/proxy/abstract.rb index abc1234..def5678 100644 --- a/lib/celluloid/proxy/abstract.rb +++ b/lib/celluloid/proxy/abstract.rb @@ -1,9 +1,7 @@ module Celluloid::Proxy - CLASS_METHOD = ::Kernel.instance_method(:class) - # Looks up the actual class of instance, even if instance is a proxy. def self.class_of(instance) - CLASS_METHOD.bind(instance).call + (class << instance; self; end).superclass end end
Use the metaclass to get to the superclass of BasicObject.
diff --git a/config/initializers/gds_sso.rb b/config/initializers/gds_sso.rb index abc1234..def5678 100644 --- a/config/initializers/gds_sso.rb +++ b/config/initializers/gds_sso.rb @@ -1,8 +1,3 @@ GDS::SSO.config do |config| - config.user_model = "User" - config.oauth_id = ENV.fetch("OAUTH_ID", "oauth_id") - config.oauth_secret = ENV.fetch("OAUTH_SECRET", "secret") - config.oauth_root_url = Plek.new.external_url_for("signon") - config.cache = Rails.cache config.api_only = true end
Remove redundant GDS SSO initializer This was made redundant in [1]. [1]: https://github.com/alphagov/gds-sso/pull/241
diff --git a/examples/design_by_contract.rb b/examples/design_by_contract.rb index abc1234..def5678 100644 --- a/examples/design_by_contract.rb +++ b/examples/design_by_contract.rb @@ -0,0 +1,54 @@+# Design by contract example + +class A + def initialize + @transactions = [] + @total = 0 + end + + def buy price + @transactions << price + @total += price + end + + def sell price + @transactions << price # Wrong + @total -= price + end + +end + +############################## + +$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) + +require 'aspector' + +class Object + def assert bool, message = 'Assertion failure' + $stderr.puts message unless bool + end +end + +class ContractExample < Aspector::Base + + before do |price, &block| + assert price > 0, "Price is #{price}, should be greater than 0" + end + + after do |*args, &block| + sum = @transactions.reduce(&:+) + assert @total == sum, "Total(#{@total}) and sum of transactions(#{sum}) do not match" + end + +end + +############################## + +ContractExample.apply A, :methods => %w[buy sell] + +a = A.new +a.buy 10 +a.buy -10 +a.sell 10 +
Add design by contract example
diff --git a/models/firm.rb b/models/firm.rb index abc1234..def5678 100644 --- a/models/firm.rb +++ b/models/firm.rb @@ -22,7 +22,9 @@ def self.byname(name) ret = [] - all_data = Firm.all(:name.ilike => name) + modified_name = name.sub(/'|"/, '%') + + all_data = Firm.all(:name.ilike => modified_name) all_data.each do |firm| ret.push(firm['firm_id']) end
Replace quotes with % for searching by name
diff --git a/lib/gds_api/json_utils.rb b/lib/gds_api/json_utils.rb index abc1234..def5678 100644 --- a/lib/gds_api/json_utils.rb +++ b/lib/gds_api/json_utils.rb @@ -2,6 +2,7 @@ require 'net/http' require 'ostruct' require_relative 'core-ext/openstruct' +require_relative 'version' module GdsApi::JsonUtils USER_AGENT = "GDS Api Client v. #{GdsApi::VERSION}"
Make sure the version constant is available before we use it
diff --git a/KZAsserts.podspec b/KZAsserts.podspec index abc1234..def5678 100644 --- a/KZAsserts.podspec +++ b/KZAsserts.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "KZAsserts" - s.version = "1.0" + s.version = "1.0.1" s.summary = "KZAsserts is set of expanded assert macros that don't crash on release builds and support asynchronus code execution." s.description = <<-DESC KZAsserts has been created to allow developers to assert assumptions without worrying about crashing client facing versions of the app, it simplifies error handling by supporting asynchronus code execution and automatic error generation. @@ -15,6 +15,7 @@ s.platform = :ios, '4.0' s.ios.deployment_target = '4.0' s.osx.deployment_target = '10.7' + s.tvos.deployment_target = '9.0' s.requires_arc = true s.source_files = 'Classes'
Add tvOS deployment target and bump version to 1.0.1
diff --git a/lib/rb-inotify/version.rb b/lib/rb-inotify/version.rb index abc1234..def5678 100644 --- a/lib/rb-inotify/version.rb +++ b/lib/rb-inotify/version.rb @@ -20,5 +20,5 @@ # THE SOFTWARE. module INotify - VERSION = '0.9.9' + VERSION = '0.10.0' end
Include development dependencies when building on travis.
diff --git a/lib/releasecop/checker.rb b/lib/releasecop/checker.rb index abc1234..def5678 100644 --- a/lib/releasecop/checker.rb +++ b/lib/releasecop/checker.rb @@ -1,14 +1,15 @@ module Releasecop class Checker - attr_accessor :name, :envs + attr_accessor :name, :envs, :working_dir - def initialize(name, envs) + def initialize(name, envs, working_dir = Releasecop::CONFIG_DIR) self.name = name self.envs = envs.map { |e| Releasecop::ManifestItem.new(name, e) } + self.working_dir = working_dir end def check - Dir.chdir(CONFIG_DIR) do + Dir.chdir(working_dir) do `git clone #{envs.first.git} #{'--bare' if envs.all?(&:bare_clone?)} #{name} > /dev/null 2>&1` Dir.chdir(name) do
Allow working directory to be overridden
diff --git a/Casks/vistrails.rb b/Casks/vistrails.rb index abc1234..def5678 100644 --- a/Casks/vistrails.rb +++ b/Casks/vistrails.rb @@ -0,0 +1,7 @@+class Vistrails < Cask + url 'http://downloads.sourceforge.net/project/vistrails/vistrails/v2.0.3/vistrails-mac-10.6-intel-2.0.3-a6ad79347667.dmg' + homepage 'http://www.vistrails.org/index.php/Main_Page' + version '2.0.3' + sha1 '1381f58a8946792ed448ae072607cee9ed32a041' + link 'VisTrails' +end
Add cask for VisTrails 2.0.3. Add cask for VisTrails, an open-source scientific workflow and provenance management system that supports data exploration and visualization.
diff --git a/config/boot.rb b/config/boot.rb index abc1234..def5678 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -4,4 +4,4 @@ require "bundler/setup" # Set up gems listed in the Gemfile. # make the ExecJs use NodeJs - ENV['EXECJS_RUNTIME'] = 'Node' +# ENV['EXECJS_RUNTIME'] = 'Node'
Stop using node for the execjs runtime. Try switching back to therubyrhino.
diff --git a/Casks/font-lato.rb b/Casks/font-lato.rb index abc1234..def5678 100644 --- a/Casks/font-lato.rb +++ b/Casks/font-lato.rb @@ -1,16 +1,24 @@ class FontLato < Cask - url 'http://www.latofonts.com/download/LatoOFL.zip' + url 'http://www.latofonts.com/download/Lato2OFL.zip' homepage 'http://www.latofonts.com/' version 'latest' sha256 :no_check - font 'OTF/Lato-Bla.otf' - font 'OTF/Lato-BlaIta.otf' - font 'OTF/Lato-Bol.otf' - font 'OTF/Lato-BolIta.otf' - font 'OTF/Lato-Hai.otf' - font 'OTF/Lato-HaiIta.otf' - font 'OTF/Lato-Lig.otf' - font 'OTF/Lato-LigIta.otf' - font 'OTF/Lato-Reg.otf' - font 'OTF/Lato-RegIta.otf' + font 'Lato2OFL/Lato-Black.ttf' + font 'Lato2OFL/Lato-BlackItalic.ttf' + font 'Lato2OFL/Lato-Bold.ttf' + font 'Lato2OFL/Lato-BoldItalic.ttf' + font 'Lato2OFL/Lato-Hairline.ttf' + font 'Lato2OFL/Lato-HairlineItalic.ttf' + font 'Lato2OFL/Lato-Heavy.ttf' + font 'Lato2OFL/Lato-HeavyItalic.ttf' + font 'Lato2OFL/Lato-Italic.ttf' + font 'Lato2OFL/Lato-Light.ttf' + font 'Lato2OFL/Lato-LightItalic.ttf' + font 'Lato2OFL/Lato-Medium.ttf' + font 'Lato2OFL/Lato-MediumItalic.ttf' + font 'Lato2OFL/Lato-Regular.ttf' + font 'Lato2OFL/Lato-Semibold.ttf' + font 'Lato2OFL/Lato-SemiboldItalic.ttf' + font 'Lato2OFL/Lato-Thin.ttf' + font 'Lato2OFL/Lato-ThinItalic.ttf' end
Update Lato to version 2
diff --git a/lib/asendia/product.rb b/lib/asendia/product.rb index abc1234..def5678 100644 --- a/lib/asendia/product.rb +++ b/lib/asendia/product.rb @@ -12,10 +12,13 @@ attribute :reserved_stock, Integer def self.fetch(client, product_ids) - client.request( + response = client.request( :get_stock_update, ProductIDList: product_ids.join(',') - ).map { |record| Product.new_from_api(record) } + ) + + response = [response] unless response.is_a?(Array) + response.map { |record| Product.new_from_api(record) } end def self.new_from_api(record)
Work around issue with API/Savon
diff --git a/core/spec/models/zone_spec.rb b/core/spec/models/zone_spec.rb index abc1234..def5678 100644 --- a/core/spec/models/zone_spec.rb +++ b/core/spec/models/zone_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Zone do +describe Spree::Zone do let(:zone) { Factory :zone }
Fix references in Zone model spec
diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb index abc1234..def5678 100644 --- a/config/initializers/session_store.rb +++ b/config/initializers/session_store.rb @@ -1,3 +1,3 @@ # Be sure to restart your server when you modify this file. -CartoDB::Application.config.session_store :cookie_store, :key => '_cartodb_session', :domain => CartoDB.domain +CartoDB::Application.config.session_store :cookie_store, :key => '_cartodb_session', :domain => ".cartodb.com"
Use root domain as session cookie domain
diff --git a/lib/cancan/matchers.rb b/lib/cancan/matchers.rb index abc1234..def5678 100644 --- a/lib/cancan/matchers.rb +++ b/lib/cancan/matchers.rb @@ -28,6 +28,6 @@ end description do - "should be able to #{args.map(&:to_s).join(' ')}" + "expected to be able to #{args.map(&:to_s).join(' ')}" end end
Update wording for description for new style
diff --git a/simple_backend/db/seeds.rb b/simple_backend/db/seeds.rb index abc1234..def5678 100644 --- a/simple_backend/db/seeds.rb +++ b/simple_backend/db/seeds.rb @@ -3,3 +3,7 @@ password = '123' users = [] recipes = [] + +10.times do + users << User.create(name: Faker::Name.first_name, password: password) +end
Create 10 users using faker and set password
diff --git a/config/routes.rb b/config/routes.rb index abc1234..def5678 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,7 @@ Rails.application.routes.draw do - mount_devise_token_auth_for 'User', at: 'auth' + mount_devise_token_auth_for 'User', at: 'auth', controllers: { + registrations: 'devise/registration_custom' + } # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html namespace :api do namespace :v1 do
Set custom controller for registrations
diff --git a/config/routes.rb b/config/routes.rb index abc1234..def5678 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -9,7 +9,7 @@ end resources :competitions do - #resources :business_sizes + resources :business_sizes resources :competitions_teams do get :delete, :on => :collection post :remove, :on => :collection
Fix admin business size form
diff --git a/config/routes.rb b/config/routes.rb index abc1234..def5678 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -22,7 +22,7 @@ end resources :users, path: :members do - resource :account_activation, path: :activation, as: :activation + resource :account_activation, except: :show, path: :activation, as: :activation resource :password, only: %i[edit update] resource :admin, only: %i[create destroy] get 'search', on: :member
Remove route for GET /members/:user_id/activation
diff --git a/config/routes.rb b/config/routes.rb index abc1234..def5678 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,8 +1,8 @@ Rails.application.routes.draw do root to: 'sites#index' - post 'omniauth/callback' => 'omniauth#callback', as: :omniauth - post '/auth/:provider/callback' => 'omniauth#callback' + post 'omniauth/callback' => 'omniauth#callback', as: :omniauth + get '/auth/:provider/callback' => 'omniauth#callback' delete '/signout' => 'sessions#destroy', as: :sign_out
Revert "Try fixing route after omniauth update" This reverts commit ec79b90d20aa9fbd4a43e2c4eeb757eb748e91c0.
diff --git a/spec/requests/tags_spec.rb b/spec/requests/tags_spec.rb index abc1234..def5678 100644 --- a/spec/requests/tags_spec.rb +++ b/spec/requests/tags_spec.rb @@ -0,0 +1,17 @@+require "spec_helper" + +describe "Tags" do + let(:tag) { FactoryGirl.create(:tag) } + let!(:thread) { FactoryGirl.create(:message_thread, tags: [tag]) } + let!(:issue) { FactoryGirl.create(:issue, tags: [tag]) } + let!(:library_note) { FactoryGirl.create(:library_note) } + + it "should show results" do + library_note.item.tags = [tag] + visit tag_path(tag) + page.should have_content(I18n.t(".tags.show.heading", name: tag.name)) + page.should have_link(thread.title) + page.should have_link(issue.title) + page.should have_link(library_note.title) + end +end
Test that the correct results show up on the tags page.
diff --git a/examples/broadcast/in-ruby.rb b/examples/broadcast/in-ruby.rb index abc1234..def5678 100644 --- a/examples/broadcast/in-ruby.rb +++ b/examples/broadcast/in-ruby.rb @@ -0,0 +1,18 @@+#!/usr/bin/env ruby +require 'socket' +require 'ipaddr' + +MULTICAST_ADDR = "224.0.0.3" +PORT = 47002 + +ip = IPAddr.new(MULTICAST_ADDR).hton + IPAddr.new("127.0.0.1").hton + +sock = UDPSocket.new +sock.setsockopt(Socket::IPPROTO_IP, Socket::IP_ADD_MEMBERSHIP, ip) +sock.bind(Socket::INADDR_ANY, PORT) + +puts 'Running, interrupt to exit.' +loop do + msg, info = sock.recvfrom(256) + puts "From #{info[3]}, xy says: #{msg}" +end
Add broadcast receiver example, in Ruby.
diff --git a/init.rb b/init.rb index abc1234..def5678 100644 --- a/init.rb +++ b/init.rb @@ -20,6 +20,4 @@ menu :project_menu, :deploys, { :controller => 'deploys', :action => 'index' }, :caption => 'Deploys', :after=>:activity, :param=>:project_id - menu :project_menu, :deployer, { :controller => 'deploys', :action => 'new' }, :caption => 'New Deploy', :after=>:deploys, :param=>:project_id - end
Remove new issue from project menu
diff --git a/init.rb b/init.rb index abc1234..def5678 100644 --- a/init.rb +++ b/init.rb @@ -2,7 +2,7 @@ Redmine::Plugin.register :redmine_pureftpd_user do name 'Redmine Pureftpd User plugin' - author 'Author name' - description 'This is a plugin for Redmine' - version '0.0.1' + author 'Bernd Ahlers' + description 'This plugin maintains a table with pureftpd compatible users.' + version '0.9' end
Add a description, my name and a version number.
diff --git a/lib/dugway/template.rb b/lib/dugway/template.rb index abc1234..def5678 100644 --- a/lib/dugway/template.rb +++ b/lib/dugway/template.rb @@ -29,7 +29,8 @@ def render(request, variables={}) if html? liquifier = Liquifier.new(request) - rendered_content = liquifier.render(content, variables) + content_to_render = variables[:page] && variables[:page]['content'] || content + rendered_content = liquifier.render(content_to_render, variables) if standalone_html? rendered_content
Fix issue loading content for custom pages
diff --git a/lib/wright/resource/link.rb b/lib/wright/resource/link.rb index abc1234..def5678 100644 --- a/lib/wright/resource/link.rb +++ b/lib/wright/resource/link.rb @@ -10,10 +10,10 @@ attr_accessor :source attr_reader :target - alias :target :name - alias :from :target - alias :to :source - alias :to= :source= + alias_method :target, :name + alias_method :from, :target + alias_method :to, :source + alias_method :to=, :source= def create! might_update_resource do
Use alias_method instead of alias
diff --git a/lib/fallback_router.rb b/lib/fallback_router.rb index abc1234..def5678 100644 --- a/lib/fallback_router.rb +++ b/lib/fallback_router.rb @@ -4,3 +4,25 @@ class << self end end + +class ActionDispatch::Routing::Mapper + + # Synthesizes HTTP HEAD routes, by extending any GET routes in the route_set to also respond to HEAD. + # + # This works around a bug in Rails 4.x where if an engine is mounted at '/' that accepts a wildcard glob, + # implicitly generated HEAD routes are not prioritized high enough in the routing table to be routed correctly, + # and will be accidentally routed to the mounted engine instead of the application. + # + # @param route_set an ActionDispatch::Routing::RouteSet to modify + # + def synthesize_head_routes(route_set, options = {}) + route_set.routes.each { |r| + constraint = r.constraints[:request_method] + if constraint === "GET" && !(constraint === "HEAD") + constraint_with_head = Regexp.compile(constraint.inspect.gsub(%r{/\^},'^').gsub(%r{\$/},'|HEAD$')) + r.constraints[:request_method] = constraint_with_head + end + } + end + +end
Add synthesize_head_routes helper to workaround HEAD routing bug in some Rails 4.x releases
diff --git a/lib/scratch/actions.rb b/lib/scratch/actions.rb index abc1234..def5678 100644 --- a/lib/scratch/actions.rb +++ b/lib/scratch/actions.rb @@ -7,6 +7,23 @@ def self.copy_templates(dest) + end + + def self.copy_file(src, dest) + FileUtils.cp(src, dest) + true + rescue Errno::ENOENT => e + $stderr.puts CLI::error("Could not copy file: #{e.message}") + return false + rescue Errno::EACCES => e + $stderr.puts CLI::error("Problem with permission while trying to copy #{e.message}") + return false + rescue ArgumentError + $stderr.puts CLI::error('Could not copy source to itself') + return false + rescue => e + $stderr.puts CLI::error("Unknown error while trying to copy file: #{e.message}") + return false end class Exec
Copy function that handles most known errors, it is wrapper over FileUtils.cp
diff --git a/lib/spree_omnikassa.rb b/lib/spree_omnikassa.rb index abc1234..def5678 100644 --- a/lib/spree_omnikassa.rb +++ b/lib/spree_omnikassa.rb @@ -12,7 +12,7 @@ end def self.activate - Dir.glob(File.join(File.dirname(__FILE__), "../../app/**/*_decorator*.rb")) do |c| + Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")) do |c| Rails.configuration.cache_classes ? require(c) : load(c) end end
Load decorators from correct dir, now that engine code was moved.
diff --git a/lib/tasks/test_js.rake b/lib/tasks/test_js.rake index abc1234..def5678 100644 --- a/lib/tasks/test_js.rake +++ b/lib/tasks/test_js.rake @@ -1 +1,7 @@-Rake::Task[:test].enhance { Rake::Task["konacha:run"].invoke } +Rake::Task[:test].enhance { Rake::Task['konacha:run'].invoke } + +namespace :test do + desc 'Test javascript with konacha via browser.' + task :js => 'konacha:serve' do + end +end
Add test:js task aliasing konacha:serve
diff --git a/spec/acceptance/class_spec.rb b/spec/acceptance/class_spec.rb index abc1234..def5678 100644 --- a/spec/acceptance/class_spec.rb +++ b/spec/acceptance/class_spec.rb @@ -15,19 +15,9 @@ end end - context 'sources_ensure => present:' do + context 'sources_manage => present:' do it 'runs successfully' do - pp = "class { 'git': sources_manage => true, sources_ensure => present, }" - - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stderr).not_to match(/error/i) - end - end - end - - context 'sources_ensure => absent:' do - it 'runs successfully' do - pp = "class { 'git': sources_manage => true, sources_ensure => absent, }" + pp = "class { 'git': sources_manage => true }" apply_manifest(pp, :catch_failures => true) do |r| expect(r.stderr).not_to match(/error/i)
Add acceptance test to check for package install and uninstall.
diff --git a/spec/factories/navigations.rb b/spec/factories/navigations.rb index abc1234..def5678 100644 --- a/spec/factories/navigations.rb +++ b/spec/factories/navigations.rb @@ -1,6 +1,6 @@ FactoryGirl.define do factory :navigation do - sequence(:name) { |n| "foo-#{n}" } + sequence(:identifier) { |n| "foo-#{n}" } description 'foo' end end
Rename name to identifier in the navigation factory.
diff --git a/spec/support/active_record.rb b/spec/support/active_record.rb index abc1234..def5678 100644 --- a/spec/support/active_record.rb +++ b/spec/support/active_record.rb @@ -11,13 +11,14 @@ ActiveRecord::Base.establish_connection(:default) ActiveRecord::Base.connection.execute <<SQL - --Create the dummy database CREATE TABLE IF NOT EXISTS sources ( id INTEGER PRIMARY KEY AUTOINCREMENT, val NUMERIC, content TEXT ); +SQL + ActiveRecord::Base.connection.execute <<SQL CREATE TABLE IF NOT EXISTS destinations ( id INTEGER PRIMARY KEY AUTOINCREMENT, val NUMERIC,
Fix creating the destinations table.
diff --git a/Casks/handbrakecli-nightly.rb b/Casks/handbrakecli-nightly.rb index abc1234..def5678 100644 --- a/Casks/handbrakecli-nightly.rb +++ b/Casks/handbrakecli-nightly.rb @@ -1,6 +1,6 @@ cask :v1 => 'handbrakecli-nightly' do - version '6945svn' - sha256 '303289b4ed14f9053d1ccaf01bd440d33418a8303cdf9c69e0116d45cec5b9e3' + version '6985svn' + sha256 'c2dd1a1c94dff36b74bbabea48d0361666208b94b305aa0e9b87aa182b6af989' url "http://download.handbrake.fr/nightly/HandBrake-#{version}-MacOSX.6_CLI_x86_64.dmg" homepage 'http://handbrake.fr'
Update HandbrakeCLI Nightly to v6985svn HandBrakeCLI Nightly v6985svn built 2015-03-14.
diff --git a/spec/models/question_spec.rb b/spec/models/question_spec.rb index abc1234..def5678 100644 --- a/spec/models/question_spec.rb +++ b/spec/models/question_spec.rb @@ -4,5 +4,6 @@ "add some examples to (or delete) #{__FILE__}" describe 'polymorphism works for the questions model' do + end end
Add end to block in Question spec
diff --git a/Casks/adobe-air.rb b/Casks/adobe-air.rb index abc1234..def5678 100644 --- a/Casks/adobe-air.rb +++ b/Casks/adobe-air.rb @@ -1,8 +1,8 @@ class AdobeAir < Cask - url 'http://airdownload.adobe.com/air/mac/download/3.9/AdobeAIR.dmg' + url 'http://airdownload.adobe.com/air/mac/download/4.0/AdobeAIR.dmg' homepage 'https://get.adobe.com/air/' - version '3.9' - sha1 '69863ef58dca864c9b9016b512ea79e5d1429498' + version '4.0' + sha1 'f319c2c603ff39e596c1c78c257980cf4fb0d0ef' caskroom_only true after_install do
Update Adobe Air to 4.0
diff --git a/.github/workflows/scripts/tag_info.rb b/.github/workflows/scripts/tag_info.rb index abc1234..def5678 100644 --- a/.github/workflows/scripts/tag_info.rb +++ b/.github/workflows/scripts/tag_info.rb @@ -10,11 +10,8 @@ --------------------------------------------------------- #{label.center(64)} --------------------------------------------------------- - - Pushed by: #{data.dig("pusher", "name")&.cyan} Repository: #{data.dig("repository", "full_name")&.cyan} - Head Commit Details: @@ -23,6 +20,5 @@ Author: #{data.dig("head_commit", "author", "username")&.cyan} Committer: #{data.dig("head_commit", "committer", "username")&.cyan} SHA ID: #{data.dig("head_commit", "id")&.cyan} - --------------------------------------------------------- TEXT
Remove printed blank lines from tag details
diff --git a/api.rb b/api.rb index abc1234..def5678 100644 --- a/api.rb +++ b/api.rb @@ -18,7 +18,7 @@ end entries = [] - regex = /FORECAST VALID (\d+\/\w+) (\d+.\d+N)\s+(\d+.\d+W)\s+MAX WIND\s+(\d+ KT).+GUSTS\s+(\d+ KT)/ + regex = /FORECAST VALID (\d+\/\w+) (\d+.\d+N)\s+(\d+.\d+W).*\s+MAX WIND\s+(\d+ KT).+GUSTS\s+(\d+ KT)/ matches = res.body.scan(regex) matches.each do |match| entries << { id: match[0], north: match[1], west: match[2], max: match[3], gusts: match[4] }
Update forecast regex to support INLAND labels Parser was breaking when "...INLAND" appear at the end of the first line
diff --git a/Casks/spectacle.rb b/Casks/spectacle.rb index abc1234..def5678 100644 --- a/Casks/spectacle.rb +++ b/Casks/spectacle.rb @@ -1,10 +1,16 @@ class Spectacle < Cask - version '0.8.8' - sha256 '7c7386e526cbabedb1e16f2e3366c7842712f590985fe9d4f57ff9c0a7854bcf' + if MacOS.version < :mavericks + version '0.8.6' + sha256 '3e367d2d7e6fe7d5f41d717d49cb087ba7432624b71ddd91c0cfa9d5a5459b7c' + else + version '0.8.8' + sha256 '7c7386e526cbabedb1e16f2e3366c7842712f590985fe9d4f57ff9c0a7854bcf' + + appcast 'http://spectacleapp.com/updates/appcast.xml', + :sha256 => '5d75e2e07886ca135916e224b4b5c1468d9af1ea8ef355db33b28bff511fa6b2' + end url "https://s3.amazonaws.com/spectacle/downloads/Spectacle+#{version}.zip" - appcast 'http://spectacleapp.com/updates/appcast.xml', - :sha256 => '5d75e2e07886ca135916e224b4b5c1468d9af1ea8ef355db33b28bff511fa6b2' homepage 'http://spectacleapp.com/' license :mit
Add Spectacle 0.8.6 for older (<Mavericks) Macs. Closes #7114.
diff --git a/Casks/tagspaces.rb b/Casks/tagspaces.rb index abc1234..def5678 100644 --- a/Casks/tagspaces.rb +++ b/Casks/tagspaces.rb @@ -2,6 +2,7 @@ version '2.3.0' sha256 '1b4823fc7ddae593df58c65f8269563569e57b2edc043861fc574c66e43d9c35' + # github.com/tagspaces/tagspaces was verified as official when first introduced to the cask url "https://github.com/tagspaces/tagspaces/releases/download/v#{version}/tagspaces-#{version}-osx64.zip" appcast 'https://github.com/tagspaces/tagspaces/releases.atom', checkpoint: '933c2a514b6a87d2ebf01e7cf730c6396ab0d681663f34501ff87e85706b4869'
Fix `url` stanza comment for TagSpaces.
diff --git a/core/db/migrate/20150806190833_add_id_and_timestamp_to_promotion_rule_user.rb b/core/db/migrate/20150806190833_add_id_and_timestamp_to_promotion_rule_user.rb index abc1234..def5678 100644 --- a/core/db/migrate/20150806190833_add_id_and_timestamp_to_promotion_rule_user.rb +++ b/core/db/migrate/20150806190833_add_id_and_timestamp_to_promotion_rule_user.rb @@ -0,0 +1,13 @@+class AddIdAndTimestampToPromotionRuleUser < ActiveRecord::Migration + def up + add_column :spree_promotion_rules_users, :id, :primary_key + add_column :spree_promotion_rules_users, :created_at, :datetime + add_column :spree_promotion_rules_users, :updated_at, :datetime + end + + def down + remove_column :spree_promotion_rules_users, :updated_at + remove_column :spree_promotion_rules_users, :created_at + remove_column :spree_promotion_rules_users, :id + end +end
Add id and timestamp to spree_promotion_rule_user
diff --git a/app.rb b/app.rb index abc1234..def5678 100644 --- a/app.rb +++ b/app.rb @@ -1,11 +1,27 @@ require "sinatra/base" -require "sinatra/reloader" if development? +require "sinatra/reloader" require "twitter" class Star < Sinatra::Base + configure do + @@config = YAML.load_file('config.yml') + + Twitter.configure do |config| + config.consumer_key = @@config["twitter"]["consumer_key"] + config.consumer_secret = @@config["twitter"]["consumer_secret"] + config.oauth_token = @@config["twitter"]["oauth_token"] + config.oauth_token_secret = @@config["twitter"]["oauth_token_secret"] + end + end + + configure :development do + register Sinatra::Reloader + also_reload "*.rb" + end + get '/' do - 'Star' + Twitter.favorites[0].to_s end end
Add Twitter configuration. Load config values from yaml file.
diff --git a/app.rb b/app.rb index abc1234..def5678 100644 --- a/app.rb +++ b/app.rb @@ -5,6 +5,17 @@ DataMapper.setup(:default, "sqlite://#{File.expand_path(File.dirname(__FILE__))}/db/tdrb.db") +class Task + include DataMapper::Resource + + property :id, Serial + property :body, Text + property :created_at, DateTime + property :tags, CommaSeparatedList +end + +DataMapper.auto_migrate! + get '/' do 'Hello, world.' end
Create Task table and call ::auto_migrate
diff --git a/db/migrate/20210729055206_change_id_columns_types_for_spree_volume_prices.rb b/db/migrate/20210729055206_change_id_columns_types_for_spree_volume_prices.rb index abc1234..def5678 100644 --- a/db/migrate/20210729055206_change_id_columns_types_for_spree_volume_prices.rb +++ b/db/migrate/20210729055206_change_id_columns_types_for_spree_volume_prices.rb @@ -0,0 +1,9 @@+class ChangeIdColumnsTypesForSpreeVolumePrices < ActiveRecord::Migration[4.2] + def change + change_table(:spree_volume_prices) do |t| + t.change :variant_id, :bigint + t.change :role_id, :bigint + t.change :volume_price_model_id, :bigint + end + end +end
Change integer id columns into bigint
diff --git a/cookbooks/pybossa/recipes/default.rb b/cookbooks/pybossa/recipes/default.rb index abc1234..def5678 100644 --- a/cookbooks/pybossa/recipes/default.rb +++ b/cookbooks/pybossa/recipes/default.rb @@ -11,7 +11,7 @@ end execute "install pybossa requirements" do - command ". vagrant_env/bin/activate; pip install -e ." + command ". vagrant_env/bin/activate; pip install --pre -e ." cwd "/vagrant" end
Use --pre for pip 1.4
diff --git a/euler5.rb b/euler5.rb index abc1234..def5678 100644 --- a/euler5.rb +++ b/euler5.rb @@ -0,0 +1,19 @@+=begin + +2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. + +What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20? + +=end + +def smallest_multiple(limit) + i = limit * 2 + until !((limit / 2)..limit).any? { |n| i % n != 0 } + i += limit + end + i +end + +# Driver tests +p smallest_multiple(10) == 2520 +p smallest_multiple(20) == 232792560
Add solution for problem 5
diff --git a/db/data_migration/20170818104227_convert_unknown_news_articles_to_valid_news_articles.rb b/db/data_migration/20170818104227_convert_unknown_news_articles_to_valid_news_articles.rb index abc1234..def5678 100644 --- a/db/data_migration/20170818104227_convert_unknown_news_articles_to_valid_news_articles.rb +++ b/db/data_migration/20170818104227_convert_unknown_news_articles_to_valid_news_articles.rb @@ -0,0 +1,21 @@+begin + # Update NewsArticles in Whitehall + unknown_news_articles = NewsArticle.by_subtype(NewsArticleType::Unknown) + document_ids = unknown_news_articles.map { |n| n.document_id }.uniq + press_releases = unknown_news_articles.includes(:document).select { |n| n.slug.include?("press-release") } + news_stories = unknown_news_articles - press_releases + + press_releases.update_all(news_article_type_id: NewsArticleType::PressRelease.id) + press_releases.where(minor_change: false, change_note: nil).update_all(change_note: "This news article was converted to a press release") + + news_stories.update_all(news_article_type_id: NewsArticleType::NewsStory.id) + news_stories.where(minor_change: false, change_note: nil).update_all(change_note: "This news article was converted to a news story") + + # Republish updated NewsArticles to PublishingAPI + document_ids.each do |id| + PublishingApiDocumentRepublishingWorker.perform_async_in_queue("bulk_republishing", id) + print "." + end +rescue NameError => e + puts "Can't apply data migration: #{e.message}" +end
Add data migration to convert unknown news articles The NewsArticleType Unknown is a legacy concept. These are NewsArticles that were never categorised into one of the other NewsArticleTypes. These are surfaced on the frontend via the [Announcements page](www.gov.uk/government/announcements) and do get shown when filtering by PressRelease or NewsStory. Therefore it seems acceptable to convert these into the relevant types. This will enable us to remove the ‘Unknown’ NewsArticleType as well as some code that goes with this special case (in a future PR).
diff --git a/tasks/buildr_artifact_patch.rake b/tasks/buildr_artifact_patch.rake index abc1234..def5678 100644 --- a/tasks/buildr_artifact_patch.rake +++ b/tasks/buildr_artifact_patch.rake @@ -0,0 +1,46 @@+raise 'Patch already integrated into buildr code' unless Buildr::VERSION.to_s == '1.5.6' + +class URI::HTTP + private + + def write_internal(options, &block) + options ||= {} + connect do |http| + trace "Uploading to #{path}" + http.read_timeout = 500 + content = StringIO.new + while chunk = yield(RW_CHUNK_SIZE) + content << chunk + end + headers = { 'Content-MD5' => Digest::MD5.hexdigest(content.string), 'Content-Type' => 'application/octet-stream', 'User-Agent' => "Buildr-#{Buildr::VERSION}" } + request = Net::HTTP::Put.new(request_uri.empty? ? '/' : request_uri, headers) + request.basic_auth URI.decode(self.user), URI.decode(self.password) if self.user + response = nil + with_progress_bar options[:progress], path.split('/').last, content.size do |progress| + request.content_length = content.size + content.rewind + stream = Object.new + class << stream; + self; + end.send :define_method, :read do |*args| + bytes = content.read(*args) + progress << bytes if bytes + bytes + end + request.body_stream = stream + response = http.request(request) + end + + case response + when Net::HTTPRedirection + # Try to download from the new URI, handle relative redirects. + trace "Redirected to #{response['Location']}" + content.rewind + return (self + URI.parse(response['location'])).write_internal(options) {|bytes| content.read(bytes)} + when Net::HTTPSuccess + else + raise RuntimeError, "Failed to upload #{self}: #{response.message}" + end + end + end +end
Apply patch to work around Buildr password encoding issue
diff --git a/test/lib/test_core_extensions.rb b/test/lib/test_core_extensions.rb index abc1234..def5678 100644 --- a/test/lib/test_core_extensions.rb +++ b/test/lib/test_core_extensions.rb @@ -9,6 +9,7 @@ assert_equal "FALSE".to_b, false assert_equal " true ".to_b, true assert_equal " false ".to_b, false + assert_equal "Any true value".to_b, "Any true value" end # Taken from ActiveSupport: /activesupport/test/core_ext/blank_test.rb
Update string core ext to_b test so string with other content that doesn't match even if it contains true/false should return the same value.
diff --git a/Formula/tmptoml.rb b/Formula/tmptoml.rb index abc1234..def5678 100644 --- a/Formula/tmptoml.rb +++ b/Formula/tmptoml.rb @@ -1,4 +1,4 @@-class TmpToml < Formula +class Tmptoml < Formula desc "Command-line utility to render Tera templates using a toml config file as the variable source." homepage "https://github.com/uptech/tmptoml" url "https://github.com/uptech/tmptoml.git", tag: "0.1.3", revision: "f4faf718dddc00b1e31dcb455fe0c28bca1fc574"
Fix class name for Tmptoml in Formula ps-id: BA5BFDF4-45E8-4261-8CF0-4261970251C3
diff --git a/lib/license_finder/package_managers/pipenv.rb b/lib/license_finder/package_managers/pipenv.rb index abc1234..def5678 100644 --- a/lib/license_finder/package_managers/pipenv.rb +++ b/lib/license_finder/package_managers/pipenv.rb @@ -11,16 +11,18 @@ end def current_packages - packages = [] + packages = {} each_dependency do |name, data, group| version = canonicalize(data['version']) - if package = packages.find { |x| x.name == name && x.version == version } + key = key_for(name, version) + + if package = packages[key] package.groups << group else - packages.push(build_package_for(name, version, [group])) + packages[key] = build_package_for(name, version, [group]) end end - packages + packages.values end def possible_package_paths @@ -48,5 +50,9 @@ def build_package_for(name, version, groups) PipPackage.new(name, version, PyPI.definition(name, version), groups: groups) end + + def key_for(name, version) + [name, version].map(&:to_s).join('-') + end end end
Use a Hash for O(1) lookup
diff --git a/config/initializers/multiple_token_strategy.rb b/config/initializers/multiple_token_strategy.rb index abc1234..def5678 100644 --- a/config/initializers/multiple_token_strategy.rb +++ b/config/initializers/multiple_token_strategy.rb @@ -10,7 +10,8 @@ user_token = AuthToken.find_by_token(params[:auth_token]) if user_token - if user_token.user + user = user_token.user + if user user.after_database_authentication success!(user) end
Fix problem with authentication strategy
diff --git a/app/models/api/scaled_area.rb b/app/models/api/scaled_area.rb index abc1234..def5678 100644 --- a/app/models/api/scaled_area.rb +++ b/app/models/api/scaled_area.rb @@ -3,9 +3,7 @@ # Area features which are disabled in the ETM front-end for all scaled # scenarios. - DISABLED_FEATURES = [ - :has_other, :has_electricity_storage, :has_fce, :use_network_calculations - ].freeze + DISABLED_FEATURES = [:has_other, :has_fce, :use_network_calculations] # Area features which may be turned on or off by the user when the start a new # scaled scenario.
Enable storage features in testing grounds If the full-size region sets has_electricity_storage=false, storage-related pages will still not be shown. However, if the region permits storage, it will no longer be forcibly turned off in scaled-down scenarios. Closes #1880
diff --git a/cruise_config.rb b/cruise_config.rb index abc1234..def5678 100644 --- a/cruise_config.rb +++ b/cruise_config.rb @@ -1,5 +1,5 @@ require 'fileutils' Project.configure do |project| - project.build_command = 'source /usr/local/rvm/scripts/rvm && rvm use ruby-1.8.7-p249@diaspora && gem update --system && ruby lib/cruise/build.rb' + project.build_command = 'source /usr/local/rvm/scripts/rvm && rvm use ruby-1.8.7-p249@diaspora && rm Gemfile.lock && gem update --system && ruby lib/cruise/build.rb' end
Remove Gemfile.lock before doing rake cruise
diff --git a/spec/controllers/chat_messages_controller_spec.rb b/spec/controllers/chat_messages_controller_spec.rb index abc1234..def5678 100644 --- a/spec/controllers/chat_messages_controller_spec.rb +++ b/spec/controllers/chat_messages_controller_spec.rb @@ -2,39 +2,51 @@ require "rspec/mocks" describe ChatMessagesController do + before do + @user = Factory(:user) + @group = Factory(:group, :founder => @user) + @chat_room = @group.chat_room + + test_sign_in(@user) + end + describe "#create" do before do - @user = Factory(:user) - @group = Factory(:group, :founder => @user) - - test_sign_in(@user) + REDIS.should_receive(:publish) + post :create, + :group_id => @group.id, + :chat_room_id => @chat_room.id, + :chat_message => { :content => "Hi there" } end - context "with js format" do - it "should respond with :created status" do + specify { subject.should redirect_to(group_chat_room_path(@group)) } + end + + describe "#create.js" do + describe "with valid data" do + before do REDIS.should_receive(:publish) - post :create, :group_id => @group.id, :chat_message => { :content => "Hi there JS" }, :format => "js" - - response.status.should be == 201 + post :create, + :group_id => @group.id, + :chat_room_id => @chat_room.id, + :chat_message => { :content => "Hi there JS" }, + :format => "js" end - it "should respond with :bad_request status with invalid data" do - post :create, :group_id => @group.id, :format => "js" - - response.status.should be == 400 - end + specify { response.should be_success } end - context "with html format" do - subject do - post :create, :group_id => @group.id, :chat_message => { :content => "Hi there" } + describe "with invalid data" do + before do + post :create, + :group_id => @group.id, + :chat_room_id => @chat_room.id, + :chat_message => {}, + :format => "js" end - it "should redirect to group_chat_room" do - ::REDIS.should_receive(:publish) + specify { response.should_not be_success } + end - subject.should redirect_to(group_chat_room_path(@group)) - end - end end end
Refactor ChatMessagesController spec, fix errors in spec
diff --git a/spec/unit/puppet/provider/cs_property_crm_spec.rb b/spec/unit/puppet/provider/cs_property_crm_spec.rb index abc1234..def5678 100644 --- a/spec/unit/puppet/provider/cs_property_crm_spec.rb +++ b/spec/unit/puppet/provider/cs_property_crm_spec.rb @@ -0,0 +1,51 @@+require 'spec_helper' + +describe Puppet::Type.type(:cs_property).provider(:crm) do + before do + described_class.stubs(:command).with(:crm).returns 'crm' + end + + context 'when getting instances' do + let :instances do + + test_cib = <<-EOS + <cib> + <configuration> + <crm_config> + <cluster_property_set> + <nvpair name="apples" value="red"/> + <nvpair name="oranges" value="orange"/> + </cluster_property_set> + </crm_config> + </configuration> + </cib> + EOS + + described_class.expects(:block_until_ready).returns(nil) + Puppet::Util::SUIDManager.expects(:run_and_capture).with(['crm', 'configure', 'show', 'xml']).at_least_once.returns([test_cib, 0]) + instances = described_class.instances + end + + it 'should have an instance for each <nvpair> in <cluster_property_set>' do + expect(instances.count).to eq(2) + end + + describe 'each instance' do + let :instance do + instances.first + end + + it "is a kind of #{described_class.name}" do + expect(instance).to be_a_kind_of(described_class) + end + + it "is named by the <nvpair>'s name attribute" do + expect(instance.name).to eq("apples") + end + + it "has a value corresponding to the <nvpair>'s value attribute" do + expect(instance.value).to eq("red") + end + end + end +end
Implement basic tests for cs_property provider
diff --git a/lib/sidekiq-unique-jobs/middleware/client/connectors/testing_inline.rb b/lib/sidekiq-unique-jobs/middleware/client/connectors/testing_inline.rb index abc1234..def5678 100644 --- a/lib/sidekiq-unique-jobs/middleware/client/connectors/testing_inline.rb +++ b/lib/sidekiq-unique-jobs/middleware/client/connectors/testing_inline.rb @@ -1,4 +1,5 @@ require 'sidekiq-unique-jobs/middleware/client/connectors/connector' +require 'sidekiq-unique-jobs/middleware/server/unique_jobs' module SidekiqUniqueJobs module Middleware
Fix dependency error in inline testing connector
diff --git a/db/migrate/20161228101445_sourceable_status.rb b/db/migrate/20161228101445_sourceable_status.rb index abc1234..def5678 100644 --- a/db/migrate/20161228101445_sourceable_status.rb +++ b/db/migrate/20161228101445_sourceable_status.rb @@ -0,0 +1,9 @@+class SourceableStatus < ActiveRecord::Migration[5.0] + def change + add_column :groups, :status, :integer, default: 0 + + add_column :rooms, :status, :integer, default: 0 + + add_column :users, :status, :integer, default: 0 + end +end
Add - Add Sourceable status
diff --git a/db-purge.gemspec b/db-purge.gemspec index abc1234..def5678 100644 --- a/db-purge.gemspec +++ b/db-purge.gemspec @@ -11,7 +11,7 @@ Clean the database prior to tests with db-purge. TEXT spec.files = Dir['{lib}/**/*', '*.gemspec'] + - ['Rakefile'] + ['LICENSE', 'README.rdoc', 'CHANGELOG', 'Rakefile'] spec.require_paths = ['lib'] spec.has_rdoc = false
Include other text files in the gem
diff --git a/faraday-detailed_logger.gemspec b/faraday-detailed_logger.gemspec index abc1234..def5678 100644 --- a/faraday-detailed_logger.gemspec +++ b/faraday-detailed_logger.gemspec @@ -25,7 +25,7 @@ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - spec.add_runtime_dependency "faraday" + spec.add_runtime_dependency "faraday", "~> 0.8" spec.add_development_dependency "appraisal", "~> 2.0" spec.add_development_dependency "bundler", "~> 1.12"
Set a minimum version constraint on Faraday.
diff --git a/spec/functional/fc009_spec.rb b/spec/functional/fc009_spec.rb index abc1234..def5678 100644 --- a/spec/functional/fc009_spec.rb +++ b/spec/functional/fc009_spec.rb @@ -11,8 +11,8 @@ it { is_expected.not_to violate_rule } end - context "on chef 13.9.1 with a cookbook that uses ifconfig attributes introduced in 14.0" do - foodcritic_command("--chef-version", "13.9.1", "--no-progress", ".") + context "on chef 13.11.3 with a cookbook that uses ifconfig attributes introduced in 14.0" do + foodcritic_command("--chef-version", "13.11.3", "--no-progress", ".") recipe_file <<-EOH ifconfig 'foo' do family 'inet'
Update spec for Chef 13.11.3 Signed-off-by: Tim Smith <764ef62106582a09ed09dfa0b6bff7c05fd7d1e4@chef.io>
diff --git a/spec/index_controller_spec.rb b/spec/index_controller_spec.rb index abc1234..def5678 100644 --- a/spec/index_controller_spec.rb +++ b/spec/index_controller_spec.rb @@ -0,0 +1,15 @@+require 'spec_helper' + +describe 'index controller' do + describe "GET '/' " do + it 'loads the homepage' do + get('/') + expect(last_response).to be_ok + end + + it 'contains appropriate header' do + get('/') + expect(last_response.body).to include("iNaturalist Info!") + end + end +end
Add simple tests for index controller
diff --git a/spec/models/character_spec.rb b/spec/models/character_spec.rb index abc1234..def5678 100644 --- a/spec/models/character_spec.rb +++ b/spec/models/character_spec.rb @@ -6,4 +6,25 @@ it_behaves_like 'content with privacy' it_behaves_like 'content with an is_public scope' it { is_expected.to validate_presence_of(:name) } + + context "when character having a sibling is deleted" do + before do + @alice = create(:character, name: "Alice") + @bob = create(:character, name: "Bob") + @alice.siblings << @bob + @alice.destroy() + end + + it "don't delete the sibling" do + expect(Character.exists?(@bob.id)).to be true + end + + it "delete sibling relation" do + expect(@alice.siblings.include?(@bob)).to be false + end + + it "delete reverse sibling relation" do + expect(@bob.siblings.include?(@alice)).to be false + end + end end
Add deletion test for sibling relation
diff --git a/spec/models/following_spec.rb b/spec/models/following_spec.rb index abc1234..def5678 100644 --- a/spec/models/following_spec.rb +++ b/spec/models/following_spec.rb @@ -1,5 +1,48 @@ require 'spec_helper' describe Following do - pending "add some examples to (or delete) #{__FILE__}" + it { should belong_to(:followee) } + it { should belong_to(:follower) } + + [:followee_id, :follower_id].each do |attr| + it { should validate_presence_of(attr) } + end + + describe "callbacks" do + let(:following) { Following.make(followee: followee, follower: follower) } + let(:followee) { User.make } + let(:follower) { User.make } + let(:counter) { double("counter", increment: true, decrement: true) } + + before do + following.stub(:persisted?) { true } + following.stub(:notify) { true } + followee.stub(:followers_count) { counter } + followee.stub(:push_stats) { true } + end + + context "create" do + it "increments user stats" do + followee.followers_count.should_receive(:increment) + following.run_callbacks(:create) + end + + it "pushes the new stats" do + followee.should_receive(:push_stats) + following.run_callbacks(:create) + end + end + + context "destroy" do + it "decrements user stats" do + followee.followers_count.should_receive(:decrement) + following.run_callbacks(:destroy) + end + + it "pushes the new stats" do + followee.should_receive(:push_stats) + following.run_callbacks(:destroy) + end + end + end end
Add basic specs for Following
diff --git a/spec/tic_tac_toe/rack_spec.rb b/spec/tic_tac_toe/rack_spec.rb index abc1234..def5678 100644 --- a/spec/tic_tac_toe/rack_spec.rb +++ b/spec/tic_tac_toe/rack_spec.rb @@ -1,5 +1,14 @@ require 'spec_helper' +require 'rack' +require 'tic_tac_toe/rack_shell' describe TicTacToe::RackShell do + it 'can receive an index/root GET request' do + app = TicTacToe::RackShell.new_shell + req = Rack::MockRequest.new(app) + response = req.get("/") + expect(response.accepted?).to be_truthy + end + end
Add a basic MockRequest test for RackShell
diff --git a/doc/ex/splice.rb b/doc/ex/splice.rb index abc1234..def5678 100644 --- a/doc/ex/splice.rb +++ b/doc/ex/splice.rb @@ -5,9 +5,6 @@ # Demonstrate the splice method. img = Image.read('images/Flower_Hat.jpg').first - -geom = Geometry.new(20,20, img.columns/2, img.rows/2) - -spliced_img = img.splice(geom, 'red') +spliced_img = img.splice(img.columns/2, img.rows/2, 20, 20, 'gray80') spliced_img.write('splice.jpg')
Update to use new arg list
diff --git a/lib/mongoid/fields/mappings.rb b/lib/mongoid/fields/mappings.rb index abc1234..def5678 100644 --- a/lib/mongoid/fields/mappings.rb +++ b/lib/mongoid/fields/mappings.rb @@ -9,8 +9,6 @@ # definable field in Mongoid. module Mappings extend self - - MODULE = Mongoid::Fields::Internal # Get the custom field type for the provided class used in the field # definition. @@ -27,12 +25,12 @@ if klass.nil? Internal::Object elsif foreign_key - MODULE::ForeignKeys.const_get(klass.to_s.demodulize) + Internal::ForeignKeys.const_get(klass.to_s.demodulize) else modules = "BSON::|ActiveSupport::" match = klass.to_s.match(Regexp.new("^(#{ modules })?(\\w+)$")) - if match and MODULE.const_defined?(match[2]) - MODULE.const_get(match[2]) + if match and Internal.const_defined?(match[2]) + Internal.const_get(match[2]) else klass end
Use the actual constant since we don't need it's string representation
diff --git a/lib/pycall/pyobject_wrapper.rb b/lib/pycall/pyobject_wrapper.rb index abc1234..def5678 100644 --- a/lib/pycall/pyobject_wrapper.rb +++ b/lib/pycall/pyobject_wrapper.rb @@ -1,7 +1,8 @@ module PyCall module PyObjectWrapper - def initialize(pyobj, pytype) + def initialize(pyobj, pytype=nil) check_type pyobj, pytype + pytype ||= LibPython.PyObject_Type(pyobj) @__pyobj__ = pyobj end @@ -41,7 +42,8 @@ private def check_type(pyobj, pytype) - return if pyobj.kind_of?(PyObject) && pyobj.kind_of?(pytype) + return if pyobj.kind_of?(PyObject) + return if pytype.nil? || pyobj.kind_of?(pytype) raise TypeError, "the argument must be a PyObject of #{pytype}" end end
Make pytype ignorable in PyObjectWrapper
diff --git a/lib/extras/simple_form_extensions.rb b/lib/extras/simple_form_extensions.rb index abc1234..def5678 100644 --- a/lib/extras/simple_form_extensions.rb +++ b/lib/extras/simple_form_extensions.rb @@ -13,13 +13,19 @@ args << options # rubocop:disable AssignmentInCondition if cancel = options.delete(:cancel) - template.content_tag :div, class: 'col-sm-offset-2' do - submit(*args, &block) + ' ' + template.link_to( - template.button_tag(I18n.t('simple_form.buttons.cancel'), - type: 'button', class: 'btn btn-default'), cancel) + template.content_tag :div, class: 'form-group' do + template.content_tag :div, class: 'col-sm-offset-2 col-sm-10' do + submit(*args, &block) + ' ' + template.link_to( + template.button_tag(I18n.t('simple_form.buttons.cancel'), + type: 'button', class: 'btn btn-default'), cancel) + end end else - submit(*args, &block) + template.content_tag :div, class: 'form-group' do + template.content_tag :div, class: 'col-sm-offset-2 col-sm-10' do + submit(*args, &block) + end + end end # rubocop:enable AssignmentInCondition end
Fix submit button alignment in all cases
diff --git a/lib/tumblargh/renderer/base.rb b/lib/tumblargh/renderer/base.rb index abc1234..def5678 100644 --- a/lib/tumblargh/renderer/base.rb +++ b/lib/tumblargh/renderer/base.rb @@ -36,8 +36,12 @@ real_post end - def escape(str) + def escape_html(str) CGI.escapeHTML(str) + end + + def escape_url(url) + CGI.escape(url) end def strip_html(str)
Add an escape_url helper, rename existing escape to escape_html
diff --git a/lib/verifier/expressions/if.rb b/lib/verifier/expressions/if.rb index abc1234..def5678 100644 --- a/lib/verifier/expressions/if.rb +++ b/lib/verifier/expressions/if.rb @@ -7,6 +7,14 @@ class IfBranch attr_reader :condition, :body + + def self.if(condition, body) + IfBranch.new(condition, body) + end + + def self.else(body) + IfBranch.new(nil, body) + end def initialize(condition, body) @condition = condition
Add nice constructors to 'If' expression
diff --git a/lib/kindle/annotator/models/books.rb b/lib/kindle/annotator/models/books.rb index abc1234..def5678 100644 --- a/lib/kindle/annotator/models/books.rb +++ b/lib/kindle/annotator/models/books.rb @@ -30,7 +30,7 @@ private def books_collection - @collection.map { |r| Book.new(r) } + @collection.map { |record| Book.new(record) } end end end
Change to use `record` instead of `r`
diff --git a/lib/fog/core/deprecated/connection.rb b/lib/fog/core/deprecated/connection.rb index abc1234..def5678 100644 --- a/lib/fog/core/deprecated/connection.rb +++ b/lib/fog/core/deprecated/connection.rb @@ -14,9 +14,9 @@ class Connection < Fog::XML::Connection def request(params, &block) if params.key?(:parser) - Fog::Logger.deprecation("Fog::XML::Connection is deprecated use Fog::XML::Connection instead [light_black](#{caller.first})[/]") + Fog::Logger.deprecation("Fog::Connection is deprecated use Fog::XML::Connection instead [light_black](#{caller.first})[/]") else - Fog::Logger.deprecation("Fog::XML::Connection is deprecated use Fog::Core::Connection instead [light_black](#{caller.first})[/]") + Fog::Logger.deprecation("Fog::Connection is deprecated use Fog::Core::Connection instead [light_black](#{caller.first})[/]") end super(params) end
Fix typo: Fog::Connection is deprecated, not Fog::XML::Connection. Commit 0e1daf3d did a mass rename and accidentally renamed the intended deprecated method.
diff --git a/recipes/client.rb b/recipes/client.rb index abc1234..def5678 100644 --- a/recipes/client.rb +++ b/recipes/client.rb @@ -20,7 +20,7 @@ # Installs InfluxDB client libraries [:cli, :ruby].each do |flavor| - next unless node[:influxdb][:client][flavor][:enable] + next unless (node[:influxdb][:client][flavor][:enable] rescue nil) include_recipe "influxdb::#{flavor}_client" end
Handle if a flavor isn't set in attributes
diff --git a/resources/preference.rb b/resources/preference.rb index abc1234..def5678 100644 --- a/resources/preference.rb +++ b/resources/preference.rb @@ -29,4 +29,4 @@ attribute :package_name, :kind_of => String, :name_attribute => true attribute :glob, :kind_of => String attribute :pin, :kind_of => String -attribute :pin_priority, :kind_of => String +attribute :pin_priority, :kind_of => [String, Integer]
Add type integer for pin_priority
diff --git a/Casks/julia.rb b/Casks/julia.rb index abc1234..def5678 100644 --- a/Casks/julia.rb +++ b/Casks/julia.rb @@ -1,6 +1,6 @@ cask 'julia' do - version '0.4.2' - sha256 '9ca3756d43cc10d950fafa6e93dd7f4c6ebeade5edb5307cc1e3217b04f5bbe1' + version '0.4.3' + sha256 '1d9010af32a2bb6cf58b20d4fb21165edd8d15399dd4ffdde7934b5fedd1a2ac' # amazonaws.com is the official download host per the vendor homepage url "https://s3.amazonaws.com/julialang/bin/osx/x64/#{version.sub(%r{\.\d+$}, '')}/julia-#{version}-osx10.7+.dmg"
Update to new version of Julia Updating version number and sha256 to Julia 0.4.3
diff --git a/Casks/tiled.rb b/Casks/tiled.rb index abc1234..def5678 100644 --- a/Casks/tiled.rb +++ b/Casks/tiled.rb @@ -0,0 +1,7 @@+class Tiled < Cask + url 'http://downloads.sourceforge.net/project/tiled/tiled-qt/0.9.1/tiled-qt-0.9.1.dmg' + homepage 'http://www.mapeditor.org/' + version '0.9.1' + sha1 'f7f30ec8761ffd7f293242287ff4d462e7ee17fb' + link 'Tiled.app' +end
Add a cask for Tiled.app
diff --git a/docman.gemspec b/docman.gemspec index abc1234..def5678 100644 --- a/docman.gemspec +++ b/docman.gemspec @@ -29,4 +29,5 @@ spec.add_dependency 'diffy' spec.add_dependency 'io-console' spec.add_dependency 'json' + spec.add_dependency 'etc' end
Add etc gem to work with ruby 2.5+.
diff --git a/lib/veewee/provider/vmfusion/box/export_ova.rb b/lib/veewee/provider/vmfusion/box/export_ova.rb index abc1234..def5678 100644 --- a/lib/veewee/provider/vmfusion/box/export_ova.rb +++ b/lib/veewee/provider/vmfusion/box/export_ova.rb @@ -41,7 +41,7 @@ # before exporting the system needs to be shut down # otherwise the debug log will show - The specified virtual disk needs repair - shell_exec("#{File.dirname(vmrun_cmd).shellescape}/ovftool/ovftool.bin #{debug} #{flags} #{vmx_file_path.shellescape} #{name}.ova") + shell_exec("#{File.dirname(vmrun_cmd).shellescape}#{"/VMware OVF Tool/ovftool".shellescape} #{debug} #{flags} #{vmx_file_path.shellescape} #{name}.ova") end end end
Correct ovftool path for Fusion 5
diff --git a/test/unit/iterator_test.rb b/test/unit/iterator_test.rb index abc1234..def5678 100644 --- a/test/unit/iterator_test.rb +++ b/test/unit/iterator_test.rb @@ -18,4 +18,12 @@ iterator.map(&:name).must_equal ['testname'] iterator.map(&:name).must_equal ['testname'] end + + it 'allows breaking off the loop' do + bin.add Gst::ElementFactory.make 'fakesink', 'othername' + iterator.map(&:name).must_equal ['othername', 'testname'] + result = nil + iterator.each { |it| result = it; break if it.name == 'othername' } + result.name.must_equal 'othername' + end end
Add test to demonstrate breaking of the loop works
diff --git a/lib/discordrb/events/await.rb b/lib/discordrb/events/await.rb index abc1234..def5678 100644 --- a/lib/discordrb/events/await.rb +++ b/lib/discordrb/events/await.rb @@ -17,7 +17,7 @@ class AwaitEventHandler < EventHandler def matches?(event) # Check for the proper event type - return false unless event.is_a? TypingEvent + return false unless event.is_a? AwaitEvent [ matches_all(@attributes[:key], event.key) { |a, e| a == e },
Change the event check type for the AwaitEventHandler
diff --git a/lib/foodcritic/rules/fc070.rb b/lib/foodcritic/rules/fc070.rb index abc1234..def5678 100644 --- a/lib/foodcritic/rules/fc070.rb +++ b/lib/foodcritic/rules/fc070.rb @@ -0,0 +1,63 @@+rule "FC070", "Ensure supports metadata defines valid platforms" do + tags %w{metadata} + metadata do |ast, filename| + # Where did this come from? We pulled every unique platform for supermarket cookbooks + # and then looked at all the invalid names. Lots of typos and bad characters and then + # a few entirely made up platforms + bad_chars = [" ", "'", ",", "\"", "/", "]", "[", "{", "}", "-", "=", ">"] + invalid_platforms = %w{ + aws + archlinux + amazonlinux + darwin + debuan + mingw32 + mswin + mac_os_x_server + linux + oel + oraclelinux + rhel + schientific + scientificlinux + sles + solaris + true + ubundu + ubunth + ubunutu + windwos + xcp + } + matches = false + + metadata_platforms = supported_platforms(ast).map { |x| x[:platform] } + + metadata_platforms.each do |plat| + break if matches # we found one on the previous run so stop looking + + # see if the platform is uppercase, which is invalid + unless plat.scan(/[A-Z]/).empty? + matches = true + break # stop looking + end + + # search for platform strings with bad strings in them + # these can't possibly be valid platforms + bad_chars.each do |char| + unless plat.scan(char).empty? + matches = true + break # stop looking + end + end + + # see if the platform is a commonly mistaken platform string + if invalid_platforms.include?(plat) + matches = true + break # stop looking + end + end + + [file_match(filename)] if matches + end +end
Add FC070 to detect invalid platform supports in metadata Signed-off-by: Tim Smith <764ef62106582a09ed09dfa0b6bff7c05fd7d1e4@chef.io>
diff --git a/lib/fulcrum/media_resource.rb b/lib/fulcrum/media_resource.rb index abc1234..def5678 100644 --- a/lib/fulcrum/media_resource.rb +++ b/lib/fulcrum/media_resource.rb @@ -11,8 +11,8 @@ 'default_content_type must be implemented in derived classes' end - def attributes_for_upload(file, id = new_id, content_type = default_content_type, attrs = {}) - file = Faraday::UploadIO.new(file, content_type) + def attributes_for_upload(file, id = new_id, content_type = nil, attrs = {}) + file = Faraday::UploadIO.new(file, content_type || default_content_type) resource_attributes = { file: file, access_key: id } @@ -23,7 +23,7 @@ attributes end - def create(file, id = new_id, content_type = default_content_type, attrs = {}) + def create(file, id = new_id, content_type = nil, attrs = {}) call(:post, create_action, attributes_for_upload(file, id, content_type, attrs)) end
Use the default a little later.
diff --git a/lib/net/socket/socket-hack.rb b/lib/net/socket/socket-hack.rb index abc1234..def5678 100644 --- a/lib/net/socket/socket-hack.rb +++ b/lib/net/socket/socket-hack.rb @@ -1,7 +1,10 @@-require 'socket' +require 'net/http' +require 'net/ftp' -module Net::Socket - ::Socket.constants.each do |name| - const_set(name, ::Socket.const_get(name)) - end +class Net::HTTP + Socket = ::Socket end + +class Net::FTP + Socket = ::Socket +end
Use a safer method of fixing Net::HTTP and Net::FTP, as suggested by @wilkie.
diff --git a/lib/rundock/operation/task.rb b/lib/rundock/operation/task.rb index abc1234..def5678 100644 --- a/lib/rundock/operation/task.rb +++ b/lib/rundock/operation/task.rb @@ -4,7 +4,7 @@ def run(backend, attributes = {}) @instruction.each do |i| unless attributes[:task].key?(i) - Logger.warn("[WARN]task not found and ignored: #{i}") + Logger.warn("task not found and ignored: #{i}") next end
Fix delete duplicate log output label
diff --git a/lib/vines/web/command/init.rb b/lib/vines/web/command/init.rb index abc1234..def5678 100644 --- a/lib/vines/web/command/init.rb +++ b/lib/vines/web/command/init.rb @@ -4,14 +4,14 @@ class Init def run(opts) raise 'vines-web init <domain>' unless opts[:args].size == 1 - raise "vines gem required: gem install vines" unless vines_installed? + raise 'vines gem required: gem install vines' unless vines_installed? domain = opts[:args].first.downcase base = File.expand_path(domain) `vines init #{domain}` unless File.exists?(base) - web = File.expand_path("../../../../../public", __FILE__) + web = File.expand_path('../../../../../public', __FILE__) FileUtils.cp_r(Dir.glob("#{web}/*"), 'web') puts "Web assets installed: #{domain}" @@ -22,6 +22,7 @@ def vines_installed? require 'vines/version' + true rescue LoadError false end
Fix vines gem install check.
diff --git a/spec/factories/locations.rb b/spec/factories/locations.rb index abc1234..def5678 100644 --- a/spec/factories/locations.rb +++ b/spec/factories/locations.rb @@ -10,6 +10,6 @@ FactoryBot.define do factory :location do - name { Faker::Address.city } + name { Faker::Address.unique.city } end end
Fix flakey test related with non unique location generation Tests like the following: https://github.com/ministryofjustice/Claim-for-Crown-Court-Defence/blob/0ea00787062887099785c2c2ea6ec307d34ef53a/spec/controllers/external_users/claims_controller_spec.rb#L657 were creating factory data for a location using Faker::Address.city but even though the location model expects unique names, the existent definition (using Faker) did not guarantee that. This fixes makes use of the `unique` method in Faker: https://github.com/stympy/faker#ensuring-unique-values
diff --git a/spec/integration/gc_spec.rb b/spec/integration/gc_spec.rb index abc1234..def5678 100644 --- a/spec/integration/gc_spec.rb +++ b/spec/integration/gc_spec.rb @@ -0,0 +1,31 @@+require 'spec_helper' + + +RSpec::Matchers.define :have_instance_count_of do |expected| + match do |actual| + ObjectSpace.each_object(actual).count == expected + end + + failure_message_for_should do |actual| + "expected that #{actual} to have instance count of #{expected} but got #{ObjectSpace.each_object(actual).count}" + end +end + +module LIFX + describe "garbage collection" do + describe "transports" do + it "cleans up the transports when a client is cleaned up" do + client = Client.new(transport_manager: TransportManager::LAN.new) + + expect(Transport::UDP).to have_instance_count_of(2) + + client = nil + GC.start + + [Client, NetworkContext, TransportManager::Base, Transport::Base, Light, LightCollection].each do |klass| + expect(klass).to have_instance_count_of(0) + end + end + end + end +end
Add a spec for things being removed from GC
diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb index abc1234..def5678 100644 --- a/spec/models/account_spec.rb +++ b/spec/models/account_spec.rb @@ -5,4 +5,10 @@ it { should accept_values_for(:title, "Test", "Test Account!") } it { should_not accept_values_for(:title, "", nil) } + + it { should accept_values_for(:code, "test", "test_account") } + it { should_not accept_values_for(:code, "", nil) } + + it { should accept_values_for(:account_type, FactoryGirl.build(:current_assets), FactoryGirl.build(:costs) ) } + it { should_not accept_values_for(:account_type, nil) } end
Test validations for Account.code and Account.account_type.
diff --git a/spec/mpeg4/box_path_spec.rb b/spec/mpeg4/box_path_spec.rb index abc1234..def5678 100644 --- a/spec/mpeg4/box_path_spec.rb +++ b/spec/mpeg4/box_path_spec.rb @@ -0,0 +1,47 @@+require 'file_data/formats/mpeg4/box_path' +require 'support/test_stream' +require 'file_data/helpers/stream_view' + +RSpec.describe FileData::BoxPath do + let(:view) do + v = Helpers::StreamView.new(TestStream.get_stream(bytes)) + v.seek(v.start_pos) + return v + end + + describe '#get_path' do + context 'when searching for a path that does not exist' do + let(:bytes) do + [[0, 0, 0, 8], # keys box size + 'keys'.each_byte.map { |x| x }, # keys box type 'keys' + [0, 0, 0, 24], # container box size + 'cbss'.each_byte.map { |x| x }, # container box type + [0, 0, 0, 8], # item1 box size + 'itm1'.each_byte.map { |x| x }, # item1 box type + [0, 0, 0, 8], # item2 box size + 'itm2'.each_byte.map { |x| x }].flatten # item2 box type + end + + it 'returns nil' do + expect(FileData::BoxPath.get_path(view, 'cbss', 'itm1', 'nope')).to be_nil + end + end + + context 'when searching for a path that does exist' do + let(:bytes) do + [[0, 0, 0, 8], # keys box size + 'keys'.each_byte.map { |x| x }, # keys box type 'keys' + [0, 0, 0, 24], # container box size + 'cbss'.each_byte.map { |x| x }, # container box type + [0, 0, 0, 8], # item1 box size + 'itm1'.each_byte.map { |x| x }, # item1 box type + [0, 0, 0, 8], # item2 box size + 'itm2'.each_byte.map { |x| x }].flatten # item2 box type + end + + it 'finds the box' do + expect(FileData::BoxPath.get_path(view, 'cbss', 'itm1').type).to eq('itm1') + end + end + end +end
Improve test coverage of box_path.rb
diff --git a/spec/pronto/message_spec.rb b/spec/pronto/message_spec.rb index abc1234..def5678 100644 --- a/spec/pronto/message_spec.rb +++ b/spec/pronto/message_spec.rb @@ -2,11 +2,15 @@ module Pronto describe Message do + let(:message) { Message.new(path, line, level, msg, '8cda581') } + + let(:path) { 'README.md' } + let(:line) { Git::Line.new } + let(:msg) { 'message' } + let(:level) { :warning } + describe '.new' do - subject { Message.new(path, line, level, msg, '8cda581') } - let(:path) { 'README.md' } - let(:line) { Rugged::Diff::Line.new } - let(:msg) { 'message' } + subject { message } Message::LEVELS.each do |message_level| context "set log level to #{message_level}" do @@ -14,6 +18,31 @@ its(:level) { should == message_level } end end + + context 'bad level' do + let(:level) { :random } + specify do + lambda { subject }.should raise_error + end + end + end + + describe '#full_path' do + subject { message.full_path } + + context 'line is nil' do + let(:line) { nil } + it { should be_nil } + end + end + + describe '#repo' do + subject { message.repo } + + context 'line is nil' do + let(:line) { nil } + it { should be_nil } + end end end end
Add more specs for Pronto::Message
diff --git a/ejaydj.gemspec b/ejaydj.gemspec index abc1234..def5678 100644 --- a/ejaydj.gemspec +++ b/ejaydj.gemspec @@ -21,6 +21,7 @@ spec.add_runtime_dependency "rest-client", "~> 1.7" spec.add_runtime_dependency "json" spec.add_runtime_dependency "twitter" + spec.add_runtime_dependency "googl" spec.add_development_dependency "bundler", "~> 1.6" spec.add_development_dependency "rake", "~> 10.0"
Add googl url shortener to runtime dependencies
diff --git a/gem-homepage.gemspec b/gem-homepage.gemspec index abc1234..def5678 100644 --- a/gem-homepage.gemspec +++ b/gem-homepage.gemspec @@ -3,11 +3,11 @@ Gem::Specification.new do |s| s.name = "gem-homepage" - s.version = "0.0.1" + s.version = "0.0.2" s.platform = Gem::Platform::RUBY s.authors = ["Tony Doan"] s.email = ["tdoan@tdoan.com"] - s.homepage = "http://github.com/tdon/gem-homepage" + s.homepage = "http://github.com/tdoan/gem-homepage" s.summary = "Open the homepage of a gem" s.description = s.summary
Fix typo in homepage for gem-hompage, bump version.
diff --git a/config/initializers/sentry.rb b/config/initializers/sentry.rb index abc1234..def5678 100644 --- a/config/initializers/sentry.rb +++ b/config/initializers/sentry.rb @@ -5,7 +5,7 @@ config.dsn = ENV['SENTRY_DSN'] config.breadcrumbs_logger = [:active_support_logger] - # Send 5% of transactions for performance monitoring - config.traces_sample_rate = 0.05 + # Send 10% of transactions for performance monitoring + config.traces_sample_rate = 0.1 end end
Revert "Reduce the Sentry sampling to 5%" This reverts commit 507d08ed62231721d88869056e3023a3eac153f0.
diff --git a/recipes/pacaur.rb b/recipes/pacaur.rb index abc1234..def5678 100644 --- a/recipes/pacaur.rb +++ b/recipes/pacaur.rb @@ -3,12 +3,9 @@ package('expac') { action :install } package('yajl') { action :install } -bash 'Importing key for cower' do - code <<-EOH - pacman-key --recv-key 1EB2638FF56C0C53 - pacman-key --lsign 1EB2638FF56C0C53 - EOH +pacman_aur 'cower' do + skippgpcheck true + action [:build, :install] end -pacman_aur('cower'){ action [:build, :install] } pacman_aur('pacaur'){ action [:build, :install] }
Use skippgpcheck instead of importing key (to the wrong keyring, besides). The default build user 'nobody' has no home directory, so cannot locally sign keys.
diff --git a/app/models/plot.rb b/app/models/plot.rb index abc1234..def5678 100644 --- a/app/models/plot.rb +++ b/app/models/plot.rb @@ -1,9 +1,9 @@ class Plot < ApplicationRecord validates :plot_id, presence: true - validates :latitude, presence: true, numericality: { greater_than: 0 } - validates :longitude, presence: true, numericality: { greater_than: 0 } - validates :elevation, numericality: { greater_than: 0, allow_nil: true } - validates :area, numericality: { greater_than: 0, allow_nil: true } + validates_numericality_of :latitude, greater_than: 0, allow_nil: true + validates_numericality_of :longitude, greater_than: 0, allow_nil: true + validates_numericality_of :elevation, greater_than: 0, allow_nil: true + validates_numericality_of :area, greater_than: 0, allow_nil: true validates :location_description, presence: true validates :aspect, presence: true validates :origin, presence: true
Undo validation changes, it broke too many tests and should be a different issue at this point
diff --git a/app/models/user.rb b/app/models/user.rb index abc1234..def5678 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -10,7 +10,7 @@ validates :name, presence: true validates :email, presence: true validates :password, presence: true - + include BCrypt def password @@ -21,4 +21,14 @@ @password = Password.create(new_password) self.password_hash = @password end + + def self.authenticate(username, password) + user = User.find_by(name: username) + if user && user.password == password + user + else + nil + end + end + end
Add authentication method to User model.
diff --git a/app/models/user.rb b/app/models/user.rb index abc1234..def5678 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -12,7 +12,8 @@ field "permissions", type: Hash attr_accessible :email, :name, :uid, :version - + attr_accessible :uid, :email, :name, :permissions, as: :oauth + def self.find_by_uid(uid) where(uid: uid).first end
Fix signin for reals this time
diff --git a/app/models/vote.rb b/app/models/vote.rb index abc1234..def5678 100644 --- a/app/models/vote.rb +++ b/app/models/vote.rb @@ -3,4 +3,6 @@ belongs_to :user belongs_to :response + validates :user, uniqueness: { scope: :response, + message: "User can only vote on this response once."} end
Resolve merge conflict by keeping validations that prevent users from voting on more than one response per question.
diff --git a/apache-log.gemspec b/apache-log.gemspec index abc1234..def5678 100644 --- a/apache-log.gemspec +++ b/apache-log.gemspec @@ -8,12 +8,15 @@ gem.version = Apache::Log::VERSION gem.authors = ["Fabian Becker"] gem.email = ["halfdan@xnorfz.de"] - gem.description = %q{Helper library for managing, parsing and generating Apache log files (or nginx)} - gem.summary = %q{Helper library for managing, parsing and generating Apache log files (or nginx)} + gem.summary = %q{Easily manage, parse and generate Apache/nginx log files} gem.homepage = "http://github.com/halfdan/apache-log" + gem.description = <<-DESC + Helper library for managing, parsing and generating Apache log files (or nginx) + DESC gem.files = `git ls-files`.split($/) gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) } gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) gem.require_paths = ["lib"] + gem.add_development_dependency "rspec", "~> 2.12.0" end
Add RSpec as development dependency