diff
stringlengths
65
26.7k
message
stringlengths
7
9.92k
diff --git a/lib/string_ext.rb b/lib/string_ext.rb index abc1234..def5678 100644 --- a/lib/string_ext.rb +++ b/lib/string_ext.rb @@ -0,0 +1,9 @@+String.class_eval do + def constantize + const = Kernel + self.split('::').each do |const_str| + const = const.const_get const_str + end + return const + end +end unless String.instance_methods.include?(:constantize)
Add constantize to String object if the String object cannot constantize.
diff --git a/lib/tankulator.rb b/lib/tankulator.rb index abc1234..def5678 100644 --- a/lib/tankulator.rb +++ b/lib/tankulator.rb @@ -1,43 +1,45 @@-require 'tankulator/entry' -require 'tankulator/gastank' - module Tankulator + # Starts running everything + # Returns nothing def self.run - inputFileName = '' + require 'tankulator/entry' + require 'tankulator/gastank' + if ARGV.count == 0 - print 'Please enter the name of the file read from: ' - inputFileName = gets.chomp + puts "USAGE: tankulator <filename>" + #print 'Please enter the name of the file read from: ' + #inputFileName = gets.chomp else inputFileName = ARGV[0] - end + + if File.exists?(inputFileName) + newTank = GasTank.new + puts 'Reading file input...' - if File.exists?(inputFileName) - newTank = GasTank.new - puts 'Reading file input...' + inputFile = File.open(inputFileName, 'r') + # Read in tank information + # the first four lines are as follows + newTank.start_date = inputFile.readline # start date + newTank.end_date = inputFile.readline # end date + newTank.cost = inputFile.readline.to_f # cost of tank + newTank.total_distance_confirmation = inputFile.readline # total distance + newTank.driver_aliases = inputFile.readline # make printing drivers a bit better - inputFile = File.open(inputFileName, 'r') - # Read in tank information - # the first four lines are as follows - newTank.start_date = inputFile.readline # start date - newTank.end_date = inputFile.readline # end date - newTank.cost = inputFile.readline.to_f # cost of tank - newTank.total_distance_confirmation = inputFile.readline # total distance - newTank.driver_aliases = inputFile.readline # make printing drivers a bit better + # read in the rest of the lines until we hit the end of the file + begin + while + newTank.add_entry(Entry.new(inputFile.readline)) + end + rescue EOFError + #puts "All lines read" + end - # read in the rest of the lines until we hit the end of the file - begin - while - newTank.add_entry(Entry.new(inputFile.readline)) - end - rescue EOFError - #puts "All lines read" + inputFile.close() + puts newTank + newTank.driver_summaries + else + puts 'That file does not exist. Exiting.' end - - inputFile.close() - puts newTank - newTank.driver_summaries - else - puts 'That file does not exist. Exiting.' end end end
Print out USAGE when not properly called
diff --git a/lib/tara/shell.rb b/lib/tara/shell.rb index abc1234..def5678 100644 --- a/lib/tara/shell.rb +++ b/lib/tara/shell.rb @@ -4,6 +4,7 @@ class Shell def self.exec(command) output = %x(#{command}) + $stderr.puts(%(#{command}: #{output})) if ENV['TARA_DEBUG'] unless $?.success? raise ExecError, %(Command `#{command}` failed with output: #{output}) end
Add debug statement to Shell.exec For, you know, debugging purposes. I’d prefer to have some kind of logger, but for now this’ll work.
diff --git a/LightRoute.podspec b/LightRoute.podspec index abc1234..def5678 100644 --- a/LightRoute.podspec +++ b/LightRoute.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "LightRoute" - s.version = "2.1.9" + s.version = "2.1.10" s.summary = "LightRoute is easy transition between view controllers and support many popylar arhitectures" s.description = <<-DESC LightRoute is easy transition between view controllers and support many popylar arhitectures. This framework very flow for settings your transition and have userfriendly API.
Update spec to version 2.1.10
diff --git a/cookbooks/omf/recipes/default.rb b/cookbooks/omf/recipes/default.rb index abc1234..def5678 100644 --- a/cookbooks/omf/recipes/default.rb +++ b/cookbooks/omf/recipes/default.rb @@ -6,9 +6,18 @@ # # All rights reserved - Do Not Redistribute # -%w(ruby ruby-dev build-essential libssl-dev).each do |p| - package p do - action :upgrade +case node["platform_family"] +when "rhel" + %w(ruby ruby-devel make gcc gpp gcc-c++ openssl-devel).each do |p| + package p do + action :upgrade + end + end +when "debian" + %w(ruby ruby-dev build-essential libssl-dev).each do |p| + package p do + action :upgrade + end end end
Add package requirements for RHEL
diff --git a/Library/Homebrew/cmd/versions.rb b/Library/Homebrew/cmd/versions.rb index abc1234..def5678 100644 --- a/Library/Homebrew/cmd/versions.rb +++ b/Library/Homebrew/cmd/versions.rb @@ -11,7 +11,7 @@ Please use the homebrew-versions tap instead: https://github.com/Homebrew/homebrew-versions EOS - ARGV.formulae.all? do |f| + ARGV.formulae.each do |f| versions = FormulaVersions.new(f) path = versions.repository_path versions.each do |version, rev|
Use .each, not .all? to enumerate formulae
diff --git a/lib/oboe_fu.rb b/lib/oboe_fu.rb index abc1234..def5678 100644 --- a/lib/oboe_fu.rb +++ b/lib/oboe_fu.rb @@ -1,6 +1,6 @@ require 'oboefu/util' -if defined?(Rails) and Rails::VERSION::MAJOR == "3" +if defined?(Rails) and Rails::VERSION::MAJOR == 3 module OboeFu class Railtie < Rails::Railtie initializer "oboe_fu.start" do |app|
Change string to integer in init code
diff --git a/server.rb b/server.rb index abc1234..def5678 100644 --- a/server.rb +++ b/server.rb @@ -33,7 +33,7 @@ sleep 1 end - printer.close_all_windows + ncurses_printer.close_all_windows rescue => ex Curses.close_screen puts ex.message
Fix closing old printer and not curses printer
diff --git a/spec/models/micropost_spec.rb b/spec/models/micropost_spec.rb index abc1234..def5678 100644 --- a/spec/models/micropost_spec.rb +++ b/spec/models/micropost_spec.rb @@ -24,14 +24,6 @@ it { should be_valid } - describe "accessible attributes" do - it "should not allow access to user_id" do - expect do - Micropost.new(user_id: user.id) - end.should raise_error - end - end - describe "when user_id is not present" do before { @micropost.user_id = nil }
Remove mass assignmente test, because rails 4 move this funcionality to controller
diff --git a/lib/villein.rb b/lib/villein.rb index abc1234..def5678 100644 --- a/lib/villein.rb +++ b/lib/villein.rb @@ -3,3 +3,6 @@ module Villein # Your code goes here... end + +require 'villein/client' +require 'villein/agent'
Load Villein::Client, Agent in default
diff --git a/lib/yumlcmd.rb b/lib/yumlcmd.rb index abc1234..def5678 100644 --- a/lib/yumlcmd.rb +++ b/lib/yumlcmd.rb @@ -26,8 +26,9 @@ opts.parse!(args) lines = IO.readlines(input).collect!{|l| l.gsub("\n", "")}.reject{|l| l =~ /#/} - - writer = open("yuml-output.#{ext}", "wb") + output = input.replace(".", "-") + output = output + "-output" + writer = open(output + ".#{ext}", "wb") res = Net::HTTP.start("yuml.me", 80) {|http| http.get(URI.escape("/diagram#{type}/class/#{lines.join(",")}"))
Use input filename as base for output filename
diff --git a/lib/appium_console.rb b/lib/appium_console.rb index abc1234..def5678 100644 --- a/lib/appium_console.rb +++ b/lib/appium_console.rb @@ -6,45 +6,8 @@ module Appium; end unless defined? Appium module Appium::Console - # Check for env vars in .txt - toml = File.join Dir.pwd, 'appium.txt' - - class Env - def initialize data - @data = data - end - - def update *args - args.each do |name| - var = @data[name] - ENV[name] = var if var - end - end - end - - if File.exists? toml - require 'toml' - require 'ap' - puts "Loading #{toml}" - - # bash requires A="OK" - # toml requires A = "OK" - # - # A="OK" => A = "OK" - data = File.read(toml).gsub /([^\s])\=(")/, "\\1 = \\2" - data = TOML::Parser.new(data).parsed - ap data - - env = Env.new data - env.update 'APP_PATH', 'APP_APK', 'APP_PACKAGE', - 'APP_ACTIVITY', 'APP_WAIT_ACTIVITY', - 'SELENDROID' - - # Ensure app path is absolute - ENV['APP_PATH'] = File.expand_path ENV['APP_PATH'] if ENV['APP_PATH'] - end - require 'appium_lib' + load_appium_txt file: Dir.pwd + '/appium.txt' start = File.expand_path '../start.rb', __FILE__ cmd = ['-r', start]
Move appium.txt loading to appium_lib
diff --git a/messaging.gemspec b/messaging.gemspec index abc1234..def5678 100644 --- a/messaging.gemspec +++ b/messaging.gemspec @@ -1,7 +1,7 @@ # -*- encoding: utf-8 -*- Gem::Specification.new do |s| s.name = 'messaging' - s.version = '0.4.0.0' + s.version = '0.4.1.0' s.summary = 'Messaging primitives for Eventide' s.description = ' '
Package version increased from 0.4.0.0 to 0.4.1.0
diff --git a/messaging.gemspec b/messaging.gemspec index abc1234..def5678 100644 --- a/messaging.gemspec +++ b/messaging.gemspec @@ -1,7 +1,7 @@ # -*- encoding: utf-8 -*- Gem::Specification.new do |s| s.name = 'evt-messaging' - s.version = '0.12.3.0' + s.version = '0.12.3.1' s.summary = 'Messaging primitives for Eventide' s.description = ' '
Package version is increased from 0.12.3.0 to 0.12.3.1
diff --git a/exercises/nth-prime/nth_prime_test.rb b/exercises/nth-prime/nth_prime_test.rb index abc1234..def5678 100644 --- a/exercises/nth-prime/nth_prime_test.rb +++ b/exercises/nth-prime/nth_prime_test.rb @@ -1,27 +1,7 @@ #!/usr/bin/env ruby -# frozen_string_literal: true gem 'minitest', '>= 5.0.0' require 'minitest/autorun' - -require 'prime' -ERROR_MESSAGE = <<-MSG.freeze -Using Ruby's Prime class is probably the best way to do this in a -'real' application; but this is an exercise, not a real application, -so you're expected to implement this yourself. -MSG - -class Prime - [:each, :new, :prime?, :take].each do |m| - define_method(m) { |*_| fail ERROR_MESSAGE } - end -end - -class Integer - [:prime?, :each_prime].each do |m| - define_method(m) { |*_| fail ERROR_MESSAGE } - end -end require_relative 'nth_prime'
Remove constraint on Prime class usage. Since this was throwing an error in new versions of Ruby it is best to remove it since it was impacting the exercise.
diff --git a/spec/http_spec.rb b/spec/http_spec.rb index abc1234..def5678 100644 --- a/spec/http_spec.rb +++ b/spec/http_spec.rb @@ -16,7 +16,7 @@ async 'returns false when the request failed' do HTTP.get('data/non_existant.txt') do |response| - run_async { response.ok?.should be_true } + run_async { response.ok?.should be_false } end end end
Fix broken http spec (bad spec)
diff --git a/db/data_migration/20140131115415_add_endorsing_sponsoring_and_supporting_visa_applicants_mainstream_category.rb b/db/data_migration/20140131115415_add_endorsing_sponsoring_and_supporting_visa_applicants_mainstream_category.rb index abc1234..def5678 100644 --- a/db/data_migration/20140131115415_add_endorsing_sponsoring_and_supporting_visa_applicants_mainstream_category.rb +++ b/db/data_migration/20140131115415_add_endorsing_sponsoring_and_supporting_visa_applicants_mainstream_category.rb @@ -0,0 +1,7 @@+MainstreamCategory.create!( + slug: "endorsing-sponsoring-and-supporting-visa-applicants", + title: "Endorsing, sponsoring and supporting visa applicants", + parent_title: "Employers' sponsorship", + parent_tag: "visas-immigration/employers-sponsorship", + description: "Information for employers, educators and legal practitioners on endorsing and sponsoring visa applicants, and getting refugees the support they're entitled to." +)
Add 'Endorsing, sponsoring and supporting visa applicants' https://www.pivotaltracker.com/story/show/64751384
diff --git a/lib/romaji_kit/cli.rb b/lib/romaji_kit/cli.rb index abc1234..def5678 100644 --- a/lib/romaji_kit/cli.rb +++ b/lib/romaji_kit/cli.rb @@ -2,10 +2,16 @@ module RomajiKit class CLI < Thor + class_option :upcase, type: :boolean, aliases: '-u' + desc 'hepburnize', 'Convert kana to hepburn' - option :upcase, type: :boolean, aliases: '-u' def hepburnize(text) puts Converter.hepburnize(text, options[:upcase]) + end + + desc 'nihon', 'Convert kana to Nihon-shiki romaji' + def nihon(text) + puts Converter.nihon(text, options[:upcase]) end end
Add `nihon` method for CLI
diff --git a/lib/syncer/actions.rb b/lib/syncer/actions.rb index abc1234..def5678 100644 --- a/lib/syncer/actions.rb +++ b/lib/syncer/actions.rb @@ -12,7 +12,7 @@ return unless env[:machine].config.syncer.run_on_startup - # If Vagrant up/reload/resume exited successfully, run this rsync-auto + # If vagrant up/reload/resume exited successfully, run rsync-auto at_exit do env[:machine].env.cli("rsync-auto") if $!.status == 0 end
Fix extra word in comment
diff --git a/lib/vail/generator.rb b/lib/vail/generator.rb index abc1234..def5678 100644 --- a/lib/vail/generator.rb +++ b/lib/vail/generator.rb @@ -21,7 +21,7 @@ end end - @config[:repetitions].times.each do + (@config[:repetitions].times.inject([]) { |r,i| r << instructions }).each do |instructions| instructions.each do |i| if i[:command] == :sound Beep::Sound.generate(i[:instruction])
Refactor of building the morse instructions - first pass
diff --git a/spec/factories/ecm_comments_comments.rb b/spec/factories/ecm_comments_comments.rb index abc1234..def5678 100644 --- a/spec/factories/ecm_comments_comments.rb +++ b/spec/factories/ecm_comments_comments.rb @@ -1,7 +1,7 @@ FactoryGirl.define do factory :ecm_comments_comment, class: Ecm::Comments::Comment do - association :creator, factory: :user - association :commentable, factory: :post + association :creator, factory: :ecm_user_area_user + association :commentable, factory: :ecm_blog_post name 'John Doe' email '[email protected]' body 'This is a comment!'
Change creator and commentable factories.
diff --git a/spec/acceptance/whos_dated_who_spec.rb b/spec/acceptance/whos_dated_who_spec.rb index abc1234..def5678 100644 --- a/spec/acceptance/whos_dated_who_spec.rb +++ b/spec/acceptance/whos_dated_who_spec.rb @@ -0,0 +1,21 @@+require 'spec_helper' + +describe WhosDatedWho do + let(:client) { WhosDatedWho::Client.new } + + context "smoke test" do + it "fetches and parses the correct results" do + result = client.fetch('Candice Swanepoel') + expect(result.status).to eq(:dating) + expect(result.biography.first_name).to eq('Candice') + expect(result.biography.last_name).to eq('Swanepoel') + expect(result.biography.age).to eq(26) + + result = client.fetch('Katheryn Winnick') + expect(result.status).to eq(:unknown) + expect(result.biography.first_name).to eq('Katheryn') + expect(result.biography.last_name).to eq('Winnick') + expect(result.biography.age).to eq(37) + end + end +end
Add an acceptance test that hits the network
diff --git a/spec/features/create_a_project_spec.rb b/spec/features/create_a_project_spec.rb index abc1234..def5678 100644 --- a/spec/features/create_a_project_spec.rb +++ b/spec/features/create_a_project_spec.rb @@ -11,8 +11,8 @@ fill_in 'Name', with: 'Project Jellyfish' fill_in 'Icon', with: 'http://www.example.com/image.png' fill_in 'Budget', with: '$100,000' - fill_in 'Start Date', with: '2015-01-01' - fill_in 'End Date', with: '2016-01-01' + fill_in 'Start Date', with: '2020-01-01' + fill_in 'End Date', with: '2020-12-01' find('a', text: 'CREATE').click expect(page).to have_content('Project created successfully.')
Update start and end dates in test Validations where failing because we were trying to schedule a project start date for before today.
diff --git a/spec/will_paginate/materialize_spec.rb b/spec/will_paginate/materialize_spec.rb index abc1234..def5678 100644 --- a/spec/will_paginate/materialize_spec.rb +++ b/spec/will_paginate/materialize_spec.rb @@ -5,7 +5,5 @@ expect(WillPaginate::Materialize::VERSION).not_to be nil end - it 'does something useful' do - expect(false).to eq(true) - end + # TODO: Add specs.. end
Add TODO to write specs
diff --git a/app/controllers/progress_updates_controller.rb b/app/controllers/progress_updates_controller.rb index abc1234..def5678 100644 --- a/app/controllers/progress_updates_controller.rb +++ b/app/controllers/progress_updates_controller.rb @@ -36,6 +36,11 @@ end end + def destroy + ProgressUpdate.find(params[:id]).destroy + redirect_to "/" + end + private def update_params
Add progress update destroy route
diff --git a/app/controllers/renalware/events_controller.rb b/app/controllers/renalware/events_controller.rb index abc1234..def5678 100644 --- a/app/controllers/renalware/events_controller.rb +++ b/app/controllers/renalware/events_controller.rb @@ -10,9 +10,9 @@ end def create - @event = Event.new(event_params) + @event = @patient.events.new(event_params) authorize @event - @event.patient_id = @patient.id + if @event.save redirect_to patient_events_path(@patient), :notice => "You have successfully added an encounter/event." else @@ -27,7 +27,7 @@ private def event_params - params.require(:event).permit(:patient_id, :event_type_id, :date_time, :description, :notes) + params.require(:event).permit(:event_type_id, :date_time, :description, :notes) end end -end+end
Leverage association when building model
diff --git a/spec/time_spec.rb b/spec/time_spec.rb index abc1234..def5678 100644 --- a/spec/time_spec.rb +++ b/spec/time_spec.rb @@ -3,6 +3,10 @@ describe "parsing an iso8601 formatted time to a Time object" do before do @time = Time.iso8601("2012-05-31T19:41:33Z") + end + + it "should be a time" do + @time.instance_of?(Time).should == true end it "should have a valid year" do
Add a spec verifying that Time.iso8601 returns an instance of Time
diff --git a/core/app/classes/opinion_type.rb b/core/app/classes/opinion_type.rb index abc1234..def5678 100644 --- a/core/app/classes/opinion_type.rb +++ b/core/app/classes/opinion_type.rb @@ -1,4 +1,4 @@-class OpinionType +module OpinionType def self.types ['believes', 'disbelieves', 'doubts'] end
Use module instead of class
diff --git a/tinkey.rb b/tinkey.rb index abc1234..def5678 100644 --- a/tinkey.rb +++ b/tinkey.rb @@ -6,8 +6,8 @@ class Tinkey < Formula desc "A command line tool to generate and manipulate keysets for the Tink cryptography library" homepage "https://github.com/google/tink/tree/master/tools/tinkey" - url "https://storage.googleapis.com/tinkey/tinkey-1.5.0.tar.gz" - sha256 "bd148e684ffba85b8499bcfe29c8ed1e9dedef52eddd35dabb0a34e396790b90" + url "https://storage.googleapis.com/tinkey/tinkey-1.6.0.tar.gz" + sha256 "51d9694a704d00fbac04862a6427ad5f17bf59f91d5e963517d8799141e737c0" bottle :unneeded
Update Tinkey URL and SHA-256 hash for Tink 1.6.0. PiperOrigin-RevId: 374341425
diff --git a/week-9/nums_to_words.rb b/week-9/nums_to_words.rb index abc1234..def5678 100644 --- a/week-9/nums_to_words.rb +++ b/week-9/nums_to_words.rb @@ -0,0 +1,24 @@+# Numbers to English Words + + +# I worked on this challenge [Alone]. +# This challenge took me [#] hours. + + +# Pseudocode_____________________________________________________ +# INPUT: Numbers +# OUTPUT: String/English eqluivalent of the number +#Create a Program/Method that takes an interger as an argument +# +# +# +# + +# Initial Solution + + + + +# Refactored Solution + +# Reflection
Add working directory for w9
diff --git a/core/threadgroup/default_spec.rb b/core/threadgroup/default_spec.rb index abc1234..def5678 100644 --- a/core/threadgroup/default_spec.rb +++ b/core/threadgroup/default_spec.rb @@ -0,0 +1,11 @@+require File.expand_path('../../../spec_helper', __FILE__) + +describe "ThreadGroup::Default" do + it "is a ThreadGroup instance" do + ThreadGroup::Default.should be_kind_of(ThreadGroup) + end + + it "is the ThreadGroup of the main thread" do + ThreadGroup::Default.should == Thread.main.group + end +end
Add spec for ThreadGroup::Default constant Based on MRI docs and passing in MIR 1.9.3
diff --git a/work/consider/having.rb b/work/consider/having.rb index abc1234..def5678 100644 --- a/work/consider/having.rb +++ b/work/consider/having.rb @@ -0,0 +1,75 @@+## THIS IS NOT THUROUGH ENOUGH +## PROBABY SHOULD MAKE SPECIAL SUBCLASSES +## OF HASH TO HANDLE THIS CONCEPT. +# +# IMPORTANT TODO!!!! + +# + +class Hash + + attr_accessor :fallback + + # Define a fallback object for #fetch and #[]. + # + # f = Hash[:b=>2] + # h = Hash[:a=>1].having_aquisition(f) + # h[:b] => 2 + + def having_aquisition(fallback) + + @fallback = fallback + + unless @fallsback + + def self.[](key) + begin + return @fallback[key] if @fallback and not key?(key) + rescue + end + val = super +p val + val.fallback(self) if Hash == val + val + end + + def self.fetch(key, *args, &blk) + begin + return @fallback.fetch(key, *args, &blk) if @fallback and not key?(key) + rescue + end + val = super + val.fallback(self) if Hash == val + val + end + + @fallsback = true + end + + self + end + + # Define a fallback object for #fetch and #[]. + # + # f = Hash[:b=>2] + # h = Hash[:a=>1].having_fallback(f) + # h[:b] => 2 + + def having_fallback(parent=nil) + @fallback = parent + unless @fallsback + def self.[](key) + return @fallback[key] if @fallback and not key?(key) rescue super + super + end + + def self.fetch(key, *args, &blk) + return @fallback.fetch(key, *args, &blk) if @fallback and not key?(key) rescue super + super + end + @fallsback = true + end + self + end + +end
Add considertion to work directory. [admin]
diff --git a/environment.rb b/environment.rb index abc1234..def5678 100644 --- a/environment.rb +++ b/environment.rb @@ -13,4 +13,4 @@ end end -DB = Sequel.connect(ENV['DATABASE'] || "postgres://localhost/#{Db.name}") +DB = Sequel.connect(ENV['DATABASE_URL'] || "postgres://localhost/#{Db.name}")
Rollback previous commit to use DATABSE_URL
diff --git a/spec/acceptance/upload_spec.rb b/spec/acceptance/upload_spec.rb index abc1234..def5678 100644 --- a/spec/acceptance/upload_spec.rb +++ b/spec/acceptance/upload_spec.rb @@ -40,3 +40,18 @@ Warden.test_reset! end end + +describe 'upload from URL', :type => :feature do + before(:each) do + user = create(:user) + login_as(user, :scope => :user) + end + + it 'will upload from a URL' do + Image.count.should eq 0 + visit '/' + fill_in 'Upload from URL', :with => 'uploadstuffto.me/test_image.png' + click_button 'Upload from this URL' + Image.count.should eq 1 + end +end
Add spec to test uploading from URL
diff --git a/spec/models/item_model_spec.rb b/spec/models/item_model_spec.rb index abc1234..def5678 100644 --- a/spec/models/item_model_spec.rb +++ b/spec/models/item_model_spec.rb @@ -0,0 +1,27 @@+require 'rails_helper' + +RSpec.describe Item do + let(:item) { FactoryBot.create(:item)} + + before do + # Do nothing + end + + after do + # Do nothing + end + + context 'when creating an Item' do + it 'checks that the subject is not blank' do + item.subject = '' + item.save + expect(item.errors[:subject].size).to eq(1) + end + + it 'checks that the standard name has at least 3 characters' do + item.standard = '45' + item.save + expect(item.errors[:standard].size).to eq(1) + end + end +end
Improve item tests, part 2
diff --git a/spec/support/database_setup.rb b/spec/support/database_setup.rb index abc1234..def5678 100644 --- a/spec/support/database_setup.rb +++ b/spec/support/database_setup.rb @@ -2,6 +2,6 @@ config.before(:suite) do DatabaseCleaner[:mongoid].strategy = :truncation DatabaseCleaner.clean - Rails.application.load_seed + SeedFu.seed end end
Change to seed-fu for seeding during tests too.
diff --git a/spec/support/helper_methods.rb b/spec/support/helper_methods.rb index abc1234..def5678 100644 --- a/spec/support/helper_methods.rb +++ b/spec/support/helper_methods.rb @@ -13,7 +13,8 @@ def metric_not_activated?(metric_name) MetricFu.configuration.configure_metrics - if MetricFu::Metric.get_metric(metric_name.intern).activate + metric = MetricFu::Metric.get_metric(metric_name.intern) + if metric.activated false else p "Skipping #{metric_name} tests, not activated"
Check if metric is activated; was bypassing ripper check
diff --git a/week-6/gps.rb b/week-6/gps.rb index abc1234..def5678 100644 --- a/week-6/gps.rb +++ b/week-6/gps.rb @@ -0,0 +1,42 @@+# Your Names +# 1)Catie Stallings +# 2) + +# We spent [#] hours on this challenge. + +# Bakery Serving Size portion calculator. + +def serving_size_calc(item_to_make, num_of_ingredients) + library = {"cookie" => 1, "cake" => 5, "pie" => 7} + error_counter = 3 + + library.each do |food| + if library[food] != library[item_to_make] + error_counter += -1 + end + end + + if error_counter > 0 + raise ArgumentError.new("#{item_to_make} is not a valid input") + end + + serving_size = library.values_at(item_to_make)[0] + remaining_ingredients = num_of_ingredients % serving_size + + case remaining_ingredients + when 0 + return "Calculations complete: Make #{num_of_ingredients / serving_size} of #{item_to_make}" + else + return "Calculations complete: Make #{num_of_ingredients / serving_size} of #{item_to_make}, you have #{remaining_ingredients} leftover ingredients. Suggested baking items: TODO: MAKE THIS FEATURE" + end +end + +p serving_size_calc("pie", 7) +p serving_size_calc("pie", 8) +p serving_size_calc("cake", 5) +p serving_size_calc("cake", 7) +p serving_size_calc("cookie", 1) +p serving_size_calc("cookie", 10) +p serving_size_calc("THIS IS AN ERROR", 5) + +# Reflection
Add initial file for GPS 2.3
diff --git a/lib/clarifai/client/curator_search.rb b/lib/clarifai/client/curator_search.rb index abc1234..def5678 100644 --- a/lib/clarifai/client/curator_search.rb +++ b/lib/clarifai/client/curator_search.rb @@ -2,14 +2,28 @@ class Client # Defines methods related to Curator Index management module CuratorSearch - def search(index, query, size=50, start=0, search_options={}) + def search(index, search_options={}) + response = post("curator/#{index}/search", search_options.to_json, params_encoder, encode_json=true) + response + end + + def query_string_search(index, query, size=50, start=0, search_options={}) options = { query: { query_string: query }, num: size, start: start } - response = post("curator/#{index}/search", options.to_json, params_encoder, encode_json=true) - response + search(index, options) + end + + def tags_search(index, tags, size=50, start=0, search_options={}) + tags = [tags] if tags.is_a? String + options = { + query: { tags: tags }, + num: size, + start: start + } + search(index, options) end def similar_search(index, image_urls, size=50, start=0, search_options={}) @@ -19,8 +33,7 @@ num: size, start: start } - response = post("curator/#{index}/search", options.to_json, params_encoder, encode_json=true) - response + search(index, options) end end end
Add support for searching using tags operator
diff --git a/lib/redmine_git_hosting/patches/project_patch.rb b/lib/redmine_git_hosting/patches/project_patch.rb index abc1234..def5678 100644 --- a/lib/redmine_git_hosting/patches/project_patch.rb +++ b/lib/redmine_git_hosting/patches/project_patch.rb @@ -22,7 +22,7 @@ # Find all repositories owned by project which are Repository::Git def gitolite_repos - repositories.select{|x| x.is_a?(Repository::Git)}.sort{|x, y| x.id <=> x.id} + repositories.select{|x| x.is_a?(Repository::Git)}.sort{|x, y| x.id <=> y.id} end # Return first repo with a blank identifier (should be only one!)
Fix repo order with Postgres
diff --git a/lib/minitest_to_rspec/exp/hash_exp.rb b/lib/minitest_to_rspec/exp/hash_exp.rb index abc1234..def5678 100644 --- a/lib/minitest_to_rspec/exp/hash_exp.rb +++ b/lib/minitest_to_rspec/exp/hash_exp.rb @@ -8,8 +8,11 @@ @exp = sexp.dup end + # A slightly nicer implementation would be: + # `@exp[1..-1].each_slice(2).to_h` + # but that would require ruby >= 2.1 def to_h - @exp[1..-1].each_slice(2).to_h + Hash[@exp[1..-1].each_slice(2).to_a] end end end
Fix ruby 2.0 compatability issue
diff --git a/lib/ossboard/services/task_twitter.rb b/lib/ossboard/services/task_twitter.rb index abc1234..def5678 100644 --- a/lib/ossboard/services/task_twitter.rb +++ b/lib/ossboard/services/task_twitter.rb @@ -26,6 +26,7 @@ end # Keep extra 5 symbols for spaces and ... + # TODO: update length to 200 TWEET_MAX_LENGTH = 135 end end
Add one more tech debt todo
diff --git a/test/inputs/hidden_input_test.rb b/test/inputs/hidden_input_test.rb index abc1234..def5678 100644 --- a/test/inputs/hidden_input_test.rb +++ b/test/inputs/hidden_input_test.rb @@ -20,10 +20,11 @@ assert_no_select 'label' end - test 'required/optional options should not be generated for hidden inputs' do + test 'required/aria-required/optional options should not be generated for hidden inputs' do with_input_for @user, :name, :hidden assert_no_select 'input.required' assert_no_select 'input[required]' + assert_no_select 'input[aria-required]' assert_no_select 'input.optional' assert_select 'input.hidden#user_name' end
Test aria-required for hidden inputs. [#780]
diff --git a/app/mailers/devise_mailer.rb b/app/mailers/devise_mailer.rb index abc1234..def5678 100644 --- a/app/mailers/devise_mailer.rb +++ b/app/mailers/devise_mailer.rb @@ -13,7 +13,7 @@ def confirmation_instructions(record, opts) if record.individual? document_renderer = DocumentRenderer.new - attachments['supporter.png'] = { + attachments.inline['supporter.png'] = { mime_type: 'image/png', content: File.read(Rails.root.join('public/supporter.png')) }
Stop image showing up as an attachment
diff --git a/jsrebuild.gemspec b/jsrebuild.gemspec index abc1234..def5678 100644 --- a/jsrebuild.gemspec +++ b/jsrebuild.gemspec @@ -19,6 +19,6 @@ s.executables = ["jsrebuild"] - s.files = %w(History.txt LICENCE README.md) + - Dir.glob("{bin,lib}/**/*") + s.files = Dir.glob("{bin,lib}/**/*") + + %w(History.txt LICENSE README.md) end
Fix a file name error in the gemspec.
diff --git a/gretel.gemspec b/gretel.gemspec index abc1234..def5678 100644 --- a/gretel.gemspec +++ b/gretel.gemspec @@ -17,6 +17,6 @@ gem.test_files = gem.files.grep(%r{^test/}) gem.require_paths = ["lib"] - gem.add_dependency "rails", ">= 3.2.0" + gem.add_dependency "rails", ">= 3.1.0" gem.add_development_dependency "sqlite3" end
Downgrade rails dependency to 3.1
diff --git a/Library/Homebrew/dependencies.rb b/Library/Homebrew/dependencies.rb index abc1234..def5678 100644 --- a/Library/Homebrew/dependencies.rb +++ b/Library/Homebrew/dependencies.rb @@ -51,6 +51,10 @@ deps == other.deps end alias_method :eql?, :== + + def inspect + "#<#{self.class.name}: #{to_a.inspect}>" + end end class Requirements
Improve inspect output for dependency collections
diff --git a/db/migrate/20180207095200_create_repository_list_values.rb b/db/migrate/20180207095200_create_repository_list_values.rb index abc1234..def5678 100644 --- a/db/migrate/20180207095200_create_repository_list_values.rb +++ b/db/migrate/20180207095200_create_repository_list_values.rb @@ -1,9 +1,13 @@+require File.expand_path('app/helpers/database_helper') + class CreateRepositoryListValues < ActiveRecord::Migration[5.1] - def change + include DatabaseHelper + + def up create_table :repository_list_items do |t| t.references :repository, index: true, foreign_key: true t.references :repository_column, index: true, foreign_key: true - t.text :data, index: true, using: :gin, null: false + t.text :data, null: false t.references :created_by, index: true, foreign_key: { to_table: :users } @@ -12,6 +16,8 @@ foreign_key: { to_table: :users } t.timestamps end + + add_gin_index_without_tags :repository_list_items, :data create_table :repository_list_values do |t| t.references :repository_list_item, index: true @@ -24,4 +30,9 @@ t.timestamps end end + + def down + drop_table :repository_list_items + drop_table :repository_list_values + end end
Fix migration for better search [SCI-2108]
diff --git a/app.rb b/app.rb index abc1234..def5678 100644 --- a/app.rb +++ b/app.rb @@ -16,6 +16,8 @@ def send_invitations @vip_clients = VipClients.all - return Birthday.greetings(@vip_clients) if @vip_clients.any? +if @vip_clients.any? + Birthday.greetings(@vip_clients) +end end
Change if condition for gretting call
diff --git a/app.rb b/app.rb index abc1234..def5678 100644 --- a/app.rb +++ b/app.rb @@ -4,7 +4,7 @@ require 'phone' require './lib/models' require './lib/greeter' -require './lib/unlocker_stub' +require './lib/unlocker' require './lib/twilio_watcher' require './lib/zulip_watcher'
Change away from unlocker stub
diff --git a/Casks/font-geo-sans-light.rb b/Casks/font-geo-sans-light.rb index abc1234..def5678 100644 --- a/Casks/font-geo-sans-light.rb +++ b/Casks/font-geo-sans-light.rb @@ -2,6 +2,6 @@ url 'http://moorstation.org/typoasis/designers/klein03/text02/pc/GeosansLight.zip' homepage 'http://moorstation.org/typoasis/designers/klein03/text02/geosanslite.htm' version 'latest' - sha1 '09c6e902bdf8141ec22d54e69c12daaf867d1458' + no_checksum font 'GeosansLight.ttf' end
Update Geo Sans Light to sha256 checksums
diff --git a/periscope.gemspec b/periscope.gemspec index abc1234..def5678 100644 --- a/periscope.gemspec +++ b/periscope.gemspec @@ -18,4 +18,6 @@ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") s.executables = `git ls-files -- bin/*`.split("\n").map{|f| File.basename(f) } s.require_paths = ['lib'] + + s.add_dependency 'activesupport', '~> 3.0.0' end
Add the activesupport 3 dependency.
diff --git a/db/migrate/20101026184949_create_users.rb b/db/migrate/20101026184949_create_users.rb index abc1234..def5678 100644 --- a/db/migrate/20101026184949_create_users.rb +++ b/db/migrate/20101026184949_create_users.rb @@ -0,0 +1,29 @@+class CreateUsers < ActiveRecord::Migration + def up + unless table_exists?("spree_users") + create_table "spree_users", :force => true do |t| + t.string "crypted_password", :limit => 128 + t.string "salt", :limit => 128 + t.string "email" + t.string "remember_token" + t.string "remember_token_expires_at" + t.string "persistence_token" + t.string "single_access_token" + t.string "perishable_token" + t.integer "login_count", :default => 0, :null => false + t.integer "failed_login_count", :default => 0, :null => false + t.datetime "last_request_at" + t.datetime "current_login_at" + t.datetime "last_login_at" + t.string "current_login_ip" + t.string "last_login_ip" + t.string "login" + t.integer "ship_address_id" + t.integer "bill_address_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "openid_identifier" + end + end + end +end
Add migration to create a spree_users table if it doesn't already exist
diff --git a/lib/sastrawi/morphology/disambiguator/disambiguator_prefix_rule34.rb b/lib/sastrawi/morphology/disambiguator/disambiguator_prefix_rule34.rb index abc1234..def5678 100644 --- a/lib/sastrawi/morphology/disambiguator/disambiguator_prefix_rule34.rb +++ b/lib/sastrawi/morphology/disambiguator/disambiguator_prefix_rule34.rb @@ -0,0 +1,19 @@+module Sastrawi + module Morphology + module Disambiguator + class DisambiguatorPrefixRule34 + def disambiguate(word) + contains = /^pe([bcdfghjklmnpqrstvwxyz])(.*)$/.match(word) + + if contains + matches = contains.captures + + return if /^er(.*)$/.match(matches[1]) + + return matches[0] << matches[1] + end + end + end + end + end +end
Add implementation of thirtieth-fourth rule of disambiguator prefix
diff --git a/cookbooks/docker/recipes/default.rb b/cookbooks/docker/recipes/default.rb index abc1234..def5678 100644 --- a/cookbooks/docker/recipes/default.rb +++ b/cookbooks/docker/recipes/default.rb @@ -9,6 +9,12 @@ package "docker-engine" +group 'docker' do + action :modify + append true + members [ENV['SUDO_USER']] +end + service 'docker' do action :enable end
Add user to docker group - Fixes "Cannot connect to docker daemon"
diff --git a/cookbooks/docker/recipes/default.rb b/cookbooks/docker/recipes/default.rb index abc1234..def5678 100644 --- a/cookbooks/docker/recipes/default.rb +++ b/cookbooks/docker/recipes/default.rb @@ -1,9 +1,9 @@- -remote_file "/tmp/install_docker" do - source "https://get.docker.com/" - mode 0755 +apt_repository "docker" do + uri "https://get.docker.com/ubuntu" + components ["docker", "main"] + keyserver "hkp://p80.pool.sks-keyservers.net:80" + key "36A1D7869245C8950F966E92D8576A8BA88D21E9" + action :add end -execute "install docker" do - command "sh /tmp/install_docker" -end +package "lxc-docker"
Use docker repo rather than shell installer
diff --git a/lib/rupture/fn.rb b/lib/rupture/fn.rb index abc1234..def5678 100644 --- a/lib/rupture/fn.rb +++ b/lib/rupture/fn.rb @@ -20,20 +20,28 @@ not call(*args) end end -end -class Object - def fn(name) - block = instance_method(name) - lambda do |object, *args| - block.bind(object)[*args] + def partial(*partials) + lambda do |*args| + call(*(partials + args)) end end - def fnc(name) - block = method(name) + alias -@ complement +end + +class Symbol + def ~ lambda do |object, *args| - block.bind(object)[*args] + object.method(self)[*args] end end end + +class Module + def [](method_name) + lambda do |*args| + self.send(method_name, *args) + end + end +end
Improve syntax for working with first-order functions
diff --git a/lib/tasks/om.rake b/lib/tasks/om.rake index abc1234..def5678 100644 --- a/lib/tasks/om.rake +++ b/lib/tasks/om.rake @@ -1,6 +1,7 @@ namespace :om do desc "Fetch data for all cafeterias" task :fetch => :environment do + Rails.logger.info "[INFO] Fetch cafeteria data..." date = Time.zone.now.to_date Cafeteria.all.each do |cafeteria|
Add log notice for cron task
diff --git a/test/boxen_preflight_etc_my_cnf_test.rb b/test/boxen_preflight_etc_my_cnf_test.rb index abc1234..def5678 100644 --- a/test/boxen_preflight_etc_my_cnf_test.rb +++ b/test/boxen_preflight_etc_my_cnf_test.rb @@ -0,0 +1,10 @@+require 'boxen/test' +require 'boxen/preflight/etc_my_cnf' + +class BoxenPreflightEtcMyCnfTest < Boxen::Test + def test_file_check + preflight = Boxen::Preflight::EtcMyCnf.new(mock('config')) + File.expects(:file?).with("/etc/my.cnf").returns(false) + assert preflight.ok? + end +end
Add test around /etc/my.cnf Preflight
diff --git a/app/views/components/pageflow/admin/members_tab.rb b/app/views/components/pageflow/admin/members_tab.rb index abc1234..def5678 100644 --- a/app/views/components/pageflow/admin/members_tab.rb +++ b/app/views/components/pageflow/admin/members_tab.rb @@ -4,7 +4,7 @@ def build(entry) if entry.memberships.any? table_for entry.memberships, :class => 'memberships' do - column t('activerecord.attributes.user.full_name') do |membership| + column t('activerecord.attributes.user.full_name'), class: 'name' do |membership| if authorized? :manage, User link_to membership.user.full_name, admin_user_path(membership.user), :class => 'view_creator' else
Add CSS Class to name Column of Admin Table Feature spec depends on exact class name.
diff --git a/app.rb b/app.rb index abc1234..def5678 100644 --- a/app.rb +++ b/app.rb @@ -38,7 +38,11 @@ get '/:map_name' do @location = Location.find_by_map_name(params[:map_name]) - !!@location ? erb :'show' : redirect to('/error') + if @location + erb :'show' + else + redirect to('/error') + end end end
Change ternary operator to if else statement
diff --git a/app.rb b/app.rb index abc1234..def5678 100644 --- a/app.rb +++ b/app.rb @@ -14,7 +14,7 @@ end get '/news-form' do - send_file File.join('public/app/news-form.html') + send_file File.join('app/views/news-form.html') end get '/form' do
Change file path for news-form
diff --git a/app.rb b/app.rb index abc1234..def5678 100644 --- a/app.rb +++ b/app.rb @@ -0,0 +1,50 @@+require 'pry' +require 'sinatra/base' +require_relative 'lib/tictactoe_rules' +require_relative 'lib/tictactoe_board' +require_relative 'lib/comp_player' +require_relative 'lib/web_game_engine' + +class TicTacToe < Sinatra::Base + enable :sessions + + get '/' do + session.clear + @ttt_rules = TictactoeRules.new + erb :index + end + + get '/game' do + # session['ttt_board'] = TictactoeBoard.new + @ttt_board = TictactoeBoard.new + rules = TictactoeRules.new + comp_player = CompPlayer.new + @game = WebGameEngine.new({ttt_board: session['ttt_board'], rules: rules, comp_player: comp_player}) + erb :game + end + + # post '/game' do + # ttt_board = TictactoeBoard.new + # rules = TictactoeRules.new + # comp_player = CompPlayer.new + # @game = WebGameEngine.new({ttt_board: @ttt_board, rules: rules, comp_player: comp_player}) + # # session['game'] = @game.ttt_board + + + # erb :game + # end + + post '/game/move' do + @ttt_board = TictactoeBoard.new + rules = TictactoeRules.new + comp_player = CompPlayer.new + @game = WebGameEngine.new(ttt_board: @ttt_board, rules: rules, comp_player: comp_player) + @player_input = params[:grid_position] + @ttt_board = @game.ttt_board.move(@player_input) + @ttt_board = @game.comp_player.comp_move(@ttt_board, rules) + # binding.pry + + erb :game + end + +end
Create controller at root dir
diff --git a/app/helpers/github_url_helper.rb b/app/helpers/github_url_helper.rb index abc1234..def5678 100644 --- a/app/helpers/github_url_helper.rb +++ b/app/helpers/github_url_helper.rb @@ -6,7 +6,7 @@ end def github_avatar(user, options={}) - uri = URI.parse(user.avatar_url) rescue DEFAULT_AVATAR + uri = URI.parse(user.avatar_url) rescue DEFAULT_AVATAR.dup attributes = {alt: user.name} if options[:size] uri.query ||= ''
Fix appending size to github urls
diff --git a/spec/features/project/shortcuts_spec.rb b/spec/features/project/shortcuts_spec.rb index abc1234..def5678 100644 --- a/spec/features/project/shortcuts_spec.rb +++ b/spec/features/project/shortcuts_spec.rb @@ -0,0 +1,21 @@+require 'spec_helper' + +feature 'Project shortcuts', feature: true do + let(:project) { create(:project) } + let(:user) { create(:user) } + + describe 'On a project', js: true do + before do + project.team << [user, :master] + login_as user + visit namespace_project_path(project.namespace, project) + end + + describe 'pressing "i"' do + it 'redirects to new issue page' do + find('body').native.send_key('i') + expect(page).to have_content('New Issue') + end + end + end +end
Add Rspec test for "i" shortcut
diff --git a/Re-Lax.podspec b/Re-Lax.podspec index abc1234..def5678 100644 --- a/Re-Lax.podspec +++ b/Re-Lax.podspec @@ -18,4 +18,5 @@ spec.requires_arc = true spec.platform = ['tvos'] spec.tvos.deployment_target = '9.0' + spec.swift_version = '4.1' end
Update Podspec to specify swift version support
diff --git a/aggregator.gemspec b/aggregator.gemspec index abc1234..def5678 100644 --- a/aggregator.gemspec +++ b/aggregator.gemspec @@ -8,8 +8,8 @@ spec.version = Aggregator::VERSION spec.authors = ["Joao Carlos"] spec.email = ["[email protected]"] - spec.summary = %q{TODO: Write a short summary. Required.} - spec.description = %q{TODO: Write a longer description. Optional.} + spec.summary = %q{Aggregate items on a separate thread.} + spec.description = %q{Define aggregators that run on a separate thread so that you can do more, faster.} spec.homepage = "" spec.license = "MIT"
Add gem description and summary
diff --git a/C4.podspec b/C4.podspec index abc1234..def5678 100644 --- a/C4.podspec +++ b/C4.podspec @@ -12,9 +12,11 @@ s.license = "MIT" s.authors = { "Travis" => "[email protected]", "Alejandro Isaza" => "[email protected]" } - s.platform = :ios - s.ios.deployment_target = '9.0' - s.source = { :git => "https://github.com/C4Labs/C4iOS.git", :tag => s.version } + s.ios.deployment_target = '9.3' + s.tvos.deployment_target = '9.3' - s.source_files = "C4/**/*.swift" + s.source = { :git => "https://github.com/C4Labs/C4iOS.git", :tag => s.version } + + s.source_files = "C4/**/*.swift" + s.tvos.exclude_files = 'C4/UI/UIGestureRecognizer+Closure.swift', 'C4/UI/View+Gestures.swift', 'C4/UI/Camera.swift' end
Declare tvOS support for CocoaPods
diff --git a/business_calendar.gemspec b/business_calendar.gemspec index abc1234..def5678 100644 --- a/business_calendar.gemspec +++ b/business_calendar.gemspec @@ -23,7 +23,6 @@ spec.add_development_dependency "bundler", "~> 1.3" spec.add_development_dependency "rake" spec.add_development_dependency "pry" - spec.add_development_dependency "pry-debugger" spec.add_development_dependency "rspec", "~> 3.2" spec.add_development_dependency "timecop" end
Remove pry-debugger from dev dependencies
diff --git a/lib/online_pimp/verificators/service_example.rb b/lib/online_pimp/verificators/service_example.rb index abc1234..def5678 100644 --- a/lib/online_pimp/verificators/service_example.rb +++ b/lib/online_pimp/verificators/service_example.rb @@ -1,5 +1,5 @@ module OnlinePimp::Verificators - class ServiceExample + class ServiceExample < Base attr_reader :name def initialize(name)
Make sure example inherits from base
diff --git a/app/models/idea.rb b/app/models/idea.rb index abc1234..def5678 100644 --- a/app/models/idea.rb +++ b/app/models/idea.rb @@ -7,7 +7,7 @@ has_many :voters, :through => :votes, :source => :user, :class_name => 'User' has_many :comments, -> { order(created_at: :asc) }, :dependent => :destroy do def visible - r = find :all, :conditions => { :hidden => false } + r = where :hidden => false end end has_and_belongs_to_many :tags,
Update method for finding visible Comments Old method is deprecated. Use newer 'where(conditions)' instead.
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 @@ -9,7 +9,6 @@ validates :name, presence: true, length: { maximum: 50 } # crop_attached_file :avatar enum privacy_setting: [:public_profile, :restricted_profile, :private_profile] - attr_accessor :old_password has_many :addresses def first_name
Remove unnecessary attr_accessor in User model
diff --git a/app/models/vote.rb b/app/models/vote.rb index abc1234..def5678 100644 --- a/app/models/vote.rb +++ b/app/models/vote.rb @@ -1,4 +1,6 @@ class Vote < ActiveRecord::Base + + self.primary_keys = :idea_id, :user_id belongs_to :idea belongs_to :user
Add primary keys to Vote model Specify the 'idea_id' and 'user_id' attributes are to be used as unique primary keys. Records will be uniquely identified by this composite key, not the 'id' field created and used by Rails by default.
diff --git a/app/helpers/supporters_helper.rb b/app/helpers/supporters_helper.rb index abc1234..def5678 100644 --- a/app/helpers/supporters_helper.rb +++ b/app/helpers/supporters_helper.rb @@ -18,11 +18,12 @@ end def plan_change_word_past_tense(from_plan, to_plan) - word = plan_change_word(from_plan, to_plan) - if word == "Signup" - "Signed up" + if to_plan.price > from_plan.price + "Upgraded" + elsif to_plan.price < from_plan.price + "Downgraded" else - word + "d" + raise end end
Remove unused logic path in helper
diff --git a/app/mailers/newsletter_mailer.rb b/app/mailers/newsletter_mailer.rb index abc1234..def5678 100644 --- a/app/mailers/newsletter_mailer.rb +++ b/app/mailers/newsletter_mailer.rb @@ -13,9 +13,9 @@ @newsletter_user = newsletter_user @newsletter_user.name = @newsletter_user.extract_name_from_email I18n.with_locale(@newsletter_user.lang) do - welcome_newsletter = StringBox.find_by(key: 'welcome_newsletter') - @title = welcome_newsletter.title - @content = welcome_newsletter.content + welcome_newsletter = NewsletterSetting.first + @title = welcome_newsletter.title_subscriber + @content = welcome_newsletter.content_subscriber end @is_welcome_user = true @see_in_browser = true
Use NewsletterSetting instead of StringBox as welcome_user mail content
diff --git a/spec/features/user_visits_roster_transactions_page_spec.rb b/spec/features/user_visits_roster_transactions_page_spec.rb index abc1234..def5678 100644 --- a/spec/features/user_visits_roster_transactions_page_spec.rb +++ b/spec/features/user_visits_roster_transactions_page_spec.rb @@ -2,12 +2,13 @@ feature "user visits roster transactions page" do scenario "and views a list of waiver claims in a league" do - fantasy_league = create(:fantasy_league, id: 1) + fantasy_league = create(:fantasy_league, + id: FantasyLeague::DEFAULT_LEAGUE_ID) fantasy_team = create(:fantasy_team, fantasy_league: fantasy_league) add_fantasy_player = create(:fantasy_player) drop_fantasy_player = create(:fantasy_player) transaction = create(:roster_transaction, - roster_transaction_type: "waiver claim") + roster_transaction_type: "waiver claim") create(:transaction_line_item, fantasy_team: fantasy_team, fantasy_player: drop_fantasy_player, action: "drops", roster_transaction: transaction)
Add Default League ID to spec
diff --git a/spec/service_methods/miq_ae_service_classification_spec.rb b/spec/service_methods/miq_ae_service_classification_spec.rb index abc1234..def5678 100644 --- a/spec/service_methods/miq_ae_service_classification_spec.rb +++ b/spec/service_methods/miq_ae_service_classification_spec.rb @@ -1,5 +1,4 @@ require 'spec_helper' -include AutomationSpecHelper describe MiqAeMethodService::MiqAeServiceClassification do before do @@ -10,34 +9,15 @@ end let(:user) { FactoryGirl.create(:user_with_group) } - - def setup_model(method_script) - create_ae_model_with_method(:method_script => method_script, - :name => 'VITALSTATISTIX', - :ae_namespace => 'OBELIX', - :ae_class => 'ASTERIX', - :instance_name => 'DOGMATIX', - :method_name => 'GETAFIX') - end - - def invoke_ae - MiqAeEngine.instantiate("/OBELIX/ASTERIX/DOGMATIX", user) - end + let(:categories) { MiqAeMethodService::MiqAeServiceClassification.categories } it "get a list of categories" do - setup_model("$evm.root['result'] = $evm.vmdb('Classification').categories") - cats = invoke_ae.root('result') - expect(cats.collect(&:name)).to match_array(@cat_array) + expect(categories.collect(&:name)).to match_array(@cat_array) end it "check the tags" do - script = <<-'RUBY' - categories = $evm.vmdb('Classification').categories - cc = categories.detect { |c| c.name == 'cc' } - $evm.root['result'] = cc.entries - RUBY - setup_model(script) - tags = invoke_ae.root('result') + cc = categories.detect { |c| c.name == 'cc' } + tags = cc.entries expect(tags.collect(&:name)).to match_array(@tags_array) end end
Automate methods can access categories and entries https://bugzilla.redhat.com/show_bug.cgi?id=1254953 Made the tests directly call the service model methods instead of calling automate methods. Makes the tests run faster without the overhead of Automate models (transferred from ManageIQ/manageiq@08e224a7f06a2d377d1fb24a0698bc268e6078a4)
diff --git a/app/services/registry_service.rb b/app/services/registry_service.rb index abc1234..def5678 100644 --- a/app/services/registry_service.rb +++ b/app/services/registry_service.rb @@ -4,13 +4,19 @@ def self.sync_rules last_sync = SyncAttempt.last - cl = XA::Registry::Client.new(ENV.fetch('XA_REGISTRY_URL', nil) || Settings::Defaults.registry.url) - resp = last_sync ? cl.rules(last_sync.token) : cl.rules + begin + cl = XA::Registry::Client.new(ENV.fetch('XA_REGISTRY_URL', nil) || Settings::Defaults.registry.url) - SyncAttempt.create(token: resp['since']) + resp = last_sync ? cl.rules(last_sync.token) : cl.rules + + SyncAttempt.create(token: resp['since']) + + resp['rules'].map do |ref| + Rule.create(reference: ref, public_id: UUID.generate) + end + rescue + Rails.logger.error("TODO_fix: failed to create client") + end - resp['rules'].map do |ref| - Rule.create(reference: ref, public_id: UUID.generate) - end end end
Deal with Registry connection problems
diff --git a/attributes/intellij_community_edition.rb b/attributes/intellij_community_edition.rb index abc1234..def5678 100644 --- a/attributes/intellij_community_edition.rb +++ b/attributes/intellij_community_edition.rb @@ -1,15 +1,15 @@ case node[:platform] when "centos", "redhat", "debian", "ubuntu" - default['intellij_community_edition']['download_url']="http://download.jetbrains.com/idea/ideaIC-13.1.tar.gz" + default['intellij_community_edition']['download_url']="http://download.jetbrains.com/idea/ideaIC-14.0.1.tar.gz" - default['intellij_community_edition']['name']="IntelliJ IDEA 13 CE" + default['intellij_community_edition']['name']="IntelliJ IDEA 14 CE" when "mac_os_x" - default['intellij_community_edition']['download_url']="http://download.jetbrains.com/idea/ideaIC-13.1.dmg" + default['intellij_community_edition']['download_url']="http://download.jetbrains.com/idea/ideaIC-14.0.1.dmg" - default['intellij_community_edition']['name']="IntelliJ IDEA 13 CE" + default['intellij_community_edition']['name']="IntelliJ IDEA 14 CE" end default['intellij_community_edition']['install_path']="/usr/local" -default['intellij_community_edition']['install_dir']="ideaIC-13" +default['intellij_community_edition']['install_dir']="ideaIC-14" default['intellij_community_edition']['shortcut_name']="intellij-ideaIC"
Update to Community Edition 14.0.1
diff --git a/db/migrate/20160719141858_change_lgsl_230_to_107_on_local_transaction.rb b/db/migrate/20160719141858_change_lgsl_230_to_107_on_local_transaction.rb index abc1234..def5678 100644 --- a/db/migrate/20160719141858_change_lgsl_230_to_107_on_local_transaction.rb +++ b/db/migrate/20160719141858_change_lgsl_230_to_107_on_local_transaction.rb @@ -0,0 +1,15 @@+class ChangeLgsl230To107OnLocalTransaction < Mongoid::Migration + def self.up + # "Editing of an edition with an Archived artefact is not allowed". + Edition.skip_callback(:save, :before, :check_for_archived_artefact) + + sheltered_housing_editions = LocalTransactionEdition.where(lgsl_code: 230) + sheltered_housing_editions.each do |edition| + edition.lgsl_code = 107 + edition.save!(validate: false) + end + end + + def self.down + end +end
Change sheltered housing transaction to LGSL 107 We want to use LGSL 107 (instead of 230) for the sheltered housing local transaction as it is supported in England and Wales. This migration is one of the last bits of the puzzle from this Trello card: https://trello.com/c/Zb42F6Jq/417-switch-local-transaction-for-apply-for-sheltered-housing-from-one-lgsl-to-another-3
diff --git a/spec/ruboty/toggle_switch/storage_spec.rb b/spec/ruboty/toggle_switch/storage_spec.rb index abc1234..def5678 100644 --- a/spec/ruboty/toggle_switch/storage_spec.rb +++ b/spec/ruboty/toggle_switch/storage_spec.rb @@ -2,7 +2,7 @@ describe Ruboty::ToggleSwitch::Storage do subject(:storage) { Ruboty::ToggleSwitch::Storage.new(brain) } - let(:brain) { double('brain', data: {}) } + let(:brain) { Ruboty::Brains::Memory.new } let(:key) { 'key' } describe '#[](key)' do
Use real brain instead of stub
diff --git a/app/mailers/digest_mailer.rb b/app/mailers/digest_mailer.rb index abc1234..def5678 100644 --- a/app/mailers/digest_mailer.rb +++ b/app/mailers/digest_mailer.rb @@ -14,6 +14,7 @@ end private + def posts_to_email(history) return history.daily_posts if history.frequency == 'daily' return history.weekly_posts if history.frequency == 'weekly'
Add blank line after private
diff --git a/app/models/procedure_path.rb b/app/models/procedure_path.rb index abc1234..def5678 100644 --- a/app/models/procedure_path.rb +++ b/app/models/procedure_path.rb @@ -1,5 +1,5 @@ class ProcedurePath < ApplicationRecord - validates :path, format: { with: /\A[a-z0-9_\-]{3,50}\z/ }, presence: true, allow_blank: false, allow_nil: false + validates :path, format: { with: /\A[a-z0-9_\-]{3,50}\z/ }, uniqueness: true, presence: true, allow_blank: false, allow_nil: false validates :administrateur_id, presence: true, allow_blank: false, allow_nil: false validates :procedure_id, presence: true, allow_blank: false, allow_nil: false
Add uniqueness validation to procedure path
diff --git a/frontend/app/controllers/application_controller.rb b/frontend/app/controllers/application_controller.rb index abc1234..def5678 100644 --- a/frontend/app/controllers/application_controller.rb +++ b/frontend/app/controllers/application_controller.rb @@ -26,7 +26,11 @@ def current_user=(user) @current_user = user - session[:user_id] = user.uid + if user.nil? + session.delete(:user_id) + else + session[:user_id] = user.uid + end end private
Fix deleting current user from session on signout
diff --git a/test/nidyx/test_model_base.rb b/test/nidyx/test_model_base.rb index abc1234..def5678 100644 --- a/test/nidyx/test_model_base.rb +++ b/test/nidyx/test_model_base.rb @@ -0,0 +1,26 @@+require "minitest/autorun" +require "nidyx/model_base" + +class TestModelBase < Minitest::Test + + MOCK_OPTS = { + :author => "test_author", + :company => "test_company", + :project => "test_project" + } + + def test_empty_options + model = Nidyx::ModelBase.new("ModelName", {}) + assert_equal("ModelName", model.name) + assert_equal(ENV['USER'], model.author) + assert_equal(ENV['USER'], model.owner) + assert_equal(nil, model.project) + end + + def test_full_options + model = Nidyx::ModelBase.new("ModelName", MOCK_OPTS) + assert_equal("test_author", model.author) + assert_equal("test_company", model.owner) + assert_equal("test_project", model.project) + end +end
Add option tests for model base Closes #1
diff --git a/benchmarks/allocations/helper.rb b/benchmarks/allocations/helper.rb index abc1234..def5678 100644 --- a/benchmarks/allocations/helper.rb +++ b/benchmarks/allocations/helper.rb @@ -14,10 +14,17 @@ end results = stats.allocations(alias_paths: true).group_by(*columns).from_pwd.sort_by_size.to_text + count_regex = /\s+(\d+)\z/ + + total_objects = results.split("\n").map { |line| line[count_regex, 1] }.compact.map { |c| Integer(c) }.inject(0, :+) + filtered = results.split("\n").select do |line| - count = line[/\s+(\d+)\z/, 1] + count = line[count_regex, 1] count.nil? || Integer(count) >= min_allocations - end.join("\n") + end - puts filtered + puts filtered.join("\n") + line_length = filtered.last.length + puts "-" * line_length + puts "Total:#{total_objects.to_s.rjust(line_length - "Total:".length)}" end
Add totals to allocation output.
diff --git a/app/sweepers/post_sweeper.rb b/app/sweepers/post_sweeper.rb index abc1234..def5678 100644 --- a/app/sweepers/post_sweeper.rb +++ b/app/sweepers/post_sweeper.rb @@ -1,26 +1,5 @@ class PostSweeper < ActionController::Caching::Sweeper observe CrowdblogCore::Post - def after_create(post) - expire_all(post) - end - - def after_update(post) - expire_all(post) - end - - def after_destroy(post) - expire_all(post) - end - - private - def expire_all(post) - if post.published? - expire_page(controller: '/posts', action: 'index') - expire_page(controller: '/posts', action: 'show', - year: post.year, month: post.month, day: post.day, id: post.permalink, format: 'html') - expire_page atom_feed_path(format: 'xml') - end - expire_page preview_path(post.to_param) - end + # Implement it in your base app! end
Remove sweeper code, let the implementation to be done in the container app
diff --git a/lib/helpers/find_or_create_students.rb b/lib/helpers/find_or_create_students.rb index abc1234..def5678 100644 --- a/lib/helpers/find_or_create_students.rb +++ b/lib/helpers/find_or_create_students.rb @@ -3,7 +3,7 @@ # def find_or_create_student(username) user_created = nil - using_cache = !!@user_cache + using_cache = !@user_cache.nil? if !using_cache || !@user_cache.key?(username) profile = { first_name: Faker::Name.first_name,
QUALITY: Use .nil? over double negation
diff --git a/lib/paperclip/storage/dropbox/generator_factory.rb b/lib/paperclip/storage/dropbox/generator_factory.rb index abc1234..def5678 100644 --- a/lib/paperclip/storage/dropbox/generator_factory.rb +++ b/lib/paperclip/storage/dropbox/generator_factory.rb @@ -7,7 +7,7 @@ def self.build_url_generator(storage, options) if options[:dropbox_credentials][:access_type] == "app_folder" || options[:dropbox_visibility] == "private" PrivateUrlGenerator.new(storage, options) - elsif options[:dropbox_credentials][:access_type] == "dropbox" + elsif options[:dropbox_credentials][:access_type] PublicUrlGenerator.new(storage, options) end end
Fix "undefined method `generate' for nil:NilClass" Fixes #45
diff --git a/lib/tasks/gobierto_budgets/missing_categories.rake b/lib/tasks/gobierto_budgets/missing_categories.rake index abc1234..def5678 100644 --- a/lib/tasks/gobierto_budgets/missing_categories.rake +++ b/lib/tasks/gobierto_budgets/missing_categories.rake @@ -0,0 +1,44 @@+# frozen_string_literal: true + +namespace :gobierto_budgets do + namespace :missing_categories do + desc "Check missing categories" + task :check, [:site_domain] => [:environment] do |_t, args| + site = Site.find_by!(domain: args[:site_domain]) + ine_code = site.place.id + + missing = [] + [GobiertoBudgets::BudgetLine::INCOME, GobiertoBudgets::BudgetLine::EXPENSE].each do |kind| + GobiertoBudgets::BudgetArea.all_areas_names.each do |area_name| + missing_names = GobiertoBudgets::BudgetLine.all(where: { site: site, place: site.place, kind: kind, area_name: area_name }).select{ |bl| bl.name.blank? } + if missing_names.any? + missing = missing.concat(missing_names) + end + end + end + + if missing.length == 0 + puts " - No missing category names for #{site.name} - #{site.domain}" + exit(0) + end + + file_name = "/tmp/missing_categories_#{site.id}.csv" + CSV.open(file_name, "wb") do |csv| + csv << %W{ Area Tipo Codigo Nombre Descripcion } + while missing.any? + budget_line = missing.pop + csv << [ budget_line.area.area_name[0].upcase, budget_line.kind, budget_line.code, budget_line.name, budget_line.description ] + missing.delete_if do |other_budget_line| + if other_budget_line.id.split('/')[2..-1] == budget_line.id.split('/')[2..-1] + missing.delete(other_budget_line) + end + end + end + end + + puts + puts " - Written file #{file_name}" + puts + end + end +end
Add task to check missing category names
diff --git a/spec/models/repository_protected_branche_spec.rb b/spec/models/repository_protected_branche_spec.rb index abc1234..def5678 100644 --- a/spec/models/repository_protected_branche_spec.rb +++ b/spec/models/repository_protected_branche_spec.rb @@ -31,6 +31,8 @@ it { should validate_presence_of(:permissions) } it { should validate_presence_of(:user_list) } + it { should validate_uniqueness_of(:path).scoped_to([:permissions, :repository_id]) } + it { should validate_inclusion_of(:permissions).in_array(%w(RW RW+)) } ## Serializations
Add test for ProtectBranche uniqueness
diff --git a/app/models/item.rb b/app/models/item.rb index abc1234..def5678 100644 --- a/app/models/item.rb +++ b/app/models/item.rb @@ -2,4 +2,6 @@ validates :name, presence: { message: "Name field can't be left blank"}, length: { in: 3..64, message: "Name must be between 3 and 64 characters in length" } validates :description, presence: { message: "Description field can't be left blank" }, length: { in: 3..3000, message: "Description must be between 3 and 3,000 characters" } validates :quantity, presence: { message: "Quantity field can't be left blank" }, numericality: { greater_than: 0, message: "Must be an integer greater than 0" } + # Price validation needs it to be in legit $10.99 value format + validates :price, presence: { message: "Price field can't be left blank"} end
Update Item price validation. Include comment pointing out that format still needs to be set
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 @@ -12,6 +12,6 @@ validates :name, presence: true def twitter=(handle) - write_attribute :twitter, handle.gsub(/\A@/,'') + write_attribute :twitter, handle.gsub(/\A@/,'') if handle end end
Fix setting a User's twitter handle to nil
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 @@ -2,6 +2,9 @@ # https://github.com/EppO/rolify rolify + + # Public: Username for user. + # column :username # Public: Name of user. # column :name @@ -14,6 +17,9 @@ # Public: Id of user on OAuth provider. # column :uid + + # Public: GitHub OAuth token, handy for making API requests. + # column :token # Public: Created at date and time. # column :created_at
Add comments for new User attributes.
diff --git a/messaging.gemspec b/messaging.gemspec index abc1234..def5678 100644 --- a/messaging.gemspec +++ b/messaging.gemspec @@ -1,7 +1,7 @@ # -*- encoding: utf-8 -*- Gem::Specification.new do |s| s.name = 'evt-messaging' - s.version = '0.29.0.12' + s.version = '1.0.0.0' s.summary = 'Common primitives for platform-specific messaging implementations for Eventide' s.description = ' '
Package version is increased from 0.29.0.12 to 1.0.0.0
diff --git a/lib/generators/draper/model/templates/model.rb b/lib/generators/draper/model/templates/model.rb index abc1234..def5678 100644 --- a/lib/generators/draper/model/templates/model.rb +++ b/lib/generators/draper/model/templates/model.rb @@ -1,4 +1,5 @@ class <%= singular_name.camelize %>Decorator < Draper::Base + decorates :<%= singular_name.to_sym %> # Helpers from Rails an Your Application # You can access any helper via a proxy to ApplicationController
Update template to generate 'decorates' line
diff --git a/lib/validates_email_format_of/rspec_matcher.rb b/lib/validates_email_format_of/rspec_matcher.rb index abc1234..def5678 100644 --- a/lib/validates_email_format_of/rspec_matcher.rb +++ b/lib/validates_email_format_of/rspec_matcher.rb @@ -6,7 +6,7 @@ actual.send(:"#{attribute}=", "invalid@example.") expect(actual).to be_invalid @expected_message ||= ValidatesEmailFormatOf.default_message - expect(actual.errors.added?(attribute, :invalid_email_address)).to be_truthy + expect(actual.errors.added?(attribute, @expected_message)).to be_truthy end chain :with_message do |message| @expected_message = message
Fix rspec run fail when using custom error message
diff --git a/app/app.rb b/app/app.rb index abc1234..def5678 100644 --- a/app/app.rb +++ b/app/app.rb @@ -17,7 +17,7 @@ Player.mute end get '/playing' do - "<img src='/playing.png'><br/>#{Player.playing}" + Player.playing end put '/next' do Player.next
Revert add art to playing in web.
diff --git a/modelling.gemspec b/modelling.gemspec index abc1234..def5678 100644 --- a/modelling.gemspec +++ b/modelling.gemspec @@ -18,7 +18,5 @@ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } s.require_paths = ['lib'] - # specify any dependencies here; for example: - # s.add_development_dependency 'rspec' - s.add_runtime_dependency 'rspec' + s.add_development_dependency 'rspec' end
Move rspec to development dependency
diff --git a/env.rb b/env.rb index abc1234..def5678 100644 --- a/env.rb +++ b/env.rb @@ -3,7 +3,7 @@ end configure :production do - db = URI.parse(ENV['DATABASE_URL'] || 'postgres:///localhost/mydb') + db = URI.parse(ENV['HEROKU_POSTGRESQL_ONYX_URL'] || 'postgres:///localhost/mydb') ActiveRecord::Base.establish_connection( :adapter => db.scheme == 'postgres' ? 'postgresql' : db.scheme,
Fix DB URL on Heroku