diff
stringlengths
65
26.7k
message
stringlengths
7
9.92k
diff --git a/app/controllers/guest_users_controller.rb b/app/controllers/guest_users_controller.rb index abc1234..def5678 100644 --- a/app/controllers/guest_users_controller.rb +++ b/app/controllers/guest_users_controller.rb @@ -8,6 +8,16 @@ end def create + @guest_user = GuestUser.new(guest_user_params) + + if @guest_user.save + GuestsCleanupJob.set(wait: 10.seconds).perform_later(@guest_user) + redirect_to root_path + else + # flash[:notice] = @guest_user.errors.full_messages + flash[:notice] = @guest_user.errors.full_messages.to_sentence + redirect_to new_guest_users_path + end end def partial
Update guest users create action
diff --git a/app/controllers/import/base_controller.rb b/app/controllers/import/base_controller.rb index abc1234..def5678 100644 --- a/app/controllers/import/base_controller.rb +++ b/app/controllers/import/base_controller.rb @@ -8,7 +8,7 @@ namespace.add_owner(current_user) rescue ActiveRecord::RecordNotUnique, ActiveRecord::RecordInvalid namespace = Namespace.find_by_path_or_name(@target_namespace) - unless namespace.owner == current_user + unless current_user.can?(:create_projects, namespace) @already_been_taken = true return false end
Allow projects to be imported into namespaces user is master of.
diff --git a/lib/a2ws.rb b/lib/a2ws.rb index abc1234..def5678 100644 --- a/lib/a2ws.rb +++ b/lib/a2ws.rb @@ -5,6 +5,7 @@ $:.unshift File.join(File.dirname(__FILE__),'..','lib') require 'a2ws/base' +require 'a2ws/methodize' require 'a2ws/item' require 'a2ws/image' require 'a2ws/item_search'
Include the methodize file in the gem now.
diff --git a/app/service/neighborhood_services/vacancy_data/filters/tax_delinquent.rb b/app/service/neighborhood_services/vacancy_data/filters/tax_delinquent.rb index abc1234..def5678 100644 --- a/app/service/neighborhood_services/vacancy_data/filters/tax_delinquent.rb +++ b/app/service/neighborhood_services/vacancy_data/filters/tax_delinquent.rb @@ -0,0 +1,36 @@+class NeighborhoodServices::VacancyData::Filters::TaxDelinquent + START_YEAR = 2015 + + def initialize(data) + @addresses = data.dup + end + + def filtered_data + neighborhood_addresses = @addresses['data'] + + neighborhood_addresses.select { |address| + consecutive_years = 0 + current_address = address['street_address'] + + if current_address.present? + address['disclosure_attributes'] = [] + possible_years = Array(2012..2016).reverse + + possible_years.each do |year| + if address["county_delinquent_tax_#{year}"].to_f > 0 + address['disclosure_attributes'] << year + end + end + end + + address['consecutive_years'] = consecutive_years + + if address['disclosure_attributes'].present? + address['disclosure_attributes'].unshift('<b>Tax Delinquent Years</b>') + true + else + false + end + } + end +end
Fix Broken Tax Deinquent Link
diff --git a/feidee_utils.gemspec b/feidee_utils.gemspec index abc1234..def5678 100644 --- a/feidee_utils.gemspec +++ b/feidee_utils.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |s| s.name = 'feidee_utils' - s.version = '0.0.0' + s.version = '0.0.1' s.date = '2015-05-01' s.summary = "Utils to extract useful information from Feidee Mymoney backup." s.description = "Feidee Utils provides a set of ActiveReocrd-like classes to read Feidee private backups (.kbf files). It also provides a better abstraction to the general format of transaction-account style data."
Bump version up to 0.0.1.
diff --git a/test/partial_finder_test.rb b/test/partial_finder_test.rb index abc1234..def5678 100644 --- a/test/partial_finder_test.rb +++ b/test/partial_finder_test.rb @@ -1,11 +1,16 @@ require 'test_helper' describe Lotus::View::Rendering::PartialFinder do - it 'finds the correct partial' do + it 'finds the correct partial in the same directory as the parent view' do partial_finder = Lotus::View::Rendering::PartialFinder.new(Organisations::OrderTemplates::Action, partial: 'partial', format: 'html') partial_finder.find.render(format: 'html').must_match 'Order Template Partial' partial_finder = Lotus::View::Rendering::PartialFinder.new(Organisations::Action, partial: 'partial', format: 'html') partial_finder.find.render(format: 'html').must_match 'Organisation Partial' end + + it 'finds the correct partial in a different directory to the parent view' do + partial_finder = Lotus::View::Rendering::PartialFinder.new(Organisations::OrderTemplates::Action, partial: 'shared/sidebar', format: 'html') + partial_finder.find.render(format: 'html').must_match '<div id="sidebar"></div>' + end end
Add a new test for PartialFinder and shared partials
diff --git a/lib/flop.rb b/lib/flop.rb index abc1234..def5678 100644 --- a/lib/flop.rb +++ b/lib/flop.rb @@ -6,7 +6,11 @@ module Flop class << self - attr_accessor :repo + attr_writer :repo + + def repo + @repo ||= Flop::Repository::Memory.new + end def [](feature) Flop::Feature.new(feature)
Use a memory repository by default
diff --git a/spec/features/backend/flexible_content/duplicate_spec.rb b/spec/features/backend/flexible_content/duplicate_spec.rb index abc1234..def5678 100644 --- a/spec/features/backend/flexible_content/duplicate_spec.rb +++ b/spec/features/backend/flexible_content/duplicate_spec.rb @@ -0,0 +1,54 @@+require 'rails_helper' +require_relative '../../pages/login_page' + +describe 'duplicate flexible content' do + let(:login_page) { Features::Pages::LoginPage.new } + let(:email_template_page) { Features::Pages::EmailTemplatePage.new } + + before(:each) do + login_page.visit + login_page.login + end + + it 'with success' do + article = create(:article) + widget = create(:content_text, content: 'This is my text.') + row = create(:content_row, rowable: article, locale: 'nl') + create( + :content_column, + row: row, + content_type: widget.class, + content_id: widget.id + ) + + visit "/backend/articles/#{article.id}/edit/fr" + expect(page).to have_content('Wil je de inhoud liever overnemen van een andere taal?') + + page.find('#content-rows').click_link('NL') + expect(page).to have_current_path("/backend/articles/#{article.id}/edit/fr") + expect(page).to have_content('De flexibele inhoud werd gedupliceerd.') + expect(page).to have_content('This is my text.') + end + + describe 'without success' do + it 'no such class' do + visit '/backend/content/duplicate/foo/1/nl/en' + expect(page).to have_current_path('/backend') + end + + it 'no record found for class and id combination' do + visit '/backend/content/duplicate/article/9999999/nl/en' + expect(page).to have_current_path('/backend') + end + + it 'bad source locale' do + article = create(:article) + expect { visit("/backend/content/duplicate/article/#{article.id}/foo/en") }.to raise_error(RuntimeError, 'No valid source locale provided (foo)') + end + + it 'bad destination locale' do + article = create(:article) + expect { visit("/backend/content/duplicate/article/#{article.id}/nl/foo") }.to raise_error(RuntimeError, 'No valid destination locale provided (foo)') + end + end +end
Add feature spec for the flexible content duplication.
diff --git a/similarweb.gemspec b/similarweb.gemspec index abc1234..def5678 100644 --- a/similarweb.gemspec +++ b/similarweb.gemspec @@ -22,6 +22,7 @@ spec.add_development_dependency "rake" spec.add_development_dependency "rspec" spec.add_development_dependency "pry" + spec.add_development_dependency "pry-byebug" spec.add_development_dependency "webmock" spec.add_runtime_dependency "faraday"
Add pry to debug code
diff --git a/app/controllers/auth_controller.rb b/app/controllers/auth_controller.rb index abc1234..def5678 100644 --- a/app/controllers/auth_controller.rb +++ b/app/controllers/auth_controller.rb @@ -7,7 +7,7 @@ def sign_in_action return error! "Missing parameters", 400 unless [:email, :password].none? { |x| params[x].blank? } - key = params[:email].include?('@') ? :email : :username + key = params[:email].include?('@') ? :email : :name user = User.where(key => params[:email]).first if user.valid_password?(params[:password])
Fix error when logging in by username
diff --git a/app/helpers/forem/topics_helper.rb b/app/helpers/forem/topics_helper.rb index abc1234..def5678 100644 --- a/app/helpers/forem/topics_helper.rb +++ b/app/helpers/forem/topics_helper.rb @@ -2,7 +2,7 @@ module TopicsHelper def link_to_latest_post(post) text = "#{time_ago_in_words(post.created_at)} #{t("ago_by")} #{post.user}" - link_to text, forem.forum_topic_path(post.topic.forum, post.topic, :anchor => "post-#{post.id}") + link_to text, forum_topic_path(post.topic.forum, post.topic, :anchor => "post-#{post.id}") end end end
Remove forem prefix from forum_topic_path call in link_to_latest_post
diff --git a/app/mailers/organization_mailer.rb b/app/mailers/organization_mailer.rb index abc1234..def5678 100644 --- a/app/mailers/organization_mailer.rb +++ b/app/mailers/organization_mailer.rb @@ -1,6 +1,6 @@ class OrganizationMailer < ActionMailer::Base - default :from => %{"#{ORG::NAME}" <noreply@#{ORG::DOMAIN}>} - default :reply_to => %{"#{ORG::NAME} Support" <#{ORG::EMAIL}>} + default :from => %{"#{ORG::NAME}" <#{ORG::EMAIL}>} + default :reply_to => %{"#{ORG::NAME}" <#{ORG::EMAIL}>} # If we don't define a Message-ID header, ActionMailer generates one for us. # The Message-ID generated by ActionMailer uses the machine hostname as the domain.
Allow for emails to be verified
diff --git a/app/serializers/post_serializer.rb b/app/serializers/post_serializer.rb index abc1234..def5678 100644 --- a/app/serializers/post_serializer.rb +++ b/app/serializers/post_serializer.rb @@ -1,5 +1,5 @@ class PostSerializer < BaseSerializer - attributes :id, :title, :text, :published_at + attributes :id, :title, :text, :published_at, :author_name def id object.slug
Add author name to the serializer
diff --git a/lib/brightbox-cli/server_groups.rb b/lib/brightbox-cli/server_groups.rb index abc1234..def5678 100644 --- a/lib/brightbox-cli/server_groups.rb +++ b/lib/brightbox-cli/server_groups.rb @@ -34,7 +34,7 @@ end def self.get(id) - conn.server_groups.get id + conn.get_server_group id end def self.all
Use a request to fetch a server group
diff --git a/lib/openstax/rescue_from/logger.rb b/lib/openstax/rescue_from/logger.rb index abc1234..def5678 100644 --- a/lib/openstax/rescue_from/logger.rb +++ b/lib/openstax/rescue_from/logger.rb @@ -23,10 +23,6 @@ record_system_error!("Exception cause") end end - - def config - RescueFrom.configuration - end end end end
Remove unused config method in Logger
diff --git a/gravatar-api.gemspec b/gravatar-api.gemspec index abc1234..def5678 100644 --- a/gravatar-api.gemspec +++ b/gravatar-api.gemspec @@ -7,18 +7,15 @@ spec.version = VERSION spec.authors = ["Jesse Herrick"] spec.email = ["jessegrantherrick@gmail.com"] - spec.description = %q{Easy, object oriented Gravatar API access.} - spec.summary = spec.description - spec.homepage = "https://github.com/JesseHerrick/jekyll-ftp" + spec.description = %q{A library for easy, object oriented Gravatar API access.} + spec.summary = %q{Easily access the Gravatar API in an object oriented way.} + spec.homepage = "https://github.com/JesseHerrick/gravatar-api" spec.license = "MIT" spec.files = `git ls-files`.split($/) - spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - - spec.add_runtime_dependency('colorize') - spec.add_runtime_dependency('launchy') spec.add_development_dependency('bundler') spec.add_development_dependency('rake') + spec.add_development_dependency('colorize') end
Add some things to the gemspec.
diff --git a/lib/ab_admin/menu/builder.rb b/lib/ab_admin/menu/builder.rb index abc1234..def5678 100644 --- a/lib/ab_admin/menu/builder.rb +++ b/lib/ab_admin/menu/builder.rb @@ -4,8 +4,9 @@ include ::Singleton def self.draw(&block) - I18n.locale = AbAdmin.locale if AbAdmin.locale - instance.instance_eval &block if block_given? + I18n.with_locale AbAdmin.locale do + instance.instance_eval &block if block_given? + end end def self.render(*args)
Use with_locale for menu draw
diff --git a/jekyll-typographic-apostrophe.rb b/jekyll-typographic-apostrophe.rb index abc1234..def5678 100644 --- a/jekyll-typographic-apostrophe.rb +++ b/jekyll-typographic-apostrophe.rb @@ -7,7 +7,7 @@ private def convert(page_or_post) - page_or_post.content.gsub!(/(\w)('|&#39|&apos;)/, '\1&rsquo;') + page_or_post.content.gsub!(/(\w)('|&#39|&apos;)(\w| |$)/, '\1&rsquo;\3') end end end
Make it harder to accidently convert ' inside code blocks
diff --git a/lib/core/repositories/api.rb b/lib/core/repositories/api.rb index abc1234..def5678 100644 --- a/lib/core/repositories/api.rb +++ b/lib/core/repositories/api.rb @@ -18,6 +18,7 @@ self.connection = Faraday.new(options) do |faraday| faraday.request :json faraday.request :request_id + faraday.request :retry faraday.response :raise_error faraday.response :json
Add retry middleware to API repository
diff --git a/lib/eye/patch/capistrano3.rb b/lib/eye/patch/capistrano3.rb index abc1234..def5678 100644 --- a/lib/eye/patch/capistrano3.rb +++ b/lib/eye/patch/capistrano3.rb @@ -0,0 +1,46 @@+namespace :load do + + task :defaults do + set :eye_config, -> { "config/eye.yml" } + set :eye_bin, -> { "bundle exec eye-patch" } + set :eye_roles, -> { :app } + end +end + +namespace :eye do + + desc "Start eye with the desired configuration file" + task :load_config do + on roles(fetch(:eye_roles)) do + within current_path do + execute "#{fetch(:eye_bin)} l #{fetch(:eye_config)}" + end + end + end + + desc "Stop eye and all of its monitored tasks" + task :stop do + on roles(fetch(:eye_roles)) do + within current_path do + execute "#{fetch(:eye_bin)} stop all && #{fetch(:eye_bin)} q" + end + end + end + + desc "Restart all tasks monitored by eye" + task :restart do + on roles(fetch(:eye_roles)) do + within current_path do + execute "#{fetch(:eye_bin)} r all" + end + end + end +end + +if fetch(:eye_default_hooks, true) + after "deploy:stop", "eye:stop" + after "deploy:start", "eye:load_config" + before "deploy:restart", "eye:restart" +end + +before "eye:restart", "eye:load_config"
Add capistrano extension file for Capistrano v3
diff --git a/lib/hash_builder/template.rb b/lib/hash_builder/template.rb index abc1234..def5678 100644 --- a/lib/hash_builder/template.rb +++ b/lib/hash_builder/template.rb @@ -11,12 +11,18 @@ def self.call (template) render_code = <<-RUBY -(HashBuilder.build_with_env(scope: self, locals: local_assigns) do +HashBuilder.build_with_env(scope: self, locals: local_assigns) do #{template.source} -end) +end RUBY if !is_partial?(template) - render_code = "JSON.generate(#{render_code})" + # ActiveModel defines #as_json in a way, that is not compatible + # with JSON. + if defined?(ActiveModel) + render_code = "ActiveSupport::JSON.encode(#{render_code})" + else + render_code = "JSON.generate(#{render_code})" + end end render_code @@ -28,6 +34,6 @@ end end -if defined?(Rails) +if defined?(ActionView) ActionView::Template.register_template_handler :json_builder, HashBuilder::Template end
Work around an ActiveModel bug
diff --git a/lib/cccb/modules/choice.rb b/lib/cccb/modules/choice.rb index abc1234..def5678 100644 --- a/lib/cccb/modules/choice.rb +++ b/lib/cccb/modules/choice.rb @@ -8,11 +8,16 @@ def module_load add_command :choice, "choose" do |message, args| choices = args.join(' ').split( /(?:\s+(?:\s*(?:x?or(?=\W))\s*)+\s*|,)+\s*/ ) - message.reply( if message.user.get_setting("options", "tease_me") and rand <= (get_setting("options", "tease_frequency")||0.1) - "Whichever one makes you happy, okay?!" - else - choices[ SecureRandom.random_number( choices.length ) ] - end ) + + if message.user.get_setting("options", "tease_me") + frequency = message.user.get_setting("options","tease_frequency") || 0.1 + if rand <= frequency.to_f + message.reply "Whichever one makes you happy, okay?!" + next + end + end + + message.reply( choices[ SecureRandom.random_number( choices.length ) ] ) end add_help(
Make user frequency option work
diff --git a/week-4/calculate-grade/my_solution.rb b/week-4/calculate-grade/my_solution.rb index abc1234..def5678 100644 --- a/week-4/calculate-grade/my_solution.rb +++ b/week-4/calculate-grade/my_solution.rb @@ -1,6 +1,6 @@ # Calculate a Grade -# I worked on this challenge [by myself]. +# I worked on this challenge [with Clinton Weber]. # Your Solution Below
Add credit fro Clinton on Challenge
diff --git a/lib/gakubuchi/fileutils.rb b/lib/gakubuchi/fileutils.rb index abc1234..def5678 100644 --- a/lib/gakubuchi/fileutils.rb +++ b/lib/gakubuchi/fileutils.rb @@ -17,7 +17,7 @@ private def logging(message) - ::Logger.new(STDOUT).info(message) + ::Logger.new(::STDOUT).info(message) end end end
Add prefix "::" to STDOUT for consistency
diff --git a/lib/rusic/uploaders/asset.rb b/lib/rusic/uploaders/asset.rb index abc1234..def5678 100644 --- a/lib/rusic/uploaders/asset.rb +++ b/lib/rusic/uploaders/asset.rb @@ -8,10 +8,10 @@ private def params - { asset: { file: file } } + { asset: { file: asset } } end - def file + def asset File.open(file.pathname.to_s, 'rb') end end
Use method name that doesn't clash with file
diff --git a/lib/simctl/command/create.rb b/lib/simctl/command/create.rb index abc1234..def5678 100644 --- a/lib/simctl/command/create.rb +++ b/lib/simctl/command/create.rb @@ -25,6 +25,7 @@ def reset_device(name, device_type, runtime) begin list_devices.where(name: name, os: runtime.name).each do |device| + device.kill! device.shutdown! if device.state != 'Shutdown' device.delete! end
Make reset_device also kill the device
diff --git a/lib/travis/logs/existence.rb b/lib/travis/logs/existence.rb index abc1234..def5678 100644 --- a/lib/travis/logs/existence.rb +++ b/lib/travis/logs/existence.rb @@ -21,7 +21,9 @@ end def occupied!(channel_name) - redis.set(key(channel_name), true) + key = self.key(channel_name) + redis.set(key, true) + redis.expire(key, 6 * 3600) end def occupied?(channel_name)
Expire occupation keys after 6 hours
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 @@ -1,14 +1,16 @@ class PagesController < ApplicationController append_view_path "pages" layout :layout_by_path + + def index + render :index, layout: "homepage" + end def show @page = Page.new(view_context, params[:path]) # If the page doesn't exist, throw a 404 raise ActionController::RoutingError.new("The documentation page `#{@page.basename}` does not exist") unless @page.exists? - - # For the homepage, render with a custom layout that doesn't include the sidebar etc # If there's another more correct version of the URL (for example, we changed `_` # to `-`), then redirect them to where they should be. @@ -32,9 +34,7 @@ helper_method :is_landing_page? def layout_by_path - if request.path == "/docs" - "homepage" - elsif request.path.starts_with? "/docs/apis/graphql" + if request.path.starts_with? "/docs/apis/graphql" "graphql" else "application"
Define index action for homepage - To remove the confusion of where the home page is defined, making it easier to understand what is happening - Also removing one branch in the layout conditional
diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index abc1234..def5678 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -1,31 +1,43 @@ class PostsController < ApplicationController - def index - @posts = Post.all + def index + @posts = Post.all + end + + def show + @post = Post.new + end + + def new + @post = Post.new + end + +# TODO: Fix spacing + + def create + @post = Post.create!(post_params) + if @post.save + tag = Tag.find(@post.tag_id) + + redirect_to "/moments/#{tag.name}" + end end - def show + def edit + end + + def update + + end + + def destroy + + end + + private + + def post_params + params.require(:post).permit! end - - def create - - end - - def new - - end - - def edit - - end - - def update - - end - - def destroy - - end - end
Add index, show, and create/new actions to PostsController
diff --git a/app/controllers/stats_controller.rb b/app/controllers/stats_controller.rb index abc1234..def5678 100644 --- a/app/controllers/stats_controller.rb +++ b/app/controllers/stats_controller.rb @@ -1,8 +1,9 @@ class StatsController < ApplicationController def index - procedures = Procedure.where(created_at: Time.current.all_quarter).group("date_trunc('day', created_at)").count - dossiers = Dossier.where(created_at: Time.current.all_quarter).group("date_trunc('day', created_at)").count + procedures = Procedure.where(:created_at => 90.days.ago..Time.now).group("date_trunc('day', created_at)").count + dossiers = Dossier.where(:created_at => 90.days.ago..Time.now).group("date_trunc('day', created_at)").count + @procedures = clean_hash(procedures) @dossiers = clean_hash(dossiers) end
Fix the where clause in Stats Now properly show the last 90 days of data instead of strict quarters. With the previous code, on the 1st of january, april, july and october, only one day of data would be shown.
diff --git a/lib/bud/errors.rb b/lib/bud/errors.rb index abc1234..def5678 100644 --- a/lib/bud/errors.rb +++ b/lib/bud/errors.rb @@ -1,6 +1,6 @@ module Bud # Root Bud exception type. - class BudError < Exception; end + class BudError < StandardError; end # Raised (at runtime) when a type mismatch occurs (e.g., supplying a # non-Enumerable object to the RHS of a Bud statement).
Make BudError subclass StandardError, not Exception. This is apparently what you're supposed to do when defining custom Ruby exceptions.
diff --git a/app/queries/project_filter_query.rb b/app/queries/project_filter_query.rb index abc1234..def5678 100644 --- a/app/queries/project_filter_query.rb +++ b/app/queries/project_filter_query.rb @@ -27,7 +27,9 @@ case current_filter when FILTER_TODO - items = items.todo + items = items + .todo + .order(id: :asc) # Retain the spreadsheet order when FILTER_FLAGGED items = items.flagged when FILTER_DONE
Order the project items the same way as the spreadsheet Order by the id field, as this will reflect the order in which the items were imported from the spreadsheet.
diff --git a/lib/synchro/synchronize.rb b/lib/synchro/synchronize.rb index abc1234..def5678 100644 --- a/lib/synchro/synchronize.rb +++ b/lib/synchro/synchronize.rb @@ -7,7 +7,7 @@ module ClassMethods def synchronize - after_create :synchronize + after_create :synchro_synchronize end include Synchro::Synchronize::InstanceMethods @@ -15,7 +15,7 @@ module InstanceMethods def synchro_synchronize - puts ">>>>>>>>>>>>>>>>>>> YAY! <<<<<<<<<<<<<<<<<<<<" + Rails.logger.info ">>>>>>>>>>>>>>>>>> YAY! <<<<<<<<<<<<<<<<<<" end private :synchro_synchronize
Fix method name; use logger instead of puts
diff --git a/lib/tasks/experiments.rake b/lib/tasks/experiments.rake index abc1234..def5678 100644 --- a/lib/tasks/experiments.rake +++ b/lib/tasks/experiments.rake @@ -1,6 +1,7 @@ # frozen_string_literal: true require "#{Rails.root}/lib/experiments/fall2017_cmu_experiment" +require "#{Rails.root}/lib/experiments/spring2018_cmu_experiment" namespace :experiments do desc 'Process Fall 2017 courses for CMU experiment'
Fix require statement for new experiment
diff --git a/lib/tasks/multi_spork.rake b/lib/tasks/multi_spork.rake index abc1234..def5678 100644 --- a/lib/tasks/multi_spork.rake +++ b/lib/tasks/multi_spork.rake @@ -1,12 +1,10 @@ require 'active_record' require 'multi_spork' -require 'ruby-debug' namespace :multi_spork do namespace :testdbs do desc "Clone schema of development db to test dbs to be used by multi_spork worker" task :clone => "db:load_config" do - debugger org_test_configuration = ActiveRecord::Base.configurations['test'] Rake::Task["db:schema:dump"].invoke @@ -15,7 +13,7 @@ test_configuration = org_test_configuration.clone test_configuration["database"] += (index+1).to_s ActiveRecord::Base.configurations['test'] = test_configuration - ["db:test:purge", "db:test:load_schema"].each do |task_name| + ["db:test:purge", "db:test:load_schema", "db:schema:load"].each do |task_name| Rake::Task[task_name].reenable end
Correct rake task used to clone test dbs
diff --git a/lib/flipper/ui.rb b/lib/flipper/ui.rb index abc1234..def5678 100644 --- a/lib/flipper/ui.rb +++ b/lib/flipper/ui.rb @@ -12,6 +12,9 @@ module Flipper module UI class << self + # Public: If you set this, the UI will always have a first breadcrumb that + # says "App" which points to this href. The href can be a path (ie: "/") + # or full url ("https://app.example.com/"). attr_accessor :application_breadcrumb_href end
Add docs for app crumb href option
diff --git a/test_changes.gemspec b/test_changes.gemspec index abc1234..def5678 100644 --- a/test_changes.gemspec +++ b/test_changes.gemspec @@ -28,7 +28,7 @@ spec.add_dependency "slop", '~> 4.2.0' - spec.add_development_dependency "rake", "~> 10.0" + spec.add_development_dependency 'rake', '~> 13.0.1', '>= 12.3.3' spec.add_development_dependency "rspec" spec.add_development_dependency "rubocop" end
Fix CVE-2020-8130 issue with rake
diff --git a/raven/spec/raven/raven_spec.rb b/raven/spec/raven/raven_spec.rb index abc1234..def5678 100644 --- a/raven/spec/raven/raven_spec.rb +++ b/raven/spec/raven/raven_spec.rb @@ -5,41 +5,41 @@ shared_examples 'a configured client' do it 'should have a server' do - @client.server.should == 'http://sentry.localdomain/sentry' + subject.server.should == 'http://sentry.localdomain/sentry' end it 'should have a public key' do - @client.public_key.should == '12345' + subject.public_key.should == '12345' end it 'should have a secret key' do - @client.secret_key.should == '67890' + subject.secret_key.should == '67890' end it 'should have a project ID' do - @client.project_id.should == '42' + subject.project_id.should == '42' end end context 'being initialized with a DSN string' do - before do - @client = Raven::Client.new('http://12345:67890@sentry.localdomain/sentry/42') + subject do + Raven::Client.new('http://12345:67890@sentry.localdomain/sentry/42') end it_should_behave_like 'a configured client' end context 'being initialized with a DSN option' do - before do - @client = Raven::Client.new(:dsn => 'http://12345:67890@sentry.localdomain/sentry/42') + subject do + Raven::Client.new(:dsn => 'http://12345:67890@sentry.localdomain/sentry/42') end it_should_behave_like 'a configured client' end context 'being initialized with options' do - before do - @client = Raven::Client.new(:server => 'http://sentry.localdomain/sentry', :public_key => '12345', :secret_key => '67890', :project_id => '42') + subject do + Raven::Client.new(:server => 'http://sentry.localdomain/sentry', :public_key => '12345', :secret_key => '67890', :project_id => '42') end it_should_behave_like 'a configured client'
Use the rspec concept of a subject.
diff --git a/lib/expando/project_template.rb b/lib/expando/project_template.rb index abc1234..def5678 100644 --- a/lib/expando/project_template.rb +++ b/lib/expando/project_template.rb @@ -5,6 +5,25 @@ def init! mkdir 'intents' mkdir 'entities' + + config_file_contents = <<-CONFIG_FILE +# API.AI credentials - add the credentials for your agent below +:client_access_token: REPLACE_WITH_TOKEN +:developer_access_token: REPLACE_WITH_TOKEN + CONFIG_FILE + + mkfile '.expando.rc.yaml', config_file_contents + + circleci_config_file_contents = <<-CIRCLECI_CONFIG_FILE +deployment: + staging: + branch: /.*/ + commands: + - bundle exec ./bin/expando update intents + - bundle exec ./bin/expando update entities + CIRCLECI_CONFIG_FILE + + mkfile 'circle.yaml', circleci_config_file_contents end private @@ -22,6 +41,23 @@ puts '✓'.colorize(:green) + " #{directory} directory created" end end + + # Attempt to create the specified file. Output progress to user. + # + # @param name [String] The name of the file. + # @param contents [String] The contents of the file. + def mkfile(name, contents) + full_path = File.join(Dir.pwd, name) + + if File.exist?(name) + puts '•'.colorize(:blue) + " #{name} file exists (skipping)" + else + File.open(full_path, 'w') do |file| + file << contents + end + puts '✓'.colorize(:green) + " #{name} file created" + end + end end end end
Enable creating config files when initializing project
diff --git a/features/steps/file_steps.rb b/features/steps/file_steps.rb index abc1234..def5678 100644 --- a/features/steps/file_steps.rb +++ b/features/steps/file_steps.rb @@ -21,6 +21,7 @@ FileUtils.chdir(directory) end After do + FileUtils.chdir(OriginalWorkingDirectory) cleanup.each { |dir| FileUtils.rm_rf(dir) } end
Move back to original dir before removing CWD
diff --git a/lib/ffi-gobject/ruby_closure.rb b/lib/ffi-gobject/ruby_closure.rb index abc1234..def5678 100644 --- a/lib/ffi-gobject/ruby_closure.rb +++ b/lib/ffi-gobject/ruby_closure.rb @@ -6,21 +6,21 @@ class RubyClosure < Closure BLOCK_STORE = {} - # Extend the standard GClosure layout with a field blockhash to store + # Extend the standard GClosure layout with a field block_id to store # the object_id of the associated block. class Struct < FFI::Struct layout :parent, Closure::Struct, 0, - :blockhash, :int64 + :block_id, :int64 end def block - BLOCK_STORE[self[:blockhash]] + BLOCK_STORE[self[:block_id]] end def block= block - h = block.object_id - BLOCK_STORE[h] = block - self[:blockhash] = h + id = block.object_id + BLOCK_STORE[id] = block + self[:block_id] = id end def invoke_block *args
Improve variable naming in RubyClosure.
diff --git a/lib/lanes/api/helper_methods.rb b/lib/lanes/api/helper_methods.rb index abc1234..def5678 100644 --- a/lib/lanes/api/helper_methods.rb +++ b/lib/lanes/api/helper_methods.rb @@ -4,7 +4,7 @@ module HelperMethods def bootstrap_data - Oj.dump Extension.bootstrap_data(self) + Oj.dump(Extension.bootstrap_data(self), mode: :compat) end def user_data
Use compat mode for hashes with symbol keys
diff --git a/lib/origen/errata/hw_erratum.rb b/lib/origen/errata/hw_erratum.rb index abc1234..def5678 100644 --- a/lib/origen/errata/hw_erratum.rb +++ b/lib/origen/errata/hw_erratum.rb @@ -32,7 +32,7 @@ # Software workaround object associated with erratum attr_accessor :sw_workaround - def initialize(id, overview = {}, status = {}, affected_items = {}, sw_workaround = {}) + def initialize(id, overview = {}, status = {}, affected_items = [], sw_workaround = {}) @id = id @title = overview[:title] @description = overview[:description]
Make affected_items an arrary instead of hash
diff --git a/lib/peddler/flat_file_parser.rb b/lib/peddler/flat_file_parser.rb index abc1234..def5678 100644 --- a/lib/peddler/flat_file_parser.rb +++ b/lib/peddler/flat_file_parser.rb @@ -41,7 +41,7 @@ def scrub_content content .force_encoding(encoding) - .encode('UTF-8', undef: :replace, replace: '?') + .encode('UTF-8', invalid: :replace, undef: :replace, replace: '?') end def summary?
Replace invalid chars when massaging encoding
diff --git a/cri.gemspec b/cri.gemspec index abc1234..def5678 100644 --- a/cri.gemspec +++ b/cri.gemspec @@ -15,7 +15,7 @@ s.files = Dir['[A-Z]*'] + Dir['{lib,test}/**/*'] + - [ 'cri.gemspec', '.gemtest' ] + [ 'cri.gemspec' ] s.require_paths = [ 'lib' ] s.add_dependency('colored', '>= 1.2') @@ -25,5 +25,5 @@ s.add_development_dependency('yard') s.rdoc_options = [ '--main', 'README.md' ] - s.extra_rdoc_files = [ 'ChangeLog', 'LICENSE', 'README.md', 'NEWS.md' ] + s.extra_rdoc_files = [ 'LICENSE', 'README.md', 'NEWS.md' ] end
Remove removed files from gemspec
diff --git a/lib/pubsubstub/redis_pub_sub.rb b/lib/pubsubstub/redis_pub_sub.rb index abc1234..def5678 100644 --- a/lib/pubsubstub/redis_pub_sub.rb +++ b/lib/pubsubstub/redis_pub_sub.rb @@ -13,8 +13,7 @@ end def publish(event) - RedisPubSub.pub.publish(key('pubsub'), event.to_json) - RedisPubSub.redis.zadd(key('scrollback'), event.id, event.to_json) + self.class.publish(@channel_name, event) end protected @@ -23,6 +22,11 @@ end class << self + def publish(channel_name, event) + RedisPubSub.pub.publish("#{channel_name}.pubsub", event.to_json) + RedisPubSub.redis.zadd("#{channel_name}.scrollback", event.id, event.to_json) + end + def redis @redis ||= redis_connection end
Make it easier to publish from elsewhere
diff --git a/lib/rom/support/class_macros.rb b/lib/rom/support/class_macros.rb index abc1234..def5678 100644 --- a/lib/rom/support/class_macros.rb +++ b/lib/rom/support/class_macros.rb @@ -7,8 +7,6 @@ args.each do |name| mod.module_eval <<-RUBY, __FILE__, __LINE__ + 1 - @@macros = [#{args.map(&:inspect).join(', ')}] - def #{name}(value = Undefined) if value == Undefined @#{name} @@ -16,21 +14,25 @@ @#{name} = value end end + RUBY + end - def inherited(klass) - super - macros.each do |name| - klass.public_send(name, public_send(name)) - end + mod.module_eval <<-RUBY, __FILE__, __LINE__ + 1 + @@macros = #{args.inspect} + + def inherited(klass) + super + macros.each do |name| + klass.public_send(name, public_send(name)) end + end - def macros - @@macros || [] - end - RUBY + def macros + @@macros + end + RUBY - extend(mod) - end + extend(mod) end end end
Fix code generation of ClassMacros Before this commit ClassMacros defined one `inherited` hook once per macro. This commit separates the definition of accessors and other definitions.
diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index abc1234..def5678 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -16,7 +16,7 @@ # end ActiveSupport::Inflector.inflections do |inflect| - inflect.plural /Secretary of State for (.*)/, "Secretaries of State for \\1" + inflect.plural /Secretary of State( for .*)?/, "Secretaries of State\\1" end ActiveSupport::Inflector.inflections do |inflect|
Generalize the plural for secretary of state
diff --git a/lib/sensu-plugins-kubernetes.rb b/lib/sensu-plugins-kubernetes.rb index abc1234..def5678 100644 --- a/lib/sensu-plugins-kubernetes.rb +++ b/lib/sensu-plugins-kubernetes.rb @@ -20,12 +20,40 @@ long: '--api-version', default: 'v1' + option :ca_file, + description: 'CA file to use', + long: '--ca-file CA-FILE' + + option :bearer_token, + description: 'Kubernetes serviceaccount token', + long: '--bearer-token TOKEN' + + option :bearer_token_file, + description: 'Kubernetes serviceaccount token file', + long: '--bearer-token-file TOKEN-FILE' + def get_client(cli) api_server = cli.config[:api_server] api_version = cli.config[:api_version] + ssl_options = {} + auth_options = {} + + if cli.config.key?(:ca_file) + ssl_options[:ca_file] = cli.config[:ca_file] + end + + if cli.config.key?(:bearer_token) + auth_options[:bearer_token] = cli.config[:bearer_token] + elsif cli.config.key?(:bearer_token_file) + auth_options[:bearer_token_file] = + cli.config[:bearer_token_file] + end + begin - Kubeclient::Client.new(api_server, api_version) + Kubeclient::Client.new api_server, api_version, + ssl_options: ssl_options, + auth_options: auth_options rescue warning 'Unable to connect to Kubernetes API server' end
Add additional parameters for Kubernetes
diff --git a/lib/rails_uploads/types/image.rb b/lib/rails_uploads/types/image.rb index abc1234..def5678 100644 --- a/lib/rails_uploads/types/image.rb +++ b/lib/rails_uploads/types/image.rb @@ -53,7 +53,7 @@ end def store_path(*args) - ::File.join('images', (args[0] ? args[0].to_s : 'original')) + ::File.join('images', (args[0] ? args[0].to_s.gsub('_', '-') : 'original')) end end
Use dash in presets name
diff --git a/lib/rubycritic/analysers/reek.rb b/lib/rubycritic/analysers/reek.rb index abc1234..def5678 100644 --- a/lib/rubycritic/analysers/reek.rb +++ b/lib/rubycritic/analysers/reek.rb @@ -4,7 +4,7 @@ module Analyser class Reek < ::Reek::Examiner - DEFAULT_CONFIG_FILES = ["lib/rubycritic/analysers/config.reek"] + DEFAULT_CONFIG_FILES = [File.expand_path("../config.reek", __FILE__)] def initialize(paths) super(Array(paths), DEFAULT_CONFIG_FILES)
Make path to a config file relative to the current file
diff --git a/lib/friendly_id/slug_generator.rb b/lib/friendly_id/slug_generator.rb index abc1234..def5678 100644 --- a/lib/friendly_id/slug_generator.rb +++ b/lib/friendly_id/slug_generator.rb @@ -2,7 +2,6 @@ # The default slug generator offers functionality to check slug strings for # uniqueness and, if necessary, appends a sequence to guarantee it. class SlugGenerator - attr_accessor :model_class def initialize(scope) @scope = scope
Remove unused model_class attribute from SlugGenerator
diff --git a/db/seeds.rb b/db/seeds.rb index abc1234..def5678 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -17,7 +17,8 @@ "R" => "Non-resident (Canada only)" } -res = ask 'Would you like to seed use codes? [Y/n]' +res = defined?(ask) ? ask('Would you like to seed use codes? [Y/n]') : '' + if res == '' || res.downcase == 'y' unless Spree::AvalaraEntityUseCode.count >= 16
Fix undefined method `ask' ERROR
diff --git a/lib/lita/handlers/digitalocean.rb b/lib/lita/handlers/digitalocean.rb index abc1234..def5678 100644 --- a/lib/lita/handlers/digitalocean.rb +++ b/lib/lita/handlers/digitalocean.rb @@ -21,12 +21,12 @@ def dispatch(response) submodule_name, subcommand_name, *_args = response.args - submodule_class = SUBMODULES[submodule_name.downcase.to_sym] + submodule_class = SUBMODULES[submodule_name.to_s.downcase.to_sym] if submodule_class submodule = submodule_class.new(self, client) - subcommand = subcommand_name.downcase.to_sym + subcommand = subcommand_name.to_s.downcase.to_sym if submodule.respond_to?(subcommand) begin
Convert incoming commands to strings in case they are nil.
diff --git a/db/seeds.rb b/db/seeds.rb index abc1234..def5678 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -4,6 +4,7 @@ User.destroy_all List.destroy_all Item.destroy_all +Recipe.destroy_all all_lists = [ "Jewel Osco - Sunday", @@ -36,6 +37,18 @@ "Eggs" ].map { |name| Item.create!(name: name) } + +all_recipes = [ + "Ma's Homemade Chili", + 'BMT', + "Breakfast Burrito", + "Moscow Mules", + "Pina Colada", + "Oven Baked Pizza", + "Tacos!", + "Recipe for Disaster" +] + users = [User.create!( :username => 'Jon', :password_hash => 'password'), User.create!( :username => 'Sean', @@ -49,4 +62,11 @@ list.save end + all_recipes.sample(2).map do |recipe_name| + recipe = user.recipes.create!(:name => recipe_name) + + recipe.items = all_items.sample(rand(3..7)) + recipe.save + end + end
Update seed file to include recipes
diff --git a/app/controllers/carto/builder/public/embeds_controller.rb b/app/controllers/carto/builder/public/embeds_controller.rb index abc1234..def5678 100644 --- a/app/controllers/carto/builder/public/embeds_controller.rb +++ b/app/controllers/carto/builder/public/embeds_controller.rb @@ -14,10 +14,10 @@ skip_before_filter :builder_users_only # This is supposed to be public even in beta - layout 'application_public_visualization_layout' + layout false def show - render 'show' + render 'show', layout: 'application_public_visualization_layout' end def show_protected
Fix layout of protected embed
diff --git a/spec/policies/neighborly/admin/admin_policy_spec.rb b/spec/policies/neighborly/admin/admin_policy_spec.rb index abc1234..def5678 100644 --- a/spec/policies/neighborly/admin/admin_policy_spec.rb +++ b/spec/policies/neighborly/admin/admin_policy_spec.rb @@ -4,18 +4,18 @@ subject { described_class } permissions :access? do - it 'should deny access if user is nil' do - should_not permit(nil, Neighborly::Admin) + it 'denies access if user is nil' do + expect(subject).not_to permit(nil, Neighborly::Admin) end - it 'should deny access if user is not admin' do - should_not permit(User.new, Neighborly::Admin) + it 'denies access if user is not admin' do + expect(subject).not_to permit(User.new, Neighborly::Admin) end - it 'should permit access if user is admin' do + it 'permits access if user is admin' do user = User.new user.admin = true - should permit(user, Neighborly::Admin) + expect(subject).to permit(user, Neighborly::Admin) end end end
Refactor admin policy to use expect
diff --git a/send_url_list_through_proxy.rb b/send_url_list_through_proxy.rb index abc1234..def5678 100644 --- a/send_url_list_through_proxy.rb +++ b/send_url_list_through_proxy.rb @@ -0,0 +1,16 @@+#!/usr/bin/env ruby + +# +# Requests a list of URLs through a proxy. +# + +require 'typhoeus' + +urls = File.open(ARGV.join).read.split("\n") +proxy = 'http://127.0.0.1:8080' + + +urls.each_with_index do |url, index| + response = Typhoeus.get(url, proxy: proxy, followlocation: true) + puts "#{index} - #{url} [#{response.code}]" +end
Add send urls through proxy script
diff --git a/backend/spec/routing/comable/admin/themes_routing_spec.rb b/backend/spec/routing/comable/admin/themes_routing_spec.rb index abc1234..def5678 100644 --- a/backend/spec/routing/comable/admin/themes_routing_spec.rb +++ b/backend/spec/routing/comable/admin/themes_routing_spec.rb @@ -0,0 +1,48 @@+describe Comable::Admin::ThemesController do + routes { Comable::Core::Engine.routes } + + let(:theme) { build(:theme) } + let(:path) { 'path/to/file.liquid' } + + describe 'routing' do + it 'routes to #index' do + expect(get: '/admin/themes').to route_to('comable/admin/themes#index') + end + + it 'routes to #new' do + expect(get: '/admin/themes/new').to route_to('comable/admin/themes#new') + end + + it 'routes to #show' do + expect(get: "/admin/themes/#{theme.name}").to route_to('comable/admin/themes#show', id: theme.name) + end + + it 'routes to #edit' do + expect(get: "/admin/themes/#{theme.name}/edit").to route_to('comable/admin/themes#edit', id: theme.name) + end + + it 'routes to #create' do + expect(post: '/admin/themes').to route_to('comable/admin/themes#create') + end + + it 'routes to #update' do + expect(put: "/admin/themes/#{theme.name}").to route_to('comable/admin/themes#update', id: theme.name) + end + + it 'routes to #tree' do + expect(get: "/admin/themes/#{theme.name}/tree").to route_to('comable/admin/themes#tree', id: theme.name) + end + + it 'routes to #show_file' do + expect(get: "/admin/themes/#{theme.name}/file/#{path}").to route_to('comable/admin/themes#show_file', id: theme.name, path: path) + end + + it 'routes to #update_file' do + expect(put: "/admin/themes/#{theme.name}/file/#{path}").to route_to('comable/admin/themes#update_file', id: theme.name, path: path) + end + + it 'routes to #use' do + expect(put: "/admin/themes/#{theme.name}/use").to route_to('comable/admin/themes#use', id: theme.name) + end + end +end
Add tests for the routing
diff --git a/lib/basil/skype_message.rb b/lib/basil/skype_message.rb index abc1234..def5678 100644 --- a/lib/basil/skype_message.rb +++ b/lib/basil/skype_message.rb @@ -8,7 +8,7 @@ (?<to>\w+)[,;:]\s+ # using punctuation )? (?<text>.*)$ # rest of message - /x + /mx attr_reader :chatname, :from_handle,
Return all lines of the BODY in SkypeMessage
diff --git a/spec/defines_spec_suite_tasks.rb b/spec/defines_spec_suite_tasks.rb index abc1234..def5678 100644 --- a/spec/defines_spec_suite_tasks.rb +++ b/spec/defines_spec_suite_tasks.rb @@ -33,6 +33,20 @@ end end end + + unless ruby_18? + require 'rspec/core/rake_task' + + desc "Run the unit tests" + RSpec::Core::RakeTask.new(:unit) do |t| + t.pattern = 'spec/suites/rspec_2/unit/**/*_spec.rb' + end + + desc "Run the functional (API) tests" + RSpec::Core::RakeTask.new(:functional) do |t| + t.pattern = 'spec/suites/rspec_2/functional/**/*_spec.rb' + end + end end namespace :travis do @@ -42,4 +56,8 @@ end end end + + def self.ruby_18? + RUBY_VERSION =~ /^1\.8/ + end end
Add rake tasks for running unit and functional tests
diff --git a/spec/factories/reading_groups.rb b/spec/factories/reading_groups.rb index abc1234..def5678 100644 --- a/spec/factories/reading_groups.rb +++ b/spec/factories/reading_groups.rb @@ -11,10 +11,5 @@ name "My Reading Group" description "The best one" end - - factory :public_reading_group do - name "Public Reading Group" - description "Public" - end end end
Remove unused factory for ReadingGroup
diff --git a/lib/forecast/collection.rb b/lib/forecast/collection.rb index abc1234..def5678 100644 --- a/lib/forecast/collection.rb +++ b/lib/forecast/collection.rb @@ -1,15 +1,15 @@ class Forecast class Collection < Array - def select_date(date) + def select_time(time) result = nil date_forecasts = self.select do |obj| - obj.date.to_date == date.to_date + obj.time.to_date == time.to_date end if date_forecasts.length == 0 return nil else hour_forecasts = date_forecasts.select do |obj| - obj.date.hour == obj.date.hour + obj.time.hour == obj.time.hour end if hour_forecasts.length > 0 return hour_forecasts.first @@ -17,10 +17,10 @@ return date_forecasts.first end return nil - end private + # Unused def seconds_between(date1, date2) ((Time.parse(date1.to_s) - Time.parse(date2.to_s)) / 3600).abs end
Select time instead of select date
diff --git a/spec/view_models/section_spec.rb b/spec/view_models/section_spec.rb index abc1234..def5678 100644 --- a/spec/view_models/section_spec.rb +++ b/spec/view_models/section_spec.rb @@ -0,0 +1,64 @@+describe Section do + + let(:title) { 'title' } + let(:paras) { %w{a b c} } + + it 'should initialize title' do + subject = Section.new title do + end + + subject.title.should == title + end + + it 'should create text block' do + subject = Section.new title do + block %w(a b c) + end + + subject.blocks.length.should == 1 + block = subject.blocks.first + + block.paragraphs.should contain_exactly *paras + block.heading.should be_nil + block.limit.should == 3 + end + + it 'should create heading block with limit' do + subject = Section.new title do + block 'heading', %w(a b c), limit: 5 + end + + subject.blocks.length.should == 1 + block = subject.blocks.first + + block.paragraphs.should contain_exactly *paras + block.heading.should == 'heading' + block.limit.should == 5 + end + + it 'should create extra block without heading' do + subject = Section.new title do + extra_block %w(a b c) + end + + subject.blocks.length.should == 1 + block = subject.blocks.first + + block.paragraphs.should contain_exactly *paras + block.heading.should be_nil + block.limit.should == 0 + end + + it 'should create extra block' do + subject = Section.new title do + extra_block 'heading', %w(a b c) + end + + subject.blocks.length.should == 1 + block = subject.blocks.first + + block.paragraphs.should contain_exactly *paras + block.heading.should == 'heading' + block.limit.should == 0 + end +end
Add unit test for section
diff --git a/calculators/bsa/bsa.rb b/calculators/bsa/bsa.rb index abc1234..def5678 100644 --- a/calculators/bsa/bsa.rb +++ b/calculators/bsa/bsa.rb @@ -5,8 +5,8 @@ weight = get_field_as_float :weight_in_kg height = get_field_as_float :height_in_m - raise FieldError.new('weight', 'must be greater than zero') if weight <= 0 - raise FieldError.new('height', 'must be greater than zero') if height <= 0 + fail FieldError.new('weight', 'must be greater than zero') if weight <= 0 + fail FieldError.new('height', 'must be greater than zero') if height <= 0 { value: ((weight * (height * 100)) / 3600) ** 0.5,
Use fail instead of raise to throw exceptions
diff --git a/activerecord/lib/active_record/associations/has_one_through_association.rb b/activerecord/lib/active_record/associations/has_one_through_association.rb index abc1234..def5678 100644 --- a/activerecord/lib/active_record/associations/has_one_through_association.rb +++ b/activerecord/lib/active_record/associations/has_one_through_association.rb @@ -4,10 +4,9 @@ class HasOneThroughAssociation < HasOneAssociation include ThroughAssociation - def replace(new_value) - create_through_record(new_value) - @target = new_value - loaded + def replace(record) + create_through_record(record) + self.target = record end private
Use self.target= in HasOneThroughAssociation too
diff --git a/lib/mortgage_calculator.rb b/lib/mortgage_calculator.rb index abc1234..def5678 100644 --- a/lib/mortgage_calculator.rb +++ b/lib/mortgage_calculator.rb @@ -9,6 +9,10 @@ mattr_accessor :stamp_duty_welsh_fix mattr_accessor :affordability_enabled + def self.stamp_duty_welsh_fix + @@stamp_duty_welsh_fix ||= lambda { |tool, locale| } + end + def self.configure yield self end
Revert "Revert "Default stamp duty welsh fix to a blank lambda"" This reverts commit 406b44dde3f2bec8431bd38babd783c2e6a85148.
diff --git a/lib/wlang/compiler/autospacing.rb b/lib/wlang/compiler/autospacing.rb index abc1234..def5678 100644 --- a/lib/wlang/compiler/autospacing.rb +++ b/lib/wlang/compiler/autospacing.rb @@ -28,9 +28,9 @@ when :static who.last =~ /\n/ when :wlang, :modulo - who[2..-1].any?{|s| multiline?(s)} + who[2..-1].any?{|s| s && multiline?(s)} else - who[1..-1].any?{|s| multiline?(s)} + who[1..-1].any?{|s| s && multiline?(s)} end end
Fix a bug in AutoScoping.
diff --git a/lita-talk.gemspec b/lita-talk.gemspec index abc1234..def5678 100644 --- a/lita-talk.gemspec +++ b/lita-talk.gemspec @@ -15,7 +15,7 @@ spec.require_paths = ["lib"] spec.add_runtime_dependency "lita", "~> 4.3" - spec.add_runtime_dependency "docomoru", "~> 0.1.3 " + spec.add_runtime_dependency "faraday" spec.add_development_dependency "bundler", "~> 1.3" spec.add_development_dependency "pry-byebug"
Use faraday instead of docomoru
diff --git a/spec/docstrings_spec.rb b/spec/docstrings_spec.rb index abc1234..def5678 100644 --- a/spec/docstrings_spec.rb +++ b/spec/docstrings_spec.rb @@ -1,11 +1,24 @@ require 'spec_helper' describe Docstrings do - it 'should have a version number' do - Docstrings::VERSION.should_not be_nil + class TestClass + def no_docstring + end + + def simple_docstring + """Simple""" + end end - it 'should do something useful' do - false.should be_true + def docstring_for_method(method_name) + TestClass.instance_method(method_name).docstring + end + + it "works with simple docstrings" do + docstring_for_method(:simple_docstring).should == "Simple" + end + + it "returns nil when no docstring" do + docstring_for_method(:no_docstring).should be_nil end end
Add basic spec for docstrings
diff --git a/lib/tasks/pixelfinder.rake b/lib/tasks/pixelfinder.rake index abc1234..def5678 100644 --- a/lib/tasks/pixelfinder.rake +++ b/lib/tasks/pixelfinder.rake @@ -0,0 +1,23 @@+require 'pixelfinder/image_client/image_crawler' + +namespace :pixelfinder do + namespace :save_images do + + desc "Save images from Flickr" + task :from_flickr, [:num_of_images] => [:environment] do |t, args| + PixelFinder::ImageClient::ImageCrawler.crawl( + 'flickr', + args[:num_of_images].to_i + ) + end + + desc "Save images from 500PX" + task :from_500px, [:num_of_images] => [:environment] do |t, args| + PixelFinder::ImageClient::ImageCrawler.crawl( + '500px', + args[:num_of_images].to_i + ) + end + + end +end
Add rake task for image crawler
diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb index abc1234..def5678 100644 --- a/spec/support/helpers.rb +++ b/spec/support/helpers.rb @@ -2,3 +2,7 @@ def branch(*args, &block) args.map { |sym| ActiveSupport::StringInquirer.new sym.to_s }.each(&block) end + +def mingo_id + last_response.headers['mingo_id'].to_i +end
Add 'mingo_id' as a proper spec helper.
diff --git a/spec/bin/churn_spec.rb b/spec/bin/churn_spec.rb index abc1234..def5678 100644 --- a/spec/bin/churn_spec.rb +++ b/spec/bin/churn_spec.rb @@ -2,7 +2,7 @@ describe "Churn command" do it "prints churn metrics as text by default" do - output = %x[ cd spec/samplerepo & churn ] + output = %x[ churn ] expect(output).to match /^Commits:\s*\d*\sTotal Churn:\s*\d*\sLines added:\s*\d*\sLines deleted:\s*\d*\s$/ end it "prints churn metrics as json" do
Change directory when testing default `churn` command
diff --git a/spec/factories/user.rb b/spec/factories/user.rb index abc1234..def5678 100644 --- a/spec/factories/user.rb +++ b/spec/factories/user.rb @@ -1,6 +1,6 @@ FactoryGirl.define do factory :user do |user| - sequence(:email) {|n| "barry#{n}@factory.com" } + sequence(:email) {|n| "barry#{n}@factory.example.com" } user.password "password" user.password_confirmation "password" end
Stop using non-example emails in factories Noticed this when setting up ds-auth app, which had copy-pasta setup.
diff --git a/spec/nod/asset_spec.rb b/spec/nod/asset_spec.rb index abc1234..def5678 100644 --- a/spec/nod/asset_spec.rb +++ b/spec/nod/asset_spec.rb @@ -0,0 +1,22 @@+ +require 'spec_helper' + +RSpec.describe Nod::Asset, fakefs: true do + let(:asset) { Nod::Asset } + let(:project_name) { 'test-project' } + + describe '::create_new_project' do + before do + base_files = ::File.join([Nod.root, '/base-files/*']) + + # include base files in fake file system + FakeFS::FileSystem.clone(base_files) + end + + it 'creates a directory for the project' do + asset.create_new_project(project_name) + + expect(Dir.exists?(project_name)).to be true + end + end +end
Add spec for '::create_new_project' Nod::Asset class method
diff --git a/spec/02_create_request_spec.rb b/spec/02_create_request_spec.rb index abc1234..def5678 100644 --- a/spec/02_create_request_spec.rb +++ b/spec/02_create_request_spec.rb @@ -0,0 +1,48 @@+require 'spec_helper' + +RSpec.describe "Creating Defence Request" do + specify "CSO creates a new Defence Request" do + visit SERVICE_APP_URI + + click_link "New request" + + within ".detainee" do + fill_in "Name", with: "Mannie Badder" + choose "Male" + fill_in "defence_request_date_of_birth_year", with: "1976" + fill_in "defence_request_date_of_birth_month", with: "01" + fill_in "defence_request_date_of_birth_day", with: "01" + fill_in "defence_request_detainee_address", + with: "House of the rising sun, Letsby Avenue, Right up my street, London, Greater London, XX1 1XX" + choose "defence_request_appropriate_adult_false" + choose "defence_request_interpreter_required_false" + end + + within ".case-details" do + fill_in "defence_request_investigating_officer_name", with: "Dave Mc.Copper" + fill_in "defence_request_investigating_officer_contact_number", with: "0207 111 0000" + fill_in "Custody number", with: "AN14574637587" + fill_in "Offences", with: "BadMurder" + fill_in "defence_request_circumstances_of_arrest", with: "He looked a bit shady" + choose "defence_request_fit_for_interview_true" + fill_in "defence_request_time_of_arrest_date", with: "02 Feb 2002" + fill_in "defence_request_time_of_arrest_hour", with: "02" + fill_in "defence_request_time_of_arrest_min", with: "02" + fill_in "defence_request_time_of_arrival_date", with: "01 Jan 2001" + fill_in "defence_request_time_of_arrival_hour", with: "01" + fill_in "defence_request_time_of_arrival_min", with: "01" + fill_in "defence_request_time_of_detention_authorised_date", with: "03 Mar 2003" + fill_in "defence_request_time_of_detention_authorised_hour", with: "03" + fill_in "defence_request_time_of_detention_authorised_min", with: "03" + end + + click_button "Create request" + + click_button "Submit request" + + expect(page.current_url).to eql("#{SERVICE_APP_URI}/dashboard") + + expect(page).to have_css(".name", text: "Mannie Badder") + expect(page).to have_css(".state", text: "Submitted") + end +end
Add first draft of the 'create request' test
diff --git a/spec/integration/smoke_test.rb b/spec/integration/smoke_test.rb index abc1234..def5678 100644 --- a/spec/integration/smoke_test.rb +++ b/spec/integration/smoke_test.rb @@ -1,77 +1,16 @@+require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') require File.dirname(__FILE__) + '/../../lib/mousetrap' require 'yaml' require 'activesupport' -# Requires supporting files with custom matchers and macros, etc, -# in ./support/ and its subdirectories. Dir["#{File.dirname(__FILE__)}/../support/**/*.rb"].each {|f| require f} settings = YAML.load_file(File.dirname(__FILE__) + '/settings.yml') Mousetrap.authenticate(settings['user'], settings['password']) Mousetrap.product_code = settings['product_code'] - - -all_customers = Mousetrap::Customer.all -puts all_customers.inspect -puts all_customers.to_yaml - -all_customers.each { |c| c.destroy } - -all_customers = Mousetrap::Customer.all -puts all_customers.inspect -puts all_customers.to_yaml - -__END__ - -code = 'maasdxgliu@example.com' -c = Mousetrap::Customer[code] -puts c.to_yaml -c.destroy - -puts '-' * 80 -c = Mousetrap::Customer[code] -puts c.to_yaml - - - - - -email = random_email_address -attributes = { - 'code' => email, - 'firstName' => 'Example', - 'lastName' => 'Customer', - 'email' => email, - 'subscription' => { - 'planCode' => 'TEST', - 'ccFirstName' => 'Jon', - 'ccLastName' => 'Larkowski', - 'ccNumber' => '4111111111111111', - 'ccExpiration' => '12-2012', - 'ccZip' => '90210' - } -} - -customer = Mousetrap::Customer.create attributes -puts customer - - - - -puts Mousetrap::Plan.all.to_yaml -puts Mousetrap::Customer['maasdxgliu@example.com'].to_yaml -puts Mousetrap::Plan['TEST'].to_yaml -puts Mousetrap::Customer.all.to_yaml - - -customers_hash = Mousetrap::Customer['maasdxgliu@example.com'] -customer_hash = customers_hash['customers']['customer'].slice 'firstName', 'lastName', 'email', 'code' -customer = Mousetrap::Customer.new customer_hash - -customer.first_name = random_string -puts customer.save! - -customer_hash = Mousetrap::Customer['maasdxgliu@example.com'] -puts customer_hash.to_yaml - +describe "The Wrapper Gem" do + it "works" do + true.should be_true + end +end
Remove spike code, will be proper RSpec soon
diff --git a/spec/multiple_instance_spec.rb b/spec/multiple_instance_spec.rb index abc1234..def5678 100644 --- a/spec/multiple_instance_spec.rb +++ b/spec/multiple_instance_spec.rb @@ -0,0 +1,32 @@+require 'spec_helper' + +describe Fabrication do + + context 'multiple instance' do + + let(:person1) { Fabricate(:person, :first_name => 'Jane') } + let(:person2) { Fabricate(:person, :first_name => 'John') } + + before(:all) do + Fabricator(:person) do + first_name { Faker::Name.first_name } + last_name { Faker::Name.last_name } + age { rand(100) } + end + end + + it 'person1 is named Jane' do + person1.first_name.should == 'Jane' + end + + it 'person2 is named John' do + person2.first_name.should == 'John' + end + + it 'they have different last names' do + person1.last_name.should_not == person2.last_name + end + + end + +end
Add spec for using multiple simultaneous instances
diff --git a/lib/one_one/resources/firewall_policy_resource.rb b/lib/one_one/resources/firewall_policy_resource.rb index abc1234..def5678 100644 --- a/lib/one_one/resources/firewall_policy_resource.rb +++ b/lib/one_one/resources/firewall_policy_resource.rb @@ -18,7 +18,19 @@ end action :create, 'POST /v1/firewall_policies/' do - body { |object| FirewallPolicyMapping.representation_for(:create, object) } + body do |object| + FirewallPolicyMapping.representation_for(:create, object) + end + + handler(202) do |response| + FirewallPolicyMapping.extract_single(response.body, :read) + end + end + + action :assign, 'POST /v1/firewall_policies/:id/server_ips' do + # assume the object is correctly formatted for now + # { server_ips: ["id1", "id2"] } + body { |object| object } handler(202) do |response| FirewallPolicyMapping.extract_single(response.body, :read) end
Add ability to associate vms with ip addresses
diff --git a/lib/smartdown_adapter/money_question_presenter.rb b/lib/smartdown_adapter/money_question_presenter.rb index abc1234..def5678 100644 --- a/lib/smartdown_adapter/money_question_presenter.rb +++ b/lib/smartdown_adapter/money_question_presenter.rb @@ -1,7 +1,7 @@ module SmartdownAdapter class MoneyQuestionPresenter < SmartdownAdapter::QuestionPresenter def to_response(input) - { amount: input } + input end def has_suffix_label?
Change MoneyQuestionPresenter.to_response() to not return hash. Fixes display issue.
diff --git a/lib/tasks/gobierto_budgets/custom_categories.rake b/lib/tasks/gobierto_budgets/custom_categories.rake index abc1234..def5678 100644 --- a/lib/tasks/gobierto_budgets/custom_categories.rake +++ b/lib/tasks/gobierto_budgets/custom_categories.rake @@ -2,8 +2,8 @@ namespace :gobierto_budgets do namespace :custom_categories do - desc "Import categories" - task :import, [:site_domain, :file_path] => [:environment] do |_t, args| + desc "Import categories, providing the site_domain, the file path to the categories and the locale" + task :import, [:site_domain, :file_path, :locale] => [:environment] do |_t, args| def area_name(area) case area when 'E' @@ -15,19 +15,18 @@ end end - # TODO: import data in different locales def custom_name(row) row["Nombre"] end def custom_description(row) - row["Descripción"] + # Keep both column names for compatibility reasons + row["Descripcion"] || row["Descripción"] end + I18n.locale = args[:locale] site = Site.find_by!(domain: args[:site_domain]) - ine_code = site.place.id - I18n.locale = 'ca' CSV.foreach(args[:file_path], headers: true) do |row| c = GobiertoBudgets::Category.find_or_create_by! site: site, area_name: area_name(row['Area']), kind: row['Tipo'], code: row['Codigo'] c.custom_name = custom_name(row)
Support custom categories upload in a given locale
diff --git a/judoscale-resque/test/latency_extension_test.rb b/judoscale-resque/test/latency_extension_test.rb index abc1234..def5678 100644 --- a/judoscale-resque/test/latency_extension_test.rb +++ b/judoscale-resque/test/latency_extension_test.rb @@ -0,0 +1,102 @@+# frozen_string_literal: true + +require "test_helper" +require "judoscale/resque/latency_extension" + +module Judoscale + class RedisStub + attr_reader :hash + + def initialize + @hash = Hash.new { |h, k| h[k] = [] } + end + + def sadd(key, *values) + hash[key].concat(values) + end + alias_method :rpush, :sadd + + def lindex(key, index) + hash[key][index] + end + + def lpop(key) + hash[key].shift + end + + def pipelined + yield + end + end + + class SampleJob + def self.perform + end + end + + describe Resque::LatencyExtension do + before { + @original_redis = ::Resque.redis + @redis_stub = RedisStub.new + ::Resque.redis = @redis_stub + } + after { + ::Resque.redis = @original_redis + } + + it "includes a timestamp value with each job enqueued, used to calculate latency" do + freeze_time do + ::Resque.enqueue_to "default", SampleJob + + item = ::Resque.pop("default") + _(item).must_equal({"class" => "Judoscale::SampleJob", "args" => [], "timestamp" => Time.now.utc.to_f}) + end + end + + it "calculates latency based on the oldest item in the queue" do + now = Time.now.utc + + [now, now + 12, now + 18].each { |enqueue_time| + freeze_time(enqueue_time) { ::Resque.enqueue_to "default", SampleJob } + } + + freeze_time now + 30 do + latency = ::Resque.latency("default") + _(latency).must_be_within_delta 30.0, 0.005 + end + + freeze_time now + 55.5 do + latency = ::Resque.latency("default") + _(latency).must_be_within_delta 55.5, 0.005 + end + + # Removing the oldest item to verify it uses the second enqueued item to calculate latency. + ::Resque.pop("default") + + freeze_time now + 60 do + latency = ::Resque.latency("default") + _(latency).must_be_within_delta 48.0, 0.005 + end + end + + it "calculates 0 latency for previously enqueued items that have no timestamp" do + ::Resque.enqueue_to "default", SampleJob + + @redis_stub.hash.fetch("resque:queue:default").map! { |item| + item = ::Resque.decode(item) + item.delete("timestamp") + ::Resque.encode(item) + } + + freeze_time Time.now.utc + 60 do + latency = ::Resque.latency("default") + _(latency).must_equal 0.0 + end + end + + it "calculates 0 latency when there are no items in the queue" do + latency = ::Resque.latency("default") + _(latency).must_equal 0.0 + end + end +end
Add specific tests for the resque latency extension We stub the lower layer Redis to avoid needing to have it running for the tests, but it should help ensure the behavior of Resque that we expect to extend is working correctly for storing the timestamp and calculating latency on top of it.
diff --git a/name_resolution/name_resolver.rb b/name_resolution/name_resolver.rb index abc1234..def5678 100644 --- a/name_resolution/name_resolver.rb +++ b/name_resolution/name_resolver.rb @@ -1,6 +1,5 @@-require 'resolv' - class NameResolver < Scout::Plugin + needs 'resolv' OPTIONS=<<-EOS nameserver: default: 8.8.8.8 @@ -12,9 +11,11 @@ resolver = Resolv::DNS.new(:nameserver => [option(:nameserver)]) begin - result = resolver.getaddress(option(:resolve_address)) - rescue Resolv::ResolvError => err - alert('Failed to resolve', err) + resolver.getaddress(option(:resolve_address)) + rescue Resolv::ResolvError, Resolv::ResolvTimeout => err + report(:resolved? => 0, :result => err) + else + report(:resolved? => 1) end end end
Use report instead of alert, as suggested by @ejaubaud
diff --git a/second_pass/test_second_fizzbuzz.rb b/second_pass/test_second_fizzbuzz.rb index abc1234..def5678 100644 --- a/second_pass/test_second_fizzbuzz.rb +++ b/second_pass/test_second_fizzbuzz.rb @@ -2,7 +2,7 @@ def assert(condition, failure_message) unless condition - raise failure_message + puts failure_message end end @@ -13,19 +13,13 @@ end # Test 1 -actual = fizzbuzz_of(1) -expected = 1 -assert_equality expected, actual +assert_equality 1, fizzbuzz_of(1) # Test 2 -actual = fizzbuzz_of(2) -expected = 2 -assert_equality expected, actual +assert_equality 2, fizzbuzz_of(2) # Test 3 -actual = fizzbuzz_of(3) -expected = 'Fizz' -assert_equality expected, actual +assert_equality 'Fizz', fizzbuzz_of(3) # If we got here, everything passed puts "SUCCESS!"
Use assert_equality to DRY up tests
diff --git a/griddler-cloudmailin.gemspec b/griddler-cloudmailin.gemspec index abc1234..def5678 100644 --- a/griddler-cloudmailin.gemspec +++ b/griddler-cloudmailin.gemspec @@ -6,7 +6,7 @@ Gem::Specification.new do |spec| spec.name = 'griddler-cloudmailin' spec.version = Griddler::Cloudmailin::VERSION - spec.authors = ['Dominic Sayers & Caleb Thompson'] + spec.authors = ['Dominic Sayers, Steve Smith and Caleb Thompson'] spec.email = ['dominic@sayers.cc'] spec.summary = 'Griddler Plugin for cloudmailin' spec.description = 'Griddler Plugin for cloudmailin email parsing service'
Fix rendering of authors string
diff --git a/akamai_api.gemspec b/akamai_api.gemspec index abc1234..def5678 100644 --- a/akamai_api.gemspec +++ b/akamai_api.gemspec @@ -18,7 +18,7 @@ gem.require_paths = ["lib"] gem.add_dependency 'active_support', '>= 2' - gem.add_dependency 'thor', '~> 0.14.0' + gem.add_dependency 'thor', '>= 0.14.0', '< 2.0' gem.add_dependency 'savon', '~> 1.2.0' gem.add_dependency 'builder', '~> 3.1.3'
Allow Thor > 0.14 until 1.X since Thor uses schemantic versioning. See https://github.com/rails/rails/commit/7dc83f78232a6dfcdd70292e831403933f57347b for more info.
diff --git a/app/controllers/matrices_controller.rb b/app/controllers/matrices_controller.rb index abc1234..def5678 100644 --- a/app/controllers/matrices_controller.rb +++ b/app/controllers/matrices_controller.rb @@ -50,7 +50,7 @@ redirect_to :index else flash[:notice] = "Please satisfy the reCaptcha." - render :new + redirect_to :new end end
Use redirect instead of render
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index abc1234..def5678 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -7,18 +7,16 @@ user = User.find_by(name: session_params[:name]) if user && user.authenticate(session_params[:password]) session[:user_id] = user.id - # hardcoding '/' for now so that I don't have to go into config/routes.rb before getting approval from team redirect_to '/' else flash.now[:error] = "Your login information was incorrect" - # hard-coded for now! Will replace with rails helper - redirect_to '/session/new' + redirect_to root_path end end def destroy - # set session id to nil - #redirect to homepage + session.clear + redirect_to root_path end def session_params
Refactor routes with rails helper url methods Use root_path in #create and #destroy actions in sessions controller
diff --git a/app/mailers/islay_shop/order_mailer.rb b/app/mailers/islay_shop/order_mailer.rb index abc1234..def5678 100644 --- a/app/mailers/islay_shop/order_mailer.rb +++ b/app/mailers/islay_shop/order_mailer.rb @@ -3,6 +3,8 @@ default :from => Settings.for(:shop, :email), :charset => 'UTF-8' + + layout 'mail' def thank_you(order) @order = order
Use a layout for mailing
diff --git a/app/controllers/api_flashcards/api_controller.rb b/app/controllers/api_flashcards/api_controller.rb index abc1234..def5678 100644 --- a/app/controllers/api_flashcards/api_controller.rb +++ b/app/controllers/api_flashcards/api_controller.rb @@ -12,7 +12,7 @@ if auth @current_user = auth else - render json: { message: 'Authentication failed', status: 401 } + render json: { message: 'Authentication failed'}, status: 401 end end end
Fix responce status for failed auth.
diff --git a/app/serializers/district_serializer.rb b/app/serializers/district_serializer.rb index abc1234..def5678 100644 --- a/app/serializers/district_serializer.rb +++ b/app/serializers/district_serializer.rb @@ -2,7 +2,8 @@ attributes :name, :vpc_id, :public_elb_security_group, :private_elb_security_group, :instance_security_group, :ecs_service_role, :ecs_instance_profile, :private_hosted_zone_id, :s3_bucket_name, :container_instances, - :stack_status, :nat_type + :stack_status, :nat_type, :cluster_size, :cluster_instance_type, + :cluster_backend, :cidr_block, :stack_name has_many :heritages has_many :plugins
Add some attributes to district serializer
diff --git a/app.rb b/app.rb index abc1234..def5678 100644 --- a/app.rb +++ b/app.rb @@ -36,7 +36,7 @@ "markdown": { "title": @subject, "text": "### #{@subject}\n" + - "> #{@message}\n\n" + + "> #{@message.to_json.gsub(',', ",\n")}\n\n" + "> ###### 时间 #{@time}" }, "at": {
Add a formatter for message, to make it pretty
diff --git a/lib/vapebot/bot.rb b/lib/vapebot/bot.rb index abc1234..def5678 100644 --- a/lib/vapebot/bot.rb +++ b/lib/vapebot/bot.rb @@ -15,15 +15,14 @@ Signal.trap("INT") do connection.close File.delete('bin/vapebot.pid') - abort "losing bot..." + abort "\nClosing bot..." end Signal.trap("TSTP") do - puts "Enter text to send: " + puts "\nEnter text to send: " input = gets.chomp connection.broadcastmsg(input) end - if Logger.create_dir puts "---- Checked for log directory. ----" end
Fix interrupts to display keypress on newline.
diff --git a/spec/services/search_orders_spec.rb b/spec/services/search_orders_spec.rb index abc1234..def5678 100644 --- a/spec/services/search_orders_spec.rb +++ b/spec/services/search_orders_spec.rb @@ -0,0 +1,37 @@+require 'spec_helper' + +describe SearchOrders do + let!(:distributor) { create(:distributor_enterprise) } + let!(:order1) { create(:order, distributor: distributor) } + let!(:order2) { create(:order, distributor: distributor) } + let!(:order3) { create(:order, distributor: distributor) } + + let(:enterprise_user) { distributor.owner } + + describe '#orders' do + let(:params) { {} } + let(:service) { SearchOrders.new(params, enterprise_user) } + + it 'returns orders' do + expect(service.orders.count).to eq 3 + end + end + + describe '#pagination_data' do + let(:params) { { per_page: 15, page: 1 } } + let(:service) { SearchOrders.new(params, enterprise_user) } + + it 'returns pagination data' do + expect(service.pagination_data).to eq pagination_data + end + end + + def pagination_data + { + results: 3, + pages: 1, + page: 1, + per_page: 15 + } + end +end
Add basic SearchOrders service spec
diff --git a/spec/www.fofrslevy.cz/nginx_spec.rb b/spec/www.fofrslevy.cz/nginx_spec.rb index abc1234..def5678 100644 --- a/spec/www.fofrslevy.cz/nginx_spec.rb +++ b/spec/www.fofrslevy.cz/nginx_spec.rb @@ -13,7 +13,7 @@ xit 'responds to request with response from rails app' do #think about adding domains to host file - expect(command 'curl http://www.fofrslevy.cz').to return_stdout(/.*<title>Fofrslevy.cz<\/title>.*/) + expect(command 'curl http://localhost').to return_stdout(/.*<title>RubyGems.org | your community gem host<\/title>.*/) end end
Change serverspec to check for application title - rubygems
diff --git a/app/models/user.rb b/app/models/user.rb index abc1234..def5678 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -16,8 +16,8 @@ VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-]+(?:\.[a-z\d\-]+)*\.[a-z]+\z/i validates :email, presence: true, format: { with: VALID_EMAIL_REGEX }, uniqueness: { case_sensitive: false } - validates :password, presence: true, length: { minimum: 6 } - validates :password_confirmation, presence: true + validates :password, presence: true, length: { minimum: 6 }, on: :create + validates :password_confirmation, presence: true, on: :update, allow_blank: true def name [first_name, last_name].join(' ')
Add additional validations for User model - Allow Owner to update user information from console without need of password.
diff --git a/test/react_test.rb b/test/react_test.rb index abc1234..def5678 100644 --- a/test/react_test.rb +++ b/test/react_test.rb @@ -18,8 +18,13 @@ end test 'precompiling assets works' do - Dummy::Application.load_tasks - Rake::Task['assets:precompile'].invoke - FileUtils.rm_r(File.expand_path("../dummy/public/assets", __FILE__)) + begin + ENV['RAILS_GROUPS'] = 'assets' # required for Rails 3.2 + Dummy::Application.load_tasks + Rake::Task['assets:precompile'].invoke + FileUtils.rm_r(File.expand_path("../dummy/public/assets", __FILE__)) + ensure + ENV.delete('RAILS_GROUPS') + end end end
Fix precompile test for Rails 3.2
diff --git a/lib/express_templates/components/capabilities/building.rb b/lib/express_templates/components/capabilities/building.rb index abc1234..def5678 100644 --- a/lib/express_templates/components/capabilities/building.rb +++ b/lib/express_templates/components/capabilities/building.rb @@ -2,9 +2,12 @@ module Components module Capabilities module Building - def method_missing(name, *args) - raise "#{self.class.to_s} has no method '#{name}'" - end + # commented this out because it's intercepting calls to rails helpers + # TODO: fix this... I think the whole buiding approach is broken. + # this class is empty and should probably go away. + # def method_missing(name, *args) + # raise "#{self.class.to_s} has no method '#{name}'" + # end end end end
Undo 101a650a7 as this is intercepting rails helpers
diff --git a/lib/generators/spree_conekta/install/install_generator.rb b/lib/generators/spree_conekta/install/install_generator.rb index abc1234..def5678 100644 --- a/lib/generators/spree_conekta/install/install_generator.rb +++ b/lib/generators/spree_conekta/install/install_generator.rb @@ -5,13 +5,13 @@ class_option :auto_run_migrations, type: :boolean, default: false def add_javascripts - append_file 'app/assets/javascripts/store/all.js', "\n//= require spree_conekta\n" - append_file 'app/assets/javascripts/admin/all.js', "\n//= require spree_conekta\n" + append_file 'app/assets/javascripts/store/all.js', "\n//= require store/spree_conekta\n" + append_file 'app/assets/javascripts/admin/all.js', "\n//= require store/spree_conekta\n" end def add_stylesheets - inject_into_file 'app/assets/stylesheets/store/all.css', "\n *= require spree_conekta\n", before: /\*\//, verbose: true - inject_into_file 'app/assets/stylesheets/admin/all.css', "\n *= require spree_conekta\n", before: /\*\//, verbose: true + inject_into_file 'app/assets/stylesheets/store/all.css', "\n *= require store/spree_conekta\n", before: /\*\//, verbose: true + inject_into_file 'app/assets/stylesheets/admin/all.css', "\n *= require admin/spree_conekta\n", before: /\*\//, verbose: true end def add_migrations
Fix spree_conekta generator to use the real extension assets
diff --git a/spec/models/csv_exporter/activity_session_spec.rb b/spec/models/csv_exporter/activity_session_spec.rb index abc1234..def5678 100644 --- a/spec/models/csv_exporter/activity_session_spec.rb +++ b/spec/models/csv_exporter/activity_session_spec.rb @@ -3,6 +3,27 @@ describe CsvExporter::ActivitySession do include_context 'Activity Progress Report' let(:csv_exporter) { CsvExporter::ActivitySession.new } + + describe '#header_row' do + it 'returns an array of headers' do + expect(csv_exporter.header_row).to eq(['app', 'activity', 'date', 'time_spent', 'standard', 'score', 'student']) + end + end + + describe '#data_row' do + it 'returns an array of row data' do + expected_row = [ + horshack_session.activity.classification.name, + horshack_session.activity.name, + horshack_session.completed_at.to_formatted_s(:quill_default), + horshack_session.time_spent, + horshack_session.activity.topic.name_prefix, + horshack_session.percentage, + horshack_session.user.name + ] + expect(csv_exporter.data_row(horshack_session)).to eq(expected_row) + end + end describe '#model_data' do subject { csv_exporter.model_data(mr_kotter, filters) }
Add more specs for activity session exporter