diff
stringlengths
65
26.7k
message
stringlengths
7
9.92k
diff --git a/test/panopticon_test.rb b/test/panopticon_test.rb index abc1234..def5678 100644 --- a/test/panopticon_test.rb +++ b/test/panopticon_test.rb @@ -11,20 +11,20 @@ end def test_it_returns_an_http_201_for_success - params = {:name => 'james', :owning_app => 'guides', :kind => 'guide'} + params = {:name => 'james1', :owning_app => 'guides', :kind => 'guide'} post '/slugs', :slug => params assert_equal 201, last_response.status end def test_it_returns_an_http_406_for_duplicate_slug - params = {:name => 'james', :owning_app => 'guides', :kind => 'blah'} + params = {:name => 'james2', :owning_app => 'guides', :kind => 'blah'} post '/slugs', :slug => params post '/slugs', :slug => params assert_equal 406, last_response.status end def test_get_returns_details_as_json - params = {:name => 'another-james', :owning_app => 'guides', :kind => 'blah'} + params = {:name => 'james3', :owning_app => 'guides', :kind => 'blah'} post '/slugs', :slug => params get '/slugs/another-james' assert_equal 200, last_response.status
Fix tests so that we don't get sequencing issues
diff --git a/test/integration/default/serverspec/spec_helper.rb b/test/integration/default/serverspec/spec_helper.rb index abc1234..def5678 100644 --- a/test/integration/default/serverspec/spec_helper.rb +++ b/test/integration/default/serverspec/spec_helper.rb @@ -6,6 +6,6 @@ RSpec.configure do |c| c.before :all do - c.path = '/bin:/sbin:/usr/bin' + c.path = '/bin:/sbin:/usr/sbin:/usr/bin' end end
Add /usr/sbin to RSpec path for testing.
diff --git a/test/integration/ubuntu12_04_test.rb b/test/integration/ubuntu12_04_test.rb index abc1234..def5678 100644 --- a/test/integration/ubuntu12_04_test.rb +++ b/test/integration/ubuntu12_04_test.rb @@ -6,7 +6,7 @@ end def image_id - "ami-098f5760" + "ami-9a873ff3" end def prepare_command
Fix Ubuntu 12.04 AMI ID in integration tests The previous AMI was really Ubuntu 10.10 "Maverick".
diff --git a/tinge.gemspec b/tinge.gemspec index abc1234..def5678 100644 --- a/tinge.gemspec +++ b/tinge.gemspec @@ -18,7 +18,9 @@ spec.require_paths = ["lib"] spec.add_dependency "thor" - spec.add_dependency "sass", "3.3.0.rc.2" + spec.add_dependency "sass", "~> 3.3.0.rc.2" + spec.add_dependency "ase" + spec.add_dependency "multi_json" spec.add_development_dependency "bundler", "~> 1.5" spec.add_development_dependency "rake"
Add some basic gems to gemspec
diff --git a/spec/how_bad/analyzer_spec.rb b/spec/how_bad/analyzer_spec.rb index abc1234..def5678 100644 --- a/spec/how_bad/analyzer_spec.rb +++ b/spec/how_bad/analyzer_spec.rb @@ -1,4 +1,10 @@ require 'spec_helper' describe HowBad::Analyzer do + let(:issues) { JSON.parse(open(File.expand_path('../data/issues.json', __dir__)).read) } + let(:pulls) { JSON.parse(open(File.expand_path('../data/pulls.json', __dir__)).read) } + + let(:fetcher_results) { HowBad::Fetcher::Results.new(issues, pulls) } + + end
Define variables needed for Analyzer specs.
diff --git a/spec/lib/filters/dkim_spec.rb b/spec/lib/filters/dkim_spec.rb index abc1234..def5678 100644 --- a/spec/lib/filters/dkim_spec.rb +++ b/spec/lib/filters/dkim_spec.rb @@ -0,0 +1,33 @@+require "spec_helper" + +# TODO This test currently depends on the real behaviour of the App class. Fix this +describe Filters::Dkim do + let(:mail) do + Mail.new do + text_part do + body 'An email with some text and headers' + end + end + end + let(:app) { App.create(from_domain: "foo.com") } + let(:delivery) { mock_model(Delivery, app: app, data: mail.encoded) } + let(:filter) { Filters::Dkim.new(delivery) } + + describe "#data" do + context "dkim is disabled" do + it { Mail.new(filter.data).header["DKIM-Signature"].should be_nil } + end + + context "dkim is enabled" do + before :each do + app.update_attributes(dkim_enabled: true) + end + + it { + # Signature is different every time (because of I assume a random salt). So, we're just + # going to test for the presence of the header + Mail.new(filter.data).header["DKIM-Signature"].should_not be_nil + } + end + end +end
Add simple test for dkim filtering
diff --git a/lib/dominus/document.rb b/lib/dominus/document.rb index abc1234..def5678 100644 --- a/lib/dominus/document.rb +++ b/lib/dominus/document.rb @@ -1,4 +1,5 @@-require "dominus/item" +require "delegate" + module Dominus class Document < SimpleDelegator @@ -23,7 +24,6 @@ def items @items ||= super.each_with_object({}) do |item, hash| hash[item.name] = item.values.to_a - #ObjectSpace.define_finalizer(item, Item.cleanup(item)) item.recycle end end
Remove some old requiring, added require for delegate
diff --git a/spec/support/devise_helper.rb b/spec/support/devise_helper.rb index abc1234..def5678 100644 --- a/spec/support/devise_helper.rb +++ b/spec/support/devise_helper.rb @@ -1,4 +1,4 @@ RSpec.configure do |config| - config.include Devise::TestHelpers, type: :controller + config.include Devise::Test::ControllerHelpers, type: :controller config.include Devise::TestHelpers, type: :view end
Remove deprecation messages on devise
diff --git a/lib/attribrutal/model.rb b/lib/attribrutal/model.rb index abc1234..def5678 100644 --- a/lib/attribrutal/model.rb +++ b/lib/attribrutal/model.rb @@ -36,7 +36,7 @@ if coercer && coercer.respond_to?(:coerce) coercer.send(:coerce, raw_attributes[sym], attrs[:default]) else - raw_attributes[sym] || attrs[:default] + raw_attributes[sym] ||= attrs[:default] end end
Store the default value in raw attributes on access
diff --git a/lib/chef/knife/compat.rb b/lib/chef/knife/compat.rb index abc1234..def5678 100644 --- a/lib/chef/knife/compat.rb +++ b/lib/chef/knife/compat.rb @@ -19,15 +19,19 @@ # Check the response back from the api call to see if # we get 'certificate' which is Chef 10 or just # 'public_key' which is Chef 11 - if client['certificate'] - cert = client['certificate'] - cert = OpenSSL::X509::Certificate.new cert - public_key_der = cert.public_key - else - public_key_der = client['public_key'] + unless client.is_a?(Chef::ApiClient) + name = client['name'] + certificate = client['certificate'] + client = Chef::ApiClient.new + client.name name + client.admin false + + cert_der = OpenSSL::X509::Certificate.new certificate + + client.public_key cert_der.public_key.to_s end - public_key = OpenSSL::PKey::RSA.new public_key_der + public_key = OpenSSL::PKey::RSA.new client.public_key public_key end
Build a Chef::ApiClient object from the json if Chef 10
diff --git a/lib/client/time_entry.rb b/lib/client/time_entry.rb index abc1234..def5678 100644 --- a/lib/client/time_entry.rb +++ b/lib/client/time_entry.rb @@ -1,12 +1,4 @@ module Beetil class TimeEntry < Beetil::Base - # Beetil::Base has a buggy implementation and cannot handle two word classes properly, until that's fixed... - def self.model_name - @_model_name = "time_entry" - end - - def self.table_name - @_table_name = "time_entries" - end end end
Remove hacks needed in TimeEntry class used to workaround model_name bug
diff --git a/lib/angus/commands/server_command.rb b/lib/angus/commands/server_command.rb index abc1234..def5678 100644 --- a/lib/angus/commands/server_command.rb +++ b/lib/angus/commands/server_command.rb @@ -1,8 +1,15 @@ module Angus class ServerCommand < Thor::Group + include Thor::Actions + + class_option :port, desc: 'use PORT (default: 9292)', type: :string, required: false + class_option :host, desc: 'listen on HOST (default: localhost)', type: :string, required: false def server - command_processor.run('rackup', verbose: false) + port_option = "-p #{options[:port]}" || '' + host_option = "--host #{options[:host]}" || '' + puts "rackup #{port_option} #{host_option}" + command_processor.run("rackup #{port_option} #{host_option}", verbose: false) end private
Add flags to server command
diff --git a/lib/atlas/dataset/derived_dataset.rb b/lib/atlas/dataset/derived_dataset.rb index abc1234..def5678 100644 --- a/lib/atlas/dataset/derived_dataset.rb +++ b/lib/atlas/dataset/derived_dataset.rb @@ -4,7 +4,7 @@ attribute :base_dataset, String attribute :scaling, Preset::Scaling - attribute :init, Hash + attribute :init, Hash[Symbol => Float] validates :scaling, presence: true
Add type coercion for initializer inputs
diff --git a/lib/domgen/ruby/model.rb b/lib/domgen/ruby/model.rb index abc1234..def5678 100644 --- a/lib/domgen/ruby/model.rb +++ b/lib/domgen/ruby/model.rb @@ -29,7 +29,7 @@ def filename fqn = qualified_name.gsub(/::/, '/') - Domgen::Naming.underscore(fqn[2..fqn.length]) + Domgen::Naming.underscore(fqn[1..fqn.length]) end end
Correct the way the filename for ruby class is generated to stop skipping the fist letter
diff --git a/lib/jbuilder/railtie.rb b/lib/jbuilder/railtie.rb index abc1234..def5678 100644 --- a/lib/jbuilder/railtie.rb +++ b/lib/jbuilder/railtie.rb @@ -3,7 +3,7 @@ class Jbuilder class Railtie < ::Rails::Railtie - initializer :jbuilder do |app| + initializer :jbuilder do ActiveSupport.on_load :action_view do ActionView::Template.register_template_handler :jbuilder, JbuilderHandler require 'jbuilder/dependency_tracker'
Remove relic and confusing argument
diff --git a/lib/keyline/resources/stock_paper.rb b/lib/keyline/resources/stock_paper.rb index abc1234..def5678 100644 --- a/lib/keyline/resources/stock_paper.rb +++ b/lib/keyline/resources/stock_paper.rb @@ -1,11 +1,15 @@ module Keyline class StockPaper include Resource + include Writeable::Resource extend Resource::ClassMethods + extend Writeable::Resource::ClassMethods path_prefix :configuration - attributes :name, :dimensions, :grain, :grammage, :color_saturation, :color, + attributes :name, :dimensions, :grain, :grammage, :color_saturation, :color, :material_id, + :thickness, :kind, :environmental_certification, :texture, :delivered_precut, :supplier_identifiers + writeable_attributes :name, :dimensions, :grain, :grammage, :color_saturation, :color, :thickness, :kind, :environmental_certification, :texture, :delivered_precut, :supplier_identifiers associations :material_quotes
Align StockPaper resource with latest version of v2 API
diff --git a/lib/moonshine/no_www.rb b/lib/moonshine/no_www.rb index abc1234..def5678 100644 --- a/lib/moonshine/no_www.rb +++ b/lib/moonshine/no_www.rb @@ -17,7 +17,7 @@ # WWW Redirect RewriteCond %{HTTP_HOST} !^#{configuration[:domain].gsub('.', '\.')}$ [NC] RewriteCond %{HTTP_HOST} ^www\.(.*) [NC] - RewriteRule ^/(.*)$ http://%1/$1 [L,R=301] + RewriteRule ^(.*)$ http://%1$1 [L,R=301] MOD_REWRITE configure( @@ -35,7 +35,7 @@ # SSL WWW Redirect RewriteCond %{HTTP_HOST} !^#{configuration[:domain].gsub('.', '\.')}$ [NC] RewriteCond %{HTTP_HOST} ^www\.(.*) [NC] - RewriteRule ^/(.*)$ https://%1/$1 [L,R=301] + RewriteRule ^(.*)$ https://%1$1 [L,R=301] MOD_REWRITE_SSL configure( @@ -48,4 +48,4 @@ end end end -end+end
Tweak RewriteRule to work with paths, and to not tack on an extra /
diff --git a/lib/rip/parsers/simple_expression.rb b/lib/rip/parsers/simple_expression.rb index abc1234..def5678 100644 --- a/lib/rip/parsers/simple_expression.rb +++ b/lib/rip/parsers/simple_expression.rb @@ -8,7 +8,7 @@ include Parslet include Rip::Parsers::Object - rule(:simple_expression) { simple_expression_fancy >> expression_terminator? } + rule(:simple_expression) { simple_expression_fancy >> spaces? >> expression_terminator? } rule(:simple_expression_fancy) { assignment | object }
Allow spaces before an expression terminator
diff --git a/lib/roger/mockupfile.rb b/lib/roger/mockupfile.rb index abc1234..def5678 100644 --- a/lib/roger/mockupfile.rb +++ b/lib/roger/mockupfile.rb @@ -23,9 +23,9 @@ # @attr :path [Pathname] The path of the Mockupfile for this project attr_accessor :path, :project - def initialize(project) + def initialize(project, path = nil) @project = project - @path = Pathname.new(project.path + "Mockupfile") + @path = (path && Pathname.new(path)) || Pathname.new(project.path + "Mockupfile") end # Actually load the mockupfile
Allow setting the Mockupfile path in Mockupfile as well
diff --git a/app/controllers/carto/api/public/kuviz_presenter.rb b/app/controllers/carto/api/public/kuviz_presenter.rb index abc1234..def5678 100644 --- a/app/controllers/carto/api/public/kuviz_presenter.rb +++ b/app/controllers/carto/api/public/kuviz_presenter.rb @@ -11,7 +11,7 @@ def to_hash { - visualization: @kuviz.id, + id: @kuviz.id, name: @kuviz.name, privacy: @kuviz.privacy, created_at: @kuviz.created_at,
Change kuviz presenter to return id instead of visualization field
diff --git a/lib/spbtv_code_style.rb b/lib/spbtv_code_style.rb index abc1234..def5678 100644 --- a/lib/spbtv_code_style.rb +++ b/lib/spbtv_code_style.rb @@ -1,4 +1,4 @@ # Just namespace for version number module SpbtvCodeStyle - VERSION = '1.3.1'.freeze + VERSION = '1.3.0'.freeze end
Revert "version bump to 1.3.1" This reverts commit adf6356b2d8e5749fabba9ea084d41745c3fd843.
diff --git a/lib/chamber/filters/failed_decryption_filter.rb b/lib/chamber/filters/failed_decryption_filter.rb index abc1234..def5678 100644 --- a/lib/chamber/filters/failed_decryption_filter.rb +++ b/lib/chamber/filters/failed_decryption_filter.rb @@ -29,7 +29,8 @@ value.match(BASE64_STRING_PATTERN) fail Chamber::Errors::DecryptionFailure, - 'Failed to decrypt values in your settings.' + "Failed to decrypt #{key} (with an encrypted value of '#{value}') " \ + 'in your settings.' end end
Feature: Add key and encrypted value to failed decryption error message Previously it would just say that it failed to decrypt a value, but wouldn't give you any information on which one it was, so it was impossible to fix. -------------------------------------------------------------------------------- Change-Id: I1f3f92dc889cd3a901af66de57fd63a4ed2d380a Signed-off-by: Jeff Felchner <8a84c204e2d4c387d61d20f7892a2bbbf0bc8ae8@thekompanee.com>
diff --git a/tty-progressbar.gemspec b/tty-progressbar.gemspec index abc1234..def5678 100644 --- a/tty-progressbar.gemspec +++ b/tty-progressbar.gemspec @@ -21,7 +21,7 @@ spec.required_ruby_version = '>= 2.0.0' spec.add_dependency "tty-cursor", '~> 0.5.0' - spec.add_dependency "tty-screen", '~> 0.5.0' + spec.add_dependency "tty-screen", '~> 0.6.0' spec.add_development_dependency 'bundler', '>= 1.5.0', '< 2.0' spec.add_development_dependency 'rspec', '~> 3.1'
Change to use latest tty-screen
diff --git a/lib/endpoint_base/concerns/exception_handler.rb b/lib/endpoint_base/concerns/exception_handler.rb index abc1234..def5678 100644 --- a/lib/endpoint_base/concerns/exception_handler.rb +++ b/lib/endpoint_base/concerns/exception_handler.rb @@ -6,9 +6,11 @@ if EndpointBase.rails? rescue_from Exception, :with => :rails_exception_handler elsif EndpointBase.sinatra? + # Ensure error handlers run + set :show_exceptions, false + error do log_exception(env['sinatra.error']) - result 500, env['sinatra.error'].message end end
Make sure all sinatra error handlers run See sinatra implementation for reference: https://github.com/sinatra/sinatra/blob/77438afd761e30610c9b1efda38d39fce1d1d01b/lib/sinatra/base.rb#L1097-L1124
diff --git a/lib/vagrant-grid5000/action/connect_grid5000.rb b/lib/vagrant-grid5000/action/connect_grid5000.rb index abc1234..def5678 100644 --- a/lib/vagrant-grid5000/action/connect_grid5000.rb +++ b/lib/vagrant-grid5000/action/connect_grid5000.rb @@ -18,7 +18,6 @@ env[:g5k].logger = Logger.new(STDOUT) env[:g5k].logger.progname = 'ruby-cute' env[:g5k].logger.datetime_format = "%Y-%m-%d %H:%M:%S " - # FIXME customize logger to make it clear that ruby-cute is the one displaying messages if $last_check_time.nil? or $last_check_time + 60 < Time::now raise "Unable to retrieve the list of sites and find nancy in it" if not env[:g5k].site_uids.include?('nancy') $last_check_time = Time::now
Drop FIXME that was actually done
diff --git a/spec/acceptance/support/sphinx_controller.rb b/spec/acceptance/support/sphinx_controller.rb index abc1234..def5678 100644 --- a/spec/acceptance/support/sphinx_controller.rb +++ b/spec/acceptance/support/sphinx_controller.rb @@ -30,6 +30,14 @@ def start config.controller.start + rescue Riddle::CommandFailedError => error + puts <<-TXT + +The Sphinx #{type} command failed: + Command: #{error.command_result.command} + Status: #{error.command_result.status} + Output: #{error.command_result.output} + TXT end def stop
Improve error messages for spec daemon failures.
diff --git a/spec/controllers/comments_controller_spec.rb b/spec/controllers/comments_controller_spec.rb index abc1234..def5678 100644 --- a/spec/controllers/comments_controller_spec.rb +++ b/spec/controllers/comments_controller_spec.rb @@ -1,9 +1,24 @@ require 'rails_helper' describe CommentsController, :type => :controller do - # context "#index" do - it "user can see comments on queried translation" do - pending - end - # end + it "#index" do + pending + end + + it "#new" do + pending + end + + it "#create" do + pending + end + + it "#edit" do + pending + end + + it "#destroy" do + pending + end + end
Add skeleton with user stories for comments spec
diff --git a/spec/controllers/patients_controller_spec.rb b/spec/controllers/patients_controller_spec.rb index abc1234..def5678 100644 --- a/spec/controllers/patients_controller_spec.rb +++ b/spec/controllers/patients_controller_spec.rb @@ -1,13 +1,6 @@ require 'rails_helper' RSpec.describe PatientsController, :type => :controller do - - describe "GET show" do - it "returns http success" do - get :show - expect(response).to have_http_status(:success) - end - end # When a doctor checks a terminate box a soft delete is triggered. # And the deleted_at value is not nil. @@ -15,19 +8,19 @@ describe "PATCH update" do before do - @patient = FactoryGirl.create(:patient) + @patient = FactoryGirl.create(:patient) end it "should redirect when the patient is updated" do patch :update, id: @patient.id, patient: { patient_medications_attributes: {} } - expect(response).to have_http_status(:found) + expect(response).to have_http_status(:found) end it "should render the form when update fails" do patch :update, id: @patient.id, patient: { forename: " " } - expect(response).to have_http_status(:success) + expect(response).to have_http_status(:success) end - + end end
Fix failing test for unavailable route
diff --git a/myasorubka.gemspec b/myasorubka.gemspec index abc1234..def5678 100644 --- a/myasorubka.gemspec +++ b/myasorubka.gemspec @@ -12,7 +12,7 @@ spec.description = 'Myasorubka is a morphological data processor.' spec.summary = 'Myasorubka is a morphological data proceesor ' \ 'that supports AOT and MULTEXT-East notations.' - spec.homepage = 'https://github.com/ustalov/myasorubka' + spec.homepage = 'https://github.com/dustalov/myasorubka' spec.license = 'MIT' spec.files = `git ls-files`.split($/)
Fix the homepage link [ci skip]
diff --git a/plugin_gems.rb b/plugin_gems.rb index abc1234..def5678 100644 --- a/plugin_gems.rb +++ b/plugin_gems.rb @@ -17,3 +17,4 @@ download "fluent-plugin-webhdfs", "0.4.1" download "fluent-plugin-rewrite-tag-filter", "1.4.1" download "fluent-plugin-td-monitoring", "0.2.0" +download "fluent-plugin-google-cloud", "0.1.3"
Package Google cloud logging plugin. - Also updates plugin version to 0.1.3 (was 0.1.1)
diff --git a/app/controllers/index.rb b/app/controllers/index.rb index abc1234..def5678 100644 --- a/app/controllers/index.rb +++ b/app/controllers/index.rb @@ -16,10 +16,10 @@ # Handle POST-request (Receive and save the uploaded file) post "/" do p "*" * 100 - p params + p APP_ROOT.join(Dir.pwd + '/public/uploads/' + params['myfile'][:filename]).to_s p "*" * 100 - File.open(File.dirname(__FILE__) + '/../../public/uploads/' + params['myfile'][:filename], "w") do |f| + File.open(APP_ROOT.join(Dir.pwd + '/public/uploads/' + params['myfile'][:filename]).to_s, "w") do |f| f.write(File.open(params['myfile'][:tempfile], "r").read) end
Fix pathing issue with image upload
diff --git a/app/models/gend_image.rb b/app/models/gend_image.rb index abc1234..def5678 100644 --- a/app/models/gend_image.rb +++ b/app/models/gend_image.rb @@ -7,7 +7,7 @@ belongs_to :src_image has_one :gend_thumb - has_many :captions + has_many :captions, :order => :id belongs_to :user validates :user, presence: true
Set order for captions association.
diff --git a/lib/buildr_plus/util.rb b/lib/buildr_plus/util.rb index abc1234..def5678 100644 --- a/lib/buildr_plus/util.rb +++ b/lib/buildr_plus/util.rb @@ -18,6 +18,10 @@ def is_addon_loaded?(addon) $LOADED_FEATURES.any? { |f| f =~ /\/addon\/buildr\/#{addon}\.rb$/ } end + + def subprojects(project) + Buildr.projects(:scope => project.name).collect { |p| p.name } + end end end end
Add helper method that lists the names of all subprojects
diff --git a/app/controllers/requests_controller.rb b/app/controllers/requests_controller.rb index abc1234..def5678 100644 --- a/app/controllers/requests_controller.rb +++ b/app/controllers/requests_controller.rb @@ -19,6 +19,19 @@ end end + def show + @request = Request.find_by(params[:id]) + end + + def update + + end + + def destroy + request = Request.find_by(params[:id]) + redirect_to root + end + private def request_attributes
Add routes for edit, update, delete
diff --git a/app/controllers/services_controller.rb b/app/controllers/services_controller.rb index abc1234..def5678 100644 --- a/app/controllers/services_controller.rb +++ b/app/controllers/services_controller.rb @@ -16,13 +16,22 @@ end def create - @service = Service.new(params.require(:service).permit(:service_type, :name, :hosted, :port, :environment_variables)) + @service = Service.new(create_params) if @service.save StartServiceJob.perform_later(@service) if @service.hosted? redirect_to services_path else - # raise @service.errors.to_json render :new end end + + private + + def create_params + # Create a temp service so that we can get the default environment variable keys. + # @todo there will be a cleaner way to do this + service_env_keys = Service.new(params.require(:service).permit(:service_type)).service.default_environment_variables.keys + + params.require(:service).permit(:service_type, :name, :hosted, :port, environment_variables: service_env_keys) + end end
Allow saving of env keys
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index abc1234..def5678 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -1,12 +1,15 @@ class SessionsController < ApplicationController def create - twitch_id = request.env['omniauth.auth'].uid + auth = request.env['omniauth.auth'] + + twitch_id = auth.uid user = User.find_by(twitch_id: twitch_id) || User.new(twitch_id: twitch_id) user.update( - name: request.env['omniauth.auth'].info.name, - email: request.env['omniauth.auth'].info.email, - avatar: request.env['omniauth.auth'].info.logo + name: auth.info.nickname, + email: auth.info.email, + avatar: auth.info.image, + twitch_token: auth.credentials.token ) if user.errors.present?
Fix bug that caused various user-related 404s
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index abc1234..def5678 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -1,6 +1,7 @@ class SessionsController < ApplicationController def new + response.headers['X-Csrf-Token'] = form_authenticity_token end def create @@ -18,4 +19,4 @@ sign_out redirect_to root_url end -end+end
Add CSRF token to header
diff --git a/lib/camaraderie/user.rb b/lib/camaraderie/user.rb index abc1234..def5678 100644 --- a/lib/camaraderie/user.rb +++ b/lib/camaraderie/user.rb @@ -10,7 +10,7 @@ Camaraderie.membership_types.each do |type| class_eval <<-RUBY, __FILE__, __LINE__ + 1 def #{type}_of?(organization) - !!memberships.admins.where(organization: organization).exists? + !!memberships.#{type.pluralize}.where(organization: organization).exists? end RUBY end
Fix issue with type_of? methods
diff --git a/components/plugins/textfilters/amazon_controller.rb b/components/plugins/textfilters/amazon_controller.rb index abc1234..def5678 100644 --- a/components/plugins/textfilters/amazon_controller.rb +++ b/components/plugins/textfilters/amazon_controller.rb @@ -4,14 +4,14 @@ end def self.description - "Automatically turn amazon:ASIN URLs into affiliate links to Amazon items" + "Automatically turn amazon:ASIN URLs into affiliate links to Amazon items using your Amazon Associate ID" end def filtertext text=params[:text] - affiliateid=(params[:filterparams])['amazon-affiliateid'] + associateid=(params[:filterparams])['amazon-associate-id'] render :text => text.gsub(/<a href="amazon:([^"]+)"/, - "<a href=\"http://www.amazon.com/exec/obidos/ASIN/\\1/#{affiliateid}\"") + "<a href=\"http://www.amazon.com/exec/obidos/ASIN/\\1/#{associateid}\"") end def self.default_config
Fix amazon affiliate/associate so (a) it's consistent with Amazon's nomenclature and (b) it actually works right git-svn-id: 70ab0960c3db1cbf656efd6df54a8f3de72dc710@587 820eb932-12ee-0310-9ca8-eeb645f39767
diff --git a/content_stream/config/initializers/recommendable.rb b/content_stream/config/initializers/recommendable.rb index abc1234..def5678 100644 --- a/content_stream/config/initializers/recommendable.rb +++ b/content_stream/config/initializers/recommendable.rb @@ -2,7 +2,8 @@ Recommendable.configure do |config| # Recommendable's connection to Redis - config.redis = Redis.new(:host => 'localhost', :port => 6379, :db => 0) + redis_host = ENV['REDIS_HOST'] || 'localhost' + config.redis = Redis.new(:host => redis_host, :port => 6379, :db => 0) config.orm = :active_record
Read redis host config from ENV
diff --git a/spec/postgresql/migrate/migrate_bigint_spec.rb b/spec/postgresql/migrate/migrate_bigint_spec.rb index abc1234..def5678 100644 --- a/spec/postgresql/migrate/migrate_bigint_spec.rb +++ b/spec/postgresql/migrate/migrate_bigint_spec.rb @@ -0,0 +1,67 @@+describe 'Ridgepole::Client#diff -> migrate' do + context 'when add bigint column' do + let(:actual_dsl) { '' } + + let(:expected_dsl) { + if condition(:activerecord_5) + erbh(<<-EOS) + create_table "bigint_test", id: false, force: :cascade do |t| + t.bigint "b" + end + EOS + else + erbh(<<-EOS) + create_table "bigint_test", id: false, force: :cascade do |t| + t.integer "b", limit: 8 + end + EOS + end + } + + before { subject.diff(actual_dsl).migrate } + subject { client } + + it { + delta = subject.diff(expected_dsl) + expect(delta.differ?).to be_truthy + delta.migrate + expect(subject.dump).to match_fuzzy expected_dsl + } + end + + context 'when no change' do + let(:dsl) { + erbh(<<-EOS) + create_table "bigint_test", id: false, force: :cascade do |t| + t.bigint "b" + end + EOS + } + + let(:expected_dsl) { + if condition(:activerecord_5) + erbh(<<-EOS) + create_table "bigint_test", id: false, force: :cascade do |t| + t.bigint "b" + end + EOS + else + erbh(<<-EOS) + create_table "bigint_test", id: false, force: :cascade do |t| + t.integer "b", limit: 8 + end + EOS + end + } + + before { subject.diff(dsl).migrate } + subject { client } + + it { + delta = subject.diff(expected_dsl) + expect(delta.differ?).to be_falsey + delta.migrate + expect(subject.dump).to match_fuzzy expected_dsl + } + end +end
Add bigint spec for postgres
diff --git a/core/spec/screenshots/non_signed_in_spec.rb b/core/spec/screenshots/non_signed_in_spec.rb index abc1234..def5678 100644 --- a/core/spec/screenshots/non_signed_in_spec.rb +++ b/core/spec/screenshots/non_signed_in_spec.rb @@ -1,9 +1,17 @@ require 'screenshot_helper' describe "Non signed in pages:", type: :feature do + include Acceptance::ChannelHelper + include Screenshots::DiscussionHelper + describe "Profile page page" do it "it renders correctly" do @user = sign_in_user create :full_user + + factlink = backend_create_fact + channel = backend_create_channel_of_user @user + backend_add_fact_to_channel factlink, channel + sign_out_user visit user_path(@user)
Create discussion and add fact to channel
diff --git a/spec/classes/openldap_server_install_spec.rb b/spec/classes/openldap_server_install_spec.rb index abc1234..def5678 100644 --- a/spec/classes/openldap_server_install_spec.rb +++ b/spec/classes/openldap_server_install_spec.rb @@ -1,10 +1,6 @@ require 'spec_helper' describe 'openldap::server::install' do - - let :pre_condition do - "class {'openldap::server':}" - end let(:facts) {{ :osfamily => 'Debian', @@ -12,6 +8,9 @@ }} context 'with no parameters' do + let :pre_condition do + "class {'openldap::server':}" + end it { should compile.with_all_deps } it { should contain_class('openldap::server::install') } it { should contain_package('slapd').with({ @@ -19,4 +18,10 @@ })} end + context 'with suffix' do + let :pre_condition do + "class {'openldap::server': suffix => 'cn=admin,dc=example,dc=com', }" + end + it { should compile.with_all_deps } + end end
Add testcase for suffix not starting with dc=
diff --git a/spec/lib/importers/category_importer_spec.rb b/spec/lib/importers/category_importer_spec.rb index abc1234..def5678 100644 --- a/spec/lib/importers/category_importer_spec.rb +++ b/spec/lib/importers/category_importer_spec.rb @@ -20,9 +20,9 @@ end context 'for depth 1' do - let(:category) { 'Category:Monty Python films' } - let(:article_in_cat) { "Monty Python's Life of Brian" } - let(:article_in_subcat) { 'Knights Who Say "Ni!"' } + let(:category) { 'Category:Monty Python' } + let(:article_in_cat) { 'Monty Python v. American Broadcasting Companies, Inc.' } + let(:article_in_subcat) { "Monty Python's Life of Brian" } let(:depth) { 1 } it 'works recursively for subcategories' do
Update spec for on-wiki changes to categories An update to the categorization made this example of a sub-category search break.
diff --git a/spec/presenters/ci/trigger_presenter_spec.rb b/spec/presenters/ci/trigger_presenter_spec.rb index abc1234..def5678 100644 --- a/spec/presenters/ci/trigger_presenter_spec.rb +++ b/spec/presenters/ci/trigger_presenter_spec.rb @@ -0,0 +1,51 @@+require 'spec_helper' + +describe Ci::TriggerPresenter do + set(:user) { create(:user) } + set(:project) { create(:project) } + + set(:trigger) do + create(:ci_trigger, token: '123456789abcd', project: project) + end + + let(:subject) do + described_class.new(trigger, current_user: user) + end + + before do + project.add_maintainer(user) + end + + context 'when user is not a trigger owner' do + describe '#token' do + it 'exposes only short token' do + expect(subject.token).not_to eq trigger.token + expect(subject.token).to eq '1234' + end + end + + describe '#has_token_exposed?' do + it 'does not have token exposed' do + expect(subject).not_to have_token_exposed + end + end + end + + context 'when user is a trigger owner and builds admin' do + before do + trigger.update(owner: user) + end + + describe '#token' do + it 'exposes full token' do + expect(subject.token).to eq trigger.token + end + end + + describe '#has_token_exposed?' do + it 'has token exposed' do + expect(subject).to have_token_exposed + end + end + end +end
Add some specs for trigger presenter
diff --git a/lib/spirit.rb b/lib/spirit.rb index abc1234..def5678 100644 --- a/lib/spirit.rb +++ b/lib/spirit.rb @@ -3,7 +3,6 @@ require 'toystore' # Standard Library Dependencies -require 'securerandom' require 'singleton' #Internal Dependencies
Remove securerandom -- now handled by toystore
diff --git a/lib/status.rb b/lib/status.rb index abc1234..def5678 100644 --- a/lib/status.rb +++ b/lib/status.rb @@ -42,38 +42,8 @@ @root ||= Pathname.new(__FILE__).parent.parent end - # Fetch resource from cache or locally - # - # @param [String] url - # the url to fetch - # - # @param [Class:Presenter] presenter - # the presenter to instantiate on new data - # - # @return [Presenter] - # presenter instance - # - # @api private - # - def self.fetch(url, presenter) - cache.fetch(url) do - Request.run(url, presenter) - end - end - - # Return cache - # - # @return [Cache] - # - # @api private - # - def self.cache - @cache ||= Cache.new - end - end -require 'status/cache' require 'status/application' require 'status/repository' require 'status/action'
Remove the rest of the cache infrastructure
diff --git a/spec/support/authentication.rb b/spec/support/authentication.rb index abc1234..def5678 100644 --- a/spec/support/authentication.rb +++ b/spec/support/authentication.rb @@ -1,8 +1,7 @@ module Authentication def logged_in @user ||= create(:user) - - sign_in(@user, :bypass => Devise.masquerade_bypass_warden_callback) + sign_in(@user) end def current_user
Fix sign_in by_pass option for the auth test
diff --git a/spec/unit/sexp_builder_spec.rb b/spec/unit/sexp_builder_spec.rb index abc1234..def5678 100644 --- a/spec/unit/sexp_builder_spec.rb +++ b/spec/unit/sexp_builder_spec.rb @@ -0,0 +1,25 @@+require 'turn/autorun' +require 'sexp_processor' +require 'roffle/sexp_builder' + +describe Roffle::SexpBuilder do + describe ".method_def" do + it "returns a :defn sexp with 0 arity" do + body = s(:call, nil, :puts, s(:str, "####")) + sexp = Roffle::SexpBuilder.method_def(:print_banner, [], [body]) + sexp.must_equal s(:defn, :print_banner, s(:args), body) + end + + it "returns a :defn sexp with arguments" do + body = s(:call, nil, :puts, s(:lvar, :amount)) + sexp = Roffle::SexpBuilder.method_def(:print_details, [:outstanding], [body]) + sexp.must_equal s(:defn, :print_details, s(:args, :outstanding), body) + end + + it "returns a :defn sexp with multi-line body" do + body = [s(:call, nil, :puts, s(:lvar, :amount)), s(:call, nil, :puts, s(:ivar, :@name))] + sexp = Roffle::SexpBuilder.method_def(:print_details, [:amount], body) + sexp.must_equal s(:defn, :print_details, s(:args, :amount), *body) + end + end +end
Add tests for the SexpBuilder class
diff --git a/teifacsimile_to_jekyll.gemspec b/teifacsimile_to_jekyll.gemspec index abc1234..def5678 100644 --- a/teifacsimile_to_jekyll.gemspec +++ b/teifacsimile_to_jekyll.gemspec @@ -11,4 +11,5 @@ s.homepage = 'https://github.com/emory-libraries-ecds/teifacsimile-to-jekyll' # 'http://rubygems.org/gems/hola' s.license = 'Apache 2' + s.add_runtime_dependency "nokogiri" end
Add nokogiri dependency to gemspec
diff --git a/lib/services/dispatch.rb b/lib/services/dispatch.rb index abc1234..def5678 100644 --- a/lib/services/dispatch.rb +++ b/lib/services/dispatch.rb @@ -6,12 +6,12 @@ intercept_emails: false, submission: nitpick.submission, from: nitpick.nitpicker.username, - regarding: 'nitpick' + subject: "New nitpick from #{nitpick.nitpicker.username}" }.merge(options) new(options).ship end - attr_reader :to, :name, :from, :submission, :site_root, :regarding + attr_reader :to, :name, :from, :submission, :site_root, :subject def initialize options @submission = options.fetch(:submission) @@ -21,7 +21,7 @@ @from = options.fetch(:from) @intercept_emails = options.fetch(:intercept_emails) @site_root = options.fetch(:site_root) - @regarding = options.fetch(:regarding) + @subject = "[exercism.io] #{options.fetch(:subject)}" end def ship @@ -32,10 +32,6 @@ intercept_emails: @intercept_emails, ).ship self - end - - def subject - "[exercism.io] New #{regarding} from #{from}" end def body
Refactor email subject in Dispatch
diff --git a/lib/terraforming/util.rb b/lib/terraforming/util.rb index abc1234..def5678 100644 --- a/lib/terraforming/util.rb +++ b/lib/terraforming/util.rb @@ -17,21 +17,9 @@ File.join(File.expand_path(File.dirname(__FILE__)), "template", template_name) << ".erb" end - def generate_tfstate(resources) - tfstate = { - "version" => 1, - "serial" => 1, - "modules" => [ - { - "path" => [ - "root" - ], - "outputs" => {}, - "resources" => resources - } - ] - } - + def generate_tfstate(resources, tfstate_base = nil) + tfstate = tfstate_base || tfstate_skeleton + tfstate["modules"][0]["resources"] = tfstate["modules"][0]["resources"].merge(resources) JSON.pretty_generate(tfstate) end @@ -44,5 +32,21 @@ json.strip end end + + def tfstate_skeleton + { + "version" => 1, + "serial" => 1, + "modules" => [ + { + "path" => [ + "root" + ], + "outputs" => {}, + "resources" => {}, + } + ] + } + end end end
Modify .generate_tfstate to take tfstate_base arg
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 @@ -2,7 +2,7 @@ config.user_model = "User" config.oauth_id = 'abcdefghjasndjkasndmigratorator' config.oauth_secret = 'secret' - config.oauth_root_url = Plek.current.find("authentication") + config.oauth_root_url = Plek.current.find("signon") config.default_scope = "Migratorator" config.basic_auth_user = 'api' config.basic_auth_password = 'defined_on_rollout_not'
Remove reference to 'authentication' when calling Plek This was more unnecessary indirection, let's just use signon.
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 @@ -2,5 +2,5 @@ config.user_model = "User" config.oauth_id = ENV['OAUTH_ID'] || "abcdefghjasndjkasndwhitehall" config.oauth_secret = ENV['OAUTH_SECRET'] || "secret" - config.oauth_root_url = Plek.find("signon") + config.oauth_root_url = Plek.new.external_url_for("signon") end
Use external URLs for Signon This uses the new external_url_for method in Plek, which handles environments where the URLs for internal and external routing are different.
diff --git a/lib/presenter/helper.rb b/lib/presenter/helper.rb index abc1234..def5678 100644 --- a/lib/presenter/helper.rb +++ b/lib/presenter/helper.rb @@ -1,8 +1,12 @@ module Presenter module Helper include Presenter::Naming - def present(model) - presenter = presenter_from_model_object(model).new(model) + def present(object_or_collection) + if object_or_collection.respond_to?(:map) # If it is a collection + object_or_collection.map { |object| presenter_from_model_object(object).new(object) } + else # If it is a single object + presenter_from_model_object(object_or_collection).new(object_or_collection) + end end end end
Allow present method to accept collections
diff --git a/lib/scrapers/version.rb b/lib/scrapers/version.rb index abc1234..def5678 100644 --- a/lib/scrapers/version.rb +++ b/lib/scrapers/version.rb @@ -1,5 +1,5 @@ module Scrapers - VERSION = "0.4.1" + VERSION = "0.4.2" DESCRIPTION = "A library of web site scrapers utilizing mechanize and other goodies. Helpful in gathering images, moving things, saving things, etc." SUMMARY = "Web site scrapers" LICENSE = "MIT"
Generalize return parameters img_title and img_alt
diff --git a/lib/tasks/geocoder.rake b/lib/tasks/geocoder.rake index abc1234..def5678 100644 --- a/lib/tasks/geocoder.rake +++ b/lib/tasks/geocoder.rake @@ -8,7 +8,7 @@ klass.not_geocoded.each do |obj| obj.geocode; obj.save - sleep(sleep_timer.to_f) if sleep_timer.present? + sleep(sleep_timer.to_f) unless sleep_timer.nil? end end end
Use "unless .nil?" instead of "if .present?"
diff --git a/test/functional/admin/aliases_controller_test.rb b/test/functional/admin/aliases_controller_test.rb index abc1234..def5678 100644 --- a/test/functional/admin/aliases_controller_test.rb +++ b/test/functional/admin/aliases_controller_test.rb @@ -21,7 +21,7 @@ test "destroy team alias" do team = FactoryGirl.create(:team) team_alias = team.aliases.create!(:name => "Alias") - delete :destroy, :id => team_alias.to_param, :persoteam_id => team_alias.team.to_param, :format => "js" + delete :destroy, :id => team_alias.to_param, :team_id => team_alias.team.to_param, :format => "js" assert_response :success assert !Alias.exists?(team_alias.id), "alias" end
Fix bad param in test
diff --git a/quick_look.gemspec b/quick_look.gemspec index abc1234..def5678 100644 --- a/quick_look.gemspec +++ b/quick_look.gemspec @@ -8,8 +8,8 @@ spec.version = QuickLook::VERSION spec.authors = ["Arron Mabrey"] spec.email = ["arron@mabreys.com"] - spec.summary = %q{TODO: Write a short summary. Required.} - spec.description = %q{TODO: Write a longer description. Optional.} + spec.summary = %q{A very simplistic ruby wrapper around QuickLook for OS X.} + spec.description = %q{A very simplistic ruby wrapper around QuickLook for OS X} spec.homepage = "" spec.license = "MIT"
Add a description to gemspec
diff --git a/Casks/clipy.rb b/Casks/clipy.rb index abc1234..def5678 100644 --- a/Casks/clipy.rb +++ b/Casks/clipy.rb @@ -2,6 +2,7 @@ version '1.0.10' sha256 '526b875be7770b2d8fde600fed663c4138ebf756935e2fa0f95763f22a3c791a' + # github.com/Clipy/Clipy was verified as official when first introduced to the cask url "https://github.com/Clipy/Clipy/releases/download/#{version}/Clipy_#{version}.dmg" appcast 'https://clipy-app.com/appcast.xml', checkpoint: '44203442d251e8975e00bbd8fc79ecb31ebf5e20c3251b95fb965280c6d1cff6'
Fix `url` stanza comment for Clipy.
diff --git a/Freddy.podspec b/Freddy.podspec index abc1234..def5678 100644 --- a/Freddy.podspec +++ b/Freddy.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "Freddy" - s.version = "3.0.0" + s.version = "3.0.2" s.summary = "A JSON parsing library written in Swift" s.description = <<-DESC
Update podspec version to latest GitHub release
diff --git a/recipes/zsh.rb b/recipes/zsh.rb index abc1234..def5678 100644 --- a/recipes/zsh.rb +++ b/recipes/zsh.rb @@ -10,14 +10,19 @@ repository 'http://github.com/robbyrussell/oh-my-zsh.git' reference 'master' action :sync + notifies :run, "bash[copy zshrc]", :immediately end - file '/root/.zshrc' do - owner 'root' - group 'root' - mode 0755 - content ::File.open('/root/.oh-my-zsh/templates/zshrc.zsh-template').read - action :create + bash 'copy zshrc' do + user 'root' + cmd = 'cp /root/.oh-my-zsh/templates/zshrc.zsh-template /root/.zshrc' + code <<-EOH + set -x + set -e + #{cmd} + EOH + action :nothing + notifies :run, 'bash[Change Shell to Oh-my-zsh]', :immediately end bash 'Change Shell to Oh-my-zsh' do @@ -28,5 +33,6 @@ set -e #{cmd} EOH + action :nothing end end
Change file move and string together commands with notifies.
diff --git a/spec/annotations_spec.rb b/spec/annotations_spec.rb index abc1234..def5678 100644 --- a/spec/annotations_spec.rb +++ b/spec/annotations_spec.rb @@ -3,23 +3,15 @@ class CoAspects::ExistingAspect; end describe CoAspects::Annotations do + before { class Dummy; extend CoAspects::Annotations; end } + describe 'annotations' do it 'should not raise an error when the aspect exists' do - expect { - class Dummy - extend CoAspects::Annotations - _existing - end - }.not_to raise_error + expect { class Dummy; _existing; end }.not_to raise_error end it 'should raise an error when the aspect does not exist' do - expect { - class Dummy - extend CoAspects::Annotations - _inexisting - end - }.to raise_error( + expect { class Dummy; _inexisting; end }.to raise_error( CoAspects::AspectNotFoundError, /InexistingAspect.*_inexisting/) end end
Clean up dummy creation in specs
diff --git a/spec/deep_struct_spec.rb b/spec/deep_struct_spec.rb index abc1234..def5678 100644 --- a/spec/deep_struct_spec.rb +++ b/spec/deep_struct_spec.rb @@ -1,40 +1,56 @@ require 'yelp/deep_struct' describe DeepStruct do - it 'should create deeply nested structs from nested hash tables' do - hash = { foo: 1, - bar: { - baz: 2, - bender: { - bending: { - rodriguez: true - } - } - }, - fry: [ - {past: true}, - {present: true}, - {future: true} - ], - turunga: 'leela', - 'hubert' => 'farnsworth', - zoidberg: [ - 'doctor', - 'homeowner', - 'moviestar' - ] - } + let(:hash) do + { foo: 1, + bar: { + baz: 2, + bender: { + bending: { + rodriguez: true + } + } + }, + fry: [ + {past: true}, + {present: true}, + {future: true} + ], + turunga: 'leela', + 'hubert' => 'farnsworth', + zoidberg: [ + 'doctor', + 'homeowner', + 'moviestar' + ] + } + end - object = DeepStruct.new(hash) - object.foo.should eql 1 - object.bar.baz.should eql 2 - object.bar.bender.bending.rodriguez.should eql true - object.fry[0].past.should eql true - object.fry[1].present.should eql true - object.fry[2].future.should eql true - object.turunga.should eql 'leela' - object.hubert.should eql 'farnsworth' - object.zoidberg.size.should eql 3 - object.zoidberg[0].should eql 'doctor' + before(:each) do + @object = DeepStruct.new(hash) + end + + it 'should turn top level into a struct' do + @object.foo.should eql 1 + end + + it 'should recursively create structs all the way down the hash' do + @object.bar.baz.should eql 2 + @object.bar.bender.bending.rodriguez.should eql true + end + + it 'should correctly create arrays with hases into new structs' do + @object.fry[0].past.should eql true + @object.fry[1].present.should eql true + @object.fry[2].future.should eql true + end + + it 'should turn string keys into structs' do + @object.hubert.should eql 'farnsworth' + end + + it 'should maintain arrays with non hashes' do + @object.zoidberg.size.should eql 3 + @object.zoidberg[0].should eql 'doctor' end end
Refactor the deepstruct spec into multiple tests
diff --git a/spec/pages/login_page.rb b/spec/pages/login_page.rb index abc1234..def5678 100644 --- a/spec/pages/login_page.rb +++ b/spec/pages/login_page.rb @@ -1,15 +1,19 @@+# @author Dumitru Ursu +require 'spec_helper' + +# This class creates a page object to the login page class LoginPage include Capybara::DSL + include Rails.application.routes.url_helpers - def visit_page - visit '/' - self + def initialize(user) + @user = user + visit new_user_session_path(:en) end - def login(user) - fill_in 'email', with: user.email - fill_in 'password', with: 'password' - click_on 'Log In' + def login + fill_in 'email', with: @user.email + fill_in 'password', with: @user.password + click_on 'Sign In' end end -
Add login function to Login page
diff --git a/app/models/concerns/planting_search.rb b/app/models/concerns/planting_search.rb index abc1234..def5678 100644 --- a/app/models/concerns/planting_search.rb +++ b/app/models/concerns/planting_search.rb @@ -3,11 +3,11 @@ included do searchkick merge_mappings: true, - mappings: { + mappings: { properties: { - created_at: { type: :integer }, + created_at: { type: :integer }, harvests_count: { type: :integer }, - photos_count: { type: :integer } + photos_count: { type: :integer } } } @@ -15,32 +15,32 @@ def search_data { - slug: slug, - crop_slug: crop.slug, - crop_name: crop.name, - crop_id: crop_id, - owner_id: owner_id, - owner_name: owner.login_name, - owner_slug: owner.slug, - planted_from: planted_from, - photos_count: photos.size, - harvests_count: harvests.size, - has_photos: photos.size.positive?, - active: active?, - thumbnail_url: default_photo&.thumbnail_url, + slug: slug, + crop_slug: crop.slug, + crop_name: crop.name, + crop_id: crop_id, + owner_id: owner_id, + owner_name: owner.login_name, + owner_slug: owner.slug, + planted_from: planted_from, + photos_count: photos.size, + harvests_count: harvests.size, + has_photos: photos.size.positive?, + active: active?, + thumbnail_url: default_photo&.thumbnail_url, percentage_grown: percentage_grown.to_i, - created_at: created_at.to_i + created_at: created_at.to_i } end def self.homepage_records(limit) search('*', - limit: limit, - where: { + limit: limit, + where: { photos_count: { gt: 0 } }, boost_by: [:created_at], - load: false) + load: false) end end end
[CodeFactor] Apply fixes to commit 4c91da8
diff --git a/Napkin.podspec b/Napkin.podspec index abc1234..def5678 100644 --- a/Napkin.podspec +++ b/Napkin.podspec @@ -27,5 +27,5 @@ s.dependency 'Luncheon', '~> 0' s.dependency 'Eureka', '~> 1.7.0' - s.dependency 'Placemat', '~> 0.2.0' + s.dependency 'Placemat', '~> 0' end
Remove strict dependency on Placemat
diff --git a/Cheetah.podspec b/Cheetah.podspec index abc1234..def5678 100644 --- a/Cheetah.podspec +++ b/Cheetah.podspec @@ -20,7 +20,7 @@ # s.osx.deployment_target = "10.7" # s.watchos.deployment_target = "2.0" - s.source = { :git => "https://github.com/suguru/Cheetah.git", :tag => "0.2.6" } + s.source = { :git => "https://github.com/suguru/Cheetah.git", :tag => "0.3.0" } s.source_files = "Classes", "Cheetah/*.swift"
Update source version to 0.3.0
diff --git a/recipes/default.rb b/recipes/default.rb index abc1234..def5678 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -22,12 +22,14 @@ chef_gem 'chef-vault' do # ~FC009 source node['chef-vault']['gem_source'] version node['chef-vault']['version'] + clear_sources true unless node['chef-vault']['gem_source'].nil? compile_time true end else chef_gem 'chef-vault' do source node['chef-vault']['gem_source'] version node['chef-vault']['version'] + clear_sources true unless node['chef-vault']['gem_source'].nil? action :nothing end.run_action(:install) end
Fix custom gem sources being ignored As per https://docs.chef.io/resource_chef_gem.html#properties If we don't clear the sources, Rubygems is still used. This leads to failures in locked down environments where the Internet is not directly reachable.
diff --git a/recipes/default.rb b/recipes/default.rb index abc1234..def5678 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -8,6 +8,8 @@ create_file 'log/.gitkeep' create_file 'tmp/.gitkeep' +gsub_file 'config/application.rb', 'require "rails/test_unit/railtie"', '# require "rails/test_unit/railtie"' + git :init append_file '.gitignore', load_template('gitignore','git')
Comment out reference to test_unit railtie in application.rb
diff --git a/recipes/default.rb b/recipes/default.rb index abc1234..def5678 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -6,3 +6,18 @@ # # All rights reserved - Do Not Redistribute # + +pkg = value_for_platform( + [ "centos", "fedora", "redhat" ] => { + "default" => "mod_evasive" + }, + [ "debian", "ubuntu" ] => { + "default" => "libapache2-mod-evasive" + } +) + +package pkg do + action :install +end + +
Install the relevant package for the distribution.
diff --git a/recipes/service.rb b/recipes/service.rb index abc1234..def5678 100644 --- a/recipes/service.rb +++ b/recipes/service.rb @@ -25,9 +25,9 @@ service 'procps' do supports :restart => true, :reload => true, :status => false - case node[:platform] + case node['platform'] when 'ubuntu' - if node[:platform_version].to_f >= 9.10 + if node['platform_version'].to_f >= 9.10 provider Chef::Provider::Service::Upstart end end
Fix FC019: Access node attributes in a consistent manner
diff --git a/webhookr-stripe.gemspec b/webhookr-stripe.gemspec index abc1234..def5678 100644 --- a/webhookr-stripe.gemspec +++ b/webhookr-stripe.gemspec @@ -11,6 +11,7 @@ gem.description = "A webhookr extension to support Stripe webhooks." gem.summary = gem.description gem.homepage = "http://github.com/gerrypower/webhookr-stripe" + gem.license = "MIT" gem.files = `git ls-files`.split($/) gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
Add license to the gemspec
diff --git a/roles/tilecache.rb b/roles/tilecache.rb index abc1234..def5678 100644 --- a/roles/tilecache.rb +++ b/roles/tilecache.rb @@ -15,7 +15,7 @@ :munin => { :plugins => { :cpu => { - :user => { :warning => 100, :critical => 200 } + :user => { :warning => 200, :critical => 400 } } } },
Increase CPU altering thresholds for tile caches
diff --git a/sass-rails.gemspec b/sass-rails.gemspec index abc1234..def5678 100644 --- a/sass-rails.gemspec +++ b/sass-rails.gemspec @@ -14,7 +14,7 @@ s.rubyforge_project = "sass-rails" - s.add_runtime_dependency 'sass', '~> 3.1.10' + s.add_runtime_dependency 'sass', '>= 3.1.10' s.add_runtime_dependency 'railties', '~> 3.1.0' s.add_runtime_dependency 'actionpack', '~> 3.1.0' s.add_runtime_dependency 'tilt', '~> 1.3.2'
Allow Sass 3.2 to be used with rails 3.1.
diff --git a/test/helper.rb b/test/helper.rb index abc1234..def5678 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -1,6 +1,7 @@ require 'tempfile' require 'simplecov' +require 'coveralls' if SimpleCov.usable? if defined?(TracePoint) @@ -13,10 +14,12 @@ at_exit { RaccCoverage.stop } end - require 'coveralls' - Coveralls.wear! + SimpleCov.start do + self.formatter = SimpleCov::Formatter::MultiFormatter[ + SimpleCov::Formatter::HTMLFormatter, + Coveralls::SimpleCov::Formatter + ] - SimpleCov.start do add_filter "/test/" add_filter "/lib/parser/lexer.rb"
Use Coveralls formatter alongside SimpleCov.
diff --git a/tools/newi.rb b/tools/newi.rb index abc1234..def5678 100644 --- a/tools/newi.rb +++ b/tools/newi.rb @@ -4,6 +4,15 @@ { public class <class> : Instruction { + public void Execute(ProgrammingModel model, Memory memory, byte argument) + { + throw new System.NotImplementedException(); + } + + public int CyclesFor(AddressingMode mode) + { + throw new System.NotImplementedException(); + } } } }
Add empty implementations of the abstract methods
diff --git a/spec/factories/tasks_taskables_verifications.rb b/spec/factories/tasks_taskables_verifications.rb index abc1234..def5678 100644 --- a/spec/factories/tasks_taskables_verifications.rb +++ b/spec/factories/tasks_taskables_verifications.rb @@ -2,6 +2,6 @@ FactoryGirl.define do factory :tasks_taskables_verification, aliases: [:verification], class: 'Tasks::Taskables::Verification' do - verifiable nil + association :verifiable, factory: :tasks_taskables_question end end
Add verifiable to verification factories
diff --git a/spec/views/validation/validate.html.erb_spec.rb b/spec/views/validation/validate.html.erb_spec.rb index abc1234..def5678 100644 --- a/spec/views/validation/validate.html.erb_spec.rb +++ b/spec/views/validation/validate.html.erb_spec.rb @@ -9,7 +9,8 @@ :no_encoding => "The encoding of your CSV file is not being declared in the HTTP response.", :invalid_encoding => "Your CSV appears to be encoded in <code>iso-8859-1</code>, but invalid characters were found", :wrong_content_type => "Your CSV file is being delivered with an incorrect <code>Content-Type</code>", - :no_content_type => "Your CSV file is being delivered without a <code>Content-Type</code> header" + :no_content_type => "Your CSV file is being delivered without a <code>Content-Type</code> header", + :nonrfc_line_breaks => "Your CSV appears to use <code>LF</code> line-breaks" }.each do |k, v| message = Csvlint::ErrorMessage.new(:type => k) @@ -18,6 +19,7 @@ validator.stub(:content_type) { "text/plain" } validator.stub(:extension) { ".csv" } validator.stub(:headers) { {"content-type" => "text/plain"} } + validator.stub(:line_breaks) { "\n" } validator render :partial => "validation/message", :locals => { :message => message, :validator => validator }
Test line break error display
diff --git a/acceptance/tests/commands/legacy-sub-commands.rb b/acceptance/tests/commands/legacy-sub-commands.rb index abc1234..def5678 100644 --- a/acceptance/tests/commands/legacy-sub-commands.rb +++ b/acceptance/tests/commands/legacy-sub-commands.rb @@ -3,7 +3,7 @@ ["puppetdb-ssl-setup","puppetdb-import","puppetdb-export","puppetdb-anonymize"].each do |k| result = on database, "/usr/sbin/#{k} -h" - assert_match(/WARNING: #{k} style of executing puppetdb commands is deprecated/, result.stdout, "Legacy sub-command did not returning a deprecation WARNING line") + assert_match(/WARNING: #{k} style of executing puppetdb subcommands is deprecated/, result.stdout, "Legacy sub-command did not returning a deprecation WARNING line") end end end
Change regex for legacy subcommand warning test Signed-off-by: Ken Barber <470bc578162732ac7f9d387d34c4af4ca6e1b6f7@bob.sh>
diff --git a/Spinner.podspec b/Spinner.podspec index abc1234..def5678 100644 --- a/Spinner.podspec +++ b/Spinner.podspec @@ -3,7 +3,7 @@ spec.version = '1.2.3' spec.summary = 'Present loading indicators anywhere quickly and easily' - spec.homepage = 'https://github.com/nodes-ios/Serpent' + spec.homepage = 'https://github.com/nodes-ios/Spinner' spec.author = { 'Mostafa Amer' => 'mostafamamer@gmail.com' } spec.source = { :git => 'https://github.com/nodes-ios/Spinner.git', :tag => spec.version.to_s } spec.license = 'MIT'
Update home page on podspec Co-Authored-By: Peter Bødskov <bd717b81a9f41e5683aecd28e8bbebd00ddfb849@nodes.dk>
diff --git a/app/controllers/kuroko2/executions_controller.rb b/app/controllers/kuroko2/executions_controller.rb index abc1234..def5678 100644 --- a/app/controllers/kuroko2/executions_controller.rb +++ b/app/controllers/kuroko2/executions_controller.rb @@ -8,7 +8,7 @@ def destroy if @execution.try!(:pid) - hostname = Kuroko2::Worker.executing(@execution.id).try!(:hostname) + hostname = Kuroko2::Worker.executing(@execution.id).try!(:hostname) || '' # XXX: Store pid and hostname for compatibility Kuroko2::ProcessSignal.create!(pid: @execution.pid, hostname: hostname, execution_id: @execution.id) end
Insert empty string when hostname is missing
diff --git a/app/controllers/scripts_controller.rb b/app/controllers/scripts_controller.rb index abc1234..def5678 100644 --- a/app/controllers/scripts_controller.rb +++ b/app/controllers/scripts_controller.rb @@ -6,7 +6,10 @@ end def show - + @script = Script.find(params[:id]) + @story = Story.new + # Have this go to show page that shows new story form partials + # render "stories/new" end
Write skeleton script show route
diff --git a/app/controllers/apps/plugins_admin_controller.rb b/app/controllers/apps/plugins_admin_controller.rb index abc1234..def5678 100644 --- a/app/controllers/apps/plugins_admin_controller.rb +++ b/app/controllers/apps/plugins_admin_controller.rb @@ -16,7 +16,6 @@ return render_error(404) unless @plugin.active? lookup_context.prefixes.prepend(params[:controller].sub("plugins/#{plugin_name}", "#{plugin_name}/views")) self.append_view_path(Rails.root.join("app", 'apps', "plugins")) - admin_breadcrumb_add(@plugin.title, "") end -end+end
Remove extra plugin title in breadcrumbs
diff --git a/app/controllers/email_confirmation_controller.rb b/app/controllers/email_confirmation_controller.rb index abc1234..def5678 100644 --- a/app/controllers/email_confirmation_controller.rb +++ b/app/controllers/email_confirmation_controller.rb @@ -3,28 +3,39 @@ include AuthToken def verify - verifier = AuthTokenVerifier.new(params[:token]).verify - - ## FIXME seed and fetch from DB - # - view = File.read("#{Rails.root}/app/liquid/views/layouts/email-confirmation-follow-up.liquid") - template = Liquid::Template.parse(view) if verifier.success? - minutes_in_a_year = 1.year.abs / 60 - encoded_jwt = encode_jwt(verifier.authentication.member.token_payload, minutes_in_a_year) - - cookies.signed['authentication_id'] = { - value: encoded_jwt, - expires: 1.year.from_now - } + bake_cookies end @rendered = template.render( 'errors' => verifier.errors, 'members_dashboard_url' => Settings.members.dashboard_url ).html_safe + ## FIXME seed and fetch from DB + # + render 'email_confirmation/follow_up', layout: 'generic' - render 'email_confirmation/follow_up', layout: 'generic' end + + private + + def verifier + @verifier ||= AuthTokenVerifier.new(params[:token]).verify + end + + def bake_cookies + minutes_in_a_year = 1.year.abs / 60 + encoded_jwt = encode_jwt(verifier.authentication.member.token_payload, minutes_in_a_year) + + cookies.signed['authentication_id'] = { + value: encoded_jwt, + expires: 1.year.from_now + } + end + + def template + @template ||= Liquid::Template.parse(File.read("#{Rails.root}/app/liquid/views/layouts/email-confirmation-follow-up.liquid")) + end + end
Tidy up the email confirmation controller just a little bit
diff --git a/app/controllers/webhooks/github_controller.rb b/app/controllers/webhooks/github_controller.rb index abc1234..def5678 100644 --- a/app/controllers/webhooks/github_controller.rb +++ b/app/controllers/webhooks/github_controller.rb @@ -10,43 +10,45 @@ def process_request type = request.headers['X-GitHub-Event'] - if payload = ::Github::Payload.load(type, params) + return unless type == 'push' - product = Product.with_repo(payload.repo).first - if product.nil? - log "Product not found: #{payload.repo}" - return - end + payload = ::Github::Payload.load(type, params) + log 'Malformed payload' and return unless payload - if payload.nil? - log "Malformed payload" - else - # specs for this are found here: - # http://developer.github.com/v3/activity/events/types/#pushevent + product = Product.with_repo(payload.repo).first + log "Product not found: #{payload.repo}" and return unless product - if type == 'push' - Github::UpdateCommitCount.perform_async(product.id) - payload.commits.each do |commit| - author = commit['author'] - if username = author['username'] - user = User.find_by(github_login: username) + # specs for this are found here: + # http://developer.github.com/v3/activity/events/types/#pushevent - work = WorkFactory.create_with_transaction_entry!( - product: product, - user: user, - url: commit['url'], - metadata: { author: author, message: commit['message'], distinct: commit['distinct'], sha: commit['sha'] } - ) + Github::UpdateCommitCount.perform_async(product.id) - Activities::GitPush.publish!( - actor: user, - subject: work, - target: product - ) - end - end - end - end + payload.commits.each do |commit| + author = commit['author'] + + username = author['username'] + next unless username + + user = User.find_by(github_login: username) + next unless user + + work = WorkFactory.create_with_transaction_entry!( + product: product, + user: user, + url: commit['url'], + metadata: { + author: author, + message: commit['message'], + distinct: commit['distinct'], + sha: commit['sha'] + } + ) + + Activities::GitPush.publish!( + actor: user, + subject: work, + target: product + ) end end
Refactor and remove any potential null key violations
diff --git a/features/support/style_info.rb b/features/support/style_info.rb index abc1234..def5678 100644 --- a/features/support/style_info.rb +++ b/features/support/style_info.rb @@ -20,5 +20,5 @@ # have to use global variables.... $active_button_color = "rgb(208, 208, 255)" $inactive_button_color = "rgb(255, 255, 255)" -$active_confirmation_color = "rgb(103, 148, 255)" +$active_confirmation_color = "rgb(176, 176, 255)" $inactive_confirmation_color = "rgb(255, 255, 255)"
Bring acceptance tests into line with prior color-palette updates.
diff --git a/vat_id_validator.gemspec b/vat_id_validator.gemspec index abc1234..def5678 100644 --- a/vat_id_validator.gemspec +++ b/vat_id_validator.gemspec @@ -17,7 +17,7 @@ gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) gem.require_paths = %w[lib] - gem.add_dependency 'activemodel' + gem.add_dependency 'activemodel', '~>3.2.12' gem.add_development_dependency 'yard' gem.add_development_dependency 'rspec'
Use Rails 3 as Rails 4 is not yet supported
diff --git a/examples/composition/scale_exercise.rb b/examples/composition/scale_exercise.rb index abc1234..def5678 100644 --- a/examples/composition/scale_exercise.rb +++ b/examples/composition/scale_exercise.rb @@ -0,0 +1,41 @@+require 'musicality' +include Musicality +include Pitches +include Meters +include ScaleClasses + +def scale_exercise scale_class, base_pitch, rhythm + scale = scale_class.to_pitch_seq(base_pitch) + n = scale_class.count + m = rhythm.size + + rseq = RepeatingSequence.new((0...m).to_a) + aseq = AddingSequence.new([0]*(m-1) + [1]) + cseq = CompoundSequence.new(:+,[aseq,rseq]) + pgs = cseq.take(m*n).map {|i| scale.at(i) } + notes = make_notes(rhythm, pgs) + + make_notes([3/4.to_r,-1/4.to_r], [scale.at(n)]) + + rseq = RepeatingSequence.new(n.downto(n+1-m).to_a) + aseq = AddingSequence.new([0]*(m-1) + [-1]) + cseq = CompoundSequence.new(:+,[aseq,rseq]) + pgs = cseq.take(m*n).map {|i| scale.at(i) } + notes += make_notes(rhythm, pgs) + + make_notes([3/4.to_r,-1/4.to_r], [scale.at(0)]) + + return notes +end + +score = Score::Measured.new(FOUR_FOUR,120) do |s| + s.parts["scale"] = Part.new(Dynamics::MP) do |p| + Heptatonic::Prima::MODES.each do |mode_n,scale_class| + [[1/4.to_r,1/4.to_r,1/2.to_r]].each do |rhythm| + p.notes += scale_exercise(scale_class, C3, rhythm) + end + end + end + s.program.push 0...s.measures_long +end + +seq = ScoreSequencer.new(score.to_timed(200)).make_midi_seq("scale" => 1) +File.open("./scale_exercise.mid", 'wb'){ |fout| seq.write(fout) }
Add an example composition file.
diff --git a/lib/tasks/app.rake b/lib/tasks/app.rake index abc1234..def5678 100644 --- a/lib/tasks/app.rake +++ b/lib/tasks/app.rake @@ -10,31 +10,4 @@ task :run_carton do Tachikoma::Application.run 'carton' end - - # Deprecated: Please use `tachikoma:run_bundle` or `tachikoma:run_carton` instead - task :load do - warn '[DEPRECATION] `tachikoma:load` is deleted. Please use `tachikoma:run_bundle` or `tachikoma:run_carton instead.' - end - - # Deprecated: Please use `tachikoma:run_bundle` or `tachikoma:run_carton` instead - task :fetch do - warn '[DEPRECATION] `tachikoma:fetch` is deleted. Please use `tachikoma:run_bundle` or `tachikoma:run_carton instead.' - end - - # Deprecated: Please use `tachikoma:run_bundle` or `tachikoma:run_carton` instead - task :bundle do - warn '[DEPRECATION] `tachikoma:bundle` is deprecated. Please use `tachikoma:run_bundle` or `tachikoma:run_carton` instead.' - Tachikoma::Application.run 'bundle' - end - - # Deprecated: Please use `tachikoma:run_bundle` or `tachikoma:run_carton` instead - task :carton do - warn '[DEPRECATION] `tachikoma:carton` is deprecated. Please use `tachikoma:run_bundle` or `tachikoma:run_carton` instead.' - Tachikoma::Application.run 'carton' - end - - # Deprecated: Please use `tachikoma:run_bundle` or `tachikoma:run_carton` instead - task :pull_request do - warn '[DEPRECATION] `tachikoma:pull_request` is deleted. Please use `tachikoma:run_bundle` or `tachikoma:run_carton` instead.' - end end
Remove deprcated code from task
diff --git a/lib/frecon/db.rb b/lib/frecon/db.rb index abc1234..def5678 100644 --- a/lib/frecon/db.rb +++ b/lib/frecon/db.rb @@ -1,13 +1,13 @@ require "logger" require "mongoid" -Mongoid.load!("mongoid.yml") +Mongoid.load!(File.join(File.dirname(__FILE__), "mongoid.yml")) Mongoid.logger.level = Logger::DEBUG -Mongoid.logger = Logger.new("log/mongoid.log") +Mongoid.logger = Logger.new($stdout) Moped.logger.level = Logger::DEBUG -Moped.logger = Logger.new("log/moped.log") +Moped.logger = Logger.new($stdout) Dir.glob("models/*.rb").each do |file| require_relative file
Fix loading Mongoid, output to stdout
diff --git a/lib/kanji/cli.rb b/lib/kanji/cli.rb index abc1234..def5678 100644 --- a/lib/kanji/cli.rb +++ b/lib/kanji/cli.rb @@ -18,7 +18,7 @@ desc "server", "Start the application server" def server - `shotgun config.ru > stdout` + `shotgun config.ru` end map "s" => "server"
Stop logging server output to stdout file
diff --git a/foodr-backend/app/controllers/searches_controller.rb b/foodr-backend/app/controllers/searches_controller.rb index abc1234..def5678 100644 --- a/foodr-backend/app/controllers/searches_controller.rb +++ b/foodr-backend/app/controllers/searches_controller.rb @@ -1,7 +1,4 @@ class SearchesController < ApplicationController - - def create - end def save search = Search.find_by(id: params[:id])
Remove create method from search controller
diff --git a/guides/rails_guides/helpers_ja.rb b/guides/rails_guides/helpers_ja.rb index abc1234..def5678 100644 --- a/guides/rails_guides/helpers_ja.rb +++ b/guides/rails_guides/helpers_ja.rb @@ -13,11 +13,11 @@ def docs_for_sitemap(position) case position when "L" - documents_by_section.to(3) + documents_by_section.to(4) when "C" - documents_by_section.from(4).take(2) + documents_by_section.from(5).take(2) when "R" - documents_by_section.from(6) + documents_by_section.from(7) else raise "Unknown position: #{position}" end
Add and sort guides with new genre '他の構成要素' in Footer
diff --git a/examples/dump_history.rb b/examples/dump_history.rb index abc1234..def5678 100644 --- a/examples/dump_history.rb +++ b/examples/dump_history.rb @@ -0,0 +1,37 @@+#!/usr/bin/env ruby + +dir = File.dirname(__FILE__) + '/../lib' +$LOAD_PATH << dir unless $LOAD_PATH.include?(dir) + +require 'rubygems' +require 'currentcost/meter' + +require 'optparse' + +# Command-line options +options = {:port => '/dev/ttyS0'} +OptionParser.new do |opts| + opts.on("-p", "--serial_port SERIAL_PORT", "serial port") do |p| + options[:port] = p + end +end.parse! + +# A simple observer class which will receive updates from the meter +class HistoryObserver + def update(xml) + if xml.include?('<hist>') + puts xml + end + end +end + +# Create meter +meter = CurrentCost::Meter.new(options[:port], :cc128 => true) +# Create observer +observer = HistoryObserver.new +# Register observer with meter +meter.protocol.add_observer(observer) +# Wait a while, let things happen +sleep(60) +# Close the meter object to stop it receiving data +meter.close
Add an example that dumps history data
diff --git a/examples/reverse_body.rb b/examples/reverse_body.rb index abc1234..def5678 100644 --- a/examples/reverse_body.rb +++ b/examples/reverse_body.rb @@ -0,0 +1,19 @@+# Run me like this: +# ruby -I lib/ -rubygems examples/reverse_body.rb + +require 'bundler' +Bundler.setup +require 'metaphor' +require 'metaphor/input/stdin_input' +require 'metaphor/processor/stdout_processor' + +class Reverse + def process(headers, body) + [ headers, body.reverse ] + end +end + +m = Metaphor.new +m.processors << Reverse.new +m.processors << Metaphor::Processor::StdoutProcessor.new +m.process Metaphor::Input::StdinInput.new
Add a simple example: reverse the message body.
diff --git a/06_frequent_characters.rb b/06_frequent_characters.rb index abc1234..def5678 100644 --- a/06_frequent_characters.rb +++ b/06_frequent_characters.rb @@ -0,0 +1,4 @@+by_freq = ARGF.each_line.map { |l| l.strip.chars }.transpose.map(&:tally).map { |f| + f.to_a.sort_by(&:last).map(&:first) +} +puts %i(last first).map { |s| by_freq.map(&s).join }
Add day 06: Frequen Characters
diff --git a/test/features/feature_test.rb b/test/features/feature_test.rb index abc1234..def5678 100644 --- a/test/features/feature_test.rb +++ b/test/features/feature_test.rb @@ -28,14 +28,10 @@ actual_pdf.binwrite(actual) if expect_pdf.exist? - assert match_expect_pdf?, message('Does not match expect.pdf. Check diff.pdf for details.') + assert match_expect_pdf?, 'Does not match expect.pdf. Check diff.pdf for details.' else - flunk message('expect.pdf does not exist.') + flunk 'expect.pdf does not exist.' end - end - - def message(msg) - "[#{feature_name}] #{msg}" end def template_path(filename = 'template.tlf')
Improve error message in feature tests
diff --git a/test/fixtures/sample_app.rb b/test/fixtures/sample_app.rb index abc1234..def5678 100644 --- a/test/fixtures/sample_app.rb +++ b/test/fixtures/sample_app.rb @@ -5,9 +5,18 @@ class SampleApp < Sinatra::Base get '/v1/users' do + headers 'Content-Type' => 'application/json' + body '{}' end post '/v1/users' do + headers 'Content-Type' => 'application/json' + body '{}' + end + + get '/v1/users/:id' do + headers 'Content-Type' => 'application/json' + body '{}' end put '/v1/users/:id' do
Update sample app to deal with json checking
diff --git a/lib/g5_authenticatable_api/grape_helpers.rb b/lib/g5_authenticatable_api/grape_helpers.rb index abc1234..def5678 100644 --- a/lib/g5_authenticatable_api/grape_helpers.rb +++ b/lib/g5_authenticatable_api/grape_helpers.rb @@ -9,7 +9,7 @@ else throw :error, message: 'Unauthorized', status: 401, - headers: {'WWW-Authenticate' => authenticate_header} + headers: {'WWW-Authenticate' => authenticate_response_header} end end end @@ -30,11 +30,11 @@ rescue OAuth2::Error => error throw :error, message: 'Unauthorized', status: 401, - headers: {'WWW-Authenticate' => authenticate_header(error)} + headers: {'WWW-Authenticate' => authenticate_response_header(error)} end end - def authenticate_header(error=nil) + def authenticate_response_header(error=nil) auth_header = "Bearer" if error
Rename helper method for clarity