diff
stringlengths
65
26.7k
message
stringlengths
7
9.92k
diff --git a/lib/service_objects/update_legacy_email_table.rb b/lib/service_objects/update_legacy_email_table.rb index abc1234..def5678 100644 --- a/lib/service_objects/update_legacy_email_table.rb +++ b/lib/service_objects/update_legacy_email_table.rb @@ -2,11 +2,11 @@ class UpdateLegacyEmailTable < Base DB = Sequel.connect(Settings.ws.db.to_hash) - def self.insert(email) + def insert(change, email) DB[:email].insert(idnumber: change.biola_id, email: email) end - def self.insert_and_update(biola_id, old_email, new_email) + def insert_and_update(biola_id, old_email, new_email) DB[:email].where(idnumber: biola_id, email: old_email).update(primary: 0) DB[:email].insert(idnumber: biola_id, email: new_email) end
Remove self to include the change hash
diff --git a/app/serializers/group_serializer.rb b/app/serializers/group_serializer.rb index abc1234..def5678 100644 --- a/app/serializers/group_serializer.rb +++ b/app/serializers/group_serializer.rb @@ -6,7 +6,7 @@ def student_count return object.student_count if object.has_attribute?(:student_count) - return object[:student_count] if object.has_key(:student_count) + return object[:student_count] if object.has_attribute?(:has_key?) && object.has_key?(:student_count) return 0 end end
FIX: Check object has hasKey? in group serializer
diff --git a/lib/secret_mail/controller.rb b/lib/secret_mail/controller.rb index abc1234..def5678 100644 --- a/lib/secret_mail/controller.rb +++ b/lib/secret_mail/controller.rb @@ -8,9 +8,11 @@ module SecretMail class Controller def self.process message, &block - record = MailAction.find_valid(message.to, message.from) - if record - Controller.new record, message, &block + message.to.each do |to| + record = MailAction.find_valid(to, message.from[0]) + if record + Controller.new record, message, &block + end end end
Handle to and from correctly
diff --git a/lib/fog/aws/models/rds/log_files.rb b/lib/fog/aws/models/rds/log_files.rb index abc1234..def5678 100644 --- a/lib/fog/aws/models/rds/log_files.rb +++ b/lib/fog/aws/models/rds/log_files.rb @@ -6,21 +6,44 @@ class RDS class LogFiles < Fog::Collection + attribute :filters attribute :rds_id model Fog::AWS::RDS::LogFile - def all - data = service.describe_db_log_files(rds_id).body['DescribeDBLogFilesResult']['DBLogFiles'] - load(data) # data is an array of attribute hashes + def initialize(attributes) + self.filters ||= {} + super + end + + # This method deliberately returns only a single page of results + def all(filters=filters) + self.filters.merge!(filters) + + result = service.describe_db_log_files(rds_id, filters).body['DescribeDBLogFilesResult'] + self.filters[:marker] = result['Marker'] + load(result['DBLogFiles']) + end + + def each(filters=filters) + if block_given? + begin + page = self.all(filters) + # We need to explicitly use the base 'each' method here on the page, otherwise we get infinite recursion + base_each = Fog::Collection.instance_method(:each) + base_each.bind(page).call { |log_file| yield log_file } + end while self.filters[:marker] + end + self end def get(file_name=nil) - data = service.describe_db_log_files(rds_id, {:filename_contains => file_name}).body['DescribeDBLogFilesResult']['DBLogFiles'].first - new(data) # data is an attribute hash + if file_name + matches = self.select {|log_file| log_file.name.upcase == file_name.upcase} + return matches.first unless matches.empty? + end rescue Fog::AWS::RDS::NotFound - nil end - + nil end end end
Add 'each' that iterates over all log files Use 'select' to do an exact match when seeking a specific log file.
diff --git a/lib/govuk_security_audit/scanner.rb b/lib/govuk_security_audit/scanner.rb index abc1234..def5678 100644 --- a/lib/govuk_security_audit/scanner.rb +++ b/lib/govuk_security_audit/scanner.rb @@ -12,6 +12,10 @@ @root = File.dirname(path) @database = Bundler::Audit::Database.new + + # Stop Bundler trying to find a Gemfile to accompany our Lockfiles + ENV["BUNDLE_GEMFILE"] = "Dummy" + @lockfile = Bundler::LockfileParser.new(File.read(path)) end end
Allow Scanner to work outside a Bundler environment When a LockfileParser is initialised, Bundler will try to find the related Gemfile in the current directory’s hierarchy. If the tool is run from a directory that doesn't have a Gemfile in its hierarchy, Bundler will raise an exception and make the tool fail. As we don’t need to do anything with the Gemfile in this tool, we tell Bundler the location of a (dummy) Gemfile explicitly so it doesn’t go looking.
diff --git a/lib/saxlsx/column_name_generator.rb b/lib/saxlsx/column_name_generator.rb index abc1234..def5678 100644 --- a/lib/saxlsx/column_name_generator.rb +++ b/lib/saxlsx/column_name_generator.rb @@ -8,9 +8,9 @@ if char.nil? FIRST elsif char < LAST - previous[0..-2] + (char.ord + 1).chr + previous[0..-2] + char.next else - "#{next_to(previous[0..-2])}A" + next_to(previous[0..-2]) + FIRST end end end
Simplify column name generator more
diff --git a/omnibus-ansible-dk/config/software/serverspec.rb b/omnibus-ansible-dk/config/software/serverspec.rb index abc1234..def5678 100644 --- a/omnibus-ansible-dk/config/software/serverspec.rb +++ b/omnibus-ansible-dk/config/software/serverspec.rb @@ -2,7 +2,7 @@ default_version "master" relative_path "serverspec" -source git: "git@github.com:mizzy/serverspec.git" +source git: "git://github.com/mizzy/serverspec.git" if windows? dependency "ruby-windows"
Fix another bad git URL
diff --git a/lib/trailblazer/rails/controller.rb b/lib/trailblazer/rails/controller.rb index abc1234..def5678 100644 --- a/lib/trailblazer/rails/controller.rb +++ b/lib/trailblazer/rails/controller.rb @@ -34,7 +34,7 @@ module Render def render(cell=nil, options={}, *, &block) - return super unless defined?(::Cell) && cell.kind_of?(::Cell::ViewModel) + return super unless cell.kind_of?(::Cell::ViewModel) render_cell(cell, options) end
Revert "Check whether Cell is defined before trying to render" This reverts commit d70a98a4fde47936d618433a66175c158c2898dd.
diff --git a/lib/catarse_stripe/engine.rb b/lib/catarse_stripe/engine.rb index abc1234..def5678 100644 --- a/lib/catarse_stripe/engine.rb +++ b/lib/catarse_stripe/engine.rb @@ -5,15 +5,15 @@ #end module ActionDispatch::Routing class Mapper - def mount_catarse_stripe_at(mount_location) - scope mount_location do - get 'payment/stripe/:id/review' => 'payment/stripe#review', :as => 'review_stripe' - post 'payment/stripe/notifications' => 'payment/stripe#ipn', :as => 'ipn_stripe' - match 'payment/stripe/:id/notifications' => 'payment/stripe#notifications', :as => 'notifications_stripe' - match 'payment/stripe/:id/pay' => 'payment/stripe#pay', :as => 'pay_stripe' - match 'payment/stripe/:id/success' => 'payment/stripe#success', :as => 'success_stripe' - match 'payment/stripe/:id/cancel' => 'paymentstripe#cancel', :as => 'cancel_stripe' - match 'payment/stripe/:id/charge' => 'paymentstripe#charge', :as => 'charge_stripe' + def mount_catarse_stripe_at(payment) + scope payment do + get '/stripe/:id/review' => 'stripe#review', :as => 'review_stripe' + post '/stripe/notifications' => 'stripe#ipn', :as => 'ipn_stripe' + match '/stripe/:id/notifications' => 'stripe#notifications', :as => 'notifications_stripe' + match '/stripe/:id/pay' => 'stripe#pay', :as => 'pay_stripe' + match '/stripe/:id/success' => 'stripe#success', :as => 'success_stripe' + match '/stripe/:id/cancel' => 'stripe#cancel', :as => 'cancel_stripe' + match '/stripe/:id/charge' => 'stripe#charge', :as => 'charge_stripe' end end end
Change route to share application
diff --git a/spec/integration/aws_internet_gateway_spec.rb b/spec/integration/aws_internet_gateway_spec.rb index abc1234..def5678 100644 --- a/spec/integration/aws_internet_gateway_spec.rb +++ b/spec/integration/aws_internet_gateway_spec.rb @@ -0,0 +1,46 @@+require 'spec_helper' + +describe Chef::Resource::AwsInternetGateway do + extend AWSSupport + + when_the_chef_12_server "exists", organization: 'foo', server_scope: :context do + with_aws "with a VPC and an internet gateway" do + vpc = nil + internet_gateway = nil + + before { + vpc = driver.ec2.vpcs.create('10.0.0.0/24') + } + + it "aws_internet_gateway 'test_internet_gateway' with no parameters" do + expect_recipe { + aws_internet_gateway 'test_internet_gateway' + }.to create_an_aws_internet_gateway('test_internet_gateway').and be_idempotent + end + + it "aws_internet_gateway 'test_internet_gateway' with attached vpc" do + expect_recipe { + aws_internet_gateway 'test_internet_gateway' do + vpc vpc.id + end + }.to create_an_aws_internet_gateway('test_internet_gateway').and be_idempotent + filters = [ + {:name => 'attachment.vpc-id', :values => [vpc.id]} + ] + desc_internet_gws = driver.ec2.client.describe_internet_gateways(:filters => filters)[:internet_gateway_set] + internet_gateway = driver.ec2.internet_gateways[desc_internet_gws.first[:internet_gateway_id]] + expect(desc_internet_gws).not_to be_empty + end + + after { + if internet_gateway && internet_gateway.exists? && !internet_gateway.vpc.nil? + internet_gateway.detach(vpc.id) + end + + if vpc && vpc.exists? + vpc.delete + end + } + end + end +end
Add integration tests for the aws_internet_gateway provider.
diff --git a/app/validators/date_validator.rb b/app/validators/date_validator.rb index abc1234..def5678 100644 --- a/app/validators/date_validator.rb +++ b/app/validators/date_validator.rb @@ -4,7 +4,7 @@ if parts.any?(&:present?) parsed = Date.civil *parts.map(&:to_i) rescue nil - record.errors.add attribute, I18n.t('errors.messages.invalid') unless parsed + record.errors.add(attribute) unless parsed end end end
Remove static translation path and just let active model errors do its own thing - keeps the lookup process the same as any other error
diff --git a/app/workers/csv_export_worker.rb b/app/workers/csv_export_worker.rb index abc1234..def5678 100644 --- a/app/workers/csv_export_worker.rb +++ b/app/workers/csv_export_worker.rb @@ -5,7 +5,7 @@ csv_export = CsvExport.find(csv_export_id) return if csv_export.sent? csv_export.export! - CsvExportMailer.csv_download(csv_export).deliver + CsvExportMailer.csv_download(csv_export).deliver_now csv_export.mark_sent! end -end+end
Fix rails 4.2+ deprecated warnings for MessageDelivery.deliver() Rails 4.2+ deprecated ActionMailer::MessageDelivery.deliver() in favor of a split interface deliver_now() and deliver_later(). The old deliver() was plumbed through to deliver_now(). Let's just use that directly. empirical-core currently uses rails (4.2.5.1) per Gemfile.lock. This fixes the following warnings in Travis-CI: DEPRECATION WARNING: `#deliver` is deprecated and will be removed in Rails 5. Use `#deliver_now` to deliver immediately or `#deliver_later` to deliver through Active Job. (called from perform at /home/usera/Coding/empirical-core/app/workers/csv_export_worker.rb:8) See: http://apidock.com/rails/v4.2.1/ActionMailer/MessageDelivery/deliver http://guides.rubyonrails.org/4_2_release_notes.html
diff --git a/test/service_test_case.rb b/test/service_test_case.rb index abc1234..def5678 100644 --- a/test/service_test_case.rb +++ b/test/service_test_case.rb @@ -1,11 +1,11 @@ require 'test_helper' -require 'capybara/poltergeist' +# require 'capybara/poltergeist' require 'minitest/metadata' -require 'helpers/capybara' -require 'helpers/drivers' -require 'helpers/dsl' +# require 'helpers/capybara' +# require 'helpers/drivers' +# require 'helpers/dsl' require 'helpers/email' require 'helpers/files' require 'helpers/cap_api_import' @@ -15,9 +15,9 @@ include ActiveJob::TestHelper include ActionMailer::TestHelper - include H2o::Test::Helpers::Capybara - include H2o::Test::Helpers::Drivers - include H2o::Test::Helpers::DSL + # include H2o::Test::Helpers::Capybara + # include H2o::Test::Helpers::Drivers + # include H2o::Test::Helpers::DSL include H2o::Test::Helpers::Email include H2o::Test::Helpers::Files include H2o::Test::Helpers::CapApiImport
Remove unneeded packages from ServiceTestCase object.
diff --git a/lib/jiffy/outputters/json.rb b/lib/jiffy/outputters/json.rb index abc1234..def5678 100644 --- a/lib/jiffy/outputters/json.rb +++ b/lib/jiffy/outputters/json.rb @@ -12,8 +12,6 @@ rule :begin_string, :payload => "\"" rule :end_string, :payload => "\"" rule :null, :payload => "null" - rule :nan, :payload => "NaN" - rule :inf, :payload => "Infinity" rule :true, :payload => "true" rule :false, :payload => "false" rule :char
Remove handling of :nan and :inf tokens The parser stopped emitting these tokens a while ago.
diff --git a/lib/tasks/announcements.rake b/lib/tasks/announcements.rake index abc1234..def5678 100644 --- a/lib/tasks/announcements.rake +++ b/lib/tasks/announcements.rake @@ -4,9 +4,10 @@ desc 'Announce blocking feature' task blocking: :environment do message = <<-TXT.squish - A partir de ahora, puedes bloquear a otros usuarios y ya no te podrán - volver a contactar, ni ver tus regalos, comentarios o cualquier actividad - tuya en Nolotiro. Serás invisible para ellos! + Ahora puedes castigar la falta de seriedad, los plantones o cualquier otro + comportamiento que no te guste de otros usuarios de Nolotiro. Visita el + perfil del usuario al que quieres bloquear y haz click en el enlace de + "bloquear" que aparece. A partir de entonces eres invisible para él! TXT Announcement.create!(message: message,
Clarify usage of blockings in the announcement People don't seem to have understand the feature. We'll destroy the current announcement and create another one with more explanations.
diff --git a/spec/services/external_users/create_user_spec.rb b/spec/services/external_users/create_user_spec.rb index abc1234..def5678 100644 --- a/spec/services/external_users/create_user_spec.rb +++ b/spec/services/external_users/create_user_spec.rb @@ -0,0 +1,42 @@+require 'rails_helper' + +RSpec.describe ExternalUsers::CreateUser do + let(:user) { create(:user) } + + subject(:service) { described_class.new(user) } + + describe '#call!' do + it 'creates a provider with new unique LGFS and firm AGFS supplier numbers' do + expect { service.call! } + .to change { Provider.where(provider_type: 'firm').count }.by(1) + + new_provider = Provider.order('created_at').last + expect(new_provider.lgfs_supplier_numbers.size).to eq(1) + expect(new_provider.lgfs_supplier_numbers.first.supplier_number).to match(/^9X\d{3}X$/) + end + + it 'creates an external user related with the provided user and the created provider' do + expect { service.call! } + .to change { ExternalUser.count }.by(1) + + new_provider = Provider.order('created_at').last + new_external_user = ExternalUser.order('created_at').last + expect(new_external_user.user).to eq(user) + expect(new_external_user.provider).to eq(new_provider) + end + + context 'when the provider is not created due to some error' do + before do + expect(Provider) + .to receive(:create!) + .with(any_args) + .and_raise(StandardError, 'BOOM!!!') + end + + it 'does not create an external user related with the provided user' do + expect { service.call! rescue nil } + .not_to change { ExternalUser.count } + end + end + end +end
Add test coverage for create user service
diff --git a/netuitive_rails_agent.gemspec b/netuitive_rails_agent.gemspec index abc1234..def5678 100644 --- a/netuitive_rails_agent.gemspec +++ b/netuitive_rails_agent.gemspec @@ -10,7 +10,7 @@ s.files = files s.homepage = 'http://rubygems.org/gems/netuitive_rails_agent' - s.license = 'Apache v2.0' + s.license = 'Apache-2.0' s.add_runtime_dependency 'netuitive_ruby_api', '>= 1.0.1' s.add_development_dependency 'netuitived', '>= 1.0.1' end
Update Gemspec to use a valid license
diff --git a/spec/functional/fc082_spec.rb b/spec/functional/fc082_spec.rb index abc1234..def5678 100644 --- a/spec/functional/fc082_spec.rb +++ b/spec/functional/fc082_spec.rb @@ -15,4 +15,9 @@ recipe_file "node.normal['foo']['bar'] = baz" it { is_expected.to_not violate_rule } end + + context "with a cookbook with a recipe that reads a value using node.set" do + recipe_file "foo = node.set['foo']" + it { is_expected.to violate_rule } + end end
Expand the test for the read scenario Signed-off-by: Tim Smith <764ef62106582a09ed09dfa0b6bff7c05fd7d1e4@chef.io>
diff --git a/lib/tasks/import/covid19_mhclg.rake b/lib/tasks/import/covid19_mhclg.rake index abc1234..def5678 100644 --- a/lib/tasks/import/covid19_mhclg.rake +++ b/lib/tasks/import/covid19_mhclg.rake @@ -0,0 +1,64 @@+require "csv" + +# rubocop:disable Metrics/BlockLength +namespace :import do + desc "Imports COVID-19 shielding links from MHCLG's Google Sheet" + task covid19_mhclg: :environment do + SERVICE_MAPPINGS = { + "Single Vulnerable People URL" => { lgsl: 1287, lgil: 8 }, + # "volunteering" => { lgsl: 1113, lgil: 8 }, + }.freeze + + DOC_ID = "10U5nHFusxMPAh93aleuPYpE-l8ZOJGOjClQemoeIx5A".freeze + SHEET_ID = "543314380".freeze + CSV_URL = URI.parse("https://docs.google.com/spreadsheets/d/#{DOC_ID}/export?gid=#{SHEET_ID}&format=csv&id=#{DOC_ID}") + + response = Net::HTTP.get_response(CSV_URL) + unless response.code_type == Net::HTTPOK + raise "Error downloading CSV in #{self.class}" + end + + csv = CSV.parse(response.body, headers: true) + + # Sanity check + raise "Missing 'GSS' column" if csv["GSS"].compact.empty? + + SERVICE_MAPPINGS.keys.each do |k| + raise "Missing '#{csv[k]}' column" if csv[k].compact.empty? + end + + SERVICE_MAPPINGS.each do |type, codes| + service_interaction = ServiceInteraction.find_or_create_by( + service: Service.find_by!(lgsl_code: codes[:lgsl]), + interaction: Interaction.find_by!(lgil_code: codes[:lgil]), + ) + + csv.each do |row| + url = row[type]&.strip + next if url.blank? + + begin + URI.parse(url) + rescue URI::InvalidURIError + puts "Invalid URL '#{url}' for area #{row['GSS']}, skipping" + next + end + + local_authority = LocalAuthority.find_by(gss: row["GSS"]) + unless local_authority + puts "Could not find local authority GSS=#{row['GSS']}" + next + end + + link = Link.find_or_initialize_by( + local_authority: local_authority, + service_interaction: service_interaction, + ) + link.url = url + link.save! + end + puts "Done" + end + end +end +# rubocop:enable Metrics/BlockLength
Add script to import COVID urls from MHCLG MHCLG have been collecting local URLs for supporting vulnerable people from local council websites in a [Google Sheet][]. This script imports them into Local Links Manager for LGSL 1287 and LGIL 8, based on the rationale in [this PR][624]. The script fetches the CSV directly from Google Docs, which means that the document first needs to be made publicly downloadable by anyone with the link. First it performs a sanity check to ensure the sheet is in the correct format. It next finds any existing `Link`s for each `LocalAuthority` for the `ServiceInteraction`, overwriting the URL if a `Link` already exists, or creating it if it doesn't. [Google Sheet]: https://docs.google.com/spreadsheets/d/10U5nHFusxMPAh93aleuPYpE-l8ZOJGOjClQemoeIx5A/edit?ts=5eaadb03#gid=2060364237 [624]: https://github.com/alphagov/local-links-manager/pull/624
diff --git a/lib/tasks/migrate/migrate_iids.rake b/lib/tasks/migrate/migrate_iids.rake index abc1234..def5678 100644 --- a/lib/tasks/migrate/migrate_iids.rake +++ b/lib/tasks/migrate/migrate_iids.rake @@ -0,0 +1,31 @@+desc "GITLAB | Build internal ids for issues and merge requests" +task migrate_iids: :environment do + puts 'Issues'.yellow + Issue.where(iid: nil).find_each(batch_size: 100) do |issue| + begin + issue.set_iid + if issue.save + print '.' + else + print 'F' + end + rescue + print 'F' + end + end + + puts 'done' + puts 'Merge Requests'.yellow + MergeRequest.where(iid: nil).find_each(batch_size: 100) do |mr| + begin + mr.set_iid + if mr.save + print '.' + else + print 'F' + end + rescue => ex + print 'F' + end + end +end
Create task to create iid for existing issues/mr
diff --git a/lib/convection/model/template/resource/aws_sqs_queue_policy.rb b/lib/convection/model/template/resource/aws_sqs_queue_policy.rb index abc1234..def5678 100644 --- a/lib/convection/model/template/resource/aws_sqs_queue_policy.rb +++ b/lib/convection/model/template/resource/aws_sqs_queue_policy.rb @@ -12,7 +12,7 @@ extend Forwardable type 'AWS::SQS::QueuePolicy' - property :queues, 'Queues' + property :queue, 'Queues', :type => :list attr_reader :document def_delegators :@document, :allow, :id, :version, :statement
Use aggregation approach for building queue list.
diff --git a/boxen.gemspec b/boxen.gemspec index abc1234..def5678 100644 --- a/boxen.gemspec +++ b/boxen.gemspec @@ -21,6 +21,6 @@ gem.add_dependency "octokit", "~> 1.15" gem.add_dependency "puppet", "~> 3.0" - gem.add_development_dependency "minitest", "3.5.0" # pinned for mocha - gem.add_development_dependency "mocha", "~> 0.12" + gem.add_development_dependency "minitest", "4.4.0" # pinned for mocha + gem.add_development_dependency "mocha", "~> 0.13" end
Update minitest and mocha dependencies
diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/%name%.gemspec b/railties/lib/rails/generators/rails/plugin_new/templates/%name%.gemspec index abc1234..def5678 100644 --- a/railties/lib/rails/generators/rails/plugin_new/templates/%name%.gemspec +++ b/railties/lib/rails/generators/rails/plugin_new/templates/%name%.gemspec @@ -18,14 +18,10 @@ s.test_files = Dir["test/**/*"] <% end -%> - # If your gem is dependent on a specific version (or higher) of Rails: - <%= '# ' if options.dev? || options.edge? -%>s.add_dependency "rails", ">= <%= Rails::VERSION::STRING %>" + <%= '# ' if options.dev? || options.edge? -%>s.add_dependency "rails", "~> <%= Rails::VERSION::STRING %>" +<% if full? && !options[:skip_javascript] -%> + # s.add_dependency "<%= "#{options[:javascript]}-rails" %>" +<% end -%> -<% unless options[:skip_javascript] || !full? -%> - # If your gem contains any <%= "#{options[:javascript]}-specific" %> javascript: - # s.add_dependency "<%= "#{options[:javascript]}-rails" %>" - -<% end -%> - # Declare development-specific dependencies: s.add_development_dependency "<%= gem_for_database %>" end
Tidy up a bit plugin new gemspec
diff --git a/script/marriage-abroad-responses-leading-to-outcome-for-country.rb b/script/marriage-abroad-responses-leading-to-outcome-for-country.rb index abc1234..def5678 100644 --- a/script/marriage-abroad-responses-leading-to-outcome-for-country.rb +++ b/script/marriage-abroad-responses-leading-to-outcome-for-country.rb @@ -0,0 +1,21 @@+country_name = ARGV.shift +outcome_name = ARGV.shift + +filename = 'marriage-abroad-responses-and-expected-results.yml' +filepath = Rails.root.join('test', 'data', filename) + +yaml = File.read(filepath) +responses_and_expected_results = YAML.load(yaml) + +data_for_outcome_and_country = responses_and_expected_results.select do |hash| + hash[:next_node] == outcome_name.to_sym && + hash[:responses].first == country_name +end + +response_sets = data_for_outcome_and_country.map do |hash| + hash[:responses] +end + +response_sets.each do |responses| + puts responses.join(', ') +end
Add script to list responses for country and outcome This displays the responses for the specified country that lead to the specified outcome. It's going to help me when extracting the marriage-abroad services from the templates.
diff --git a/spec/features/user_studies_spec.rb b/spec/features/user_studies_spec.rb index abc1234..def5678 100644 --- a/spec/features/user_studies_spec.rb +++ b/spec/features/user_studies_spec.rb @@ -0,0 +1,42 @@+require "rails_helper" +require "support/user_account_feature_helper" + +RSpec.describe "User studies page" do + let(:user) { FactoryGirl.create(:user) } + let(:other_user) { FactoryGirl.create(:user) } + let(:admin_user) { FactoryGirl.create(:admin_user) } + let!(:user_studies) do + FactoryGirl.create_list(:study, 20, principal_investigator: user) + end + let!(:other_user_studies) do + FactoryGirl.create_list(:study, 20, principal_investigator: other_user) + end + + it "lists the user's studies" do + sign_in_account(user.email) + visit user_studies_path(user) + user_studies.last(10).each do |study| + expect(page).to have_link(study.title, href: study_path(study)) + end + end + + it "returns a forbidden page when you try to access another user's page" do + sign_in_account(user.email) + visit user_studies_path(other_user) + expect(page).to have_text "You are not allowed to access the page" + end + + it "lets an admin access any user's page" do + sign_in_account(admin_user.email) + + visit user_studies_path(user) + user_studies.last(10).each do |study| + expect(page).to have_link(study.title, href: study_path(study)) + end + + visit user_studies_path(other_user) + other_user_studies.last(10).each do |study| + expect(page).to have_link(study.title, href: study_path(study)) + end + end +end
Add feature specs for user studies page
diff --git a/test/unit/services/panopticon_registerer_test.rb b/test/unit/services/panopticon_registerer_test.rb index abc1234..def5678 100644 --- a/test/unit/services/panopticon_registerer_test.rb +++ b/test/unit/services/panopticon_registerer_test.rb @@ -12,6 +12,27 @@ assert_requested(request, times: 2) end + def test_sending_correct_data_to_panopticon + stub_request(:put, "http://panopticon.dev.gov.uk/artefacts/a-smart-answer.json"). + with(body: { + slug: "a-smart-answer", + owning_app: "smartanswers", + kind: "smart-answer", + name: "The Smart Answer.", + description: nil, + state: nil, + }) + + registerable = OpenStruct.new( + slug: 'a-smart-answer', + title: 'The Smart Answer.', + ) + + silence_logging do + PanopticonRegisterer.new([registerable]).register + end + end + private # The registerer is quite noisy.
Add test for data sent to panopticon We'd like to test exactly what is being sent to panopticon. This test verifies the JSON payload sent to the API.
diff --git a/lib/facter/mac_encryption_enabled.rb b/lib/facter/mac_encryption_enabled.rb index abc1234..def5678 100644 --- a/lib/facter/mac_encryption_enabled.rb +++ b/lib/facter/mac_encryption_enabled.rb @@ -6,7 +6,7 @@ confine :kernel => "Darwin" setcode do osver = Facter.value('macosx_productversion_major') - if osver == "10.8" or osver =="10.9" + if osver == "10.8" or osver =="10.9" or osver == "10.10" output = Facter::Util::Resolution.exec("/usr/bin/fdesetup status") enabled = output.split("\n").first if enabled=="FileVault is On."
Support for an unreleased OS
diff --git a/lib/noir/command/new/makefile/tex.rb b/lib/noir/command/new/makefile/tex.rb index abc1234..def5678 100644 --- a/lib/noir/command/new/makefile/tex.rb +++ b/lib/noir/command/new/makefile/tex.rb @@ -19,7 +19,7 @@ .PHONY : clean all open remake clean: - rm -f *.dvi *.aux *.log *.pdf *.ps *.gz *.bbl *.blg *.toc *~ *.core + rm -f *.dvi *.aux *.log *.pdf *.ps *.gz *.bbl *.blg *.toc *~ *.core *.cpt all: $(TARGET).pdf
Add *.cpt to clean up targets for TeX Makefile
diff --git a/sumo_seed.gemspec b/sumo_seed.gemspec index abc1234..def5678 100644 --- a/sumo_seed.gemspec +++ b/sumo_seed.gemspec @@ -26,4 +26,5 @@ s.add_development_dependency "rspec", "~> 3.3.0" s.add_development_dependency "database_cleaner" s.add_development_dependency "carrierwave" + s.add_development_dependency "pg" end
Add missing pg dependency for travis
diff --git a/lib/travis/logs/sidekiq/log_parts.rb b/lib/travis/logs/sidekiq/log_parts.rb index abc1234..def5678 100644 --- a/lib/travis/logs/sidekiq/log_parts.rb +++ b/lib/travis/logs/sidekiq/log_parts.rb @@ -12,6 +12,7 @@ sidekiq_options queue: 'log_parts', retry: 3 def perform(payload) + Travis.logger.debug('running with payload') log_part_processor.run(payload) end
Add more logging around receiver -> logs handoff
diff --git a/lib/hn_history/app.rb b/lib/hn_history/app.rb index abc1234..def5678 100644 --- a/lib/hn_history/app.rb +++ b/lib/hn_history/app.rb @@ -1,20 +1,25 @@ require 'hn_history' -require 'hn_history/api' -require 'hn_history/web' + +require 'grape' +require 'sinatra' if ENV['RACK_ENV'] == "production" require 'oboe' require 'oboe/inst/rack' Oboe::Config[:tracing_mode] = 'through' + Oboe::Config[:sample_rate] = 1000000 + Oboe::Config[:verbose] = true +end - Oboe::Ruby.initialize -end +require 'hn_history/api' +require 'hn_history/web' def app Rack::Builder.app do if ENV['RACK_ENV'] == "production" - use Oboe::Rack + # Force the Grape API to use Oboe + HnHistory::BaseAPI.use ::Oboe::Rack end use Rack::Session::Cookie
Rearrange to get Grape support working
diff --git a/json_key_transformer_middleware.gemspec b/json_key_transformer_middleware.gemspec index abc1234..def5678 100644 --- a/json_key_transformer_middleware.gemspec +++ b/json_key_transformer_middleware.gemspec @@ -15,5 +15,5 @@ gem.add_runtime_dependency('oj', '2.14.2') gem.add_runtime_dependency('oj_mimic_json', '1.0.1') - gem.add_runtime_dependency('rails', '5.0.0.beta1') + gem.add_runtime_dependency('rails', '>= 5.0.0.beta1') end
Change Rails dependency to be '>= 5.0.0.beta1'
diff --git a/lib/nutrella/cache.rb b/lib/nutrella/cache.rb index abc1234..def5678 100644 --- a/lib/nutrella/cache.rb +++ b/lib/nutrella/cache.rb @@ -39,7 +39,7 @@ end def cache_contents - @cached_cache_contents ||= YAML.load_file(path) + @cache_contents ||= YAML.load_file(path) end end end
Use idiomatic naming of memoization.
diff --git a/lib/tfa/storage.rb b/lib/tfa/storage.rb index abc1234..def5678 100644 --- a/lib/tfa/storage.rb +++ b/lib/tfa/storage.rb @@ -2,8 +2,8 @@ class Storage include Enumerable - def initialize(filename:) - @storage = PStore.new(File.join(Dir.home, ".#{filename}.pstore")) + def initialize(options) + @storage = PStore.new(File.join(Dir.home, ".#{options[:filename]}.pstore")) end def each
Read the filename property being passed in
diff --git a/lib/twingly/url.rb b/lib/twingly/url.rb index abc1234..def5678 100644 --- a/lib/twingly/url.rb +++ b/lib/twingly/url.rb @@ -2,14 +2,14 @@ require 'public_suffix' PublicSuffix::List.private_domains = false - -SCHEMES = %w(http https) module Twingly module URL module_function UrlObject = Struct.new(:url, :domain) do + SCHEMES = %w(http https) + def valid? url && domain && SCHEMES.include?(url.normalized_scheme) end
Move SCHEMES from the global namespace into UrlObject
diff --git a/lib/schnitzel/text.rb b/lib/schnitzel/text.rb index abc1234..def5678 100644 --- a/lib/schnitzel/text.rb +++ b/lib/schnitzel/text.rb @@ -2,11 +2,11 @@ class Text < Node attr_accessor :color, :text - def initialize(text: "", color: 0xffffffff, size: 20, **args) + def initialize(text: "", font: Gosu::default_font_name, color: 0xffffffff, size: 20, **args) super(args) @text = text @color = color - @font = Gosu::Font.new($window, Gosu::default_font_name, size) + @font = Gosu::Font.new($window, font, size) end def draw
Set the font in Text.new
diff --git a/honey_format.gemspec b/honey_format.gemspec index abc1234..def5678 100644 --- a/honey_format.gemspec +++ b/honey_format.gemspec @@ -23,4 +23,5 @@ spec.add_development_dependency 'benchmark-ips' spec.add_development_dependency 'rspec' spec.add_development_dependency 'simplecov' + spec.add_development_dependency 'byebug' end
Add byebug to development dependenies for debugging
diff --git a/lib/active_admin/gallery/engine.rb b/lib/active_admin/gallery/engine.rb index abc1234..def5678 100644 --- a/lib/active_admin/gallery/engine.rb +++ b/lib/active_admin/gallery/engine.rb @@ -4,7 +4,7 @@ class Engine < ::Rails::Engine engine_name "activeadmin_gallery" - initializer "Railsyard precompile hook", group: :assets do |app| + initializer "Railsyard precompile hook", group: :all do |app| app.config.assets.precompile += [ "active_admin/gallery/sortable.js", "active_admin/gallery.css",
Fix assets precompile with config.assets.initialize_on_precompile = true
diff --git a/lib/api.rb b/lib/api.rb index abc1234..def5678 100644 --- a/lib/api.rb +++ b/lib/api.rb @@ -7,6 +7,10 @@ configure do enable :cross_origin +end + +configure :development do + set :show_exceptions, :after_handler end configure :production do @@ -35,14 +39,14 @@ end get '/' do - jsonp(details: 'http://fixer.io', version: App.version) + jsonp details: 'http://fixer.io', version: App.version end get '/latest' do jsonp snapshot end -get %r((?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})) do +get(/(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})/) do process_date jsonp snapshot end
Use error helper in development
diff --git a/lib/conductor/conductor_invalid.rb b/lib/conductor/conductor_invalid.rb index abc1234..def5678 100644 --- a/lib/conductor/conductor_invalid.rb +++ b/lib/conductor/conductor_invalid.rb @@ -1,5 +1,5 @@ module Conductor - class ConductorInvalid < Exception + class ConductorInvalid < StandardError attr_accessor :conductor def initialize(conductor)
Make Conductor::ConductorInvalid subclass StandardError rather than Exception
diff --git a/lib/configurethis/configuration.rb b/lib/configurethis/configuration.rb index abc1234..def5678 100644 --- a/lib/configurethis/configuration.rb +++ b/lib/configurethis/configuration.rb @@ -10,7 +10,7 @@ def root=(key) @values = load_configuration.fetch(key) - rescue KeyError + rescue ::KeyError raise "'#{key}' is not configured in #{path}" end @@ -19,7 +19,7 @@ val = @values.fetch(key) return ValueContainer.new(val, path) if val.is_a?(Hash) val - rescue KeyError + rescue ::KeyError raise "'#{key}' is not configured in #{path}" end
Resolve unitialized constant error in Ruby 1.8.7
diff --git a/plugins/system/conntrack-metrics.rb b/plugins/system/conntrack-metrics.rb index abc1234..def5678 100644 --- a/plugins/system/conntrack-metrics.rb +++ b/plugins/system/conntrack-metrics.rb @@ -39,7 +39,7 @@ default: 'conntrack' def run - value = `conntrack -C #{config[:table]}`.strip + value = `conntrack -C #{config[:table]} 2>/dev/null`.strip timestamp = Time.now.to_i output config[:scheme], value, timestamp
Exclude errors in the conntrack shell output This keeps warning messages from being sent to graphite in addition to the metric values.
diff --git a/modules/auxiliary/scanner/http/wordpress/wp_mashshare_info_disclosure.rb b/modules/auxiliary/scanner/http/wordpress/wp_mashshare_info_disclosure.rb index abc1234..def5678 100644 --- a/modules/auxiliary/scanner/http/wordpress/wp_mashshare_info_disclosure.rb +++ b/modules/auxiliary/scanner/http/wordpress/wp_mashshare_info_disclosure.rb @@ -0,0 +1,65 @@+## +# This module requires Metasploit: http://metasploit.com/download +# Current source: https://github.com/rapid7/metasploit-framework +## + +require 'msf/core' + +class Metasploit4 < Msf::Auxiliary + + include Msf::HTTP::Wordpress + include Msf::Auxiliary::Scanner + include Msf::Auxiliary::Report + + def initialize(info = {}) + super(update_info(info, + 'Name' => 'WordPress Mashshare Plugin Info Disclosure', + 'Description' => %q{ + This module attempts to exploit a information disclosure in Mashshare for Wordpress, + version 2.3.0 and likely prior in order if the instance is vulnerable. + }, + 'Author' => + [ + 'James Hooker', # Vulnerability Discovery + 'Roberto Soares Espreto <robertoespreto[at]gmail.com>' # Metasploit Module + ], + 'License' => MSF_LICENSE, + 'References' => + [ + ['OSVDB', '120988'], + ['WPVDB', '7936'], + ['URL', 'https://research.g0blin.co.uk/g0blin-00045/'] + ], + 'DisclosureDate' => 'Apr 25 2015' + )) + end + + def check + check_plugin_version_from_readme('mashsharer', '2.3.1') + end + + def run_host(ip) + + res = send_request_cgi( + 'uri' => normalize_uri(wordpress_url_admin_ajax), + 'vars_get' => { + 'action' => '-', + 'mashsb-action' => 'tools_tab_system_info' + } + ) + + unless res && res.body + print_error("#{peer} - Server did not respond in an expected way") + return + end + + if res.code == 200 && res.body.include?('Site Info') + print_good("#{peer} - Vulnerable to Information Disclosure the \"ViperGB 1.3.10\" plugin for Wordpress") + vprint_good("Information Disclosure: #{res.body}") + p = store_loot('wp_mashshare', 'text/html', ip, res.body, 'tools_tab_system_info') + print_good("Save in: #{p}") + else + print_error("#{peer} - Failed, maybe the target isn't vulnerable.") + end + end +end
Add WordPress Mashshare Plugin Info Disclosure.
diff --git a/lib/map.rb b/lib/map.rb index abc1234..def5678 100644 --- a/lib/map.rb +++ b/lib/map.rb @@ -1,9 +1,13 @@ class Map - def initialize(window, mapfile) - @window = window - @tileset = Gosu::Image.load_tiles(window, 'media/32x32diagonal_lines.png', - 32, 32, false) - end + def initialize(window, mapfile) + @window = window + @tileset = Gosu::Image.load_tiles(window, 'media/32x32diagonal_lines.png', + 32, 32, false) + end + + def get_lines(file) + @lines = File.readlines(file).map { |line| line.chomp } + end end
Create get_lines method, covert tabs to spaces
diff --git a/test/appharbor_test.rb b/test/appharbor_test.rb index abc1234..def5678 100644 --- a/test/appharbor_test.rb +++ b/test/appharbor_test.rb @@ -15,6 +15,9 @@ branches = JSON.parse(env[:body])['branches'] assert_equal 1, branches.size + + branch = branches[payload['ref'].sub(/\Arefs\/heads\//, '')] + assert_not_nil branch end svc = service({"token" => token, "application_slug" => application_slug}, payload)
Verify that payload ref name is in the list of branches
diff --git a/test/wolverine_test.rb b/test/wolverine_test.rb index abc1234..def5678 100644 --- a/test/wolverine_test.rb +++ b/test/wolverine_test.rb @@ -8,10 +8,10 @@ end def test_reset! - dir = Wolverine.root_directory - assert_equal Wolverine.root_directory, dir + dir = Wolverine.send(:root_directory) + assert_equal Wolverine.send(:root_directory), dir Wolverine.reset! - refute_equal Wolverine.root_directory, dir + refute_equal Wolverine.send(:root_directory), dir end def test_instantiate_wolverine_with_config
Fix broken test stemmed from private class method
diff --git a/Casks/intellij-idea-eap.rb b/Casks/intellij-idea-eap.rb index abc1234..def5678 100644 --- a/Casks/intellij-idea-eap.rb +++ b/Casks/intellij-idea-eap.rb @@ -1,6 +1,6 @@ cask :v1 => 'intellij-idea-eap' do - version '141.104.1' - sha256 'a59b096cbf012f42dbaf108026de12fa1a3caf16a0f87cbc5f20aa44fa2f2156' + version '141.588.1' + sha256 '4748d0785eb9e7df24fe43524ee196db69ebde50125eb2d6879702eecc64a604' url "http://download-cf.jetbrains.com/idea/ideaIU-#{version}.dmg" homepage 'https://confluence.jetbrains.com/display/IDEADEV/IDEA+14.1+EAP'
Update IntelliJ IDEA EAP to version 141.588.1
diff --git a/lib/formatters/update_formatter.rb b/lib/formatters/update_formatter.rb index abc1234..def5678 100644 --- a/lib/formatters/update_formatter.rb +++ b/lib/formatters/update_formatter.rb @@ -8,18 +8,22 @@ end def example_passed(notification) - report_status notification.example.location, "passed" + report :name => notification.example.location, :status => "passed" end def example_failed(notification) - report_status notification.example.location, "failed" + report({ + :name => notification.example.location, + :status => "failed", + :backtrace => notification.exception.backtrace, + }) end def example_pending(notification) - report_status notification.example.location, "pending" + report :name => notification.example.location, :status => "pending" end - def report_status(name, status) - @output << "#{JSON.unparse :name => name, :status => status}\n" + def report(data) + @output << "#{JSON.unparse data}\n" end end
Include backtrace when reporting example results
diff --git a/spec/requests/large_request_spec.rb b/spec/requests/large_request_spec.rb index abc1234..def5678 100644 --- a/spec/requests/large_request_spec.rb +++ b/spec/requests/large_request_spec.rb @@ -5,7 +5,7 @@ RSpec.describe 'A very large request', type: :request do it 'should not overflow cookies' do - get '/admin', foo: 'x' * ActionDispatch::Cookies::SignedCookieJar::MAX_COOKIE_SIZE + get '/admin', foo: 'x' * ActionDispatch::Cookies::MAX_COOKIE_SIZE expect(response.status).to eq(302) # HTTP status 302 - Found ## Use the newer syntax if rspec gets upgraded # expect(response).to have_http_status(:redirect)
Fix namespacing in cookies test NameError: uninitialized constant ActionDispatch::Cookies::SignedCookieJar::MAX_COOKIE_SIZE # ./spec/requests/large_request_spec.rb:8
diff --git a/spree_personalised_products.gemspec b/spree_personalised_products.gemspec index abc1234..def5678 100644 --- a/spree_personalised_products.gemspec +++ b/spree_personalised_products.gemspec @@ -18,7 +18,7 @@ s.add_dependency 'spree_core', '~> 1.2.0' - s.add_development_dependency 'capybara' + s.add_development_dependency 'capybara', '~> 1.1' s.add_development_dependency 'factory_girl_rails', '~> 1.7.0' s.add_development_dependency 'ffaker' s.add_development_dependency 'rspec-rails'
Update gemspect to keep capybara on 1.1
diff --git a/lib/kosmos/packages/kw_rocketry.rb b/lib/kosmos/packages/kw_rocketry.rb index abc1234..def5678 100644 --- a/lib/kosmos/packages/kw_rocketry.rb +++ b/lib/kosmos/packages/kw_rocketry.rb @@ -0,0 +1,8 @@+class KWRocketry < Kosmos::Package + title 'KW Rocketry' + url 'http://kerbalspaceport.com/wp/wp-content/themes/kerbal/inc/download.php?f=uploads/2013/12/KW-Release-Package-v2.5.6B.zip' + + def install + merge_directory 'KW Release Package v2.5.6B/GameData' + end +end
Add a package for KW-rocketry.
diff --git a/lib/kracken/token_authenticator.rb b/lib/kracken/token_authenticator.rb index abc1234..def5678 100644 --- a/lib/kracken/token_authenticator.rb +++ b/lib/kracken/token_authenticator.rb @@ -19,11 +19,15 @@ end def body - JSON.parse(response.body) + if response + JSON.parse(response.body) + end end def etag - response.headers["etag"] + if response + response.headers["etag"] + end end private
Add nil check for request before calling methods Demeter: It's the law. This will allow the token auth object to respond with nill if the response was never created or set to nil for some reason.
diff --git a/provider/lib/tasks/rcov.rake b/provider/lib/tasks/rcov.rake index abc1234..def5678 100644 --- a/provider/lib/tasks/rcov.rake +++ b/provider/lib/tasks/rcov.rake @@ -0,0 +1,43 @@+begin + require 'rcov/rcovtask' +rescue LoadError + raise 'Could not find the rcov gem, please run `gem install rcov` to get some metrics' +end + +namespace :test do + + namespace :coverage do + + desc "Delete aggregate coverage data." + task :clean do + rm_f "reports/coverage/coverage.data" + end + + desc "Open code coverage reports in a browser." + task :show => 'test:coverage' do + system("open reports/coverage/functional/index.html") + end + + end + + desc 'Aggregate code coverage for unit, functional and integration tests' + task :coverage => "test:coverage:clean" + + + %w[unit functional].each do |target| + namespace :coverage do + Rcov::RcovTask.new(target) do |t| + t.libs << "test" + t.test_files = FileList["test/#{target}/**/*_test.rb"] + t.output_dir = "reports/coverage/#{target}" + t.verbose = true + t.rcov_opts << '--rails --aggregate reports/coverage/coverage.data' + t.rcov_opts << '--exclude gems --exclude app' + t.rcov_opts << '--exclude "yaml,parser.y,racc,(erb),(eval),(recognize_optimized),erb"' if RUBY_PLATFORM =~ /java/ + t.rcov_opts << '--include-file "vendor/plugins/oauth2_provider/app/.*\.rb" --html' + end + end + task :coverage => ['db:migrate', 'db:test:prepare', "test:coverage:#{target}"] + end + +end
Add a task to generate coverage reports.
diff --git a/Library/Homebrew/test/dev-cmd/bump_spec.rb b/Library/Homebrew/test/dev-cmd/bump_spec.rb index abc1234..def5678 100644 --- a/Library/Homebrew/test/dev-cmd/bump_spec.rb +++ b/Library/Homebrew/test/dev-cmd/bump_spec.rb @@ -8,7 +8,7 @@ it_behaves_like "parseable arguments" end - describe "formula", :integration_test do + describe "formula", :integration_test, :needs_network do it "returns data for single valid specified formula" do install_test_formula "testball"
Mark `brew bump` test with `:needs_network.
diff --git a/lib/processor/observer/null_observer.rb b/lib/processor/observer/null_observer.rb index abc1234..def5678 100644 --- a/lib/processor/observer/null_observer.rb +++ b/lib/processor/observer/null_observer.rb @@ -7,7 +7,7 @@ attr_reader :processor def initialize(options = {}) - @messenger = options.fetch :messenger, Processor::Messenger.new(:info, STDOUT, self.class.name) + @messenger = options.fetch :messenger, Processor::Messenger.new(:info, STDERR, self.class.name) @processor = options.fetch :processor, nil end
Use STDERR as default stream for messenger
diff --git a/lib/active_ldap_fabrication.rb b/lib/active_ldap_fabrication.rb index abc1234..def5678 100644 --- a/lib/active_ldap_fabrication.rb +++ b/lib/active_ldap_fabrication.rb @@ -1,4 +1,4 @@-# Copyright (C) 2011 Kouhei Sutou <kou@clear-code.com> +# Copyright (C) 2011-2013 Kouhei Sutou <kou@clear-code.com> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -14,6 +14,6 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -require 'active_ldap' -require 'active_ldap_fabrication/version' -require 'fabrication/generator/active_ldap' +require "active_ldap" +require "active_ldap_fabrication/version" +require "fabrication/generator/active_ldap"
Use " (double quote) for string literal
diff --git a/lib/front_end_builds/engine.rb b/lib/front_end_builds/engine.rb index abc1234..def5678 100644 --- a/lib/front_end_builds/engine.rb +++ b/lib/front_end_builds/engine.rb @@ -1,5 +1,3 @@-require 'active_model_serializers' - module FrontEndBuilds class Engine < ::Rails::Engine isolate_namespace FrontEndBuilds
Remove require call to ams
diff --git a/lib/ggi/definition_importer.rb b/lib/ggi/definition_importer.rb index abc1234..def5678 100644 --- a/lib/ggi/definition_importer.rb +++ b/lib/ggi/definition_importer.rb @@ -14,7 +14,7 @@ def import return @@definitions if @@definitions - json = File.read(File.join(__dir__, '..', '..', 'public', 'eol_definitions.json')) + json = File.read(File.expand_path("../../public/eol_definitions.json", __dir__)) @@definitions = JSON.parse(json) @@definitions.select! { |uri| Ggi::Uri.all.any? { |ggi_uri| ggi_uri.uri == uri["uri"] } } end
Improve syntax for finding file, fixes spec
diff --git a/Formula/mplayer.rb b/Formula/mplayer.rb index abc1234..def5678 100644 --- a/Formula/mplayer.rb +++ b/Formula/mplayer.rb @@ -5,22 +5,27 @@ head 'svn://svn.mplayerhq.hu/mplayer/trunk' depends_on 'pkg-config' => :recommended + depends_on 'yasm' => :optional # http://github.com/mxcl/homebrew/issues/#issue/87 depends_on :subversion if MACOS_VERSION < 10.6 def install - # LLVM-2206 can't handle some of the assembly - # Using gcc_4_2 doesn't work, failing mysteriously (check this again) + # Do not use pipes, per bug report + # http://github.com/mxcl/homebrew/issues#issue/622 + # and MacPorts + # http://trac.macports.org/browser/trunk/dports/multimedia/mplayer-devel/Portfile + # any kind of optimisation breaks the build + ENV.gcc_4_2 ENV['CC'] = '' ENV['LD'] = '' - # any kind of optimisation breaks the build - ENV['CFLAGS'] = '-w -pipe' + ENV['CFLAGS'] = '' + ENV['CXXFLAGS'] = '' - args = ['./configure', "--prefix=#{prefix}"] + args = ["--prefix=#{prefix}", "--enable-largefiles", "--enable-apple-remote"] args << "--target=x86_64-Darwin" if Hardware.is_64_bit? and MACOS_VERSION >= 10.6 - system *args + system './configure', *args system "make" system "make install" end
Update Mplayer formula to compile on 10.5.
diff --git a/lib/juicy/build_environment.rb b/lib/juicy/build_environment.rb index abc1234..def5678 100644 --- a/lib/juicy/build_environment.rb +++ b/lib/juicy/build_environment.rb @@ -1,10 +1,11 @@ module Juicy + BUILD_SENSITIVE_VARIABLES = %w[RUBYOPT BUNDLE_GEMFILE RACK_ENV MONGOLAB_URI] class BuildEnvironment attr_reader :env def initialize @env = ENV.to_hash.tap do |env| - %w[RUBYOPT BUNDLE_GEMFILE RACK_ENV MONGOLAB_URI].each do |var| + BUILD_SENSITIVE_VARIABLES.each do |var| env[var] = nil end env["BUNDLE_CONFIG"] = "/nonexistent"
Define the variables to be cleaned for testing
diff --git a/lib/rack/tracker/controller.rb b/lib/rack/tracker/controller.rb index abc1234..def5678 100644 --- a/lib/rack/tracker/controller.rb +++ b/lib/rack/tracker/controller.rb @@ -3,7 +3,7 @@ module Controller def tracker(&block) if block_given? - yield(Rack::Tracker::HandlerDelegator.new(env)) + yield(Rack::Tracker::HandlerDelegator.new(respond_to?(:request) ? request.env : env)) end end end
Add support for Rails 5.1 Rails controller `env` was deprecated and removed but we love backwards compatibility and keep the old behaviour
diff --git a/lib/tasks/lint_alert_docs.rake b/lib/tasks/lint_alert_docs.rake index abc1234..def5678 100644 --- a/lib/tasks/lint_alert_docs.rake +++ b/lib/tasks/lint_alert_docs.rake @@ -0,0 +1,27 @@+desc "Check if the monitoring_docs_url's in puppet definitions link to an existing page" +task :lint_alert_docs do + checks = Dir.glob("modules/**/*.pp").map do |filename| + code = File.read(filename) + code.scan(%r[monitoring_docs_url\((.*)\)]).to_a + end.flatten.compact.uniq + + puts "ICINGA ALERTS NOT IN DOCS" + + checks.each do |check| + next if check == "$healthcheck_opsmanual" + unless File.exist?("../docs.publishing.service.gov.uk/source/manual/alerts/#{check}.html.md") + puts "NOT FOUND: #{check}" + end + end + + puts "\n\nDOCS NOT LINKED FROM ICINGA" + + Dir.glob("../docs.publishing.service.gov.uk/source/manual/alerts/*.md").each do |filename| + name = File.basename(filename).sub('.html.md', '') + next if name.end_with?('healthcheck-not-ok') + + unless checks.include?(name) + puts "NOT FOUND: #{name}" + end + end +end
Add rake task to verify that docs & puppet are in sync
diff --git a/lib/tasks/update_printers.rake b/lib/tasks/update_printers.rake index abc1234..def5678 100644 --- a/lib/tasks/update_printers.rake +++ b/lib/tasks/update_printers.rake @@ -1,19 +1,32 @@+require 'csv' require 'net/http' + +def get_all_csv + uri = URI 'http://print.chalmers.se/public/pls.cgi' + res = Net::HTTP.post_form(uri, 'textver' => 'CSV export') + xml = Nokogiri::XML(res.body) + text = xml.css('pre').children.text.strip + CSV.parse(text, { + col_sep: "\t", + header_converters: :symbol, + headers: true, + return_headers: true + }).drop(1) +end + namespace :cthit do desc "Update glorious printers" task update_printers: :environment do - uri = URI('http://print.chalmers.se/public/pls.cgi') - res = Net::HTTP.post_form(uri, 'textver' => 'CSV export') - lines = res.body.split("\n") - lines.drop(12).each do |printer| - values = printer.split("\t") - - next unless values.length == 6 + csv = get_all_csv + Printer.where('name NOT IN (?)', csv.map{ |c| c[:printer].strip }).delete_all - p = Printer.create(name: values[0].strip, location: values[2].strip, media: values[4].strip) - puts p + csv.each do |printer| + pp = Printer.find_or_initialize_by(name: printer[:printer].strip) + pp.update_attributes({ + location: printer[:printer].strip, + media: printer[:size].strip + }) + puts pp end - end - -end+end
Make printer adding script repeatable
diff --git a/lib/twterm/tab/mentions_tab.rb b/lib/twterm/tab/mentions_tab.rb index abc1234..def5678 100644 --- a/lib/twterm/tab/mentions_tab.rb +++ b/lib/twterm/tab/mentions_tab.rb @@ -2,6 +2,18 @@ module Tab class MentionsTab include StatusesTab + + def close + fail NotClosableError + end + + def fetch + @client.mentions do |statuses| + statuses.reverse.each(&method(:prepend)) + sort + yield if block_given? + end + end def initialize(client) fail ArgumentError, 'argument must be an instance of Client class' unless client.is_a? Client @@ -19,18 +31,6 @@ fetch { scroll_manager.move_to_top } @auto_reloader = Scheduler.new(300) { fetch } end - - def fetch - @client.mentions do |statuses| - statuses.reverse.each(&method(:prepend)) - sort - yield if block_given? - end - end - - def close - fail NotClosableError - end end end end
Sort methods of Tab::MentionsTab in alphabetical order
diff --git a/manageiq-appliance-dependencies.rb b/manageiq-appliance-dependencies.rb index abc1234..def5678 100644 --- a/manageiq-appliance-dependencies.rb +++ b/manageiq-appliance-dependencies.rb @@ -1,2 +1,2 @@ # Add gems here, in Gemfile syntax, which are dependencies of the appliance itself rather than a part of the ManageIQ application -gem "manageiq-appliance_console", "~>7.0", :require => false +gem "manageiq-appliance_console", "~>7.0", ">=7.0.2", :require => false
Move minimum to 7.0.2 to bring in the latest manageiq-password
diff --git a/LYCategory.podspec b/LYCategory.podspec index abc1234..def5678 100644 --- a/LYCategory.podspec +++ b/LYCategory.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = 'LYCategory' - s.version = '1.2.8' + s.version = '1.2.9' s.summary = 'The categories.' s.description = <<-DESC
Modify : pod spec version 1.2.9
diff --git a/united-workers.gemspec b/united-workers.gemspec index abc1234..def5678 100644 --- a/united-workers.gemspec +++ b/united-workers.gemspec @@ -21,4 +21,6 @@ spec.add_development_dependency "bundler", "~> 1.5" spec.add_development_dependency "rake" spec.add_development_dependency "rspec" + + spec.add_runtime_dependency "bunny", ">= 1.3.1" end
Add runtime gem dependency on bunny
diff --git a/PageMenuController.podspec b/PageMenuController.podspec index abc1234..def5678 100644 --- a/PageMenuController.podspec +++ b/PageMenuController.podspec @@ -20,5 +20,5 @@ 'PageMenuController' => ['PageMenuController/Resources/**/*.xib'] } - s.dependency 'SnapKit' + s.dependency 'SnapKit', '~> 0.22.0' end
Change dependency to swift 2 version of snapkit
diff --git a/app/controllers/forem/moderation_controller.rb b/app/controllers/forem/moderation_controller.rb index abc1234..def5678 100644 --- a/app/controllers/forem/moderation_controller.rb +++ b/app/controllers/forem/moderation_controller.rb @@ -31,7 +31,7 @@ helper_method :forum def ensure_moderator_or_admin - unless forem_admin_or_moderator?(forum) + if !forem_admin? && !forum.moderator?(forem_user) raise CanCan::AccessDenied end end
Revert accidental breakage of moderator/admin checking in moderation controller
diff --git a/app/controllers/incline/sessions_controller.rb b/app/controllers/incline/sessions_controller.rb index abc1234..def5678 100644 --- a/app/controllers/incline/sessions_controller.rb +++ b/app/controllers/incline/sessions_controller.rb @@ -12,7 +12,9 @@ ## # GET /incline/login def new - + # Before displaying the login form, make sure an external auth system shouldn't be used. + auth_url = ::Incline::UserManager.begin_external_authentication(request) + redirect_to auth_url unless auth_url.blank? end ##
Check for external auth before login.
diff --git a/app/models/neighborly/balanced/verification.rb b/app/models/neighborly/balanced/verification.rb index abc1234..def5678 100644 --- a/app/models/neighborly/balanced/verification.rb +++ b/app/models/neighborly/balanced/verification.rb @@ -0,0 +1,28 @@+module Neighborly::Balanced + class Verification + def self.find(uri) + new(::Balanced::Verification.find(uri)) + end + + def initialize(balanced_verification) + @source = balanced_verification + end + + def bank_account + ::Balanced::BankAccount.find(bank_account_uri) + end + + def bank_account_uri + uri.match(/\A(?<bank_account_uri>.+)\/verifications/)[:bank_account_uri] + end + + # Delegate instance methods to Balanced::Verification object + def method_missing(method, *args, &block) + if @source.respond_to? method + @source.public_send(method, *args, &block) + else + super + end + end + end +end
Create our version of Balanced::Verification with a bank account
diff --git a/section03/lesson03/trouble.rb b/section03/lesson03/trouble.rb index abc1234..def5678 100644 --- a/section03/lesson03/trouble.rb +++ b/section03/lesson03/trouble.rb @@ -0,0 +1,31 @@+# Section 3 - Lesson 3 - New Chords Cm, Fm, Gm, Db, Eb, Ab +# Trouble - Coldplay +require "#{Dir.home}/ruby/pianoforall/section03/lesson03/half_beat_bounce" +use_synth :piano +use_bpm 40 + +in_thread(name: :right_hand) do + half_beat_bounce_treble(:F4, shift: -2) + half_beat_bounce_treble(:D4, :minor, shift: -1) + 2.times do + half_beat_bounce_treble(:A4, :minor, shift: -2) + end + half_beat_bounce_treble(:Eb4, shift: -1) + half_beat_bounce_treble(:G3, :minor) + 2.times do + half_beat_bounce_treble(:F3) + end +end + +in_thread(name: :left_hand) do + half_beat_bounce_bass(:F3, multiple: true) + half_beat_bounce_bass(:D3) + 2.times do + half_beat_bounce_bass(:A2) + end + half_beat_bounce_bass(:Eb3, multiple: true) + half_beat_bounce_bass(:G2) + 2.times do + half_beat_bounce_bass(:F2) + end +end
Add Trouble, and finish lesson 3
diff --git a/spec/helpers/application_helper/buttons/catalog_item_button_spec.rb b/spec/helpers/application_helper/buttons/catalog_item_button_spec.rb index abc1234..def5678 100644 --- a/spec/helpers/application_helper/buttons/catalog_item_button_spec.rb +++ b/spec/helpers/application_helper/buttons/catalog_item_button_spec.rb @@ -0,0 +1,23 @@+require 'spec_helper' + +describe ApplicationHelper::Button::CatalogItemButton do + let (:session) { Hash.new } + before do + @view_context = setup_view_context_with_sandbox({}) + allow(@view_context).to receive(:current_user).and_return(FactoryGirl.create(:user)) + @button = described_class.new(@view_context, {}, {}, {:child_id => "ab_button_new"}) + end + + context "#role_allows_feature?" do + it "will be skipped" do + expect(@button.role_allows_feature?).to be false + end + + it "won't be skipped" do + EvmSpecHelper.seed_specific_product_features("catalogitem_new") + feature = MiqProductFeature.find_all_by_identifier(["everything"]) + allow(@view_context).to receive(:current_user).and_return(FactoryGirl.create(:user, :features => feature)) + expect(@button.role_allows_feature?).to be true + end + end +end
Add Rspec test for the new CatalogItemButton class
diff --git a/app/controllers/spree/api/taxons_controller.rb b/app/controllers/spree/api/taxons_controller.rb index abc1234..def5678 100644 --- a/app/controllers/spree/api/taxons_controller.rb +++ b/app/controllers/spree/api/taxons_controller.rb @@ -0,0 +1,77 @@+module Spree + module Api + class TaxonsController < Spree::Api::BaseController + respond_to :json + + def index + if taxonomy + @taxons = taxonomy.root.children + else + if params[:ids] + @taxons = Taxon.where(:id => params[:ids].split(",")) + else + @taxons = Taxon.ransack(params[:q]).result + end + end + respond_with(@taxons) + end + + def show + @taxon = taxon + respond_with(@taxon) + end + + def jstree + show + end + + def create + authorize! :create, Taxon + @taxon = Taxon.new(params[:taxon]) + @taxon.taxonomy_id = params[:taxonomy_id] + taxonomy = Taxonomy.find_by_id(params[:taxonomy_id]) + + if taxonomy.nil? + @taxon.errors[:taxonomy_id] = I18n.t(:invalid_taxonomy_id, :scope => 'spree.api') + invalid_resource!(@taxon) and return + end + + @taxon.parent_id = taxonomy.root.id unless params[:taxon][:parent_id] + + if @taxon.save + respond_with(@taxon, :status => 201, :default_template => :show) + else + invalid_resource!(@taxon) + end + end + + def update + authorize! :update, Taxon + if taxon.update_attributes(params[:taxon]) + respond_with(taxon, :status => 200, :default_template => :show) + else + invalid_resource!(taxon) + end + end + + def destroy + authorize! :delete, Taxon + taxon.destroy + respond_with(taxon, :status => 204) + end + + private + + def taxonomy + if params[:taxonomy_id].present? + @taxonomy ||= Taxonomy.find(params[:taxonomy_id]) + end + end + + def taxon + @taxon ||= taxonomy.taxons.find(params[:id]) + end + + end + end +end
Bring spree/api/taxons controller from spree_api as it is needed in OFN admin
diff --git a/app/overrides/spree/admin/shared/_main_menu.rb b/app/overrides/spree/admin/shared/_main_menu.rb index abc1234..def5678 100644 --- a/app/overrides/spree/admin/shared/_main_menu.rb +++ b/app/overrides/spree/admin/shared/_main_menu.rb @@ -2,7 +2,7 @@ virtual_path: 'spree/admin/shared/_main_menu', name: 'Display configuration tab for vendors', replace: 'erb[silent]:contains("current_store")', - text: '<% if can?(:admin, current_store) || current_spree_user.vendors.any? %>' + text: '<% if can?(:admin, current_store) || current_spree_user&.vendors&.any? %>' ) Deface::Override.new( virtual_path: 'spree/admin/shared/_main_menu',
Fix main menu deface when current_user doesn't exists Context: When user visit /admin/password/recover the app throws this error `ActionView::Template::Error (undefined method `vendors' for nil:NilClass)`
diff --git a/app/calculators/service_life_calculator.rb b/app/calculators/service_life_calculator.rb index abc1234..def5678 100644 --- a/app/calculators/service_life_calculator.rb +++ b/app/calculators/service_life_calculator.rb @@ -15,10 +15,26 @@ asset.manufacture_year + @policy.get_policy_item(asset).max_service_life_years end + # Calculate the service life based on the minimum of condition, or miles if the + # asset has a maximum number of miles set def by_condition(asset) - # get the predicted last year of service based on the asset rating - # and the policy method - asset.calculate_estimated_replacement_year(@policy) + + # Iterate over all the condition update events from earliest to latest + # and find the first year (if any) that the policy replacement became + # effective + asset.condition_updates.each do |event| + if event.assessed_rating < @policy.condition_threshold + return event.event_date.year + end + if event.current_mileage && policy_item.max_service_life_miles + if event.current_mileage >= policy_item.max_service_life_miles + return event.event_date.year + end + end + end + # if we didn't find a condition event that would make the policy effective + # we can simply return the age constraint + by_age(asset) end end
Fix servcie life calculator to report the first year that the replacement policy became effective for an asset
diff --git a/app/controllers/public_pages_controller.rb b/app/controllers/public_pages_controller.rb index abc1234..def5678 100644 --- a/app/controllers/public_pages_controller.rb +++ b/app/controllers/public_pages_controller.rb @@ -12,6 +12,10 @@ not_found if @profile_user.nil? @profile = @profile_user.profile not_found if @profile.nil? + + @conversation = Conversation.new if user_signed_in? render 'own_profile' if user_signed_in? && current_user == @profile_user end + + private end
Create @conversation if the user is signed in
diff --git a/app/controllers/scm_projects_controller.rb b/app/controllers/scm_projects_controller.rb index abc1234..def5678 100644 --- a/app/controllers/scm_projects_controller.rb +++ b/app/controllers/scm_projects_controller.rb @@ -1,3 +1,4 @@+ class ScmProjectsController < ApplicationController before_filter :check_access @@ -7,7 +8,7 @@ def create @scm_project= ScmProject.new(params[:scm_project]) - + @scm_project.company= current_user.company if @scm_project.save redirect_to scm_project_url(@scm_project) else
Set company for new scm_project.
diff --git a/db/migrate/20180831164909_add_index_for_identifier_to_prometheus_metric.rb b/db/migrate/20180831164909_add_index_for_identifier_to_prometheus_metric.rb index abc1234..def5678 100644 --- a/db/migrate/20180831164909_add_index_for_identifier_to_prometheus_metric.rb +++ b/db/migrate/20180831164909_add_index_for_identifier_to_prometheus_metric.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class AddIdentifierToPrometheusMetric < ActiveRecord::Migration +class AddIndexForIdentifierToPrometheusMetric < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers DOWNTIME = false
Fix add index prometheus metric
diff --git a/db/20091021092157_add_name_class_name_index.rb b/db/20091021092157_add_name_class_name_index.rb index abc1234..def5678 100644 --- a/db/20091021092157_add_name_class_name_index.rb +++ b/db/20091021092157_add_name_class_name_index.rb @@ -0,0 +1,9 @@+class AddNameClassNameIndex < ActiveRecord::Migration + def self.up + add_index :text_assets, [:name, :class_name] + end + + def self.down + remove_index :text_assets, [:name, :class_name] + end +end
Add an index for a frequent query.
diff --git a/lib/claide.rb b/lib/claide.rb index abc1234..def5678 100644 --- a/lib/claide.rb +++ b/lib/claide.rb @@ -11,7 +11,7 @@ VERSION = '0.5.0' require 'claide/ansi' - require 'claide/ansi/string_mixin_disable' + require 'claide/ansi/string_mixin' require 'claide/argv' require 'claide/command' require 'claide/help'
[CLAide] Load by default the enabled string mixin
diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index abc1234..def5678 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -8,8 +8,8 @@ https://github.com/datasets/house-prices-us.git git://github.com/datasets/gdp-uk.git git://github.com/datasets/cofog.git - https://github.com/theodi/github-viewer-test-data.git https://github.com/theodi/hot-drinks.git + https://floppy@bitbucket.org/floppy/hot-drinks.git }.map{|uri| Repository.new(uri: uri)} end
Add a bitbucket sample URL
diff --git a/app/controllers/tok/sessions_controller.rb b/app/controllers/tok/sessions_controller.rb index abc1234..def5678 100644 --- a/app/controllers/tok/sessions_controller.rb +++ b/app/controllers/tok/sessions_controller.rb @@ -5,7 +5,7 @@ @model = model_class.authenticate(model_params) if @model - render json: @model, status: :created + render json: {token: @model.authentication_token}.to_json, status: :created else render json: {"error" => "Invalid email or password!"}.to_json, status: :unprocessable_entity end
Return the authentication token only on login
diff --git a/app/models/cloud_model/services/mongodb.rb b/app/models/cloud_model/services/mongodb.rb index abc1234..def5678 100644 --- a/app/models/cloud_model/services/mongodb.rb +++ b/app/models/cloud_model/services/mongodb.rb @@ -15,7 +15,7 @@ return false unless has_backups timestamp = Time.now.strftime "%Y%m%d%H%M%S" FileUtils.mkdir_p backup_directory - command = "mongodump -h #{guest.private_address} --port #{port} -o #{backup_directory}/#{timestamp}" + command = "LC_ALL=C mongodump -h #{guest.private_address} --port #{port} -o #{backup_directory}/#{timestamp}" Rails.logger.debug command Rails.logger.debug `#{command}` @@ -34,7 +34,7 @@ def restore timestamp='latest' if File.exists? "#{backup_directory}/#{timestamp}" - command = "mongorestore --drop -h #{guest.private_address} --port #{port} #{backup_directory}/#{timestamp}" + command = "LC_ALL=C mongorestore --drop -h #{guest.private_address} --port #{port} #{backup_directory}/#{timestamp}" Rails.logger.debug command Rails.logger.debug `#{command}`
Make mongo service Backup more reliable
diff --git a/app/models/concerns/door/loggable.rb b/app/models/concerns/door/loggable.rb index abc1234..def5678 100644 --- a/app/models/concerns/door/loggable.rb +++ b/app/models/concerns/door/loggable.rb @@ -4,7 +4,7 @@ included do has_one :log_entry, as: :loggable before_create :associate_log_entry - #after_create :spam_irc + after_create :spam_irc end def public_message
Revert "Remove IRC logging of door events" This reverts commit d80d873fb65b6a187f3cafa2c5617f60c135a77e.
diff --git a/db/migrate/20110724135047_add_route_segment_stop_area_indices.rb b/db/migrate/20110724135047_add_route_segment_stop_area_indices.rb index abc1234..def5678 100644 --- a/db/migrate/20110724135047_add_route_segment_stop_area_indices.rb +++ b/db/migrate/20110724135047_add_route_segment_stop_area_indices.rb @@ -0,0 +1,12 @@+class AddRouteSegmentStopAreaIndices < ActiveRecord::Migration + def self.up + add_index :route_segments, [:route_id, :from_stop_area_id], :name => 'index_route_segments_on_from_stop_area_and_route' + add_index :route_segments, [:route_id, :to_stop_area_id], :name => 'index_route_segments_on_to_stop_area_and_route' + + end + + def self.down + remove_index :route_segments, "from_stop_area_and_route" + remove_index :route_segments, "to_stop_area_and_route" + end +end
Add indexes on route and stop_area columns of route_segment - used together in stop finding queries.
diff --git a/spec/mutations/devices/dump_spec.rb b/spec/mutations/devices/dump_spec.rb index abc1234..def5678 100644 --- a/spec/mutations/devices/dump_spec.rb +++ b/spec/mutations/devices/dump_spec.rb @@ -10,6 +10,12 @@ resources = MODEL_NAMES .map { |x| x.to_s.singularize.to_sym } .map { |x| FactoryBot.create_list(x, 4, device: device) } + tools = FactoryBot.create_list(:tool, 3, device: device) + device + .points + .where(pointer_type: "ToolSlot") + .last + .update_attributes(tool_id: tools.last.id) results = Devices::Dump.run!(device: device) MODEL_NAMES .concat(SPECIAL) @@ -18,5 +24,9 @@ expect(results[name]).to be expect(results[name]).to eq(device.send(name).map(&:body_as_json)) end + # Tests for a regression noted on 1 may 18: + tool = results[:tools].find { |x| x[:id] == tools.last.id } + expect(tool).to be + expect(tool[:status]).to eq("active") end end
Fix issue where data_dump `status` where erroneously `inactive`
diff --git a/lib/mamiya.rb b/lib/mamiya.rb index abc1234..def5678 100644 --- a/lib/mamiya.rb +++ b/lib/mamiya.rb @@ -3,9 +3,9 @@ module Mamiya - @chdir_mutex = Thread::Mutex.new + @chdir_monitor = Monitor.new def self.chdir(dir, &block) - @chdir_mutex.synchronize do + @chdir_monitor.synchronize do Dir.chdir(dir, &block) end end
Use Monitor for recursive locking
diff --git a/benchmark/core/string/bench_equal.rb b/benchmark/core/string/bench_equal.rb index abc1234..def5678 100644 --- a/benchmark/core/string/bench_equal.rb +++ b/benchmark/core/string/bench_equal.rb @@ -2,7 +2,7 @@ require 'benchmark/ips' Benchmark.ips do |x| - string_a = "#{'a' * 1_000}" + string_a = "#{'a' * 1_001}" first_char_different = "b#{'a' * 1_000}" last_char_different = "#{'a' * 1_000}b" same = string_a.dup
Make sure the string has the same length The benchmarks tries to expose different comparison times based on starting / ending with a different character so it shouldn't trigger the shortcut we have that checks length first.
diff --git a/app/controllers/mains_controller.rb b/app/controllers/mains_controller.rb index abc1234..def5678 100644 --- a/app/controllers/mains_controller.rb +++ b/app/controllers/mains_controller.rb @@ -10,9 +10,9 @@ @contact = Contact.new @contact.request = request if @contact.deliver - flash.now[:error] = nil + flash.now[:success] = "The email has been sent" else - flash.now[:error] = "Can not send message." + flash.now[:alert] = "Can not send message." redirect_to root_path end end
Refactor email code for production heroku
diff --git a/app/controllers/mains_controller.rb b/app/controllers/mains_controller.rb index abc1234..def5678 100644 --- a/app/controllers/mains_controller.rb +++ b/app/controllers/mains_controller.rb @@ -9,7 +9,7 @@ end def create - from = Email.new(email: params[:contact]["email"]) + from = Email.new(email: params[:contact]["name"] + "<" + params[:contact]["email"] + ">") subject = 'From FineHomeLiving.com' to = Email.new(email: 'brianleedongjun@gmail.com') content = Content.new(type: 'text/plain', value: params[:contact]["message"])
Add name to email header
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 @@ -5,7 +5,7 @@ def index @pages = Page.by_recent - render layout: 'admin' + switch_to_admin_layout end def show @@ -14,12 +14,12 @@ def new @page = Page.new - render layout: 'admin' + switch_to_admin_layout end def edit @page = Page.find(params[:id]) - render layout: 'admin' + switch_to_admin_layout end def create
Put back the switch_to_admin_layout. It was previously misnamed.
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 @@ -9,7 +9,8 @@ end def show - + @user = User.find_by(session[:user_id]) + # @user.question.id end def edit
Fix user controller show route
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 @@ -1,7 +1,19 @@ class UsersController < ApplicationController def gather - puts params.inspect + company = params[:c] + user_agent = request.env["HTTP_USER_AGENT"] + ip = request.remote_ip + browser = /(opera|chrome|safari|firefox|msie|trident)\/[^ ]*/i.match(user_agent).to_s.gsub("/", " ") + os = /(Mac|Windows|Linux|Android|CPU|Blackberry) \w[^;)]*/i.match(user_agent).to_s + + User.create( company: company, + user_agent: user_agent, + ip_address: ip, + browser: browser, + operating_system: os ) + + # render whatever end end
Make controller action to parse user agent
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 @@ -29,8 +29,6 @@ end def watching - # Can't do User.find(params[:id]). Figure out why - @user = Owner.friendly.find(params[:id]) - raise ActiveRecord::RecordNotFound unless @user.user? + @user = User.friendly.find(params[:id]) end end
Make things a little more concise
diff --git a/test/services/gobierto_budget_consultations/csv_exporter_test.rb b/test/services/gobierto_budget_consultations/csv_exporter_test.rb index abc1234..def5678 100644 --- a/test/services/gobierto_budget_consultations/csv_exporter_test.rb +++ b/test/services/gobierto_budget_consultations/csv_exporter_test.rb @@ -16,8 +16,8 @@ csv = @subject.export(consultation) assert_equal csv, <<~CSV id,age,gender,location,question,answer - 692345489,36,male,,Pavimentación de vías públicas,-5 - 692345489,36,male,,Inversión en Instalaciones Deportivas,5 + 692345489,35,male,,Pavimentación de vías públicas,-5 + 692345489,35,male,,Inversión en Instalaciones Deportivas,5 112679343,,,,Pavimentación de vías públicas,5 112679343,,,,Inversión en Instalaciones Deportivas,5 CSV
Revert "It's someone's birthday :cake:" This reverts commit 5f073d55f6f11465c0be5c5f16c18127b10f265a.
diff --git a/lib/custodian/api.rb b/lib/custodian/api.rb index abc1234..def5678 100644 --- a/lib/custodian/api.rb +++ b/lib/custodian/api.rb @@ -21,9 +21,11 @@ "Content-Type" => "application/json" } - body = Custodian::Samplers.compatible.collect do |sampler| + hash = Custodian::Samplers.compatible.collect do |sampler| { description: sampler.description, sample: sampler.sample } - end.to_json + end + + body = JSON.dump hash [status, headers, [body]] end
Use Ruby 1.9.3's built-in JSON module
diff --git a/db/migrate/20211005130501_rename_option_set_name_where_duplicates.rb b/db/migrate/20211005130501_rename_option_set_name_where_duplicates.rb index abc1234..def5678 100644 --- a/db/migrate/20211005130501_rename_option_set_name_where_duplicates.rb +++ b/db/migrate/20211005130501_rename_option_set_name_where_duplicates.rb @@ -13,4 +13,8 @@ add_index(:option_sets, %i[name mission_id], unique: true) end + + def down + remove_index(:option_sets, %i[name mission_id]) + end end
11992: Add down migration to allow redo
diff --git a/potatochop.gemspec b/potatochop.gemspec index abc1234..def5678 100644 --- a/potatochop.gemspec +++ b/potatochop.gemspec @@ -8,13 +8,17 @@ gem.version = Potatochop::VERSION gem.authors = ["John Mertens"] gem.email = ["john@versahq.com"] - gem.description = %q{TODO: Write a gem description} - gem.summary = %q{TODO: Write a gem summary} + gem.description = %q{Potatochop - because F$%k Photoshop, that's why.} + gem.summary = %q{Potatochop is a simple server that compiles and serves up HAML and SASS files. The goal is to reduce friction between designers and devs in a Rails project.} gem.homepage = "" gem.files = `git ls-files`.split($/) gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) } gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) gem.require_paths = ["lib"] - gem.add_development_dependency 'sinatra' + gem.add_runtime_dependency 'sinatra' + gem.add_runtime_dependency 'haml' + gem.add_development_dependency 'rspec' + gem.add_development_dependency 'rake' + gem.add_development_dependency 'simplecov' end
Add a simple summary & description
diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb index abc1234..def5678 100644 --- a/config/initializers/session_store.rb +++ b/config/initializers/session_store.rb @@ -1,10 +1,11 @@ # Be sure to restart your server when you modify this file. - -# The cookie_store can be too small for very long URLs stored by Devise. -# The maximum size of cookies is 4096 bytes. -#Openfoodnetwork::Application.config.session_store :cookie_store, key: '_openfoodnetwork_session' # Use the database for sessions instead of the cookie-based default, # which shouldn't be used to store highly confidential information # (create the session table with "rails generate session_migration") -Openfoodnetwork::Application.config.session_store :active_record_store +Openfoodnetwork::Application.config.session_store( + :active_record_store, + key: "_ofn_session_id", + domain: :all, + tld_length: 2 +)
Migrate session cookies to new setup Currently sessions set on (www.openfoodnetwork.xxx) are not usable on the bare domain (openfoonetwork.xxx). When transitioning from one to the other, the user's session is completely lost. This change means sessions on subdomains (including www) will be transferable.