diff
stringlengths
65
26.7k
message
stringlengths
7
9.92k
diff --git a/app/controllers/test_objects_controller.rb b/app/controllers/test_objects_controller.rb index abc1234..def5678 100644 --- a/app/controllers/test_objects_controller.rb +++ b/app/controllers/test_objects_controller.rb @@ -1,6 +1,14 @@ class TestObjectsController < MyplaceonlineController def may_upload true + end + + def use_bubble? + true + end + + def bubble_text(obj) + Myp.display_date_month_year_simple(obj.test_object_date, User.current_user) end protected @@ -9,7 +17,8 @@ end def sorts - ["lower(test_objects.test_object_name) ASC"] + #["lower(test_objects.test_object_name) ASC"] + ["test_objects.test_object_date DESC NULLS LAST"] end def obj_params
Add common things to test object controller such as bubble text and date sorting
diff --git a/app/controllers/users/locale_controller.rb b/app/controllers/users/locale_controller.rb index abc1234..def5678 100644 --- a/app/controllers/users/locale_controller.rb +++ b/app/controllers/users/locale_controller.rb @@ -11,6 +11,7 @@ if request.method == 'POST' render json: { success: true } else + flash[:notice] = 'Locale preference updated!' redirect_to '/' end end
Add flash notice to confirm locale change
diff --git a/app/controllers/window_rails_controller.rb b/app/controllers/window_rails_controller.rb index abc1234..def5678 100644 --- a/app/controllers/window_rails_controller.rb +++ b/app/controllers/window_rails_controller.rb @@ -26,8 +26,15 @@ redirect_to '/' end format.js do + content = nil + if(params[:window_url].blank?) + content = {:url => params[:iframe_url]} + else + raise 'URL to content is not currently supported' + content = render_to_string(params[:window_url]) + end render :update do |page| - page.open_window({:url => params[:window_url]}, params[:window_options] || {}) + page.open_window(content, params[:window_options] || {}) end end end
Allow providing URL for content or IFrame (for content currently not working)
diff --git a/kde-phonon.rb b/kde-phonon.rb index abc1234..def5678 100644 --- a/kde-phonon.rb +++ b/kde-phonon.rb @@ -2,9 +2,8 @@ class KdePhonon < Formula homepage 'http://phonon.kde.org/' - # yes, phonon-src is only shipped as .tar.xz file. - url 'ftp://ftp.kde.org/pub/kde/stable/phonon/4.6.0/src/phonon-4.6.0.tar.xz' - md5 'bbe0c1c62ed14c31479c4c1a6cf1e173' + url 'http://download.kde.org/stable/phonon/4.6.0/src/phonon-4.6.0.tar.xz' + sha1 'd8dbc188b58c6dd9c6a73d3742a25291e647bb95' depends_on 'xz' => :build depends_on 'cmake' => :build
Use KDE http mirror, add sha1
diff --git a/Nocilla.podspec b/Nocilla.podspec index abc1234..def5678 100644 --- a/Nocilla.podspec +++ b/Nocilla.podspec @@ -20,6 +20,7 @@ 'Nocilla/DSL/LSStubRequestDSL.h', 'Nocilla/DSL/LSStubResponseDSL.h', 'Nocilla/Matchers/*.h', + 'Nocilla/Model/LSHTTPBody.h', 'Nocilla/Categories/NSString+Nocilla.h', 'Nocilla/Categories/NSData+Nocilla.h']
[podspec] Fix build of user’s test target by completing public headers.
diff --git a/Casks/omnioutliner-beta.rb b/Casks/omnioutliner-beta.rb index abc1234..def5678 100644 --- a/Casks/omnioutliner-beta.rb +++ b/Casks/omnioutliner-beta.rb @@ -1,6 +1,6 @@ cask 'omnioutliner-beta' do - version '4.4.x-r251827' - sha256 'c2be9c83f1009b6407aea2b6b35da8210b8545a5acfe7aafe0853082b414d056' + version '4.4.x-r253921' + sha256 '51d80d4e4889eab3b5c5aeeda8880d1814dbe3cb06dfd4b926aa445e9711721b' url "https://omnistaging.omnigroup.com/omnioutliner-4/releases/OmniOutliner-#{version}-Test.dmg" name 'OmniOutliner'
Update OmniOutliner Beta to version 4.4.x-r253921 This commit updates the version and sha256 stanzas.
diff --git a/lib/cartodb_importer/import_mapinfofile.rb b/lib/cartodb_importer/import_mapinfofile.rb index abc1234..def5678 100644 --- a/lib/cartodb_importer/import_mapinfofile.rb +++ b/lib/cartodb_importer/import_mapinfofile.rb @@ -11,7 +11,7 @@ def import_for_org(path, file_name) if REQUIRED_EXT.inject(true) { |c, e| c && File.exists?("#{path}/#{file_name}.#{e}") } # Assume ogr2ogr - `ogr2ogr -f 'ESRI Shapefile' #{path}/#{file_name}.shp #{path}/#{file_name}.tab` + `ogr2ogr -f "ESRI Shapefile" #{path}/#{file_name}.shp #{path}/#{file_name}.tab` begin ImportShapefile.new(@url_gen).import_for_org(path, file_name) ensure
Use double quotes for windows compatibility.
diff --git a/lib/reveal-ck/commands/start_web_server.rb b/lib/reveal-ck/commands/start_web_server.rb index abc1234..def5678 100644 --- a/lib/reveal-ck/commands/start_web_server.rb +++ b/lib/reveal-ck/commands/start_web_server.rb @@ -27,7 +27,7 @@ def build_rack_app(doc_root) Rack::Builder.new do use Rack::LiveReload - use Rack::Static, index: "#{doc_root}/index.html" + use Rack::Static, :urls => {"/" => 'index.html'}, :root => "#{doc_root}" run Rack::Directory.new(doc_root) end end
Make it so that index.html is the default again I believe this changed in rack over here: https://github.com/rack/rack/commit/3f8db47322c8294e1c2399a481471c811361790e#diff-baa2333b40f04569ff6bd9ffb872fa51
diff --git a/concise_logging.gemspec b/concise_logging.gemspec index abc1234..def5678 100644 --- a/concise_logging.gemspec +++ b/concise_logging.gemspec @@ -9,7 +9,7 @@ spec.authors = ["Gerry Shaw"] spec.email = ["gerry_shaw@yahoo.com"] spec.summary = %q{Alternate logging for Rails production servers} - spec.homepage = "" + spec.homepage = "https://github.com/gshaw/concise_logging" spec.license = "MIT" spec.files = `git ls-files -z`.split("\x0")
Add link to home page
diff --git a/lib/Storm/Network/Firewall/firewall.rb b/lib/Storm/Network/Firewall/firewall.rb index abc1234..def5678 100644 --- a/lib/Storm/Network/Firewall/firewall.rb +++ b/lib/Storm/Network/Firewall/firewall.rb @@ -0,0 +1,75 @@+require "Storm/Base/model" +require "Storm/Base/sodserver" + +module Storm + module Network + module Firewall + class Firewall < Storm::Base::Model + attr_accessor :allow + attr_accessor :rules + attr_accessor :ruleset + attr_accessor :type + + def from_hash(h) + @allow = h[:allow] + @rules = h[:rules] + @ruleset = h[:ruleset] + @type = h[:type] + end + + # Get details about the current firewall settings for a particular + # server + # + # @param server [Server] the specified server + # @return [Firewall] a new Firewall object + def self.details(server) + data = Storm::Base::SODServer.remote_call \ + '/Network/Firewall/details', :uniq_id => server.uniq_id + fw = Firewall.new + fw.from_hash data + fw + end + + # Returns a list of options that the basic firewall accepts + # + # @param server [Server] the specified server + # @return [Array] an array of option strings + def self.get_basic_options(server) + data = Storm::Base::SODServer.remote_call \ + '/Network/Firewall/getBasicOptions', + :uniq_id => server.uniq_id + data[:options] + end + + # Returns the rules for the given server, regardless of type + # + # @param server [Server] the specified server + # @return [Array] an array of firewall rules + def self.rules(server) + data = Storm::Base::SODServer.remote_call \ + '/Network/Firewall/rules', :uniq_id => server.uniq_id + data[:rules] + end + + # Updates the firewall setting for a given server + # + # @param server [Server] the specified server + # @param type [String] one of 'basic', 'saved', 'advanced' or none + # @param allow [Array] + # @param rules [Array] + # @param ruleset [String] + def self.update(server, type, allow, rules, ruleset) + param = {} + param[:uniq_id] = server.uniq_id + param[:type] = type if type + param[:allow] = allow if allow + param[:rules] = rules if rules + param[:ruleset] = ruleset if ruleset + data = Storm::Base::SODServer.remote_call \ + '/Network/Firewall/update', param + data[:modified] + end + end + end + end +end
Add Firewall class and APIs
diff --git a/core/app/models/spree/stock/splitter/base.rb b/core/app/models/spree/stock/splitter/base.rb index abc1234..def5678 100644 --- a/core/app/models/spree/stock/splitter/base.rb +++ b/core/app/models/spree/stock/splitter/base.rb @@ -20,7 +20,7 @@ end def build_package(contents=[]) - Package.new(stock_location, order, contents) + Spree::Stock::Package.new(stock_location, order, contents) end end end
Use fully-qualified constant when referencing Package within Spree::Stock::Splitter::Base Fixes #2832
diff --git a/lib/data_mapper/mapper/relationship/builder/many_to_one.rb b/lib/data_mapper/mapper/relationship/builder/many_to_one.rb index abc1234..def5678 100644 --- a/lib/data_mapper/mapper/relationship/builder/many_to_one.rb +++ b/lib/data_mapper/mapper/relationship/builder/many_to_one.rb @@ -9,7 +9,7 @@ def fields super.merge({ source_key => target_key, - target_key => source_mapper.unique_alias(target_key, name) + target_key => DataMapper::Mapper.unique_alias(target_key, name) }) end end # class ManyToOne
Make the receiver of the call explicit
diff --git a/lib/attribute_ext/hidden_attributes.rb b/lib/attribute_ext/hidden_attributes.rb index abc1234..def5678 100644 --- a/lib/attribute_ext/hidden_attributes.rb +++ b/lib/attribute_ext/hidden_attributes.rb @@ -3,7 +3,7 @@ def self.included(base) base.extend(ClassMethods) base.alias_method_chain :to_xml, :hidden_attrs - base.alias_method_chain :to_json, :hidden_attrs + base.alias_method_chain :as_json, :hidden_attrs end module ClassMethods @@ -19,17 +19,24 @@ end def to_xml_with_hidden_attrs(options = nil, &block) - call_with_sanitized_attrs(:xml, options, &block) + options ||= {} + options[:except] = [] unless options[:except].is_a?(Array) + options[:except] += hidden_attribute_names(:xml, options) + + to_xml_without_hidden_attrs(options) end - def to_json_with_hidden_attrs(options = nil) - call_with_sanitized_attrs(:json, options) + def as_json_with_hidden_attrs(options = nil, &block) + options ||= {} + options[:except] = [] unless options[:except].is_a?(Array) + options[:except] += hidden_attribute_names(:json, options) + + as_json_without_hidden_attrs(options) end private - - def call_with_sanitized_attrs(format, options = nil, &block) - options ||= {} + + def hidden_attribute_names(format, options) names = [] self.class.hide_attributes.collect do |attrs, aopts| @@ -39,8 +46,6 @@ end end names.uniq - - send("to_#{format}_without_hidden_attrs".to_sym, {:except => names}.merge(options), &block) end end end
Modify as_json instead of to_json for hiding attributes.
diff --git a/lib/octicons_gem/test/octicons_test.rb b/lib/octicons_gem/test/octicons_test.rb index abc1234..def5678 100644 --- a/lib/octicons_gem/test/octicons_test.rb +++ b/lib/octicons_gem/test/octicons_test.rb @@ -7,5 +7,8 @@ assert x_icon["name"] assert x_icon["keywords"] assert x_icon["heights"] + assert x_icon["heights"]["16"] + assert x_icon["heights"]["16"]["width"] + assert x_icon["heights"]["16"]["path"] end end
Add deeper asserts to octicons test
diff --git a/app/controllers/neighborly/api/v1/tags_controller.rb b/app/controllers/neighborly/api/v1/tags_controller.rb index abc1234..def5678 100644 --- a/app/controllers/neighborly/api/v1/tags_controller.rb +++ b/app/controllers/neighborly/api/v1/tags_controller.rb @@ -4,13 +4,7 @@ before_action :require_admin! def create - tag = Tag.new(permited_params) - - if tag.save - render json: tag, status: :created - else - respond_with tag - end + respond_with Tag.create(permited_params) end private
Use only respond_with on create a tag
diff --git a/config/routes.rb b/config/routes.rb index abc1234..def5678 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -3,7 +3,8 @@ get '/sotechsha', to: 'sotechsha_overview_page#index' # Redirects - get "/releases/2016/12/12/new-backend", to: redirect('/blogs/2016/12/12/new-backend') + get "/releases/2016/12/12/new-backend", to: redirect('/news/2016/12/12/new-backend') + get "/blogs/2016/12/12/new-backend", to: redirect('/news/2016/12/12/new-backend') # Sessions get '/logout', to: 'sessions#destroy'
Change url: s/blogs/news/ to fit into coderdojo.com URI pattern
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 @@ get "/browse/:top_level_slug", to: "browse#top_level_browse_page" get "/browse/:top_level_slug/:second_level_slug", to: "browse#second_level_browse_page" + # Note that this app only receives requests for routes registered with the + # content-store (by collections-publisher) - whenever the routes below + # change, also change the routes claimed by collections-publisher. + get "/:topic_slug/:subtopic_slug/latest", as: "latest_changes", to: "subtopics#latest_changes" get "/:topic_slug/:subtopic_slug", as: :subtopic, to: "subtopics#show" get "/:topic_slug", to: "topics#show", as: :topic
Add note about routing changes The routes for this app are defined in two places - here and in collections-publisher. This note reminds us to change both. Would've prevented https://github.com/alphagov/collections-publisher/pull/93
diff --git a/server/app/controllers/files_controller.rb b/server/app/controllers/files_controller.rb index abc1234..def5678 100644 --- a/server/app/controllers/files_controller.rb +++ b/server/app/controllers/files_controller.rb @@ -19,7 +19,7 @@ rescue Exception => e logger.error e.message logger.info e.backtrace.join("\n") if params[:debug] - response = e.message + response = e.message + "\n" response << e.backtrace.join("\n") if params[:debug] render :text => response, :status => :internal_server_error end
Add a newline when assembling error response message so that the error and the backtrace don't blend together on the same line. git-svn-id: 907a5e332d9df9b9d6ff346e9993373f8c03b4a0@114 59d7d9da-0ff4-4beb-9ab8-e480f87378b2
diff --git a/pivotal_workstation/attributes/rvm.rb b/pivotal_workstation/attributes/rvm.rb index abc1234..def5678 100644 --- a/pivotal_workstation/attributes/rvm.rb +++ b/pivotal_workstation/attributes/rvm.rb @@ -4,7 +4,7 @@ # "ruby-1.8.7-p358" => { :env => "CC=gcc-4.2" }, # "ruby-1.9.2-p290" => { :env => "CC=gcc-4.2" }, # "ruby-1.9.3-p194" => { :command_line_options => "--with-gcc=clang" } - "ruby-2.0.0-p247" => { :command_line_options => "--verify-downloads 1" } + "ruby-2.0.0-p353" => { :command_line_options => "--verify-downloads 1" } } -node.default["rvm"]["default_ruby"] = "ruby-2.0.0-p247" +node.default["rvm"]["default_ruby"] = "ruby-2.0.0-p353"
Change default ruby 2 to patch level 353
diff --git a/app/contexts/merge_requests_load_context.rb b/app/contexts/merge_requests_load_context.rb index abc1234..def5678 100644 --- a/app/contexts/merge_requests_load_context.rb +++ b/app/contexts/merge_requests_load_context.rb @@ -9,7 +9,7 @@ merge_requests = case type when 'all' then merge_requests when 'closed' then merge_requests.closed - when 'assigned-to-me' then merge_requests.opened.assigned(current_user) + when 'assigned-to-me' then merge_requests.opened.assigned_to(current_user) else merge_requests.opened end
Fix missing assigned_to renaming in 2e839ce fixes #4360.
diff --git a/app/controllers/event_streams_controller.rb b/app/controllers/event_streams_controller.rb index abc1234..def5678 100644 --- a/app/controllers/event_streams_controller.rb +++ b/app/controllers/event_streams_controller.rb @@ -1,5 +1,11 @@ class EventStreamsController < ApplicationController + before_action :authenticate_user! def show - render json: EventStream.connection_info(params[:id]).to_json + pp = PaperPolicy.new(params[:id], current_user) + if pp.paper + render json: EventStream.connection_info(params[:id]).to_json + else + head :forbidden + end end end
Add some untested basic auth to streams controller
diff --git a/db/data_migration/20140328161525_migrate_environmental_detailed_guides.rb b/db/data_migration/20140328161525_migrate_environmental_detailed_guides.rb index abc1234..def5678 100644 --- a/db/data_migration/20140328161525_migrate_environmental_detailed_guides.rb +++ b/db/data_migration/20140328161525_migrate_environmental_detailed_guides.rb @@ -0,0 +1,15 @@+category_map = { + 'flooding-and-coastal-change' => ['environment-countryside/flooding-extreme-weather', 'Flooding and extreme weather'], + 'wildlife-and-habitat-conservation' => ['environment-countryside/wildlife-biodiversity', 'Wildlife and biodiversity'] +} + +category_map.each do |subcategory_slug, (new_parent_tag, new_parent_title)| + if subcategory = MainstreamCategory.find_by_slug(subcategory_slug) + subcategory.update_attributes( + parent_tag: new_parent_tag, + parent_title: new_parent_title + ) + else + raise "Missing MainstreamCategory #{subcategory_slug}" + end +end
Change the parent categories for EA subcategories.
diff --git a/app/controllers/srpm_all_bugs_controller.rb b/app/controllers/srpm_all_bugs_controller.rb index abc1234..def5678 100644 --- a/app/controllers/srpm_all_bugs_controller.rb +++ b/app/controllers/srpm_all_bugs_controller.rb @@ -1,8 +1,24 @@ class SrpmAllBugsController < ApplicationController + # after_action :print_accessed_fields + def index @branch = Branch.find_by!(name: params[:branch]) @srpm = @branch.srpms.find_by!(name: params[:id]) @all_bugs = AllBugsForSrpm.new(@srpm).decorate @opened_bugs = OpenedBugsForSrpm.new(@srpm).decorate end + + # private + # + # def print_accessed_fields + # # p @users.first.accessed_fields + # + # p @branch.accessed_fields + # + # p @srpm.accessed_fields + # + # p @all_bugs.first.accessed_fields + # + # p @opened_bugs.first.accessed_fields + # end end
Add example for debuging used attributes
diff --git a/app/models/region.rb b/app/models/region.rb index abc1234..def5678 100644 --- a/app/models/region.rb +++ b/app/models/region.rb @@ -30,7 +30,7 @@ self.geom = recipe.make unless recipe.errors.empty? recipe.errors.each do |e| - @errors.add(:recipe, e) + self.errors.add(:recipe, e) end end end
Fix bug with errors in Region.rb
diff --git a/database_sanitizer.gemspec b/database_sanitizer.gemspec index abc1234..def5678 100644 --- a/database_sanitizer.gemspec +++ b/database_sanitizer.gemspec @@ -20,7 +20,7 @@ spec.add_development_dependency 'rake', '~> 10' spec.add_development_dependency 'pg', '~> 0.17' - spec.add_runtime_dependency 'activerecord', '>= 3.0' + spec.add_runtime_dependency 'activerecord', '>= 3' spec.add_runtime_dependency 'activerecord-comments', '~> 0' spec.add_runtime_dependency 'progress', '~> 3' spec.add_runtime_dependency 'iconv', '~> 1'
Fix rspec version to work with rspec 4
diff --git a/app/models/organization.rb b/app/models/organization.rb index abc1234..def5678 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -8,7 +8,6 @@ has_many :event_groups, dependent: :destroy has_many :stewardships, dependent: :destroy has_many :stewards, through: :stewardships, source: :user - has_many :events, through: :event_groups scope :with_visible_event_count, -> do left_joins(event_groups: :events).select('organizations.*, COUNT(DISTINCT events) AS event_count') @@ -20,6 +19,10 @@ def to_s slug + end + + def events + Event.where(event_group_id: event_groups.ids) end def add_stewardship(user)
Revert Organization / Event relationship.
diff --git a/app/serializers/spree/payment_serializer.rb b/app/serializers/spree/payment_serializer.rb index abc1234..def5678 100644 --- a/app/serializers/spree/payment_serializer.rb +++ b/app/serializers/spree/payment_serializer.rb @@ -2,10 +2,11 @@ class PaymentSerializer < ActiveModel::Serializer embed :ids, include: true - attributes :id + attributes :id, + :state has_one :payment_method, serializer: PaymentMethodSerializer, root: :payment_methods has_one :source, serializer: SourceSerializer end -end+end
Add state to payment serializer
diff --git a/app/models/csv_db.rb b/app/models/csv_db.rb index abc1234..def5678 100644 --- a/app/models/csv_db.rb +++ b/app/models/csv_db.rb @@ -3,7 +3,8 @@ class << self def convert_save(target_model, csv_data, role = :default, &block) csv_file = csv_data.read - CSV.parse(csv_file, :headers => true, :header_converters => :symbol ) do |row| + parser_class = (RUBY_VERSION=='1.8.7') ? FasterCSV : CSV + parser_class.parse(csv_file, :headers => true, :header_converters => :symbol ) do |row| data = row.to_hash if data.present? if (block_given?)
Make compatible with Ruby 1.8.7.
diff --git a/app/models/device.rb b/app/models/device.rb index abc1234..def5678 100644 --- a/app/models/device.rb +++ b/app/models/device.rb @@ -14,10 +14,11 @@ has_many :peripherals, dependent: :destroy has_many :tools, dependent: :destroy has_many :images, dependent: :destroy - validates :name, uniqueness: true validates :timezone, inclusion: { in: TIMEZONES, message: BAD_TZ, allow_nil: true } + validates_presence_of :name + # Give the user back the amount of logs they are allowed to view. def limited_log_list logs.all.last(max_log_count || DEFAULT_MAX_LOGS)
Validate presence (but not uniqueness) of `name`
diff --git a/spec/controllers/boards_controller_spec.rb b/spec/controllers/boards_controller_spec.rb index abc1234..def5678 100644 --- a/spec/controllers/boards_controller_spec.rb +++ b/spec/controllers/boards_controller_spec.rb @@ -34,4 +34,8 @@ end end + describe "access control" do + it "exists" + end + end
Add pending test for BoardsController access control.
diff --git a/spec/integration/one_signal_client_spec.rb b/spec/integration/one_signal_client_spec.rb index abc1234..def5678 100644 --- a/spec/integration/one_signal_client_spec.rb +++ b/spec/integration/one_signal_client_spec.rb @@ -23,4 +23,13 @@ expect(status).to be_success expect(status.id).to_not be_nil end + + it 'sends a notification to a device' do + device_id = OneSignal.add_device(device_type: device_type, identifier: identifier).id + notification_status = OneSignal.notify(message: 'Test notification', devices_ids: device_id) + + expect(notification_status).to be_success + expect(notification_status.id).to_not be_nil + expect(notification_status.recipients).to eq(1) + end end
Add integration test for notify operation
diff --git a/test/as_test.rb b/test/as_test.rb index abc1234..def5678 100644 --- a/test/as_test.rb +++ b/test/as_test.rb @@ -0,0 +1,17 @@+require 'test_helper' + +describe 'Redis::Breadcrumb' do + before do + Redis::Breadcrumb.redis = MockRedis.new + end + + it 'can create a method to access the key through' do + class OwnedAsMethod < Redis::Breadcrumb + owns :a_key, :as => :my_key + end + + OwnedAsMethod.new.my_key.set 'hello' + + assert_equal 'hello', OwnedAsMethod.redis.get('a_key') + end +end
Add 'can create a method to access the through' test
diff --git a/spec/support/real_time/connected_client.rb b/spec/support/real_time/connected_client.rb index abc1234..def5678 100644 --- a/spec/support/real_time/connected_client.rb +++ b/spec/support/real_time/connected_client.rb @@ -1,5 +1,5 @@ RSpec.shared_context 'connected client' do |opts| - let(:client) { Slack::RealTime::Client.new(opts || { store_class: Slack::RealTime::Stores::Store }) } + let(:client) { Slack::RealTime::Client.new(opts || {}) } let(:ws) { double(Slack::RealTime::Concurrency::Mock::WebSocket) } let(:url) { 'wss://ms173.slack-msgs.com/websocket/lqcUiAvrKTP-uuid=' } let(:socket) { double(Slack::RealTime::Socket, connected?: true) }
Remove since Slack::RealTime::Store is the default anyway.
diff --git a/advent-of-code-day-4/lib/main.rb b/advent-of-code-day-4/lib/main.rb index abc1234..def5678 100644 --- a/advent-of-code-day-4/lib/main.rb +++ b/advent-of-code-day-4/lib/main.rb @@ -32,4 +32,5 @@ if __FILE__ == $0 secret_key = gets.chomp puts Hasher.lowest_initial_zeroes_added_number(secret_key, 5) + puts Hasher.lowest_initial_zeroes_added_number(secret_key, 6) end
Complete day 4 part 2 I needed no new implementation. I just called my existing method with a different number.
diff --git a/alpha-blog/app/models/article.rb b/alpha-blog/app/models/article.rb index abc1234..def5678 100644 --- a/alpha-blog/app/models/article.rb +++ b/alpha-blog/app/models/article.rb @@ -1,3 +1,9 @@ class Article < ActiveRecord::Base + # title and description for record is mandatory + validates :title, presence: true, + length: { minimum: 3, maximum: 50 } + validates :description, presence: true, + length: { minimum: 10, maximum: 300 } + end
Add validations for title and description attributes
diff --git a/config/initializers/jasminerice.rb b/config/initializers/jasminerice.rb index abc1234..def5678 100644 --- a/config/initializers/jasminerice.rb +++ b/config/initializers/jasminerice.rb @@ -1 +1 @@-Rails.application.config.assets.paths << File.join(Rails.root, "spec", "javascripts") +Rails.application.config.assets.paths << Rails.root.join("spec", "javascripts") << Rails.root.join("spec", "stylesheets")
Add both javascript and stylesheet paths.
diff --git a/features/step_definitions/generator_steps.rb b/features/step_definitions/generator_steps.rb index abc1234..def5678 100644 --- a/features/step_definitions/generator_steps.rb +++ b/features/step_definitions/generator_steps.rb @@ -1,10 +1,10 @@ Before do - `mv #{Rails.root}/features/ #{Rails.root}/features.orig/` + `mv #{Rails.root}/features/ #{Rails.root}/features.orig/ > /dev/null 2>&1` end After do `rm -rf #{Rails.root}/features` - `mv #{Rails.root}/features.orig/ #{Rails.root}/features/` + `mv #{Rails.root}/features.orig/ #{Rails.root}/features/ > /dev/null 2>&1` end Given(/^cucumber has been freshly generated$/) do
Make generator steps less noisy if there isn't a features dir in the testing app
diff --git a/spec/travis/addons/email/instruments/event_handler_spec.rb b/spec/travis/addons/email/instruments/event_handler_spec.rb index abc1234..def5678 100644 --- a/spec/travis/addons/email/instruments/event_handler_spec.rb +++ b/spec/travis/addons/email/instruments/event_handler_spec.rb @@ -3,10 +3,13 @@ describe Travis::Addons::Email::Instruments::EventHandler do include Travis::Testing::Stubs - let(:build) { stub_build(state: :failed) } + let(:build) { stub_build(state: :failed, repository: repository, on_default_branch?: true) } let(:subject) { Travis::Addons::Email::EventHandler } let(:publisher) { Travis::Notification::Publisher::Memory.new } let(:event) { publisher.events[1] } + let(:repository) { + stub_repo(users: [stub_user(email: 'svenfuchs@artweb-design.de')]) + } before :each do Travis::Notification.publishers.replace([publisher])
Add enough stubs to instruments spec
diff --git a/app/decorators/user_decorator.rb b/app/decorators/user_decorator.rb index abc1234..def5678 100644 --- a/app/decorators/user_decorator.rb +++ b/app/decorators/user_decorator.rb @@ -24,6 +24,6 @@ end def role - object.role.humanize + object.role.to_s.humanize end end
Fix admin user roles humanize string
diff --git a/app/models/description_object.rb b/app/models/description_object.rb index abc1234..def5678 100644 --- a/app/models/description_object.rb +++ b/app/models/description_object.rb @@ -1,6 +1,7 @@ class DescriptionObject < ActiveFedora::Base include Hydra::ModelMixins::RightsMetadata + before_save :set_permissions has_metadata "rightsMetadata", type: Hydra::Datastream::RightsMetadata has_metadata 'descMetadata', type: Datastream::DescriptionObjectMetadata @@ -9,8 +10,12 @@ delegate :title, to: 'descMetadata', unique: true delegate :dpn_status, to: 'descMetadata', unique: true - # delegate :institution_name, to: 'descMetadata', unique: true validates :title, :dpn_status, presence: true + private + def set_permissions + self.edit_groups = ['admin', 'institutional_admin'] + self.read_groups = ['institutional_guest'] + end end
Add default permissions settings on DescriptionObject as a before_save callback
diff --git a/yahag.gemspec b/yahag.gemspec index abc1234..def5678 100644 --- a/yahag.gemspec +++ b/yahag.gemspec @@ -8,8 +8,8 @@ gem.version = Yahag::VERSION gem.authors = ['Max Riveiro'] gem.email = ['kavu13@gmail.com'] - gem.description = %q{TODO: Write a gem description} - gem.summary = %q{TODO: Write a gem summary} + gem.description = 'Yahag is just a little gem for HockeyApp API endpoints. For now it supports only Team endpoint.' + gem.summary = 'Yahag is Yet Another HockeyApp Gem' gem.homepage = "https://github.com/kavu/yahag" gem.license = "MIT"
Fix gem desciption and summary
diff --git a/app/controllers/backend/taxes_controller.rb b/app/controllers/backend/taxes_controller.rb index abc1234..def5678 100644 --- a/app/controllers/backend/taxes_controller.rb +++ b/app/controllers/backend/taxes_controller.rb @@ -34,7 +34,7 @@ def load Tax.import_all_from_nomenclature(Preference[:country].to_sym) - redirect_to params[:redirect] + redirect_to params[:redirect] unless params[:redirect].nil? end end end
Fix load in taxes controller to be used by test
diff --git a/app/models/concerns/submittable/solvable.rb b/app/models/concerns/submittable/solvable.rb index abc1234..def5678 100644 --- a/app/models/concerns/submittable/solvable.rb +++ b/app/models/concerns/submittable/solvable.rb @@ -1,7 +1,7 @@ module Solvable def submit_solution!(user, attributes={}) content = attributes[:content] - attributes[:content] = serialize(content) if content.is_a? Hash + attributes[:content] = join_files(content) if content.is_a? Hash assignment, _ = find_assignment_and_submit! user, Solution.new(content: attributes[:content]&.normalize_whitespaces) assignment end @@ -17,17 +17,17 @@ private - def serialize(content) + def join_files(content) comment_type = Mumukit::Directives::CommentType.parse(language.comment_type) - file_declarations, file_references = content.map{|filename, content| method_name(comment_type, content, filename)}.transpose - "#{file_declarations.join "\n" }\n#{wrapWith 'content', file_references.join("\n"), comment_type}" + file_declarations, file_references = content.map{|filename, content| declare_and_reference(comment_type, content, filename)}.transpose + "#{file_declarations.join "\n" }\n#{wrap_with 'content', file_references.join("\n"), comment_type}" end - def method_name(comment_type, content, filename) - [wrapWith(filename, content, comment_type), (comment_type.comment "...#{filename}...")] + def declare_and_reference(comment_type, content, filename) + [wrap_with(filename, content, comment_type), (comment_type.comment "...#{filename}...")] end - def wrapWith(tag, text, comment_type) + def wrap_with(tag, text, comment_type) "#{comment_type.comment "<#{tag}#"}#{text}#{comment_type.comment "##{tag}>"}" end end
Refactor solution Hash to string conversion
diff --git a/app/controllers/checkin/groups_controller.rb b/app/controllers/checkin/groups_controller.rb index abc1234..def5678 100644 --- a/app/controllers/checkin/groups_controller.rb +++ b/app/controllers/checkin/groups_controller.rb @@ -4,7 +4,10 @@ @groups = {} date = params[:date] ? Date.parse(params[:date]) : Date.today CheckinTime.for_date(date, params[:campus]).each do |time| - @groups[time.time_to_s] = time.groups.all(:order => 'group_times.ordering', :select => 'group_times.print_nametag, group_times.section, groups.*').map { |g| [g.id, g.name, g.print_nametag?, g.link_code, g.section] }.group_by { |g| g[4].to_s } + @groups[time.time_to_s] = time.groups.order('group_times.ordering') + .select('group_times.print_nametag, group_times.section, groups.*') + .map { |g| [g.id, g.name, g.print_nametag?, g.link_code, g.section] } + .group_by { |g| g[4].to_s } end respond_to do |format| format.json do
Fix old style AR query.
diff --git a/app/controllers/browserlog/logs_controller.rb b/app/controllers/browserlog/logs_controller.rb index abc1234..def5678 100644 --- a/app/controllers/browserlog/logs_controller.rb +++ b/app/controllers/browserlog/logs_controller.rb @@ -16,7 +16,7 @@ respond_to do |format| format.json do render json: { - lines: lines.map! { |line| colorizer.colorize_line(line) } , + lines: lines.map! { |line| colorizer.colorize_line(line) }, last_line_number: last_line_number } end
Remove trailing whitespace before comma
diff --git a/app/controllers/incident_events_controller.rb b/app/controllers/incident_events_controller.rb index abc1234..def5678 100644 --- a/app/controllers/incident_events_controller.rb +++ b/app/controllers/incident_events_controller.rb @@ -11,9 +11,9 @@ if params[:Digits] case params[:Digits] when '1' - @event.incident.acknowledged! rescue nil + @event.incident.acknowledge! rescue nil when '2' - @event.incident.resolved! rescue nil + @event.incident.resolve! rescue nil end resp = Twilio::TwiML::Response.new do |r| r.Say @event.incident.status, voice: 'alice', language: 'en-US'
Create events by acknowledging and resolving from phone.
diff --git a/alpha-blog/app/controllers/users_controller.rb b/alpha-blog/app/controllers/users_controller.rb index abc1234..def5678 100644 --- a/alpha-blog/app/controllers/users_controller.rb +++ b/alpha-blog/app/controllers/users_controller.rb @@ -14,8 +14,9 @@ @user = User.new(user_params) if @user.save + session[:user_id] = @user.id flash[:success] = "Welcome to the alpha blog #{@user.username}!" - redirect_to articles_path + redirect_to user_path(@user) else render 'new' end
Add sign in upon sign up
diff --git a/config/initializers/_jiffybag.rb b/config/initializers/_jiffybag.rb index abc1234..def5678 100644 --- a/config/initializers/_jiffybag.rb +++ b/config/initializers/_jiffybag.rb @@ -7,4 +7,5 @@ AWS_SECRET_ACCESS_KEY AWS_BUCKET OPENSPACE_API_KEY + LEGATO_OAUTH_ACCESS_TOKEN }
Add access token to JiffyBag
diff --git a/lib/minitest/ruby_golf_metrics/reporter.rb b/lib/minitest/ruby_golf_metrics/reporter.rb index abc1234..def5678 100644 --- a/lib/minitest/ruby_golf_metrics/reporter.rb +++ b/lib/minitest/ruby_golf_metrics/reporter.rb @@ -22,7 +22,7 @@ if erg.passed begin source = RubyGolf.method(erg.method_name).to_raw_source(strip_enclosure: true) - size = source.strip.gsub(" ", "").size + size = source.strip.gsub(/\s+/, "").size io.puts " #{colorize(erg.method_name, 32)}: #{size} characters" rescue NoMethodError io.puts " #{colorize(erg.method_name, 31)}: UNDEFINED"
Make alle whitespace not count, not just spaces
diff --git a/lib/oh_auth/endpoints/authenticate_user.rb b/lib/oh_auth/endpoints/authenticate_user.rb index abc1234..def5678 100644 --- a/lib/oh_auth/endpoints/authenticate_user.rb +++ b/lib/oh_auth/endpoints/authenticate_user.rb @@ -11,13 +11,19 @@ user = User.find(request.params['username']) if user && user.authenticate?(request.params['password']) - Rack::Response.new(success) + render_json(success, 200) else - Rack::Response.new(error, 401) + render_json(error, 401) end end private + + def self.render_json(body, status_code) + Rack::Response.new(body, status_code, { + 'Content-Type' => 'application/json' + }) + end def self.success JSON({ @@ -35,3 +41,4 @@ end end end +
Add the correct content type header
diff --git a/app/importers/student_assessment_importer.rb b/app/importers/student_assessment_importer.rb index abc1234..def5678 100644 --- a/app/importers/student_assessment_importer.rb +++ b/app/importers/student_assessment_importer.rb @@ -1,5 +1,5 @@ class StudentAssessmentImporter - WHITELIST = Regexp.union(/ACCESS/, /WIDA-ACCESS/, /DIBELS/, /MCAS/, /MAP/, /MELA-O/, /MEPA/, /STAR/).freeze + WHITELIST = Regexp.union(/ACCESS/, /WIDA-ACCESS/, /DIBELS/, /MCAS/, /MAP/, /MELA-O/, /MEPA/).freeze def remote_file_name # Expects a CSV with the following headers, transformed to symbols by CsvTransformer during import:
Stop importing STAR data from X2 + The STAR SFTP server is the only source of truth about STAR + One system was importing results with subject "Math" (STAR SFTP), the other with subject "Mathematics" (Aspen X2) + Only import assessment results from one system (STAR SFTP), use the same subject name as Aspen X2 ("Mathematics") + #75
diff --git a/app/models/renalware/letters/letter_query.rb b/app/models/renalware/letters/letter_query.rb index abc1234..def5678 100644 --- a/app/models/renalware/letters/letter_query.rb +++ b/app/models/renalware/letters/letter_query.rb @@ -27,7 +27,7 @@ end def search - @search ||= Letter.extend(QueryableLetter).search(@q) + @search ||= Letter.extend(QueryableLetter).includes(:event).search(@q) end end end
Resolve global letters list N+1 issues
diff --git a/app/controllers/projects/uploads_controller.rb b/app/controllers/projects/uploads_controller.rb index abc1234..def5678 100644 --- a/app/controllers/projects/uploads_controller.rb +++ b/app/controllers/projects/uploads_controller.rb @@ -1,11 +1,8 @@ class Projects::UploadsController < Projects::ApplicationController layout 'project' - # We want to skip these filters for only the `show` action if `image?` is true, - # but `skip_before_filter` doesn't work with both `only` and `if`, so we accomplish the same like this. - skipped_filters = [:authenticate_user!, :reject_blocked!, :project, :repository] - skip_before_action *skipped_filters, only: [:show] - before_action *skipped_filters, only: [:show], unless: :image? + skip_before_action :authenticate_user!, :reject_blocked!, :project, + :repository, if: -> { action_name == 'show' && image? } def create link_to_file = ::Projects::UploadService.new(project, params[:file]).
Simplify the `skip_before_filter` logic for UploadsController
diff --git a/cucumber-timed_formatter.gemspec b/cucumber-timed_formatter.gemspec index abc1234..def5678 100644 --- a/cucumber-timed_formatter.gemspec +++ b/cucumber-timed_formatter.gemspec @@ -6,8 +6,10 @@ s.name = "cucumber-timed_formatter" s.version = Cucumber::Formatter::Timed::VERSION s.date = File.mtime(__FILE__) - s.summary = "A progress-formatter with a little more info" - s.description = "A progress-formatter with a little more info: Each Scenario is one line and the time is measured." + s.summary = "A progress-formatter with a little more info, instafailing." + s.description = "A progress-formatter with a little more info: Each Scenario is one line and the time is measured. Additionally, errors are shown immediately to be a little like instafail. + + The Formatter is ideal for Jenkins line-by-line output." s.authors = ["Matthias Viehweger"] s.email = 'kronn@kronn.de'
Add more description to gemspec
diff --git a/GTScrollNavigationBar.podspec b/GTScrollNavigationBar.podspec index abc1234..def5678 100644 --- a/GTScrollNavigationBar.podspec +++ b/GTScrollNavigationBar.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "GTScrollNavigationBar" - s.version = "0.3" + s.version = "0.4" s.summary = "A scrollable UINavigationBar that follows a UIScrollView" s.homepage = "https://github.com/luugiathuy/GTScrollNavigationBar" s.license = 'BSD'
Update Podspec to 0.4 since it breaks API compatibility
diff --git a/rails/pluralization/hsb.rb b/rails/pluralization/hsb.rb index abc1234..def5678 100644 --- a/rails/pluralization/hsb.rb +++ b/rails/pluralization/hsb.rb @@ -0,0 +1,27 @@+module RailsI18n + module Pluralization + module UpperSorbian + def self.rule + lambda do |n| + mod100 = n % 100 + + if mod100 == 1 + :one + elsif mod100 == 2 + :two + elsif mod100 == 3 || mod100 == 4 + :few + else + :other + end + end + end + end + end +end + +{ :hsb => { + :'i18n' => { + :plural => { + :keys => [:one, :two, :few, :other], + :rule => RailsI18n::Pluralization::UpperSorbian.rule }}}}
Add pluralization rule for Upper Sorbian
diff --git a/app/models/order_query.rb b/app/models/order_query.rb index abc1234..def5678 100644 --- a/app/models/order_query.rb +++ b/app/models/order_query.rb @@ -3,10 +3,11 @@ attr_accessor :warehouse_id, :order_number - validates :warehouse_id, length: { is: 2 } - validates :order_number, length: { is: 6 } + validates! :warehouse_id, length: { is: 2 } + validates! :order_number, length: { is: 6 } def to_query + valid? # This will trigger an error if parameters are invalid # I may be defeating the point of sanitizing here but the sanizitize method # wraps the query in quotes so I remove them after because Relativity # doesn't seem to be capable of handling that
Change validations to generate an exception when parameters are incorrect ID:575
diff --git a/app/models/poll_option.rb b/app/models/poll_option.rb index abc1234..def5678 100644 --- a/app/models/poll_option.rb +++ b/app/models/poll_option.rb @@ -32,8 +32,10 @@ def display_name(zone: nil) if poll.dates_as_options formatted_datetime(name, zone || poll.time_zone) + elsif poll.poll_options_attributes.any? + name.humanize else - name.humanize + name end end end
Fix casing for user-generated poll options in email
diff --git a/app/controllers/wpcc_controller.rb b/app/controllers/wpcc_controller.rb index abc1234..def5678 100644 --- a/app/controllers/wpcc_controller.rb +++ b/app/controllers/wpcc_controller.rb @@ -1,6 +1,10 @@ class WpccController < EmbeddedToolsController def exclude_syndicated_iframe_resizer? true + end + + def canonical + "https://www.moneyhelper.org.uk/#{locale}/pensions-and-retirement/auto-enrolment/workplace-pension-calculator" end protected
Update canonical url for WPCC
diff --git a/app/models/spree/purchase_order.rb b/app/models/spree/purchase_order.rb index abc1234..def5678 100644 --- a/app/models/spree/purchase_order.rb +++ b/app/models/spree/purchase_order.rb @@ -5,7 +5,7 @@ belongs_to :payment_method has_many :payments, as: :source - validates_presence_of :po_number, :organization_name + validates :po_number, :organization_name, presence: true def actions %w(complete void)
Use newer form of presence validation
diff --git a/app/models/visualization/member.rb b/app/models/visualization/member.rb index abc1234..def5678 100644 --- a/app/models/visualization/member.rb +++ b/app/models/visualization/member.rb @@ -1,7 +1,7 @@ # encoding: utf-8 require 'virtus' require 'virtus/attribute/writer/coercible' -require_relative '../../../services/data-repository/repository' +require_relative '../visualization' module CartoDB class SnakeCaseString < Virtus::Attribute::String @@ -28,13 +28,10 @@ attribute :tags, Array[String] attribute :description, String - def self.repository - @repository ||= DataRepository::Repository.new - end # self.repository - - def initialize(attributes={}) + def initialize(attributes={}, repository=nil) self.attributes = attributes - self.id ||= repository.next_id + @repository = repository || Visualization.default_repository + self.id ||= @repository.next_id end #initialize def store @@ -55,9 +52,7 @@ private - def repository - self.class.repository - end #repository + attr_reader :repository end # Member end # Visualization end # CartoDB
Make Visualization::Member use the default repository in Visualization module
diff --git a/app/overrides/include_augury_js.rb b/app/overrides/include_augury_js.rb index abc1234..def5678 100644 --- a/app/overrides/include_augury_js.rb +++ b/app/overrides/include_augury_js.rb @@ -1,13 +1,7 @@-if Rails.env.development? - Deface::Override.new(virtual_path: 'spree/layouts/admin', - name: 'augury_js', - insert_bottom: 'body', - text: '<script type="text/javascript" src="http://localhost:5000/hub.min.js"></script>' - ) -else - Deface::Override.new(virtual_path: 'spree/layouts/admin', - name: 'augury_js', - insert_bottom: 'body', - text: '<script type="text/javascript" src="//staging.hub.spreecommerce.com/hub.min.js"></script>' - ) -end +hub_javascript_url = ENV['HUB_JS_URL'] || "//staging.hub.spreecommerce.com/hub.min.js" + +Deface::Override.new(virtual_path: 'spree/layouts/admin', + name: 'augury_js', + insert_bottom: 'body', + text: "<script type='text/javascript' src='#{hub_javascript_url}'></script>" + )
Update include augury js override
diff --git a/app/helpers/icons_helper.rb b/app/helpers/icons_helper.rb index abc1234..def5678 100644 --- a/app/helpers/icons_helper.rb +++ b/app/helpers/icons_helper.rb @@ -1,4 +1,5 @@ module IconsHelper + include FontAwesome::Sass::Rails::ViewHelpers def garden_icon icon('far', 'square') end
Include font awesome (so specs pass)
diff --git a/app/helpers/repos_helper.rb b/app/helpers/repos_helper.rb index abc1234..def5678 100644 --- a/app/helpers/repos_helper.rb +++ b/app/helpers/repos_helper.rb @@ -1,6 +1,6 @@ module ReposHelper - def link_to_or_log_in(text: text, path: path, html_class: "") - path = user_signed_in? ? path : user_omniauth_authorize_path(:github, origin: request.fullpath) - button_to text, path, class: "button #{html_class}" + def link_to_or_log_in(options = {}) + path = user_signed_in? ? options[:path] : user_omniauth_authorize_path(:github, origin: request.fullpath) + button_to options[:text], path, class: "button #{options[:html_class]}" end end
Fix ruby circular reference warnings
diff --git a/activesupport/lib/active_support/core_ext/float/rounding.rb b/activesupport/lib/active_support/core_ext/float/rounding.rb index abc1234..def5678 100644 --- a/activesupport/lib/active_support/core_ext/float/rounding.rb +++ b/activesupport/lib/active_support/core_ext/float/rounding.rb @@ -12,9 +12,9 @@ # Rounds the float with the specified precision. # # x = 1.337 - # x.round_with_precision # => 1 - # x.round_with_precision(1) # => 1.3 - # x.round_with_precision(2) # => 1.34 + # x.round # => 1 + # x.round(1) # => 1.3 + # x.round(2) # => 1.34 def round_with_precision(precision = nil) precision.nil? ? round_without_precision : (self * (10 ** precision)).round / (10 ** precision).to_f end
Revert "Fix example using wrong method name" This reverts commit 5745b25c9f71d86458f2d1cda65f800cbe4e6733.
diff --git a/app/presenters/tree_builder_automation_manager_providers.rb b/app/presenters/tree_builder_automation_manager_providers.rb index abc1234..def5678 100644 --- a/app/presenters/tree_builder_automation_manager_providers.rb +++ b/app/presenters/tree_builder_automation_manager_providers.rb @@ -22,7 +22,7 @@ # Get root nodes count/array for explorer tree def x_get_tree_roots(count_only, _options) - count_only_or_objects_filtered(count_only, ManageIQ::Providers::AnsibleTower::AutomationManager, "name", :match_via_descendants => ConfiguredSystem) + count_only_or_objects_filtered(count_only, ManageIQ::Providers::AnsibleTower::AutomationManager, "name") end def x_get_tree_cmat_kids(object, count_only)
Remove descendants matching for automation providers - needed for configured systems groups only
diff --git a/lib/rails_config/railtie.rb b/lib/rails_config/railtie.rb index abc1234..def5678 100644 --- a/lib/rails_config/railtie.rb +++ b/lib/rails_config/railtie.rb @@ -1,14 +1,18 @@ if defined?(Rails::Railtie) module RailsConfig class Railtie < Rails::Railtie + config.rails_config = ActiveSupport::OrderedOptions.new # Parse the settings before any of the initializers ActiveSupport.on_load :before_initialize, :yield => true do - ::Settings = RailsConfig.load_files( + settings = RailsConfig.load_files( Rails.root.join("config", "settings.yml").to_s, Rails.root.join("config", "settings", "#{Rails.env}.yml").to_s, Rails.root.join("config", "environments", "#{Rails.env}.yml").to_s ) + + # setup the constant + Kernel.const_set(app.config.rails_config.constant || "Settings", settings) end # Rails Dev environment should reload the Settings on every request
Add the ability to define the settings object via config.rails_config.constant
diff --git a/lib/tasks/schema_tests.rake b/lib/tasks/schema_tests.rake index abc1234..def5678 100644 --- a/lib/tasks/schema_tests.rake +++ b/lib/tasks/schema_tests.rake @@ -0,0 +1,8 @@+namespace :test do + Rake::TestTask.new(:schemas => "test:prepare") do |t| + t.libs << 'test' + t.test_files = `grep -rlE "schema" test`.lines.map(&:chomp) + end + + Rake::Task['test:schemas'].comment = "Test Publishing API presenters against schemas" +end
Add a test:schemas rake task This rake task only runs tests that have the word "schema" in them. We can run this task instead of the full test (which takes 8 minutes) when testing as a downstream build from govuk-content-schemas. Having "schema" in the test file is obviously going to cause false positives, but hopefully no false negatives - which would be worse. This test run takes 10s to complete.
diff --git a/atlas.gemspec b/atlas.gemspec index abc1234..def5678 100644 --- a/atlas.gemspec +++ b/atlas.gemspec @@ -24,4 +24,5 @@ spec.add_development_dependency 'rake' spec.add_development_dependency 'vcr' spec.add_development_dependency 'rspec' + spec.add_development_dependency "pry" end
Add pry as a development dependency.
diff --git a/event_store-client.gemspec b/event_store-client.gemspec index abc1234..def5678 100644 --- a/event_store-client.gemspec +++ b/event_store-client.gemspec @@ -1,7 +1,7 @@ # -*- encoding: utf-8 -*- Gem::Specification.new do |s| s.name = 'event_store-client' - s.version = '0.1.1' + s.version = '0.1.2' s.summary = 'Common code for the EventStore client' s.description = ' '
Package version is increased from 0.1.1 to 0.1.2
diff --git a/format_utils.rb b/format_utils.rb index abc1234..def5678 100644 --- a/format_utils.rb +++ b/format_utils.rb @@ -11,7 +11,7 @@ def random_quote @quotes = IO.readlines 'dict.txt' if @quotes.nil? has_quote = rand(10000) % 2 - has_quote == 1 ? @quotes[rand(@quotes.size)] : '' + has_quote == 1 ? @quotes.sample : '' end def hash_tags
Use Array.sample to pick abritary quote
diff --git a/lib/newline_hw/config.rb b/lib/newline_hw/config.rb index abc1234..def5678 100644 --- a/lib/newline_hw/config.rb +++ b/lib/newline_hw/config.rb @@ -6,7 +6,7 @@ DEFAULTS = { "editor" => "atom", "terminal" => "Terminal", - "start_editor" => true, + "launch_editor" => true, "homework_dir" => "~/theironyard/homework", "log_file" => "~/Library/Logs/newline_hw/newlinehw.log" }.freeze @@ -35,6 +35,10 @@ config["homework_dir"] end + def launch_editor + config["launch_editor"] + end + def self.install_default File.open(CONFIG_PATH, "w+") do |f| f.write DEFAULTS.to_yaml
Rename start_editor to launch editor for a bit of clarity.
diff --git a/test/factories/products.rb b/test/factories/products.rb index abc1234..def5678 100644 --- a/test/factories/products.rb +++ b/test/factories/products.rb @@ -3,7 +3,7 @@ association :category, factory: :product_nature_category association :nature, factory: :product_nature association :variant, factory: :product_nature_variant - variety 'cultivable_zone' + variety { 'cultivable_zone' } trait :with_boolean_reading do after(:create) do |instance|
Fix last static attribute in factories
diff --git a/app/serializers/task_definition_serializer.rb b/app/serializers/task_definition_serializer.rb index abc1234..def5678 100644 --- a/app/serializers/task_definition_serializer.rb +++ b/app/serializers/task_definition_serializer.rb @@ -10,7 +10,7 @@ :restrict_status_updates, :group_set_id, :has_task_sheet?, :has_task_resources?, :due_date, :start_date, :is_graded, :max_quality_pts, - :routing_key, :assessment_enabled + :routing_key, :assessment_enabled, :has_task_assessment_resources? def weight object.weighting
FIX: Include :has_task_assessment_resources? in task_def serialiser
diff --git a/plugin/pv-prepare-commit-msg.rb b/plugin/pv-prepare-commit-msg.rb index abc1234..def5678 100644 --- a/plugin/pv-prepare-commit-msg.rb +++ b/plugin/pv-prepare-commit-msg.rb @@ -7,7 +7,7 @@ commit_msg = IO.read(commit_msg_file_path) unless commit_msg.include?($1) or commit_msg =~ /Merge branch/ File.open(commit_msg_file_path, 'w') do |file| - file.print story_id + file.print "\n" + story_id file.print commit_msg end end
Print id by default as commit description
diff --git a/plugins/guests/alpine/plugin.rb b/plugins/guests/alpine/plugin.rb index abc1234..def5678 100644 --- a/plugins/guests/alpine/plugin.rb +++ b/plugins/guests/alpine/plugin.rb @@ -6,42 +6,42 @@ name 'Alpine guest' description 'Alpine Linux guest support.' - guest('alpine', 'linux') do + guest(:alpine, :linux) do require File.expand_path('../guest', __FILE__) Guest end - guest_capability('alpine', 'configure_networks') do + guest_capability(:alpine, :configure_networks) do require_relative 'cap/configure_networks' Cap::ConfigureNetworks end - guest_capability('alpine', 'halt') do + guest_capability(:alpine, :halt) do require_relative 'cap/halt' Cap::Halt end - guest_capability('alpine', 'change_host_name') do + guest_capability(:alpine, :change_host_name) do require_relative 'cap/change_host_name' Cap::ChangeHostName end - guest_capability('alpine', 'nfs_client_install') do + guest_capability(:alpine, :nfs_client_install) do require_relative 'cap/nfs_client' Cap::NFSClient end - guest_capability('alpine', 'rsync_installed') do + guest_capability(:alpine, :rsync_installed) do require_relative 'cap/rsync' Cap::RSync end - guest_capability('alpine', 'rsync_install') do + guest_capability(:alpine, :rsync_install) do require_relative 'cap/rsync' Cap::RSync end - guest_capability('alpine', 'smb_install') do + guest_capability(:alpine, :smb_install) do require_relative 'cap/smb' Cap::SMB end
alpine: Replace capability strings with symbols Those were introduced upstream in b29864f45097.
diff --git a/telemetry-logger.gemspec b/telemetry-logger.gemspec index abc1234..def5678 100644 --- a/telemetry-logger.gemspec +++ b/telemetry-logger.gemspec @@ -1,7 +1,7 @@ # -*- encoding: utf-8 -*- Gem::Specification.new do |s| s.name = 'telemetry-logger' - s.version = '0.1.2' + s.version = '0.1.3' s.summary = 'Logging to STDERR with coloring and levels of severity' s.description = ' ' @@ -18,5 +18,5 @@ s.add_runtime_dependency 'clock', '~> 0' s.add_runtime_dependency 'dependency', '~> 0' - s.add_runtime_dependency 'rainbow', '~> 0' + s.add_runtime_dependency 'rainbow', '~> 1' end
Package version is incremented from patch number 0.1.2 to 0.1.3
diff --git a/spec/dummy/db/migrate/20110625220409_add_locked_to_forem_topics.rb b/spec/dummy/db/migrate/20110625220409_add_locked_to_forem_topics.rb index abc1234..def5678 100644 --- a/spec/dummy/db/migrate/20110625220409_add_locked_to_forem_topics.rb +++ b/spec/dummy/db/migrate/20110625220409_add_locked_to_forem_topics.rb @@ -1,5 +1,5 @@ class AddLockedToForemTopics < ActiveRecord::Migration def change - add_column :forem_topics, :locked, :boolean + add_column :forem_topics, :locked, :boolean, :null => false, :default => false end end
Add default for forem_topics locked to false in spec migrations
diff --git a/Formula/changelogparser.rb b/Formula/changelogparser.rb index abc1234..def5678 100644 --- a/Formula/changelogparser.rb +++ b/Formula/changelogparser.rb @@ -6,7 +6,7 @@ url "https://github.com/lottadot/changelogparser/archive/0.1.0.tar.gz" version "0.1.0" # shasum -a 256 - sha256 "178045c5d0a960b2b54b4fb74c98d3247cfb6085adba2ceca0694bfd641ee7d0 + sha256 "178045c5d0a960b2b54b4fb74c98d3247cfb6085adba2ceca0694bfd641ee7d0" depends_on :xcode => ["8.0", :build] depends_on 'xcproj' => :recommended
Fix typo wrt Changelogparser 0.1.0
diff --git a/test/test_coffee_script.rb b/test/test_coffee_script.rb index abc1234..def5678 100644 --- a/test/test_coffee_script.rb +++ b/test/test_coffee_script.rb @@ -4,13 +4,13 @@ class TestCoffeeScript < Test::Unit::TestCase def test_compile - assert_equal "(function() {\n puts('Hello, World!');\n})();\n", + assert_equal "(function() {\n puts('Hello, World!');\n}).call(this);\n", CoffeeScript.compile("puts 'Hello, World!'\n") end def test_compile_with_io io = StringIO.new("puts 'Hello, World!'\n") - assert_equal "(function() {\n puts('Hello, World!');\n})();\n", + assert_equal "(function() {\n puts('Hello, World!');\n}).call(this);\n", CoffeeScript.compile(io) end
Update test output for CoffeeScript 0.9.x
diff --git a/test/test_id_generation.rb b/test/test_id_generation.rb index abc1234..def5678 100644 --- a/test/test_id_generation.rb +++ b/test/test_id_generation.rb @@ -1,7 +1,7 @@ require 'test_helper' class TestIdGeneration < Test::Unit::TestCase - should "attachment IDs are UUIDs" do + should "use UUIDs for attachment IDs" do a = Progstr::Filer::Attachment.from_file(FileLike.new) b = Progstr::Filer::Attachment.from_file(FileLike.new) @@ -10,7 +10,7 @@ assert_not_equal a.id, b.id end - should "attachment IDs have hyphens removed" do + should "have attachment IDs with no hyphens" do a = Progstr::Filer::Attachment.from_file(FileLike.new) assert_match /^[^-]+$/, a.id, "IDs should contain no hyphens" end
Fix id generation test wording.
diff --git a/benchmarks/before.rb b/benchmarks/before.rb index abc1234..def5678 100644 --- a/benchmarks/before.rb +++ b/benchmarks/before.rb @@ -42,8 +42,8 @@ observers << MethodProfiler.observe(Example) observers << MethodProfiler.observe(Aop) observers << MethodProfiler.observe(Aop::Pointcut) - observers << MethodProfiler.observe(Aop::Pointcut::MethodReference) - observers << MethodProfiler.observe(Aop::Pointcut::MethodReference::Singleton) + observers << MethodProfiler.observe(Aop::MethodReference) + observers << MethodProfiler.observe(Aop::MethodReference::Singleton) 10000.times do example.heavy_add(rand(1000), rand(1000))
Fix benchmarks after moving classes
diff --git a/app/controllers/concerns/exception_handler.rb b/app/controllers/concerns/exception_handler.rb index abc1234..def5678 100644 --- a/app/controllers/concerns/exception_handler.rb +++ b/app/controllers/concerns/exception_handler.rb @@ -0,0 +1,13 @@+module ExceptionHandler + extend ActiveSupport::Concern + + included do + rescue_from ActiveRecord::RecordNotFound do |e| + json_response({ message: e.message }, :not_found) + end + + rescue_from ActiveRecord::RecordInvalid do |e| + json_response({ message: e.message }, :unprocessable_entity) + end + end +end
Create exception handler for request errors
diff --git a/spec/features/category_scopes_spec.rb b/spec/features/category_scopes_spec.rb index abc1234..def5678 100644 --- a/spec/features/category_scopes_spec.rb +++ b/spec/features/category_scopes_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -describe 'Tracked categories', js: true do +describe 'Tracked categories and template', js: true do let(:course) { create(:course, type: 'ArticleScopedProgram') } let(:user) { create(:user) } before do @@ -16,21 +16,30 @@ expect(page).to have_content 'Tracked Categories' end - it 'can be added and removed by a facilitator' do + it 'lets a facilitator add and remove a category' do visit "/courses/#{course.slug}/articles" click_button 'Add category' find('#category_name').set('Photography') - click_button 'Add this category' + find_button('Add this category').trigger('click') click_button 'OK' - expect(page).to have_content 'Photography' + expect(page).to have_content 'Category:Photography' # Re-add the same category click_button 'Add category' find('#category_name').set('Photography') - click_button 'Add this category' + find_button('Add this category').trigger('click') click_button 'OK' click_button 'Remove' expect(page).not_to have_content 'Photography' end + + it 'lets a facilitator add a template' do + visit "/courses/#{course.slug}/articles" + click_button 'Add template' + find('#category_name').set('Stub') + find_button('Add this template').trigger('click') + click_button 'OK' + expect(page).to have_content 'Template:Stub' + end end
Add feature spec for tracking a template, update broken bits
diff --git a/spec/requests/odata/root_json_spec.rb b/spec/requests/odata/root_json_spec.rb index abc1234..def5678 100644 --- a/spec/requests/odata/root_json_spec.rb +++ b/spec/requests/odata/root_json_spec.rb @@ -20,11 +20,13 @@ include_context "odata_with_forms" it "renders as expected" do + entity_1_name = "Responses: #{form.name}" + entity_2_name = "Responses: #{form_with_no_responses.name}" expect_output({ "@odata.context": "http://www.example.com/en/m/#{get_mission.compact_name}/odata/v1/$metadata", value: [ - {name: "Responses: Sample Form 1", kind: "EntitySet", url: "Responses: Sample Form 1"}, - {name: "Responses: Sample Form 2", kind: "EntitySet", url: "Responses: Sample Form 2"} + {name: entity_1_name, kind: "EntitySet", url: entity_1_name}, + {name: entity_2_name, kind: "EntitySet", url: entity_2_name} ] }.to_json) end
10592: Fix nondeterministic form name in spec
diff --git a/lib/acts_as_tenant/controller_extensions.rb b/lib/acts_as_tenant/controller_extensions.rb index abc1234..def5678 100644 --- a/lib/acts_as_tenant/controller_extensions.rb +++ b/lib/acts_as_tenant/controller_extensions.rb @@ -1,52 +1,48 @@ module ActsAsTenant module ControllerExtensions - extend ActiveSupport::Concern - included do - helper_method :current_tenant - end + helper_method :current_tenant + - module ClassMethods - - # this method allows setting the current_account by reading the subdomain and looking - # it up in the tenant-model passed to the method (defaults to Account). The method will - # look for the subdomain in a column referenced by the second argument (defaults to subdomain). - def set_current_tenant_by_subdomain(tenant = :account, column = :subdomain ) - self.class_eval do - cattr_accessor :tenant_class, :tenant_column - attr_accessor :current_tenant - end - - self.tenant_class = tenant.to_s.capitalize.constantize - self.tenant_column = column.to_sym - - self.class_eval do - before_filter :find_tenant_by_subdomain - - private - def find_tenant_by_subdomain - ActsAsTenant.current_tenant = tenant_class.where(tenant_column => request.subdomains.first).first - @current_tenant_instance = ActsAsTenant.current_tenant - end - end + + # this method allows setting the current_account by reading the subdomain and looking + # it up in the tenant-model passed to the method (defaults to Account). The method will + # look for the subdomain in a column referenced by the second argument (defaults to subdomain). + def set_current_tenant_by_subdomain(tenant = :account, column = :subdomain ) + self.class_eval do + cattr_accessor :tenant_class, :tenant_column + attr_accessor :current_tenant end - def set_current_tenant_to(current_tenant_object) - self.class_eval do - cattr_accessor :tenant_class - attr_accessor :current_tenant - before_filter lambda { @current_tenant_instance = ActsAsTenant.current_tenant = current_tenant_object } - end + self.tenant_class = tenant.to_s.capitalize.constantize + self.tenant_column = column.to_sym + + self.class_eval do + before_filter :find_tenant_by_subdomain + + private + def find_tenant_by_subdomain + ActsAsTenant.current_tenant = tenant_class.where(tenant_column => request.subdomains.first).first + @current_tenant_instance = ActsAsTenant.current_tenant + end end + end - # helper method to have the current_tenant available in the controller - def current_tenant - ActsAsTenant.current_tenant + def set_current_tenant_to(current_tenant_object) + self.class_eval do + cattr_accessor :tenant_class + attr_accessor :current_tenant + before_filter lambda { @current_tenant_instance = ActsAsTenant.current_tenant = current_tenant_object } end - - ActiveSupport.on_load(:action_controller) do - helper_method :current_tenant - end + end + + # helper method to have the current_tenant available in the controller + def current_tenant + @current_tenant_instance + end + + ActiveSupport.on_load(:action_controller) do + helper_method :current_tenant end end end
Fix to get current_tenant working3
diff --git a/lib/administrate/field/belongs_to_search.rb b/lib/administrate/field/belongs_to_search.rb index abc1234..def5678 100644 --- a/lib/administrate/field/belongs_to_search.rb +++ b/lib/administrate/field/belongs_to_search.rb @@ -5,6 +5,8 @@ module Field class BelongsToSearch < Administrate::Field::BelongsTo class Engine < ::Rails::Engine + Engine.config.assets.precompile << 'belongs_to_search.js' + Administrate::Engine.add_javascript 'belongs_to_search.js' end def associated_resource_options
[Assets] Make sure assets are properly added
diff --git a/site-cookbooks/rapidftr/recipes/default.rb b/site-cookbooks/rapidftr/recipes/default.rb index abc1234..def5678 100644 --- a/site-cookbooks/rapidftr/recipes/default.rb +++ b/site-cookbooks/rapidftr/recipes/default.rb @@ -18,15 +18,14 @@ action :pull tag node.rapidftr.tag cmd_timeout 30*60 - notifies :redeploy, "docker_container[#{node.rapidftr.image}]" - notifies :run, "rapidftr[docker-clean-unused-images]" + notifies :redeploy, "docker_container[#{node.rapidftr.image}]", :immediately end docker_container node.rapidftr.image do action :run tag node.rapidftr.tag container_name node.rapidftr.instance - port [ '80:80', '443:443', '6984:6984' ] + port %w(80:80 443:443 6984:6984) volume "/data/#{node.rapidftr.instance}:/data" detach true cmd_timeout 5*60 @@ -34,6 +33,6 @@ execute "docker-clean-unused-images" do action :run - command "docker images | grep -e '^<none>' | sed -E 's/<none> *<none> *([0-9a-z]+) *.*/\1/g' | xargs -I {} docker rmi {}" + command "docker images | grep -e '^<none>' | sed -E 's/<none> *<none> *([0-9a-z]+) *.*/\\1/g' | xargs -I {} docker rmi {}" ignore_failure true end
Use separate prod config for solr
diff --git a/spec/unit/honeybadger/backend/test_spec.rb b/spec/unit/honeybadger/backend/test_spec.rb index abc1234..def5678 100644 --- a/spec/unit/honeybadger/backend/test_spec.rb +++ b/spec/unit/honeybadger/backend/test_spec.rb @@ -15,6 +15,14 @@ it { should respond_to :notifications } + describe "#notifications" do + it "sets a default key value rather than just return one" do + expect(instance.notifications).not_to have_key(:foo) + expect(instance.notifications[:foo]).to eq [] + expect(instance.notifications).to have_key(:foo) + end + end + describe "#notify" do let(:notice) { double('Notice') }
Test cached key for test backend.
diff --git a/db/migrate/20130828171743_create_bz_query_entries.rb b/db/migrate/20130828171743_create_bz_query_entries.rb index abc1234..def5678 100644 --- a/db/migrate/20130828171743_create_bz_query_entries.rb +++ b/db/migrate/20130828171743_create_bz_query_entries.rb @@ -0,0 +1,17 @@+class CreateBzQueryEntries < ActiveRecord::Migration + def change + create_table :bz_query_entries do |t| + t.references :bz_query_output + t.string :bz_id + t.string :verion + t.string :pm_ack + t.string :devel_ack + t.string :qa_ack + t.string :doc_ack + t.string :status + + t.timestamps + end + add_index :bz_query_entries, :bz_query_output_id + end +end
Add new bz_query_entries migation file.
diff --git a/app/models/jellyfish_odl/service/server.rb b/app/models/jellyfish_odl/service/server.rb index abc1234..def5678 100644 --- a/app/models/jellyfish_odl/service/server.rb +++ b/app/models/jellyfish_odl/service/server.rb @@ -10,9 +10,10 @@ end def provision - # create key_pair name: service.uuid - # create security group (one per project) name: project-{id} - # create vpc (one per project) name: project-{id} + # SUCCESS OR FAIL NOTIFICATION + self.status = ::Service.defined_enums['status']['running'] + self.status_msg = 'running' + self.save end def start
Change status to running after provision
diff --git a/app/controllers/base_controller_decorator.rb b/app/controllers/base_controller_decorator.rb index abc1234..def5678 100644 --- a/app/controllers/base_controller_decorator.rb +++ b/app/controllers/base_controller_decorator.rb @@ -3,7 +3,7 @@ def save_search - keywords = @searcher.try :keywords + keywords = @searcher.try!(:keywords) if @products.present? and keywords.present? query = Spree::Suggestion.find_or_initialize_by_keywords(keywords)
Use “try!” instead of “try” since it’s more reliable
diff --git a/app/mailers/nopassword/no_password_emails.rb b/app/mailers/nopassword/no_password_emails.rb index abc1234..def5678 100644 --- a/app/mailers/nopassword/no_password_emails.rb +++ b/app/mailers/nopassword/no_password_emails.rb @@ -1,6 +1,6 @@ module Nopassword class NoPasswordEmails < ActionMailer::Base - include ApplicationHelper + include Nopassword::ApplicationHelper default :from => 'nopassword@alexsmolen.com', :return_path => 'nopassword@alexsmolen.com'
Use proper syntax for including helpers
diff --git a/app/presenters/dspace/community_presenter.rb b/app/presenters/dspace/community_presenter.rb index abc1234..def5678 100644 --- a/app/presenters/dspace/community_presenter.rb +++ b/app/presenters/dspace/community_presenter.rb @@ -9,7 +9,7 @@ end def metadata_fields - @metadata_fields ||= Dspace::MetadataFieldRegistry.where(metadata_field_id: Dspace::MetadataValue.where(item_id: @items.pluck("item_id")).distinct.pluck("metadata_field_id")) + @metadata_fields ||= Dspace::MetadataFieldRegistry.where(metadata_field_id: Dspace::MetadataValue.where(item_id: items.pluck("item_id")).distinct.pluck("metadata_field_id")) end end end
Change variable ref to method
diff --git a/ember_devise_simple_auth.gemspec b/ember_devise_simple_auth.gemspec index abc1234..def5678 100644 --- a/ember_devise_simple_auth.gemspec +++ b/ember_devise_simple_auth.gemspec @@ -14,7 +14,7 @@ s.description = "This gem enhances the stock Devise::SessionsController to be slightly more ajax friendly." - s.files = Dir["support/rails/{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"] + s.files = Dir["lib/**/*", "support/rails/{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"] s.test_files = Dir["test/**/*"] s.add_dependency "devise", ">= 3.0.0"
Add lib directory to gemspec
diff --git a/3/ruby/code.rb b/3/ruby/code.rb index abc1234..def5678 100644 --- a/3/ruby/code.rb +++ b/3/ruby/code.rb @@ -1,46 +1,65 @@ #!/usr/bin/env ruby -def find_factors_of_an_integer integer, array_of_factors = [] - - for i in 2..integer - if integer % i == 0 - integer = integer / i - if !array_of_factors.include?(i) - array_of_factors.push(i) +# def find_factors_of_an_integer integer, array_of_factors = [] +# +# for i in 2..integer +# if integer % i == 0 +# integer = integer / i +# if !array_of_factors.include?(i) +# array_of_factors.push(i) +# end +# find_factors_of_an_integer(integer, array_of_factors) +# break +# end +# end +# +# return array_of_factors +# +# end +# +# def find_primes_in_an_array array +# +# array_of_primes = Array.new +# +# array.each do |item| +# counter = 0 +# one_lower_than_item = item - 1 +# for i in 2...one_lower_than_item +# if item % i == 0 +# counter = counter + 1 +# end +# end +# +# if counter == 0 +# array_of_primes.push(item) +# end +# end +# +# array_of_primes.delete(1) +# +# return array_of_primes.sort +# +# end +# +# +# factors = find_factors_of_an_integer(600851475143) +# puts find_primes_in_an_array(factors) + +def is_prime number + if number >= 2 + # numbers greater than or equal to 2 may be prime + square_root = Math.sqrt(number).to_i + + for i in 2..square_root + if number % i == 0 + return false end - find_factors_of_an_integer(integer, array_of_factors) - break end + return true + else + # numbers less than 2 are not prime + return false end - - return array_of_factors - end -def find_primes_in_an_array array - - array_of_primes = Array.new - - array.each do |item| - counter = 0 - one_lower_than_item = item - 1 - for i in 2...one_lower_than_item - if item % i == 0 - counter = counter + 1 - end - end - - if counter == 0 - array_of_primes.push(item) - end - end - - array_of_primes.delete(1) - - return array_of_primes.sort - -end - - - # factors = find_factors_of_an_integer(600851475143) - # puts find_primes_in_an_array(factors)+puts is_prime 101
Remove whitespace in problem 3
diff --git a/cookbooks/universe_ubuntu/spec/unit/recipes/default_spec.rb b/cookbooks/universe_ubuntu/spec/unit/recipes/default_spec.rb index abc1234..def5678 100644 --- a/cookbooks/universe_ubuntu/spec/unit/recipes/default_spec.rb +++ b/cookbooks/universe_ubuntu/spec/unit/recipes/default_spec.rb @@ -9,7 +9,7 @@ describe 'universe_ubuntu::default' do context 'When all attributes are default, on an Ubuntu' do before do - stub_command("[ -x /home/vagrant/anaconda3/bin/conda ]").and_return(0) + stub_command('[ -x /home/vagrant/anaconda3/bin/conda ]').and_return(0) end let(:chef_run) do @@ -23,22 +23,22 @@ end pkgs = %w(golang - libjpeg-turbo8-dev - make - tmux - htop - chromium-browser - git - cmake - zlib1g-dev - libjpeg-dev - xvfb - libav-tools - xorg-dev - python-opengl - libboost-all-dev - libsdl2-dev - swig) + libjpeg-turbo8-dev + make + tmux + htop + chromium-browser + git + cmake + zlib1g-dev + libjpeg-dev + xvfb + libav-tools + xorg-dev + python-opengl + libboost-all-dev + libsdl2-dev + swig) pkgs.each do |name| it "install #{name} package" do
Use simple quote when don't need interpolation, indentation
diff --git a/Casks/prezi.rb b/Casks/prezi.rb index abc1234..def5678 100644 --- a/Casks/prezi.rb +++ b/Casks/prezi.rb @@ -5,7 +5,7 @@ # akamaihd.net is the official download host per the vendor homepage url "https://prezi-a.akamaihd.net/desktop/Prezi#{version}.dmg" name 'Prezi' - homepage 'http://www.prezi.com/' + homepage 'https://prezi.com/' license :unknown # todo: change license and remove this comment; ':unknown' is a machine-generated placeholder app 'Prezi.app'
Fix homepage to use SSL in Prezi Cask The HTTP URL is already getting redirected to HTTPS. Using the HTTPS URL directly makes it more secure and saves a HTTP round-trip.
diff --git a/spec/first_letters_spec.rb b/spec/first_letters_spec.rb index abc1234..def5678 100644 --- a/spec/first_letters_spec.rb +++ b/spec/first_letters_spec.rb @@ -16,4 +16,9 @@ matcher = ABCing::FirstLetters.new(['Cobra', 'Acid', 'Bee']) expect(matcher.letters).to eq(['A', 'B', 'C']) end + + it 'Returns an empty result' do + matcher = ABCing::FirstLetters.new([]) + expect(matcher.letters).to eq([]) + end end
Test edgecase where an empty result is returned for FirstLetters
diff --git a/script/import-customers.rb b/script/import-customers.rb index abc1234..def5678 100644 --- a/script/import-customers.rb +++ b/script/import-customers.rb @@ -0,0 +1,51 @@+# frozen_string_literal: true + +# Read customer entries in CSV format from STDIN and create those records in +# the database. Example: +# +# rails runner script/import-customers.rb 3359 < FND-customers-Emails.csv +# +# This script was written for a once-off import. If we want to perform this +# task more often, we can make it more flexible and eventually add a +# feature to the user interface. +require 'csv' + +enterprise_id = ARGV.first + +def check_enterprise_exists(id) + enterprise = Enterprise.find(id) + puts "Importing customers for #{enterprise.name}:" +end + +def import_customer(row, enterprise_id) + email = row["Email"].downcase + tag = row["Tag"] + + print email + customer = find_or_create_customer(email, enterprise_id) + add_tag(customer, tag) + puts "" +end + +def find_or_create_customer(email, enterprise_id) + Customer.find_or_create_by( + email: email, + enterprise_id: enterprise_id, + ) { print " - newly imported" } + print " - user exists" if Spree::User.where(email: email).exists? +end + +def add_tag(customer, tag) + return if tag.blank? + + customer.tag_list.add(tag) + customer.save! +end + +check_enterprise_exists(enterprise_id) + +CSV($stdin, headers: true, row_sep: "\r\n") do |csv| + csv.each do |row| + import_customer(row, enterprise_id) + end +end
Add example script for importing customers