diff
stringlengths
65
26.7k
message
stringlengths
7
9.92k
diff --git a/metadata.rb b/metadata.rb index abc1234..def5678 100644 --- a/metadata.rb +++ b/metadata.rb @@ -4,4 +4,4 @@ license "Apache 2.0" description "System Software configuration and maintenance" long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version "0.41.3" +version "0.42.0"
Split account databag handling into a separate recipe
diff --git a/tools/upload-to-github.rb b/tools/upload-to-github.rb index abc1234..def5678 100644 --- a/tools/upload-to-github.rb +++ b/tools/upload-to-github.rb @@ -26,5 +26,17 @@ :size => File.size(file), :description => File.basename(file), :content_type => content_type) - github.repos.upload(resource, File.basename(file)) + p resource + + system("curl", + "-F", "key=#{resource.path}", + "-F", "acl=#{resource.acl}", + "-F", "success_action_status=201", + "-F", "Filename=#{resource.name}", + "-F", "AWSAccessKeyId=#{resource.accesskeyid}", + "-F", "Policy=#{resource.policy}", + "-F", "Signature=#{resource.signature}", + "-F", "Content-Type=#{resource.mime_type[0]['Content-Type']}", + "-F", "file=@#{file}", + resourec.s3_url) end
Use curl instead of github_api Because github_api's upload doesn't work... :<
diff --git a/lib/dm-predefined/predefined.rb b/lib/dm-predefined/predefined.rb index abc1234..def5678 100644 --- a/lib/dm-predefined/predefined.rb +++ b/lib/dm-predefined/predefined.rb @@ -28,13 +28,13 @@ end def define(name,attributes={}) - name = name.to_sym + name = name.to_s - predefined_attributes[name] = attributes + predefined_attributes[name.to_sym] = attributes class_eval %{ - def self.#{name} - self[:#{name}] + define_method(#{name.dump}) do + self[#{name.dump}] end }
Use better escaping of Strings when defining methods.
diff --git a/lib/method_found/interceptor.rb b/lib/method_found/interceptor.rb index abc1234..def5678 100644 --- a/lib/method_found/interceptor.rb +++ b/lib/method_found/interceptor.rb @@ -1,6 +1,14 @@ module MethodFound class Interceptor < Module - def initialize(regex, &intercept_block) + attr_reader :regex + + def initialize(regex = nil, &intercept_block) + define_method_missing(regex, &intercept_block) unless regex.nil? + define_inspect + end + + def define_method_missing(regex, &intercept_block) + @regex = regex define_method :method_missing do |method_name, *arguments, &method_block| if matches = regex.match(method_name) instance_exec(method_name, matches, *arguments, &intercept_block) @@ -12,7 +20,10 @@ define_method :respond_to_missing? do |method_name, include_private = false| (method_name =~ regex) || super(method_name, include_private) end + end + def define_inspect + regex = @regex define_method :inspect do klass = self.class name = klass.name || klass.inspect
Refactor define methods into their own methods
diff --git a/db/migrate/20160412032842_add_email_uniqueness_index.rb b/db/migrate/20160412032842_add_email_uniqueness_index.rb index abc1234..def5678 100644 --- a/db/migrate/20160412032842_add_email_uniqueness_index.rb +++ b/db/migrate/20160412032842_add_email_uniqueness_index.rb @@ -1,4 +1,5 @@ class AddEmailUniquenessIndex < ActiveRecord::Migration def change + add_index :users, :email, :unique => true end end
Add Unit test validation User
diff --git a/lib/rrj/models/active_record.rb b/lib/rrj/models/active_record.rb index abc1234..def5678 100644 --- a/lib/rrj/models/active_record.rb +++ b/lib/rrj/models/active_record.rb @@ -16,7 +16,7 @@ self.primary_key = :id alias_attribute :instance, :id - alias_attribute :name, :title + alias_attribute :title, :name alias_attribute :session_id, :session alias_attribute :thread_id, :thread alias_attribute :thread_id_adm, :thread_adm
Change alias with field name
diff --git a/lib/snapme/imagesnap_command.rb b/lib/snapme/imagesnap_command.rb index abc1234..def5678 100644 --- a/lib/snapme/imagesnap_command.rb +++ b/lib/snapme/imagesnap_command.rb @@ -1,7 +1,7 @@ module Snapme class ImagesnapCommand def call(filename) - `#{command_name} #{filename}` + system(command_name, filename) end private
Use system method rather than ticks for shell out * Seems to be a little more clear and doens't require string interpolation for arguments
diff --git a/runner.rb b/runner.rb index abc1234..def5678 100644 --- a/runner.rb +++ b/runner.rb @@ -13,24 +13,51 @@ Dotenv.load -environment = ENV.fetch('ENVIRONMENT') +def main + environment = ENV.fetch('ENVIRONMENT') -database_connection = Mysql2::Client.new(DatabaseConfig.for(environment)) + database_connection = with_retries(log_message_format: "Retrying SQL connection (%d/%d)") do + Mysql2::Client.new(DatabaseConfig.for(environment)) + end -database_writer = DatabaseWriter.new(database_connection) -database_writer.save_interval = 15 + database_writer = DatabaseWriter.new(database_connection) + database_writer.save_interval = 15 -last_measurement_store = LastMeasurementStore.new + last_measurement_store = LastMeasurementStore.new -if environment == "production" - stream_splitter = P1MeterReader::DataParsing::StreamSplitter.new("/XMX5XMXABCE100129872") -else - stream_splitter = P1MeterReader::DataParsing::FakeStreamSplitter.new + if environment == "production" + stream_splitter = P1MeterReader::DataParsing::StreamSplitter.new("/XMX5XMXABCE100129872") + else + puts "Fake stream splitter" + stream_splitter = P1MeterReader::DataParsing::FakeStreamSplitter.new + end + + recorder = P1MeterReader::Recorder.new(measurement_source: stream_splitter) + + recorder.collect_data do |measurement| + database_writer.save_unless_exists(measurement) + last_measurement_store.save(measurement) + end end -recorder = P1MeterReader::Recorder.new(measurement_source: stream_splitter) +def with_retries(max_tries: 5, log_message_format: "Retrying (%d/%d)") + tries = 0 -recorder.collect_data do |measurement| - database_writer.save_unless_exists(measurement) - last_measurement_store.save(measurement) + begin + yield + rescue Mysql2::Error + tries += 1 + + if (tries > max_tries) + raise + end + + puts format(log_message_format, tries, max_tries) + sleep 2 + + retry + end end + +puts "Starting..." +main
Add retries for the initial MySQL connection.
diff --git a/config.ru b/config.ru index abc1234..def5678 100644 --- a/config.ru +++ b/config.ru @@ -7,7 +7,40 @@ require 'prometheus/middleware/exporter' use Rack::Deflater, if: ->(_, _, _, body) { body.respond_to?( :map ) && body.map(&:bytesize).reduce(0, :+) > 512 } -use Prometheus::Middleware::Collector use Prometheus::Middleware::Exporter +use Prometheus::Middleware::Collector, + +# we customize these because we dont want to keep distinct metrics for every work or file view +counter_label_builder: ->(env, code) { + # normalize path, replace work IDs to keep cardinality low. + normalized_path = env['PATH_INFO'].to_s. + gsub(/\/public_view\/.*$/, '/public_view/:id'). + gsub(/\/downloads\/.*$/, '/downloads/:id'). + gsub(/\/concern\/generic_works\/.*$/, '/concern/generic_works/:id'). + gsub(/\/concern\/file_sets\/.*$/, '/concern/file_sets/:id'). + gsub(/\/submit\/.*$/, '/submit/:id'). + gsub(/\/api\/v1\/.*$/, '/api/v1/...') + + { + code: code, + method: env['REQUEST_METHOD'].downcase, + path: normalized_path + } +}, + duration_label_builder: -> ( env, code ) { + # normalize path, replace work IDs to keep cardinality low. + normalized_path = env['PATH_INFO'].to_s. + gsub(/\/public_view\/.*$/, '/public_view/:id'). + gsub(/\/downloads\/.*$/, '/downloads/:id'). + gsub(/\/concern\/generic_works\/.*$/, '/concern/generic_works/:id'). + gsub(/\/concern\/file_sets\/.*$/, '/concern/file_sets/:id'). + gsub(/\/submit\/.*$/, '/submit/:id'). + gsub(/\/api\/v1\/.*$/, '/api/v1/...') + + { + method: env['REQUEST_METHOD'].downcase, + path: normalized_path + } +} run Rails.application
Update Prometheus metrics capture to keep path cardinality down and stop a metrics explosion
diff --git a/app/controllers/refinery/retailers/admin/retailers_controller.rb b/app/controllers/refinery/retailers/admin/retailers_controller.rb index abc1234..def5678 100644 --- a/app/controllers/refinery/retailers/admin/retailers_controller.rb +++ b/app/controllers/refinery/retailers/admin/retailers_controller.rb @@ -3,6 +3,7 @@ module Admin class RetailersController < ::Refinery::AdminController crudify :'refinery/retailers/retailer', + paging: false, order: "lower(title) ASC" helper :'refinery/retailers/retailers'
Set paging to false for Admin::RetailersController
diff --git a/app/controllers/solidus_paypal_braintree/checkouts_controller.rb b/app/controllers/solidus_paypal_braintree/checkouts_controller.rb index abc1234..def5678 100644 --- a/app/controllers/solidus_paypal_braintree/checkouts_controller.rb +++ b/app/controllers/solidus_paypal_braintree/checkouts_controller.rb @@ -11,9 +11,13 @@ ].freeze def update - @order.payments.create!(payment_params) + @payment = Spree::PaymentCreate.new(@order, payment_params).build - render text: 'ok' + if @payment.save + render text: "ok" + else + render text: "not-ok" + end end def order_params
Stop using deprecated payment create Solidus now expects us to use a PaymentCreate class instead of assigning the source attributes via magic.
diff --git a/db/migrate/20170217081027_add_partial_index_to_scores.rb b/db/migrate/20170217081027_add_partial_index_to_scores.rb index abc1234..def5678 100644 --- a/db/migrate/20170217081027_add_partial_index_to_scores.rb +++ b/db/migrate/20170217081027_add_partial_index_to_scores.rb @@ -1,5 +1,6 @@ class AddPartialIndexToScores < ActiveRecord::Migration[4.2] tag :predeploy + disable_ddl_transaction! def up duplicate_enrollment_ids = Score. @@ -12,7 +13,7 @@ Score.where(enrollment_id: duplicate_enrollment_ids, grading_period_id: nil). where.not(id: saved_scores).delete_all - add_index :scores, :enrollment_id, unique: true, where: 'grading_period_id is null' + add_index :scores, :enrollment_id, unique: true, where: 'grading_period_id is null', algorithm: :concurrently end def down
Add an `algorithm: concurrently` to our scores partial index Fixes CNVS-35193 Test plan: * specs pass Change-Id: I1a9ca04c8b1f9c82f3b9a9769611da3df79e4205 Reviewed-on: https://gerrit.instructure.com/103040 Tested-by: Jenkins Reviewed-by: Cody Cutrer <c4fe2b1d90ef8f2548c8aeabfa633434316f0305@instructure.com> Product-Review: Neil Gupta <cc4fec8a34766005dd45d48be045c08d736c11ed@instructure.com> QA-Review: Neil Gupta <cc4fec8a34766005dd45d48be045c08d736c11ed@instructure.com>
diff --git a/spec/lib/sessions/backend/activity_stream_spec.rb b/spec/lib/sessions/backend/activity_stream_spec.rb index abc1234..def5678 100644 --- a/spec/lib/sessions/backend/activity_stream_spec.rb +++ b/spec/lib/sessions/backend/activity_stream_spec.rb @@ -17,8 +17,9 @@ end it 'manages race condition' do - Thread.new { associated_tickets.each(&:destroy) } + thread = Thread.new { associated_tickets.each(&:destroy) } expect { subject.load }.not_to raise_error + thread.join end end end
Test stabilization: Unjoined threads lead to stuck test suite.
diff --git a/spec/presenters/redetermination_presenter_spec.rb b/spec/presenters/redetermination_presenter_spec.rb index abc1234..def5678 100644 --- a/spec/presenters/redetermination_presenter_spec.rb +++ b/spec/presenters/redetermination_presenter_spec.rb @@ -1,20 +1,13 @@ require 'rails_helper' describe RedeterminationPresenter do - + let(:rd) { FactoryGirl.create :redetermination, fees: 1452.33, expenses: 2455.77 } let(:presenter) { RedeterminationPresenter.new(rd, view) } - describe '#created_at' do - it 'should properly format the time' do - allow(rd).to receive(:created_at).and_return(Time.local(2015, 8, 13, 13, 15, 22)) - expect(presenter.created_at).to eq('13/08/2015 13:15') - end - end - context 'currency fields' do - + it 'should format currency amount' do expect(presenter.fees_total).to eq '£1,452.33' expect(presenter.expenses_total).to eq '£2,455.77'
Remove "created_at" spec because its no longer in the presenter nor is it actually used
diff --git a/code/english_to_numbers.rb b/code/english_to_numbers.rb index abc1234..def5678 100644 --- a/code/english_to_numbers.rb +++ b/code/english_to_numbers.rb @@ -0,0 +1,16 @@+ + + + + +def engToNum word + + # need to make sure it is a string in the array + if word + +intNum - '' + +onesWords = {'one' => 1 , 'two' => 2, 'three' => 3, 'four' => 4, 'five' => 5, 'six' => 6, 'seven' => 7, 'eight' => 8, 'nine' => 9} +tensWords = {'ten' => 10, 'twenty' => 20, 'thirty' => 30, 'fourty' => 40, 'fifty' => 50, 'sixty' => 60, 'seventy' => 70, 'eighty' => 80, 'ninety' => 90} +teenagers = {'eleven' => 11, 'twelve' => 12, 'thirteen' => 13, 'fourteen' => 14, 'fifteen' => 15, 'sixteen' => 16, 'seventeen' => 17, 'eighteen' => 18, 'nineteen' => 19} +
Set up of engToNum -> english words returning integers
diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index abc1234..def5678 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -7,6 +7,8 @@ raise ActionController::RoutingError.new('Not Found') else logger.error("[Forest][Error] 404 page not found. Looked for path \"#{request.fullpath}\"") + @body_classes ||= [] + @body_classes << 'page--404' return render 'errors/not_found' end end
Add page--404 class to body_classes when rendering page not found
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index abc1234..def5678 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -7,6 +7,7 @@ user = User.new(user_params) if user.save + session[:user_id] = user.id flash[:notice] = "Welcome, #{user.name}!" redirect_to root_path else
Add new user's id to session
diff --git a/app/models/people_network.rb b/app/models/people_network.rb index abc1234..def5678 100644 --- a/app/models/people_network.rb +++ b/app/models/people_network.rb @@ -17,8 +17,12 @@ # end def self.create_trust!(first_person, second_person) - PeopleNetwork.create!(:person => first_person, :trusted_person => second_person) - PeopleNetwork.create!(:person => second_person, :trusted_person => first_person) + PeopleNetwork.create!(:person => first_person, :trusted_person => second_person, + :entity_id => second_person, + :entity_type_id => EntityType::TRUSTED_PERSON_ENTITY) + PeopleNetwork.create!(:person => second_person, :trusted_person => first_person, + :entity_id => first_person, + :entity_type_id => EntityType::TRUSTED_PERSON_ENTITY) first_person.reputation_rating.increase_trusted_network_count second_person.reputation_rating.increase_trusted_network_count EventLog.create_trust_established_event_log(first_person, second_person)
Add enitiy id to people network when trust is established
diff --git a/app/helpers/google_vision_helper.rb b/app/helpers/google_vision_helper.rb index abc1234..def5678 100644 --- a/app/helpers/google_vision_helper.rb +++ b/app/helpers/google_vision_helper.rb @@ -1,10 +1,41 @@ module GoogleVisionHelper + require 'googleauth' require 'google/apis/vision_v1' + require 'open-uri' + require 'faraday' - vision = Google::Apis::VisionV1::VisionService.new + # http://simon.rentzke.com/google-cloud-vision-api-on-ruby + + def has_cat?(url) + image = open(url) { |f| f.read } + encoded = Base64.encode64(image) + data_hash = { + requests: [{ + image: { content: encoded }, + features: [{ + type: "LABEL_DETECTION", + maxResults: 15 + }] + }] + } + body = data_hash.to_json + conn = Faraday.new(:url => 'https://vision.googleapis.com') + response = conn.post do |req| + req.url '/v1/images:annotate?key=' + ENV["GOOGLE_APPLICATION_API_KEY"] + req.headers['Content-Type'] = 'application/json' + req.body = body + end + parsed_response = JSON.parse(response.body) + descriptions = parsed_response["responses"][0]["labelAnnotations"].map do |obj| + obj["description"] + end + valid_keywords = ["cat", "kitten"] + p descriptions + descriptions.each do |word| + return true if valid_keywords.include?(word) + end + return false + end - scopes = ['https://www.googleapis.com/auth/cloud-platform', 'https://www.googleapis.com/auth/vision'] - vision.authorization = Google::Auth.get_application_default(scopes) - -end+end
Add module that identifies cats using Google vision
diff --git a/site-cookbooks/nan-base/definitions/default.rb b/site-cookbooks/nan-base/definitions/default.rb index abc1234..def5678 100644 --- a/site-cookbooks/nan-base/definitions/default.rb +++ b/site-cookbooks/nan-base/definitions/default.rb @@ -16,6 +16,13 @@ system true end + group 'docker' do + action :manage + append true + members name + system true + end + directory "#{home_dir}/.ssh" do owner name group name
Add staff users to the docker group
diff --git a/site-cookbooks/zabbix_part/spec/spec_helper.rb b/site-cookbooks/zabbix_part/spec/spec_helper.rb index abc1234..def5678 100644 --- a/site-cookbooks/zabbix_part/spec/spec_helper.rb +++ b/site-cookbooks/zabbix_part/spec/spec_helper.rb @@ -1,4 +1,5 @@ # Added by ChefSpec +require 'chef' require 'chefspec' require 'chefspec/berkshelf'
Add dependency on Chef::Resource.identity_attr when run chefspec
diff --git a/app/models/instance.rb b/app/models/instance.rb index abc1234..def5678 100644 --- a/app/models/instance.rb +++ b/app/models/instance.rb @@ -20,5 +20,5 @@ has_many :instance_users has_many :users, through: :instance_users - has_many :announcements, class_name: Announcement.name + has_many :announcements, class_name: Instance::Announcement.name end
Fix bug in Instance model
diff --git a/spec/github/git_data/references/delete_spec.rb b/spec/github/git_data/references/delete_spec.rb index abc1234..def5678 100644 --- a/spec/github/git_data/references/delete_spec.rb +++ b/spec/github/git_data/references/delete_spec.rb @@ -21,8 +21,10 @@ it { should respond_to :remove } + it { expect { subject.delete }.to raise_error(Github::Error::Validations) } + it "should fail to delete resource if 'ref' input is missing" do - expect { subject.delete user, repo, nil }.to raise_error(ArgumentError) + expect { subject.delete user, repo }.to raise_error(ArgumentError) end it "should delete resource successfully" do
Add test for lack of arguments.
diff --git a/db/migrate/20150202171723_add_destroy_labware.rb b/db/migrate/20150202171723_add_destroy_labware.rb index abc1234..def5678 100644 --- a/db/migrate/20150202171723_add_destroy_labware.rb +++ b/db/migrate/20150202171723_add_destroy_labware.rb @@ -2,7 +2,7 @@ def self.up ActiveRecord::Base.transaction do instrument = Instrument.create ({:name => "Destroying instrument", :barcode => "destroying-instrument" }) - instrument_process = InstrumentProcess.create ({:name => "Destroying labware process", :key => "destroy_labware", + instrument_process = InstrumentProcess.create ({:name => "Destroying labware", :key => "destroy_labware", :request_instrument => false }) instrument_processes_instrument = InstrumentProcessesInstrument.create ({:instrument => instrument, :instrument_process => instrument_process, :bed_verification_type => "Verification::OutdatedLabware::Base"})
Use nice labware destruction name
diff --git a/config/initializers/aws.rb b/config/initializers/aws.rb index abc1234..def5678 100644 --- a/config/initializers/aws.rb +++ b/config/initializers/aws.rb @@ -1,8 +1,8 @@ AssetManager.aws_s3_bucket_name = if Rails.env.production? - ENV.fetch('AWS_S3_BUCKET_NAME') -else - ENV['AWS_S3_BUCKET_NAME'] -end + ENV.fetch('AWS_S3_BUCKET_NAME') + else + ENV['AWS_S3_BUCKET_NAME'] + end AssetManager.aws_s3_use_virtual_host = ENV['AWS_S3_USE_VIRTUAL_HOST'].present?
Fix some Rubocop offences & warnings in AWS config I was seeing the following locally: * Layout/IndentationWidth * Layout/ElseAlignment * Lint/EndAlignment For some reason these were not picked up by the Jenkins CI build of the master branch. I plan to investigate why this didn't happen separately.
diff --git a/test/sample_test.rb b/test/sample_test.rb index abc1234..def5678 100644 --- a/test/sample_test.rb +++ b/test/sample_test.rb @@ -0,0 +1,21 @@+require 'test_helper' + +class Chelsy::SampleTest < Minitest::Test + SAMPLE_DIR = File.expand_path('../../sample/', __FILE__) + + def test_hello + validate_generate_sample 'hello_chelsy' + end + + private + + def validate_generate_sample(name) + path = File.join(SAMPLE_DIR, "#{name}.rb") + csrc = File.read(File.join(SAMPLE_DIR, "#{name}.c")) + + assert_output(csrc) do + load path + end + end + +end
Add tests to validate sample files
diff --git a/lib/ajimi/server.rb b/lib/ajimi/server.rb index abc1234..def5678 100644 --- a/lib/ajimi/server.rb +++ b/lib/ajimi/server.rb @@ -22,6 +22,7 @@ def find(dir, find_max_depth = nil) cmd = "sudo find #{dir} -ls" cmd += " -maxdepth #{find_max_depth}" if find_max_depth + cmd += " -path /dev -prune -o -path /proc -prune" cmd += " | awk '{printf \"%s, %s, %s, %s, %s\\n\", \$11, \$3, \$5, \$6, \$7}'" stdout = command_exec(cmd) stdout.split(/\n/).map {|line| line.chomp }.sort
Exclude /dev and /proc from find
diff --git a/Casks/dwarf-fortress-macnewbie.rb b/Casks/dwarf-fortress-macnewbie.rb index abc1234..def5678 100644 --- a/Casks/dwarf-fortress-macnewbie.rb +++ b/Casks/dwarf-fortress-macnewbie.rb @@ -1,6 +1,6 @@ cask :v1 => 'dwarf-fortress-macnewbie' do - version '0.9.9' - sha256 'ca04045341330e2258e1eedf296eefa2b5fe339c7a01618449f4b1adf6478358' + version '0.9.16a' + sha256 'eb678d5bfef47a1da05ee131c2fbced6ada06359bd12e00a4c979567fecb740f' url "http://dffd.wimbli.com/download.php?id=7922&f=Macnewbie_#{version}.dmg" homepage 'http://www.bay12forums.com/smf/index.php?topic=128960'
Update Dwarf Fortress MacNewbie to 0.9.16a.
diff --git a/test/test_helper.rb b/test/test_helper.rb index abc1234..def5678 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,10 +1,10 @@ require 'bundler/setup' -require 'minitest/autorun' +require 'test/unit' require 'ventana' # Remove deprecation warning I18n.enforce_available_locales = true -class TestCase < Minitest::Unit::TestCase +class TestCase < Test::Unit::TestCase end
Switch to test/unit for compatibility
diff --git a/test/test_helper.rb b/test/test_helper.rb index abc1234..def5678 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -13,7 +13,13 @@ :database => "activerecord_metal" ) -metal = ActiveRecord::Metal.new +metal = begin + ActiveRecord::Metal.new +rescue ActiveRecord::NoDatabaseError + STDERR.puts "[ERR] Make sure there is a database 'activerecord_metal' on the current postgresql connection." + exit 0 +end + metal.ask "DROP TABLE IF EXISTS alloys" metal.ask <<-SQL CREATE TABLE alloys(
Print warning if test database is missing.
diff --git a/test/test_job_vn.rb b/test/test_job_vn.rb index abc1234..def5678 100644 --- a/test/test_job_vn.rb +++ b/test/test_job_vn.rb @@ -1,3 +1,4 @@+# frozen_string_literal: true # encoding: UTF-8 require 'helper'
Add frozen string literal comment for test
diff --git a/server.rb b/server.rb index abc1234..def5678 100644 --- a/server.rb +++ b/server.rb @@ -1,20 +1,23 @@-require 'sinatra' +require 'sinatra/base' require './models/student' -get '/hi' do - "Hello world!" -end +class StudentPinMap < Sinatra::Application + set :bind, '0.0.0.0' -get '/' do - @students = Student.all - @cluster = (params[:cluster] != 'n') + get '/' do + @students = Student.all + @cluster = (params[:cluster] != 'n') - erb :index -end + erb :index + end -post '/students' do - Student.create name: params[:name], city: params[:city] + post '/students' do + Student.create name: params[:name], city: params[:city] - redirect '/' + redirect '/' + end + + # TODO: add config.ru to run with rackup + run! end
Switch to modular sinatra style (subclass `Sinatra::Application`)
diff --git a/spec/attr_inject/core_ext_spec.rb b/spec/attr_inject/core_ext_spec.rb index abc1234..def5678 100644 --- a/spec/attr_inject/core_ext_spec.rb +++ b/spec/attr_inject/core_ext_spec.rb @@ -20,6 +20,11 @@ end +class BlankClass + def initialize + end +end + describe "attr_inject" do it "creates a method with attr_inject" do i = SimpleInject.new @@ -39,4 +44,10 @@ it "raises an error when an required attribute is unfulfiled" do expect{InjectViaInitialize.new :foo => "bar"}.to raise_error(Inject::InjectionError) end -end+ + it "allows injection on classes with no attr_inject" do + blank = BlankClass.new + blank.inject_attributes :foo => "foo", :bar => "bar" + end + +end
Test case where no injection targets are defined
diff --git a/spec/integration/cookbook_spec.rb b/spec/integration/cookbook_spec.rb index abc1234..def5678 100644 --- a/spec/integration/cookbook_spec.rb +++ b/spec/integration/cookbook_spec.rb @@ -2,15 +2,15 @@ describe 'sprout-ruby' do before :all do - expect(File).not_to be_exists('/etc/gemrc') + expect(File).not_to be_exists("#{ENV['HOME']}/.gemrc") end it 'converges without errors' do expect(system('soloist')).to eq(true) end - it 'creates a global gemrc' do - expect(File).to be_exists('/etc/gemrc') + it 'creates a local gemrc' do + expect(File).to be_exists("#{ENV['HOME']}/.gemrc") end it 'prevents `sudo gem`' do
Fix integration tests for local .gemrc installation
diff --git a/spec/models/spree/bp_hook_spec.rb b/spec/models/spree/bp_hook_spec.rb index abc1234..def5678 100644 --- a/spec/models/spree/bp_hook_spec.rb +++ b/spec/models/spree/bp_hook_spec.rb @@ -21,7 +21,9 @@ expect(@all.second['subscribeTo']).to eq 'product.modified' end - it 'sets product.destroyed webhook' do + # Pendind due to brightpearl bug + # https://www.brightpearl.com/community/forums/product-support-core-platform/webhook-http-method-delete + xit 'sets product.destroyed webhook' do expect(@all.third['subscribeTo']).to eq 'product.destroyed' end end
Set peding failing test due to brightpearl bug
diff --git a/spec/slow_shared_examples_spec.rb b/spec/slow_shared_examples_spec.rb index abc1234..def5678 100644 --- a/spec/slow_shared_examples_spec.rb +++ b/spec/slow_shared_examples_spec.rb @@ -1,8 +1,23 @@+RSpec.shared_context "shared stuff", :shared_context => :metadata do + before do + sleep 1 + end +end + describe 'Example of slow shared examples' do + # this should add 1s for each it below including + # shared example. + include_context "shared stuff" + # this should add 1.5s to the total timing of this test file recorded by knapsack_pro + # 1.5s + 1s from include_context it_behaves_like 'slow shared example test' + + # ~0.001s + 1s from include_context it do expect(true).to be true end + + # in total this file should take ~3.5s end
Add example of include_context impacting the recorded timing
diff --git a/app/mailers/invite_people_mailer.rb b/app/mailers/invite_people_mailer.rb index abc1234..def5678 100644 --- a/app/mailers/invite_people_mailer.rb +++ b/app/mailers/invite_people_mailer.rb @@ -5,7 +5,7 @@ @group = @invitation.group @message_body = message_body send_single_mail to: @invitation.recipient_email, - locale: @invitation.inviter.locale, + locale: first_supported_locale(@invitation.inviter.locale), reply_to: sender_email, subject_key: "email.group_membership_approved.subject", subject_params: {group_name: @group.full_name}
Fix locales for invite people emails
diff --git a/app/models/api/v3/area_presenter.rb b/app/models/api/v3/area_presenter.rb index abc1234..def5678 100644 --- a/app/models/api/v3/area_presenter.rb +++ b/app/models/api/v3/area_presenter.rb @@ -9,6 +9,7 @@ analysis_year area base_dataset + derived geo_id group number_of_inhabitants
Include "derived" with sparse area data
diff --git a/messaging.gemspec b/messaging.gemspec index abc1234..def5678 100644 --- a/messaging.gemspec +++ b/messaging.gemspec @@ -1,7 +1,7 @@ # -*- encoding: utf-8 -*- Gem::Specification.new do |s| s.name = 'messaging' - s.version = '0.1.0.0' + s.version = '0.2.0.0' s.summary = 'Messaging primitives for Eventide' s.description = ' '
Package version increased from 0.1.0.0 to 0.2.0.0
diff --git a/lib/csvconverter.rb b/lib/csvconverter.rb index abc1234..def5678 100644 --- a/lib/csvconverter.rb +++ b/lib/csvconverter.rb @@ -8,9 +8,9 @@ rescue LoadError puts "Failed to load #{CSVGEM} (ruby #{RUBY_VERSION})" puts "gem install #{CSVGEM}" - exit + abort end CSVParserClass = CSVGEM == 'csv' ? CSV : FasterCSV require "csv2strings/converter" -require "strings2csv/converter"+require "strings2csv/converter"
Change exit by abort to exit properly in require during tests
diff --git a/spec/scanny/checks/system_tools/gpg_usage_check_spec.rb b/spec/scanny/checks/system_tools/gpg_usage_check_spec.rb index abc1234..def5678 100644 --- a/spec/scanny/checks/system_tools/gpg_usage_check_spec.rb +++ b/spec/scanny/checks/system_tools/gpg_usage_check_spec.rb @@ -12,12 +12,24 @@ @runner.should check("GPG.method").with_issue(@issue) end - it "reports \"GPG.method\" correctly" do + it "reports \"Gpg.method\" correctly" do @runner.should check("Gpg.method").with_issue(@issue) end - it "reports \"GPG.method\" correctly" do + it "reports \"GpgKey.method\" correctly" do @runner.should check("GpgKey.method").with_issue(@issue) + end + + it "reports \"GPGME.method\" correctly" do + @runner.should check("GPGME.method").with_issue(@issue) + end + + it "reports \"Gpgr.method\" correctly" do + @runner.should check("Gpgr.method").with_issue(@issue) + end + + it "reports \"RubyGpg.method\" correctly" do + @runner.should check("RubyGpg.method").with_issue(@issue) end it "reports \"system('gpg --example-flag')\" correctly" do
Test all popular libs for ruby related to GPG
diff --git a/blz.gemspec b/blz.gemspec index abc1234..def5678 100644 --- a/blz.gemspec +++ b/blz.gemspec @@ -5,7 +5,7 @@ Gem::Specification.new do |s| s.name = 'blz' - s.version = '0.1.2' + s.version = '0.1.3' s.platform = Gem::Platform::RUBY s.summary = "BLZ (Bankleitzahlen) for Ruby"
Prepare for new version on rubygems
diff --git a/lib/namesies/cli.rb b/lib/namesies/cli.rb index abc1234..def5678 100644 --- a/lib/namesies/cli.rb +++ b/lib/namesies/cli.rb @@ -9,15 +9,18 @@ def search(q) puts "Searching for #{q}..." puts "\n" + + services = Namesies.constants - [:VERSION, :CLI, :Reporter] + if options[:only] options[:only].each do |service| Namesies.const_get(service.capitalize).send(:search, q) end else - Namesies::Domain.search(q) unless options[:except].include? 'domain' - Namesies::Twitter.search(q) unless options[:except].include? 'twitter' - Namesies::Trademark.search(q) unless options[:except].include? 'trademark' - Namesies::Rubygems.search(q) unless options[:except].include? 'rubygems' + services.each do |service| + next if options[:except] && options[:except].include?(service.to_s.downcase) + Namesies.const_get(service.capitalize).send(:search, q) + end end puts "\n" @@ -27,7 +30,7 @@ def services puts "Namesies currently searches:" Namesies.constants.each do |service| - puts " #{service}" unless [:VERSION, :CLI].include? service + puts " #{service}" unless [:VERSION, :CLI, :Reporter].include? service end end end
Rework the way services are searched so except is no longer required.
diff --git a/Auk.podspec b/Auk.podspec index abc1234..def5678 100644 --- a/Auk.podspec +++ b/Auk.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "Auk" - s.version = "5.0.0" + s.version = "6.0.0" s.license = { :type => "MIT" } s.homepage = "https://github.com/evgenyneu/Auk" s.summary = "An image slideshow for iOS written in Swift."
Update to xcode 8 beta 6
diff --git a/ja.rb b/ja.rb index abc1234..def5678 100644 --- a/ja.rb +++ b/ja.rb @@ -0,0 +1,48 @@+#!/usr/bin/env ruby +# encoding: UTF-8 +require 'prawn' +require 'base64' +require 'open-uri' +# Third party gem that will need installing +require 'zip' +require 'fileutils' + +ipa_2_fonts = 'IPAexfont00201.zip' +open(ipa_2_fonts, 'wb') do |file| + open("http://ipafont.ipa.go.jp/ipaexfont/IPAexfont00201.php") do |uri| + file.write(uri.read) + end +end +ipa_mincho = 'ipaexm.ttf' +ipa_gothic = 'ipaexg.ttf' +Zip::File.open(ipa_2_fonts) do |file| + file.each do |entry| + [ipa_mincho, ipa_gothic].each do |name| + if entry.name.match(name) + entry.extract(name) + break # inner loop only + end + end + end +end +Prawn::Document.generate('ja.pdf') do + font_families.update('IPAexFonts' => { + normal: ipa_mincho, + bold: ipa_gothic + }) + font 'IPAexFonts' + formatted_text [ + { + text: Base64.strict_decode64("UnVieemWi+eZuuiAhSA="). + force_encoding('utf-8'), + color: '85200C' + }, + + { + text: Base64.strict_decode64("UnVieemWi+eZuuiAhSA="). + force_encoding('utf-8'), + styles: [:bold] + } + ] +end +FileUtils.rm([ipa_2_fonts, ipa_mincho, ipa_gothic])
Add test file: must be removed later
diff --git a/app.rb b/app.rb index abc1234..def5678 100644 --- a/app.rb +++ b/app.rb @@ -10,7 +10,7 @@ options[:min_length] = 4 opts.on('-m', '--min LENGTH', 'Minimum length of palindrome') do |v| - options[:min_length] = v + options[:min_length] = v.to_i end opts.on('-h', '--help', 'Show this message') do
Convert min_length option to integer
diff --git a/test/orm_ext/mongo_mapper_test.rb b/test/orm_ext/mongo_mapper_test.rb index abc1234..def5678 100644 --- a/test/orm_ext/mongo_mapper_test.rb +++ b/test/orm_ext/mongo_mapper_test.rb @@ -11,6 +11,19 @@ should "be able to find the object in the database" do assert_equal @person, MongoMapperPerson._t_find(@person.id) end + + should "be able to find the associates of an object" do + person_1 = MongoMapperPerson.create(:active_record_account_id => 101) + person_2 = MongoMapperPerson.create(:active_record_account_id => 101) + person_3 = MongoMapperPerson.create(:active_record_account_id => 102) + assert_set_equal [person_1, person_2], MongoMapperPerson._t_find_associates(:active_record_account_id, 101) + end + + should "be able to associate many objects with the given object" do + end + + should "be able to get the ids of the objects associated with the given object" do + end end end
Add another mongo mapper extension test
diff --git a/simple_xlsx_reader.gemspec b/simple_xlsx_reader.gemspec index abc1234..def5678 100644 --- a/simple_xlsx_reader.gemspec +++ b/simple_xlsx_reader.gemspec @@ -16,10 +16,11 @@ gem.add_dependency 'rubyzip' gem.add_development_dependency 'minitest', '>= 5.0' + gem.add_development_dependency 'rake' gem.add_development_dependency 'pry' 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.test_files = gem.files.grep(%r{^test/}) gem.require_paths = ["lib"] end
Add rake as dev dependency for travis-ci
diff --git a/font-awesome-middleman.gemspec b/font-awesome-middleman.gemspec index abc1234..def5678 100644 --- a/font-awesome-middleman.gemspec +++ b/font-awesome-middleman.gemspec @@ -17,7 +17,7 @@ gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) gem.require_paths = ["lib"] - gem.add_runtime_dependency(%q<middleman>, ["~> 3.0.0"]) + gem.add_runtime_dependency(%q<middleman>, [">= 3.0.0"]) gem.add_development_dependency(%q<bundler>, ["~> 1.1"]) gem.add_development_dependency(%q<rspec>, ["~> 2.6.0"])
Adjust middleman dependency to >= 3.0.0
diff --git a/lib/time_records.rb b/lib/time_records.rb index abc1234..def5678 100644 --- a/lib/time_records.rb +++ b/lib/time_records.rb @@ -7,23 +7,11 @@ end def grouped_by_task - uniques = map(&:task_id).uniq - - uniques.map do |task_id| - same = select { |record| record.task_id == task_id } - - self.class.new(same) - end + group_by(&:task_id).map { |_, v| TimeRecords.new(v) } end def grouped_by_started_at - uniques = map { |time_record| time_record.started_at.to_date }.uniq - - uniques.map do |started_at| - same = select { |record| record.started_at.to_date == started_at } - - self.class.new(same) - end + group_by { |record| record.started_at.to_date }.map { |_, v| TimeRecords.new(v) } end def grouped_by_dates_between(start_date, end_date)
Refactor and shorten grouping time records code
diff --git a/lib/dimples/renderable.rb b/lib/dimples/renderable.rb index abc1234..def5678 100644 --- a/lib/dimples/renderable.rb +++ b/lib/dimples/renderable.rb @@ -2,7 +2,7 @@ module Renderable def render(context = {}, body = nil) context[:site] ||= @site - context.merge!(type => Hashie::Mash.new(@metadata)) + context[type] = Hashie::Mash.new(@metadata) output = engine.render(scope, context) { body }
Set the context item direct instead of merging it
diff --git a/app/workers/folder_import.rb b/app/workers/folder_import.rb index abc1234..def5678 100644 --- a/app/workers/folder_import.rb +++ b/app/workers/folder_import.rb @@ -0,0 +1,82 @@+module FolderImport + DATE_FORMAT = '%y%m%d' + ALBUM_FOLDER_PATTERN = /^(?<date>\d{6})(?<title>.+)$/ + ALLOWED_EXTS = ImageUploader::EXTENSION_WHITE_LIST.dup + ALLOWED_EXTS.push(*ALLOWED_EXTS.map(&:upcase)) + + def self.perform(glob) + Dir[glob].each do |album_folder| + parent_text = File.join(album_folder, 'parent.txt') + + if File.exists?(parent_text) + parent_slug = File.read(parent_text).strip + + if parent_album = Album.find_by_slug(parent_slug) + puts "Scanning path #{album_folder}" + + if parent_album.childless? + puts "Importing into already existing album #{parent_album}" + ImportAlbum.perform_async(album_folder, parent_album.id) + else + match = ALBUM_FOLDER_PATTERN.match(File.basename(album_folder)) + title = match[:title].strip + date = Date.strptime(match[:date], DATE_FORMAT) + album = parent_album.children.find_or_create_by(title: title, event_date: date) + puts "Created album with title: #{title} & event_date: #{date} within #{parent_album}." + ImportAlbum.perform_async(album_folder, album.id) + end + else + puts "Album with slug: #{parent_slug} does not exist." + end + else + puts "#{parent_text} does not exist." + end + end + end + + class ImportAlbum + include BaseWorker + + def perform(album_folder, album_id) + Dir[build_glob_pattern(album_folder)].each do |file| + ImportImage.perform_async(file, album_id) + end + + Dir["#{album_folder}/*"].each do |source_folder| + unless File.file?(source_folder) + source_name = File.basename(source_folder).gsub(/\s\d+$/, '') + + puts "Scanning source #{source_name}." + source = Source.find_or_create_by(name: source_name) + + Dir[build_glob_pattern(source_folder)].each do |file| + ImportImage.perform_async(file, album_id, source.id) + end + end + end + end + + def build_glob_pattern(source_folder) + "#{source_folder}/*.{#{FolderImport::ALLOWED_EXTS.join(',')}}" + end + end + + class ImportImage + include BaseWorker + + def perform(image_path, album_id, source_id = nil) + puts "Adding #{image_path}" + image = Image.new( + album_id: album_id, + image: File.open(image_path) + ) + + if source_id + source = Source.find(source_id) + image.sources << source + end + + image.save + end + end +end
Add rough folder importer worker.
diff --git a/benchmark-perf.gemspec b/benchmark-perf.gemspec index abc1234..def5678 100644 --- a/benchmark-perf.gemspec +++ b/benchmark-perf.gemspec @@ -6,7 +6,7 @@ spec.name = "benchmark-perf" spec.version = Benchmark::Perf::VERSION spec.authors = ["Piotr Murach"] - spec.email = [""] + spec.email = ["me@piotrmurach.com"] spec.summary = %q{Execution time and iteration performance benchmarking} spec.description = %q{Execution time and iteration performance benchmarking} spec.homepage = "" @@ -21,7 +21,7 @@ spec.required_ruby_version = '>= 2.0.0' - spec.add_development_dependency 'bundler', '~> 1.16' + spec.add_development_dependency 'bundler', '>= 1.16' spec.add_development_dependency 'rspec', '~> 3.0' - spec.add_development_dependency 'rake', '~> 10.0' + spec.add_development_dependency 'rake' end
Change to relax dev dependencies
diff --git a/lib/rsscache/feed/item.rb b/lib/rsscache/feed/item.rb index abc1234..def5678 100644 --- a/lib/rsscache/feed/item.rb +++ b/lib/rsscache/feed/item.rb @@ -67,14 +67,14 @@ item.description ? item.description.strip : '' end + alias_method :summary, :description + ## # Returns the Item's comments link. def comments item.comments ? item.comments.strip : '' end - - alias_method :summary, :description end end end
Move the summary alias back alongside description
diff --git a/lib/snapme/cli/command.rb b/lib/snapme/cli/command.rb index abc1234..def5678 100644 --- a/lib/snapme/cli/command.rb +++ b/lib/snapme/cli/command.rb @@ -2,9 +2,18 @@ module CLI class Command def self.start(args) - options = Options.parse(args) - Process.daemon(true) if options.daemon - Snapper.new(options.host, options.interval).run + options = Options.parse(args) + auth_token = ENV['SNAPME_AUTH_TOKEN'] + + if auth_token + Process.daemon(true) if options.daemon + Snapper.new(options.host, options.interval, auth_token).run + else + puts <<-MSG + Please set SNAPME_AUTH_TOKEN in your environment. You can get your + auth token from http://snapme.herokuapp.com + MSG + end end end end
Print message and quit if auth_token isn't set in environment
diff --git a/lib/usesthis/interview.rb b/lib/usesthis/interview.rb index abc1234..def5678 100644 --- a/lib/usesthis/interview.rb +++ b/lib/usesthis/interview.rb @@ -1,4 +1,9 @@ module UsesThis class Interview < Salt::Post + + def output_path(parent_path) + File.join(parent_path, 'interviews', @slug) + end + end end
Set our custom output path.
diff --git a/test/bmff/box/test_degradation_priority.rb b/test/bmff/box/test_degradation_priority.rb index abc1234..def5678 100644 --- a/test/bmff/box/test_degradation_priority.rb +++ b/test/bmff/box/test_degradation_priority.rb @@ -0,0 +1,62 @@+# coding: utf-8 +# vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent: + +require_relative '../../minitest_helper' +require 'bmff/box' +require 'stringio' + +class TestBMFFBoxDegradationPriority < MiniTest::Unit::TestCase + class DummyBox + attr_accessor :box + def find(type) + @box + end + end + + def get_sample_size(count = 1) + io = StringIO.new("", "r+:ascii-8bit") + io.extend(BMFF::BinaryAccessor) + io.write_uint32(0) + io.write_ascii("stsz") + io.write_uint8(0) # version + io.write_uint24(0) # flags + io.write_uint32(0) # sample_size + io.write_uint32(count) # sample_count + count.times do |i| + io.write_uint32(i) # entry_size + end + size = io.pos + io.pos = 0 + io.write_uint32(size) + io.pos = 0 + + box = BMFF::Box.get_box(io, nil) + dummy = DummyBox.new + dummy.box = box + dummy + end + + def test_parse + io = StringIO.new("", "r+:ascii-8bit") + io.extend(BMFF::BinaryAccessor) + io.write_uint32(0) + io.write_ascii("stdp") + io.write_uint8(0) # version + io.write_uint24(0) # flags + io.write_uint16(1) # priority + io.write_uint16(2) # priority + io.write_uint16(3) # priority + size = io.pos + io.pos = 0 + io.write_uint32(size) + io.pos = 0 + + box = BMFF::Box.get_box(io, get_sample_size(3)) + assert_instance_of(BMFF::Box::DegradationPriority, box) + assert_equal(size, box.actual_size) + assert_equal("stdp", box.type) + assert_equal(0, box.version) + assert_equal(0, box.flags) + assert_equal([1, 2, 3], box.priority) + end +end
Add a test file for BMFF::Box::DegradationPriority.
diff --git a/test/controllers/oembed_controller_test.rb b/test/controllers/oembed_controller_test.rb index abc1234..def5678 100644 --- a/test/controllers/oembed_controller_test.rb +++ b/test/controllers/oembed_controller_test.rb @@ -12,7 +12,7 @@ assert_equal DC.server_root, json_body['provider_url'] end - def test_unsupport_format + def test_unsupported_format get :oembed, :format => "lol" assert_response 501 end
Fix name of oEmbed format test name
diff --git a/app/admin/user.rb b/app/admin/user.rb index abc1234..def5678 100644 --- a/app/admin/user.rb +++ b/app/admin/user.rb @@ -11,7 +11,7 @@ # permitted << :other if params[:action] == 'create' && current_user.admin? # permitted # end - permit_params :email, :name, :avatar + permit_params :email, :name, :avatar, :password index do selectable_column @@ -31,6 +31,7 @@ f.input :email, required: true f.input :name, required: true f.input :avatar, required: true, as: :file + f.input :password end f.actions end
Add password to admin panel.
diff --git a/Gem.gemspec b/Gem.gemspec index abc1234..def5678 100644 --- a/Gem.gemspec +++ b/Gem.gemspec @@ -2,7 +2,7 @@ Gem::Specification.new do |spec| spec.homepage = "https://github.com/envygeeks/luna-rspec-formatters" - spec.summary = "A couple of RSpec formatters the way I like them." + spec.summary = "EnvyGeeks RSpec formatters dedicated to Luna." spec.files = Dir["lib/**/*.rb"] + %W(License Readme.md Gemfile) spec.description = "A couple of RSpec formatters." spec.version = Luna::Rspec::Formatters::VERSION
Update description, because it's true!
diff --git a/app/models/url.rb b/app/models/url.rb index abc1234..def5678 100644 --- a/app/models/url.rb +++ b/app/models/url.rb @@ -10,4 +10,16 @@ has_one :baseline default_scope order(:name) + + def to_param + [id, slugify(name)].join('-') + end + + private + + # @param [String] string to slugify + # @return [String] slugified version of str + def slugify(str) + str.gsub(/['’]/, '').parameterize + end end
Use slugs for URL links This feature makes the app feel a bit more polished. Change-Id: I913ee6523e31b22d9ceb1f83c9cea19a22873104
diff --git a/db/seeds.rb b/db/seeds.rb index abc1234..def5678 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,8 +1,8 @@ # Messages m1 = Message.create(body: 'help fire', phone_number: '+15558675309') -m2 = Message.create(body: 'omg i need a doc', phone_number: '+18005551234') -m3 = Message.create(body: 'send help', phone_number: '+15558886240', status: 'replied_to') -m4 = Message.create(body: 'heart attack', phone_number: '+15553605309') -m5 = Message.create(body: 'velociraptors are attacking!', phone_number: '+18007335309') +m2 = Message.create(body: 'omg i need a doc', phone_number: '+15558675309') +m3 = Message.create(body: 'send help', phone_number: '+15558675309', status: 'replied_to') +m4 = Message.create(body: 'heart attack', phone_number: '+15558675309') +m5 = Message.create(body: 'velociraptors are attacking!', phone_number: '+15558675309') r1 = Reply.create(body: 'stay calm', message_id: 3)
Modify phone numbers in seed data
diff --git a/db/seeds.rb b/db/seeds.rb index abc1234..def5678 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -10,8 +10,20 @@ require 'csv' +puts "Loading crops..." CSV.foreach(Rails.root.join('db', 'seeds', 'crops.csv')) do |row| system_name,scientific_name,en_wikipedia_url = row @crop = Crop.create(:system_name => system_name, :en_wikipedia_url => en_wikipedia_url) @crop.scientific_names.create(:scientific_name => scientific_name) end +puts "Finished loading crops" + +puts "Loading test users..." +if Rails.env.development? or Rails.env.test? + (1..3).each do |i| + @user = User.create(:username => "test#{i}", :email => "test#{i}@example.com", :password => "password#{i}") + @user.confirm! + @user.save! + end +end +puts "Finished loading test users"
Create some test users in dev and test environments. They're called test1, test2, test3 and have passwords password1 etc. Run `rake db:seed` or `rake db:setup` to get them.
diff --git a/db/seeds.rb b/db/seeds.rb index abc1234..def5678 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -3,7 +3,12 @@ User.create(name: TubularFaker.name, password: '123') end -Question.create(title: TubularFaker.company, content: TubularFaker.lingo, user: User.find(User.pluck(:id).sample)) +10.times do + question = Question.create(title: TubularFaker.company, content: TubularFaker.lingo, user: User.find(User.pluck(:id).sample)) -Answer.create(content: TubularFaker.city, user: User.find(User.pluck(:id).sample)) + 3.times do + Answer.create(content: TubularFaker.city, user: User.find(User.pluck(:id).sample), question: question) + end +end +
Create 10 questions with 3 answers each
diff --git a/db/seeds.rb b/db/seeds.rb index abc1234..def5678 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -14,6 +14,7 @@ {name: 'htg', level: 200}, {name: 'order', level: 300}, {name: 'family', level: 400}, + {name: 'subfamily', level: 450}, {name: 'genus', level: 500}, {name: 'species', level: 600}, {name: 'population', level: 650},
Add subfamily level for SocialTraits
diff --git a/cheffish.gemspec b/cheffish.gemspec index abc1234..def5678 100644 --- a/cheffish.gemspec +++ b/cheffish.gemspec @@ -6,10 +6,10 @@ s.version = Cheffish::VERSION s.platform = Gem::Platform::RUBY s.license = "Apache-2.0" - s.summary = "A library to manipulate Chef in Chef." + s.summary = "A set of Chef resources for configuring Chef." s.description = s.summary - s.author = "John Keiser" - s.email = "jkeiser@chef.io" + s.author = "Chef Software Inc." + s.email = "oss@chef.io" s.homepage = "https://github.com/chef/cheffish" s.required_ruby_version = ">= 2.4.0"
Set the author of the gem to Chef Software This mirrors many of our other projects. Signed-off-by: Tim Smith <764ef62106582a09ed09dfa0b6bff7c05fd7d1e4@chef.io>
diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index abc1234..def5678 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -7,9 +7,10 @@ def update if current_user.update_attributes(user_params) - redirect_to account_path + redirect_to account_path, notice: 'Email updated' else - render action: :show, error: "Couldn't update email" + flash.now[:error] = "Couldn't update your email address" + render action: :show end end
Add flash messaging to accounts controller
diff --git a/app/controllers/pictures_controller.rb b/app/controllers/pictures_controller.rb index abc1234..def5678 100644 --- a/app/controllers/pictures_controller.rb +++ b/app/controllers/pictures_controller.rb @@ -17,7 +17,7 @@ def destroy @picture.destroy - redirect_to pictures_url, notice: 'Picture was successfully destroyed.' + redirect_to root_path, notice: 'Picture was successfully destroyed.' end private
Change redirect path on Picture Destroy
diff --git a/app/controllers/students_controller.rb b/app/controllers/students_controller.rb index abc1234..def5678 100644 --- a/app/controllers/students_controller.rb +++ b/app/controllers/students_controller.rb @@ -8,9 +8,26 @@ end def show + respond_to do |format| + format.html {} + format.json { render json: hash_for_show_json(@student) } + end end private + + def hash_for_progress(lesson_part) + return {} unless lesson_part + + { lesson: lesson_part.lesson.ordinal, part: lesson_part.ordinal } + end + + def hash_for_show_json(student) + last_lesson_part = student.lesson_parts&.last + progress = hash_for_progress(last_lesson_part) + + { student: @student, progress: progress } + end def set_student @student = Student.find(params[:id])
Support a JSON representation of a student
diff --git a/spec/str_sanitizer_spec.rb b/spec/str_sanitizer_spec.rb index abc1234..def5678 100644 --- a/spec/str_sanitizer_spec.rb +++ b/spec/str_sanitizer_spec.rb @@ -11,6 +11,10 @@ it "has a method named 'single_quote'" do expect(StrSanitizer.respond_to? :single_quote).to eq true + end + + it "has a method named 'both_quotes'" do + expect(StrSanitizer.respond_to? :both_quotes).to eq true end it "returns a sanitized string with escaped double-quote" do
Add test for Main class to see if the class is accessable
diff --git a/bali-phy.rb b/bali-phy.rb index abc1234..def5678 100644 --- a/bali-phy.rb +++ b/bali-phy.rb @@ -7,9 +7,13 @@ depends_on 'gsl' -# fails_with_clang -# io.H:25:31: error: use of undeclared identifier 'push_back' -# void operator()(const T& t){push_back(t);} + fails_with :clang do + build 318 + cause <<-EOS.undent + io.H:25:31: error: use of undeclared identifier 'push_back' + void operator()(const T& t){push_back(t);} + EOS + end def install mkdir 'macbuild' do
Use new fails_with DSL syntax Signed-off-by: Jack Nagel <43386ce32af96f5c56f2a88e458cb94cebee3751@gmail.com>
diff --git a/script/publishing-api-sync-checks/working_group_check.rb b/script/publishing-api-sync-checks/working_group_check.rb index abc1234..def5678 100644 --- a/script/publishing-api-sync-checks/working_group_check.rb +++ b/script/publishing-api-sync-checks/working_group_check.rb @@ -0,0 +1,16 @@+# Working Groups are called PolicyGroup in the code as they have been partially +# renamed +take_part_pages = PolicyGroup.all +check = DataHygiene::PublishingApiSyncCheck.new(take_part_pages) + +check.add_expectation("format") do |content_store_payload, _| + content_store_payload["format"] == "working_group" +end +check.add_expectation("base_path") do |content_store_payload, record| + content_store_payload["base_path"] == record.search_link +end +check.add_expectation("title") do |content_store_payload, record| + content_store_payload["title"] == record.name +end + +check.perform
Add a publishing-api-sync-check for Working Groups
diff --git a/app/models/pageflow/positioned_file.rb b/app/models/pageflow/positioned_file.rb index abc1234..def5678 100644 --- a/app/models/pageflow/positioned_file.rb +++ b/app/models/pageflow/positioned_file.rb @@ -34,7 +34,7 @@ end def thumbnail_url(*args) - ImageFile.new.attachment.url(*args) + ImageFile.new.thumbnail_url(*args) end def blank?
Align thumbnail_url in PositionedFile with ImageFile
diff --git a/awsecrets.gemspec b/awsecrets.gemspec index abc1234..def5678 100644 --- a/awsecrets.gemspec +++ b/awsecrets.gemspec @@ -20,7 +20,7 @@ spec.add_runtime_dependency 'aws-sdk', '>= 2', '< 4' spec.add_runtime_dependency 'aws_config', '~> 0.1.0' - spec.add_development_dependency 'bundler', '~> 1.9' + spec.add_development_dependency 'bundler', '>= 1.9', '< 3.0' spec.add_development_dependency 'rake', '~> 10.0' spec.add_development_dependency 'rspec' spec.add_development_dependency 'rubocop'
Allow bundler version < 3.0.
diff --git a/ext/attribute_builder/extconf.rb b/ext/attribute_builder/extconf.rb index abc1234..def5678 100644 --- a/ext/attribute_builder/extconf.rb +++ b/ext/attribute_builder/extconf.rb @@ -2,7 +2,7 @@ require 'mkmf' $CFLAGS << ' -Wall -W' -$CXXFLAGS << ' -Wall -W -std=c++03' +$CXXFLAGS << ' -Wall -W -std=c++98' houdini_dir = File.expand_path('../../vendor/houdini', __dir__) $INCFLAGS << " -I#{houdini_dir}"
Use -std=c++98 for old compilers
diff --git a/lib/axiom/types/encodable.rb b/lib/axiom/types/encodable.rb index abc1234..def5678 100644 --- a/lib/axiom/types/encodable.rb +++ b/lib/axiom/types/encodable.rb @@ -5,68 +5,71 @@ # Add encoding constraints to a type module Encodable - if RUBY_VERSION >= '1.9' + # stub module for ruby 1.8 + end - # Hook called when module is extended - # - # Add #encoding DSL method to descendant and set the default to UTF-8. - # - # @param [Class<Axiom::Types::Type>] descendant - # - # @return [undefined] - # - # @api private - def self.extended(descendant) - super - descendant.accept_options :encoding - descendant.encoding Encoding::UTF_8 + module Encodable + + # Hook called when module is extended + # + # Add #encoding DSL method to descendant and set the default to UTF-8. + # + # @param [Class<Axiom::Types::Type>] descendant + # + # @return [undefined] + # + # @api private + def self.extended(descendant) + super + descendant.accept_options :encoding + descendant.encoding Encoding::UTF_8 + end + + private_class_method :extended + + # Finalize by setting up a primitive constraint + # + # @return [Axiom::Types::Encodable] + # + # @api private + def finalize + return self if frozen? + ascii_compatible? ? has_ascii_compatible_encoding : has_encoding + super + end + + private + + # Test if the encoding is ascii compatible + # + # @return [Boolean] + # + # @api private + def ascii_compatible? + encoding.ascii_compatible? + end + + # Add constraint for the ascii compatible encoding + # + # @return [undefined] + # + # @api private + def has_ascii_compatible_encoding + constraint do |object| + object.encoding.equal?(encoding) || object.to_s.ascii_only? end + end - private_class_method :extended + # Add constraint for the encoding + # + # @return [undefined] + # + # @api private + def has_encoding + constraint { |object| object.encoding.equal?(encoding) } + end - # Finalize by setting up a primitive constraint - # - # @return [Axiom::Types::Encodable] - # - # @api private - def finalize - return self if frozen? - ascii_compatible? ? has_ascii_compatible_encoding : has_encoding - super - end + end if RUBY_VERSION >= '1.9' - private - - # Test if the encoding is ascii compatible - # - # @return [Boolean] - # - # @api private - def ascii_compatible? - encoding.ascii_compatible? - end - - # Add constraint for the ascii compatible encoding - # - # @return [undefined] - # - # @api private - def has_ascii_compatible_encoding - constraint do |object| - object.encoding.equal?(encoding) || object.to_s.ascii_only? - end - end - - # Add constraint for the encoding - # - # @return [undefined] - # - # @api private - def has_encoding - constraint { |object| object.encoding.equal?(encoding) } - end - - end - end # module Encodable end # module Types end # module Axiom
Update Axiom::Types::Encodable to make it easier for YARD to parse
diff --git a/lib/akashi/vpc/instance.rb b/lib/akashi/vpc/instance.rb index abc1234..def5678 100644 --- a/lib/akashi/vpc/instance.rb +++ b/lib/akashi/vpc/instance.rb @@ -7,6 +7,7 @@ @object.internet_gateway = internet_gateway.id puts "Attached an InternetGateway (#{internet_gateway.id}) to a VPC (#{id})." end + alias attach_internet_gateway internet_gateway= class << self def create
Add alias attach_internet_gateway of internet_gateway=
diff --git a/lib/autoinc/incrementor.rb b/lib/autoinc/incrementor.rb index abc1234..def5678 100644 --- a/lib/autoinc/incrementor.rb +++ b/lib/autoinc/incrementor.rb @@ -17,7 +17,7 @@ def key "".tap do |str| - str << "#{model_name.underscore}_#{field_name}" + str << "#{model_name.to_s.underscore}_#{field_name}" str << "_#{scope_key}" unless scope_key.blank? end end
Make sure we have a <String>, not a <ModelName>
diff --git a/lib/bipbip/plugin/nginx.rb b/lib/bipbip/plugin/nginx.rb index abc1234..def5678 100644 --- a/lib/bipbip/plugin/nginx.rb +++ b/lib/bipbip/plugin/nginx.rb @@ -16,11 +16,10 @@ uri = URI.parse(server['url']) response = Net::HTTP.get_response(uri) - connections_requested = 0 - if response.code == "200" - nstats = response.body.split(/\r*\n/) - connections_requested = nstats[2].lstrip.split(/\s+/)[2].to_i - end + raise "Invalid response from server at #{server['url']}" unless response.code == "200" + + nstats = response.body.split(/\r*\n/) + connections_requested = nstats[2].lstrip.split(/\s+/)[2].to_i {:connections_requested => connections_requested} end
Raise error if response is not 200
diff --git a/db/seeds.rb b/db/seeds.rb index abc1234..def5678 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -7,13 +7,13 @@ # Character.create(name: 'Luke', movie: movies.first) User.destroy_all -DefinedWords.destroy_all +DefinedWord.destroy_all -20.times do { - User.create(first_name: Faker::Name.first_name, last_name: Faker::Name.last_name, username: Faker::RickAndMorty.character, gender: ["Male", "Female"].sample, email: Faker::Internet.unique.email, password: "booboo", dob: Faker::Date.birthday(18, 65)) -} +20.times do + User.create(first_name: Faker::Name.first_name, last_name: Faker::Name.last_name, username: Faker::RickAndMorty.character, gender: ["Male", "Female"].sample, email: Faker::Internet.unique.email, password: "booboo", dob: Faker::Date.birthday(18, 65) ) +end -200.times do { - DefinedWords.create(word: Faker::SiliconValley.company, definition: Faker::SiliconValley.quote,user: User.all.sample, origin: Origin.all.sample, example: Faker::RickAndMorty.quote) -} +200.times do + DefinedWord.create(word: Faker::Hipster.word, definition: Faker::Hacker.say_something_smart, user: User.all.sample, origin: Origin.all.sample, example: Faker::RickAndMorty.quote) +end
Remove the 's' from the end of DefinedWords and fix the fakers that were not working.
diff --git a/db/seeds.rb b/db/seeds.rb index abc1234..def5678 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -25,3 +25,7 @@ liked = [true, false].sample Vote.create(story_id: rand(1..20), user_id: rand(1..10), liked: liked) end + +## ADMIN ## + +User.create(username: "mai", password: "password", email: "mai@mai.com")
Create account for me to add admin powers to later
diff --git a/lib/bipbip/plugin/monit.rb b/lib/bipbip/plugin/monit.rb index abc1234..def5678 100644 --- a/lib/bipbip/plugin/monit.rb +++ b/lib/bipbip/plugin/monit.rb @@ -3,6 +3,11 @@ module Bipbip class Plugin::Monit < Plugin + + #See https://bitbucket.org/tildeslash/monit/src/d60968cf7972cc902e5b6e2961d44456e1d9b736/src/monit.h?at=master#cl-135 + # https://bitbucket.org/tildeslash/monit/src/d60968cf7972cc902e5b6e2961d44456e1d9b736/src/monit.h?at=master#cl-146 + STATE_FAILED = '1' + MONITOR_NOT = '0' def metrics_schema [ @@ -25,7 +30,8 @@ begin data['Running'] = status.get ? 1 : 0 - data['All_Services_ok'] = status.services.any? { |service| service.monitor == '0' || service.status == '1' } ? 0 : 1 + data['All_Services_ok'] = status.services.any? { |service| + service.monitor == MONITOR_NOT || service.status == STATE_FAILED } ? 0 : 1 rescue data['Running'] = 0 data['All_Services_ok'] = 0
Introduce constants and reference to src
diff --git a/paper_trail.gemspec b/paper_trail.gemspec index abc1234..def5678 100644 --- a/paper_trail.gemspec +++ b/paper_trail.gemspec @@ -17,6 +17,7 @@ s.add_dependency 'rails', '~> 3' + s.add_development_dependency 'rake' s.add_development_dependency 'shoulda', '2.10.3' s.add_development_dependency 'sqlite3-ruby', '~> 1.2' s.add_development_dependency 'capybara', '>= 0.4.0'
Add development dependency on Rake.
diff --git a/lib/link_thumbnailer/page.rb b/lib/link_thumbnailer/page.rb index abc1234..def5678 100644 --- a/lib/link_thumbnailer/page.rb +++ b/lib/link_thumbnailer/page.rb @@ -18,6 +18,7 @@ def generate @source = processor.call(url) + processor.http.shutdown scraper.call end
Fix bug with closed TCP connection
diff --git a/lib/microspec/expectation.rb b/lib/microspec/expectation.rb index abc1234..def5678 100644 --- a/lib/microspec/expectation.rb +++ b/lib/microspec/expectation.rb @@ -12,8 +12,8 @@ end rescue NoMethodError => exception - if Predicates[method] - if boolean ^ Predicates[method].call(actual, *expected, &block) + if predicate = Predicates[method] + if boolean ^ predicate.call(actual, *expected, &block) raise Flunked.new "failed #{type}", actual: actual, method: method, expected: expected end else
Store predicate proc in a variable
diff --git a/lib/premailer-rails3/hook.rb b/lib/premailer-rails3/hook.rb index abc1234..def5678 100644 --- a/lib/premailer-rails3/hook.rb +++ b/lib/premailer-rails3/hook.rb @@ -11,13 +11,16 @@ # reset the body and add two new bodies with appropriate types message.body = nil + t_charset = message.charset + message.html_part do - content_type "text/html; charset=utf-8" + content_type "text/html; charset=#{t_charset}" body premailer.to_inline_css end plain_text = premailer.to_plain_text if plain_text.blank? message.text_part do + content_type "text/plain; charset=#{t_charset}" body plain_text end end
Fix encoding-issues in Rails 3.1
diff --git a/lib/rack/handler/rack_jax.rb b/lib/rack/handler/rack_jax.rb index abc1234..def5678 100644 --- a/lib/rack/handler/rack_jax.rb +++ b/lib/rack/handler/rack_jax.rb @@ -0,0 +1,18 @@+module Rack + module Handler + + class RackJax + def self.run(app, option={}) + port = options.delete(:Port) || 7070 + end + + def self.valid_options + environment = ENV['RACK_ENV'] || 'development' + + { + "Port=PORT" => "Port to listen on (default: 7070)", + } + end + end + end +end
Add skeleton of a Rack Handler
diff --git a/lib/fluffy_paws/mailers.rb b/lib/fluffy_paws/mailers.rb index abc1234..def5678 100644 --- a/lib/fluffy_paws/mailers.rb +++ b/lib/fluffy_paws/mailers.rb @@ -7,11 +7,12 @@ from = Email.new(email: 'app65106927@heroku.com') subject = "Hi #{params[:user]}, your token for FluffyPaws" to = Email.new(email: params[:recipient]) - content = Content.new(type: 'text/html', - value: "<html><p>Click the link below to login</p> - <a href=\"http://localhost:9292/login/ - #{params[:token]}\">Click Me!</a> - <p>FluffyPaws team</p></html>") + content = Content.new( + type: 'text/html', + value: "<html><p>Click the link below to login</p> + <a href=\"#{ENV.fetch('SERVER_URL')}/login/#{params[:token]}\">Click Me!</a> + <p>FluffyPaws team</p></html>" + ) mail = Mail.new(from, subject, to, content) sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
Change server url to environmental variable
diff --git a/lib/tasks/mongodb_clone.rake b/lib/tasks/mongodb_clone.rake index abc1234..def5678 100644 --- a/lib/tasks/mongodb_clone.rake +++ b/lib/tasks/mongodb_clone.rake @@ -0,0 +1,10 @@+namespace :db do + namespace :copy do + namespace :production do + desc 'Copy production database' + task to_local: ['db:drop'] do + MongodbClone::MongodbReplication.new.dump.restore + end + end + end +end
Create a rake task to copy the production database and restore locally.
diff --git a/lib/tasks/users_reports.rake b/lib/tasks/users_reports.rake index abc1234..def5678 100644 --- a/lib/tasks/users_reports.rake +++ b/lib/tasks/users_reports.rake @@ -7,9 +7,9 @@ CSV.open(Rails.root.join('tmp', "submitted.csv").to_s , "wb") do |submitted_csv| CSV.open(Rails.root.join('tmp', "not_submitted.csv").to_s , "wb") do |not_submitted_csv| User.includes(:form_answers).find_each do |user| - if user.form_answers.for_year(2021).submitted.any? + if user.form_answers.for_year(2022).submitted.any? submitted_csv << [user.email, user.first_name, user.last_name] - elsif user.form_answers.for_year(2021).any? + elsif user.form_answers.for_year(2022).any? not_submitted_csv << [user.email, user.first_name, user.last_name] end end
Update year for user report csv
diff --git a/lib/geocoded_by_address.rb b/lib/geocoded_by_address.rb index abc1234..def5678 100644 --- a/lib/geocoded_by_address.rb +++ b/lib/geocoded_by_address.rb @@ -1,7 +1,7 @@ module GeocodedByAddress - unless Rails.env.test? + if Rails.env.test? def geocoder_by_address nil end
Adjust in GeocodedByAddress module to run more fast in test
diff --git a/chip-gpio.gemspec b/chip-gpio.gemspec index abc1234..def5678 100644 --- a/chip-gpio.gemspec +++ b/chip-gpio.gemspec @@ -1,7 +1,7 @@ Gem::Specification.new do |s| s.name = 'chip-gpio' - s.version = '0.0.1' + s.version = '0.0.2' s.date = '2016-09-10' s.homepage = 'http://github.com/willia4/chip-gpio' s.summary = "A ruby gem to control the GPIO pens on the CHIP computer"
Update gem version after adding direction feature
diff --git a/lib/plugins/popsinseoul.rb b/lib/plugins/popsinseoul.rb index abc1234..def5678 100644 --- a/lib/plugins/popsinseoul.rb +++ b/lib/plugins/popsinseoul.rb @@ -21,7 +21,7 @@ i += 1 end response_string.slice!(-2..-1) - m.reply "[#{date}]#{response_string}" + m.reply "[#{date} 10:30KST]#{response_string}" end def help(m)
Add scheduled time to bot response
diff --git a/lib/spinoza/system/node.rb b/lib/spinoza/system/node.rb index abc1234..def5678 100644 --- a/lib/spinoza/system/node.rb +++ b/lib/spinoza/system/node.rb @@ -28,6 +28,9 @@ end def link dst, **opts + if links[dst] + raise "Link from #{self} to #{dst} already exists." + end links[dst] = Spinoza::Link[timeline: timeline, src: self, dst: dst, **opts] end
Check for conflicting link definition.
diff --git a/config/routes.rb b/config/routes.rb index abc1234..def5678 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -17,11 +17,14 @@ end end - resources :partner_types, expect: :show + resources :partner_types, except: :show resources :partners, except: :show + resources :sponsor_levels, except: :show + resources :sponsors, except: :show + constraints ->(_req) { Apartment::Tenant.current == 'public' } do - resources :sites, expect: :show + resources :sites, except: :show end end end
Add router for sponsor and sponsor level
diff --git a/config/routes.rb b/config/routes.rb index abc1234..def5678 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -6,6 +6,10 @@ root 'application#index' post "/graphql", to: "graphql#execute" + + devise_for :users, controllers: { + registrations: :registrations + } devise_scope :user do get "sign_in", to: "devise/sessions#new"
Add devise route for registrations
diff --git a/config/routes.rb b/config/routes.rb index abc1234..def5678 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,7 +1,7 @@ Rails.application.routes.draw do # Render legal documents by using Keiyaku CSS # https://github.com/cognitom/keiyaku-css - resources :contracts, only: [:index, :show] + resources :contracts, only: [:index, :show], path: '/mou' # Redirects get "/releases/2016/12/12/new-backend", to: redirect('/news/2016/12/12/new-backend')
Change routing from /contracts to /mou
diff --git a/config/routes.rb b/config/routes.rb index abc1234..def5678 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -11,7 +11,7 @@ post 'pusher/auth', to: 'pusher#auth' - get '/active', :to => 'transactions#active', :as => :active + get '/active', :to => 'requests#active', :as => :active get '/river', :to => 'transactions#river', :as => :river get '/history', :to => 'transactions#history', :as => :history
Change active route to a requests controller action
diff --git a/app/helpers/log_helper.rb b/app/helpers/log_helper.rb index abc1234..def5678 100644 --- a/app/helpers/log_helper.rb +++ b/app/helpers/log_helper.rb @@ -2,9 +2,35 @@ # A universal logger # module LogHelper + class DoubtfireLogger < ActiveSupport::Logger + @@logger = DoubtfireLogger.new + + def initialize + # By default, nil is provided + # + # Arguments match: + # 1. logdev - filename or IO object (STDOUT or STDERR) + # 2. shift_age - number of files to keep, or age (e.g., monthly) + # 3. shift_size - maximum log file size (only used when shift_age) + #     is a number + # + # Rails.logger initialises these as nil, so we will do the same + super.new(nil,nil,nil) + end + + # Override fatal and error to puts to the console + # as well as log using Rails + def fatal(msg) + puts msg + super(msg) + end + def error(msg) + puts msg + super(msg) + end + end def logger - # Grape::API.logger - Rails.logger + DoubtfireLogger.logger end # Export functions as module functions
ENHANCE: Update logger module to use new DoubtfireLogger
diff --git a/db/seeds/development/articles.rb b/db/seeds/development/articles.rb index abc1234..def5678 100644 --- a/db/seeds/development/articles.rb +++ b/db/seeds/development/articles.rb @@ -8,6 +8,7 @@ body: "Hi, this is a test!", posted_by: "naoki", category: "tips", + tags: "Test;Tag0", language: "English", ) end @@ -17,5 +18,6 @@ body: "日本語の記事のテストです", posted_by: "test", category: "tips", + tags: "Test;Tag1", language: "Japanese", )
Add missing tags to seed data