diff
stringlengths
65
26.7k
message
stringlengths
7
9.92k
diff --git a/config/application.rb b/config/application.rb index abc1234..def5678 100644 --- a/config/application.rb +++ b/config/application.rb @@ -2,7 +2,7 @@ require 'dotenv' require './helpers/logs_helpers' -Cuba.use Rack::Static, urls: %w[/js /css], root: "public" +Cuba.use Rack::Static, urls: %w[/js /css /img], root: "public" Cuba.plugin LogsHelpers Cuba.plugin Cuba::Render Cuba.settings[:render][:template_engine] = "slim"
Add img folder for cuba.
diff --git a/lib/rsscache/feed.rb b/lib/rsscache/feed.rb index abc1234..def5678 100644 --- a/lib/rsscache/feed.rb +++ b/lib/rsscache/feed.rb @@ -3,6 +3,10 @@ module RSSCache # An RSS or Atom feed. class Feed + # Maximum number of seconds an update will return a + # cached response. + MAX_STALENESS = 900 + # Returns the Feed content; one of RSS::Rss or RSS::Atom. attr_reader :content @@ -18,7 +22,7 @@ def initialize(args = {}) @url ||= args[:url] @fetcher ||= RSSCache::Fetcher.new url: url - update + update(true) end ## @@ -53,11 +57,22 @@ end ## + # Returns the Feed's staleness. + + def staleness + Time.now - @last_fetched + end + + ## # Updates the Feed. - def update - @fetcher.fetch - @content = SimpleRSS.parse @fetcher.content + def update(force = false) + if force || staleness > MAX_STALENESS + @fetcher.fetch + @content = SimpleRSS.parse @fetcher.content + @last_fetched = Time.now + end + true end end end
Add some very basic caching behavior. A `MAX_STALENESS` in number of seconds governs whether or not the update method actually does any fetching. This is pretty much a stand-in until some more thoughtful caching is implemented. The update method accepts one parameter, defaulting to false, that determines whether a hard fetch is done regardless of the staleness. Ideally, staleness would be based in whole or in part on the historical update frequency for each individual feed. The update method would also return something more useful than `true`: perhaps any new item(s) since the last update.
diff --git a/engines/standard_tasks/spec/models/paper_admin_task_spec.rb b/engines/standard_tasks/spec/models/paper_admin_task_spec.rb index abc1234..def5678 100644 --- a/engines/standard_tasks/spec/models/paper_admin_task_spec.rb +++ b/engines/standard_tasks/spec/models/paper_admin_task_spec.rb @@ -8,15 +8,18 @@ end describe "updating paper admin" do - let(:paper) { FactoryGirl.create(:paper, :with_tasks) } + let(:sally) { create :user } + let(:bob) { create :user } + + let(:paper) { create(:paper, :with_tasks) } + let!(:role) { create(:paper_role, role: 'admin', user: bob, paper: paper) } # make bob an admin for the paper let(:phase) { paper.phases.first } let(:task) { StandardTasks::PaperAdminTask.create(phase: phase, assignee: bob, admin_id: bob.id) } - let(:sally) { create :user } - let(:bob) { create :user } context "when paper admin is changed" do it "will update paper and tasks" do expect(task).to receive(:update_paper_admin_and_tasks) + # the admin was bob, change to sally task.admin_id = sally.id task.save end @@ -25,6 +28,7 @@ context "when paper admin is not changed" do it "will not update paper or tasks" do expect(task).to_not receive(:update_paper_admin_and_tasks) + # the admin stays bob, nothing should happen. task.save end end
Fix paper admin task spec.
diff --git a/lib/sikuli/key_code.rb b/lib/sikuli/key_code.rb index abc1234..def5678 100644 --- a/lib/sikuli/key_code.rb +++ b/lib/sikuli/key_code.rb @@ -1,4 +1,6 @@ require 'java' +java_import 'org.sikuli.script.Key' +java_import 'org.sikuli.script.KeyModifier' # These constants represent keyboard codes for interacting with the keyboard. # Keyboard interaction is defined in the Sikuli::Typeable module. @@ -6,23 +8,32 @@ module Sikuli # Command Key - KEY_CMD = java.awt.event.InputEvent::META_MASK + KEY_CMD = KeyModifier::META # Shift Key - KEY_SHIFT = java.awt.event.InputEvent::SHIFT_MASK + KEY_SHIFT = KeyModifier::SHIFT # Control Key - KEY_CTRL = java.awt.event.InputEvent::CTRL_MASK + KEY_CTRL = KeyModifier::CTRL # Alt Key - KEY_ALT = java.awt.event.InputEvent::ALT_MASK + KEY_ALT = KeyModifier::ALT # Backspace Key - KEY_BACKSPACE = "\u0008" + KEY_BACKSPACE = Key::BACKSPACE # Return Key - KEY_RETURN = "\n" + KEY_RETURN = Key::ENTER # Left Arrow Key - LEFT_ARROW = "\ue003" + LEFT_ARROW = Key::LEFT + + # Right Arrow Key + RIGHT_ARROW = Key::RIGHT + + # Up Arrow Key + UP_ARROW = Key::UP + + # Down Arrow Key + DOWN_ARROW = Key::DOWN end
Use definitions of modifier keys defined by org.sikuli.script.KeyModifier Use definitions of keystrokes defined by org.sikuli.script.Key Add support for all arrow keys
diff --git a/lib/spree_robokassa.rb b/lib/spree_robokassa.rb index abc1234..def5678 100644 --- a/lib/spree_robokassa.rb +++ b/lib/spree_robokassa.rb @@ -8,7 +8,7 @@ def self.activate Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")) do |c| - Rails.env.production? ? require(c) : load(c) + Rails.application.config.cache_classes ? require(c) : load(c) end Gateway::Robokassa.register end
Change way of checking rails env.
diff --git a/rgpg.gemspec b/rgpg.gemspec index abc1234..def5678 100644 --- a/rgpg.gemspec +++ b/rgpg.gemspec @@ -13,7 +13,7 @@ s.license = 'MIT' s.authors = 'Richard Cook' s.email = 'rcook@rcook.org' - s.files = ['MIT-LICENSE.txt'] + Dir.glob('lib/**/*.rb') + s.files = ['LICENSE'] + Dir.glob('lib/**/*.rb') s.require_paths = ['lib'] s.homepage = 'https://github.com/rcook/rgpg/' end
Fix path to licence file in gemspec
diff --git a/rgpg.gemspec b/rgpg.gemspec index abc1234..def5678 100644 --- a/rgpg.gemspec +++ b/rgpg.gemspec @@ -6,7 +6,7 @@ Gem::Specification.new do |s| s.name = 'rgpg' s.version = Rgpg::GemInfo.version_string - s.date = Date.today + s.date = Date.today rescue '1970-01-01' s.executables << 'rgpg' s.summary = 'rgpg' s.description = 'Simple Ruby wrapper around "gpg" command for file encryption'
Add fallback to Unix epoch if Date.today method does not exist
diff --git a/test/features/deals/show_deal_test.rb b/test/features/deals/show_deal_test.rb index abc1234..def5678 100644 --- a/test/features/deals/show_deal_test.rb +++ b/test/features/deals/show_deal_test.rb @@ -3,7 +3,7 @@ feature "Deals::ShowADeal" do scenario "anyone can view deals" do visit root_path - page.must_have_content "Deals on Demand." + page.must_have_content "Set your Ideas on Fire!" end scenario "anyone can see list of who is supporting a deal" do
Change billboard message in show deal test.
diff --git a/lib/concourse2tracker-resource/scripts/concourse2tracker.rb b/lib/concourse2tracker-resource/scripts/concourse2tracker.rb index abc1234..def5678 100644 --- a/lib/concourse2tracker-resource/scripts/concourse2tracker.rb +++ b/lib/concourse2tracker-resource/scripts/concourse2tracker.rb @@ -36,7 +36,7 @@ response = Net::HTTP.start(create_comment_uri.hostname, create_comment_uri.port, use_ssl: true) do |http| http.request(request) end - if response.code != 200 + if response != Net::HTTPSuccess puts "Failed with response code #{response.code}" puts response.body end
Check for more encompassing HTTPSuccess instead of 200 response code
diff --git a/spec/factory_spec.rb b/spec/factory_spec.rb index abc1234..def5678 100644 --- a/spec/factory_spec.rb +++ b/spec/factory_spec.rb @@ -24,6 +24,28 @@ end describe 'meeting' do - # + context 'basic' do + let(:meeting) { FactoryGirl.create(:meeting) } + + it 'has a date' do + expect(meeting.date).not_to be_nil + end + end + + context 'past meeting' do + let(:meeting) { FactoryGirl.create(:past_meeting) } + + it 'is in the past' do + expect(meeting.date).to be_past + end + end + + context 'upcoming meeting' do + let(:meeting) { FactoryGirl.create(:upcoming_meeting) } + + it 'is in the future' do + expect(meeting.date).to be_future + end + end end end
Add specs for meeting factory
diff --git a/lib/android_interface.rb b/lib/android_interface.rb index abc1234..def5678 100644 --- a/lib/android_interface.rb +++ b/lib/android_interface.rb @@ -26,7 +26,7 @@ def location_coordinates result = DROID.getLastKnownLocation["result"] - data = result["gps"] || result["passive"] + data = result["gps"] || result["network"] || result["passive"] latitude, longitude = data["latitude"], data["longitude"] longitude ? [latitude, longitude] : false end
Improve robustness of location tracking.
diff --git a/app/controllers/companies_controller.rb b/app/controllers/companies_controller.rb index abc1234..def5678 100644 --- a/app/controllers/companies_controller.rb +++ b/app/controllers/companies_controller.rb @@ -1,12 +1,6 @@ class CompaniesController < ApplicationController - + before_filter :check_access def edit - unless current_user.admin? - flash['notice'] = _("Only admins can edit company settings.") - redirect_from_last - return - end - @company = current_user.company end @@ -16,9 +10,9 @@ @internal = @company.internal_customer if @internal.nil? - flash['notice'] = 'Unable to find internal customer.' + flash['notice'] = 'Unable to find internal customer.' render :action => 'edit' - return + return end if @company.update_attributes(params[:company]) @@ -29,6 +23,14 @@ redirect_from_last else render :action => 'edit' - end + end + end +private + def check_access + unless current_user.admin? + flash['notice'] = _("Only admins can edit company settings.") + redirect_from_last + return false + end end end
Check admin access in compnaies controller update action.
diff --git a/app/presenters/experiments_presenter.rb b/app/presenters/experiments_presenter.rb index abc1234..def5678 100644 --- a/app/presenters/experiments_presenter.rb +++ b/app/presenters/experiments_presenter.rb @@ -15,9 +15,9 @@ def notification { - message: 'Would you like to opt in to our research collaboration with Carnegie Mellon University?', + message: 'Would you like to add our latest peer discussion service to help your students with their assignment?', read_more: 'Read more here.', - read_more_link: 'http://kraut.hciresearch.org/sites/kraut.hciresearch.org/files/open/WP-Instructor-ConsentForm-v3.pdf', + read_more_link: 'https://wikiedu.org/intertwine-research-collaboration/', opt_in_link: opt_in_link, opt_out_link: opt_out_link }
Update opt-in message and link
diff --git a/app/presenters/mcas_result_presenter.rb b/app/presenters/mcas_result_presenter.rb index abc1234..def5678 100644 --- a/app/presenters/mcas_result_presenter.rb +++ b/app/presenters/mcas_result_presenter.rb @@ -1,35 +1,21 @@ class McasResultPresenter < Struct.new(:result) + delegate :math_growth_warning?, :math_performance_warning?, + :ela_performance_warning?, :ela_growth_warning?, to: :result - def math_performance - result.math_performance.present? ? result.math_performance : "—" + def results_for_presentation + [ + :math_performance, + :ela_performance, + :ela_growth, + :math_growth + ] end - def ela_performance - result.ela_performance.present? ? result.ela_performance : "—" + def method_missing(m, *args, &block) + if results_for_presentation.include? m + result.send(m).present? ? result.send(m) : "—" + else + raise NoMethodError + end end - - def ela_growth - result.ela_growth.present? ? result.ela_growth : "—" - end - - def math_growth - result.math_growth.present? ? result.math_growth : "—" - end - - def math_growth_warning? - result.math_growth_warning? - end - - def math_performance_warning? - result.math_performance_warning? - end - - def ela_performance_warning? - result.ela_performance_warning? - end - - def ela_growth_warning? - result.ela_growth_warning? - end - end
Refactor McasResultPresenter to be way DRYer * Thanks @daguar! * Less code ++++++
diff --git a/lib/ffi-ogr/http_reader.rb b/lib/ffi-ogr/http_reader.rb index abc1234..def5678 100644 --- a/lib/ffi-ogr/http_reader.rb +++ b/lib/ffi-ogr/http_reader.rb @@ -4,6 +4,14 @@ module OGR class HttpReader + + TF_MAP = { + true => 1, + false => 0, + 1 => true, + 0 => false + } + def read(url, writeable=false) file_extension = url.split('.').last driver = OGR::DRIVER_TYPES[file_extension] @@ -18,19 +26,10 @@ end end - file_name = "#{SecureRandom.urlsafe_base64}.#{file_extension}" - - http_resource = Faraday.get(url).body - - File.open(file_name, 'wb') do |f| - f.write http_resource - end - - ds = Reader.new(driver).read(file_name, writeable) - - FileUtils.rm file_name - - ds + http_data = Faraday.get(url).body + ogr_driver = OGR::FFIOGR::OGRGetDriverByName driver + data_source = OGR::FFIOGR::OGR_Dr_Open ogr_driver, http_data, TF_MAP[writeable] + OGR::Tools.cast_data_source data_source end end end
Remove temp file usage in HttpReader
diff --git a/lib/expgen/randomizer.rb b/lib/expgen/randomizer.rb index abc1234..def5678 100644 --- a/lib/expgen/randomizer.rb +++ b/lib/expgen/randomizer.rb @@ -2,16 +2,22 @@ module Randomizer extend self + def range(number) + if number == "*" + [0,5] + elsif number == "+" + [1,5] + elsif number + [number[:int].to_i, number[:int].to_i] + else + [1,1] + end + end + def repeat(number) - if number == "*" - "" - elsif number == "+" - yield - elsif number - number[:int].to_i.times.map { yield }.join - else - yield - end + first, last = range(number) + number = rand(last - first + 1) + first + number.times.map { yield }.join end def randomize(tree)
Make it a bit more random
diff --git a/spec/app_spec.rb b/spec/app_spec.rb index abc1234..def5678 100644 --- a/spec/app_spec.rb +++ b/spec/app_spec.rb @@ -36,7 +36,7 @@ Example.logger.level = Logger::ERROR @app.config[:type] = :widget - @app.perform_action + @app.run log.should include("Widgets can't perform this action!") end
Fix private function call in spec
diff --git a/lib/better_errors/exception_hint.rb b/lib/better_errors/exception_hint.rb index abc1234..def5678 100644 --- a/lib/better_errors/exception_hint.rb +++ b/lib/better_errors/exception_hint.rb @@ -10,7 +10,7 @@ /\Aundefined method `(?<method>[^']+)' for (?<val>[^:]+):(?<klass>\w+)/.match(exception.message) do |match| if match[:val] == "nil" return "Something is `nil` when it probably shouldn't be." - elsif !match[:klass].start_with? /\A0x/ + elsif !match[:klass].start_with? '0x' return "`#{match[:method]}` is being called on a `#{match[:klass]}` object, "\ "which might not be the type of object you were expecting." end
Fix passing regex to start_with?
diff --git a/authem.gemspec b/authem.gemspec index abc1234..def5678 100644 --- a/authem.gemspec +++ b/authem.gemspec @@ -4,18 +4,20 @@ require 'authem/version' Gem::Specification.new do |spec| - spec.name = "authem" - spec.version = Authem::VERSION - spec.authors = ["Paul Elliott", "Pavel Pravosud"] - spec.email = ["paul@codingfrontier.com", "pavel@pravosud.com"] - spec.summary = "Authem authenticates them by email" - spec.description = "Authem provides a simple solution for email-based authentication" - spec.homepage = "https://github.com/paulelliott/authem" - spec.license = "MIT" + spec.name = "authem" + spec.version = Authem::VERSION + spec.authors = ["Paul Elliott", "Pavel Pravosud"] + spec.email = ["paul@codingfrontier.com", "pavel@pravosud.com"] + spec.summary = "Authem authenticates them by email" + spec.description = "Authem provides a simple solution for email-based authentication" + spec.homepage = "https://github.com/paulelliott/authem" + spec.license = "MIT" - spec.files = `git ls-files`.split($/) - spec.test_files = spec.files.grep("spec") - spec.require_path = "lib" + spec.required_ruby_version = ">= 2.0.0" + + spec.files = `git ls-files`.split($/) + spec.test_files = spec.files.grep("spec") + spec.require_path = "lib" spec.add_dependency "activesupport", ">= 4.0.4" spec.add_dependency "railties", "~> 4.0"
Add Ruby version requirement to gemspec
diff --git a/lib/laziness/api/base.rb b/lib/laziness/api/base.rb index abc1234..def5678 100644 --- a/lib/laziness/api/base.rb +++ b/lib/laziness/api/base.rb @@ -3,7 +3,7 @@ class Base attr_reader :access_token - def initialize(access_token) + def initialize(access_token=nil) @access_token = access_token end @@ -19,8 +19,13 @@ end def request(method, path, arguments={}) - full_path = "#{base_path}#{path}?token=#{access_token}" - arguments.each_pair { |key, value| full_path = "#{full_path}&#{key}=#{ERB::Util.url_encode(value)}" } + full_path = "#{base_path}#{path}" + full_path = "#{full_path}?token=#{access_token}" unless access_token.nil? + arguments.each_pair do |key, value| + seperator = full_path.include?("?") ? "&" : "?" + full_path = "#{full_path}#{seperator}#{key}=#{ERB::Util.url_encode(value)}" + end + options = { headers: { "Accept" => "application/json",
Make access token optional since some api calls do not have one
diff --git a/lib/mars_photos/rover.rb b/lib/mars_photos/rover.rb index abc1234..def5678 100644 --- a/lib/mars_photos/rover.rb +++ b/lib/mars_photos/rover.rb @@ -10,5 +10,17 @@ response = HTTParty.get(url) response['photos'] end + + def get_by_sol(sol) + url = MarsPhotos::Calculations.build_url(name, sol: sol) + response = HTTParty.get(url) + response['photos'] + end + + def get_by_earth_date(earth_date) + url = MarsPhotos::Calculations.build_url(name, earth_date: earth_date) + response = HTTParty.get(url) + response['photos'] + end end end
Add get_by_sol and get_by_earth_date methods
diff --git a/lib/merb_activerecord.rb b/lib/merb_activerecord.rb index abc1234..def5678 100644 --- a/lib/merb_activerecord.rb +++ b/lib/merb_activerecord.rb @@ -1,17 +1,10 @@-if defined?(Merb::Plugins) +if defined?(Merb::Plugins) dependency "activerecord" require File.join(File.dirname(__FILE__) / "merb" / "orms" / "active_record" / "connection") Merb::Plugins.add_rakefiles(File.join(File.dirname(__FILE__) / "active_record" / "merbtasks")) - - class Merb::Orms::ActiveRecord::Connect < Merb::BootLoader - after BeforeAppLoads - - def self.run - Merb::Orms::ActiveRecord.connect - Merb::Orms::ActiveRecord.register_session_type - end - + Merb::BootLoader.before_app_loads do + Merb::Orms::ActiveRecord.connect + Merb::Orms::ActiveRecord.register_session_type end - -end+end
Use simple before_app_loads hook instead of bootloader subclass.
diff --git a/test/helpers/application_helper_test.rb b/test/helpers/application_helper_test.rb index abc1234..def5678 100644 --- a/test/helpers/application_helper_test.rb +++ b/test/helpers/application_helper_test.rb @@ -12,7 +12,7 @@ # == DateTime # test 'should return current year' do - assert_equal current_year, Time.zone.now.year + assert_equal Time.zone.now.year, current_year end #
Update params order for assert test
diff --git a/test/remote/remote_add_receiver_test.rb b/test/remote/remote_add_receiver_test.rb index abc1234..def5678 100644 --- a/test/remote/remote_add_receiver_test.rb +++ b/test/remote/remote_add_receiver_test.rb @@ -25,9 +25,9 @@ end def test_add_test_receiver - receiver = @environment.add_receiver(:test, 'http://api.example.com/post') + receiver = @environment.add_receiver(:test, 'http://testserver.com') assert_equal "test", receiver.receiver_type - assert_equal 'http://api.example.com/post', receiver.hostnames + assert_equal 'http://testserver.com', receiver.hostnames end # Coming soon
Change hostname because for some reason the former one was failing this remote test
diff --git a/spec/requests/gpdb_spec.rb b/spec/requests/gpdb_spec.rb index abc1234..def5678 100644 --- a/spec/requests/gpdb_spec.rb +++ b/spec/requests/gpdb_spec.rb @@ -7,7 +7,7 @@ :port => 5432, :host => "chorus-gpdb42", :maintenance_db => "postgres", - :db_username => "test", + :db_username => "gpadmin", :db_password => "secret" } end @@ -33,4 +33,4 @@ decoded_response.name.should == "new_name" end end -end+end
Fix db username in request spec for creating instances
diff --git a/spec/str_sanitizer_spec.rb b/spec/str_sanitizer_spec.rb index abc1234..def5678 100644 --- a/spec/str_sanitizer_spec.rb +++ b/spec/str_sanitizer_spec.rb @@ -5,30 +5,13 @@ expect(StrSanitizer::VERSION).not_to be nil end - it "has a method named 'double_quote'" do + it "can invoke the methods of Quotes module" do expect(StrSanitizer.respond_to? :double_quote).to eq true - end - - it "has a method named 'single_quote'" do expect(StrSanitizer.respond_to? :single_quote).to eq true - end - - it "has a method named 'both_quotes'" do expect(StrSanitizer.respond_to? :both_quotes).to eq true - end - - it "returns a sanitized string with escaped double-quote" do - test_string = 'He said, "Look!"' - sanitized_string = StrSanitizer.double_quote(test_string) - - expect(sanitized_string).to eq('He said, \\"Look!\\"') - end - - - it "returns a sanitized string with escaped single-quote" do - test_string = "He said, 'Look!'" - sanitized_string = StrSanitizer.single_quote(test_string) - - expect(sanitized_string).to eq("He said, \\'Look!\\'") + expect(StrSanitizer.respond_to? :has_single_quote?).to eq true + expect(StrSanitizer.respond_to? :has_double_quote?).to eq true + expect(StrSanitizer.respond_to? :has_both_quotes?).to eq true + expect(StrSanitizer.respond_to? :has_any_quote?).to eq true end end
Remove specs for Quotes module in StrSanitizer class, respond_to? method will suffice
diff --git a/lib/generators/install_generator.rb b/lib/generators/install_generator.rb index abc1234..def5678 100644 --- a/lib/generators/install_generator.rb +++ b/lib/generators/install_generator.rb @@ -0,0 +1,26 @@+require 'rails/generators/base' + +module ActiveForm + module Generators + class InstallGenerator < Rails::Generators::Base + + desc "Creates a forms directory into your app and test directories and includes the necessary JS file." + + def create_forms_app_directory + empty_directory "app/forms" + end + + def create_forms_test_directory + if File.directory?("spec") + empty_directory "spec/forms" + else + empty_directory "test/forms" + end + end + + def include_js_file + insert_into_file "app/assets/javascripts/application.js", "//= require link_helpers", :before => "//= require_tree ." + end + end + end +end
Add an install generator to create a forms directory into the app and test directories and include the JS file.
diff --git a/lib/rspec_api_helpers.rb b/lib/rspec_api_helpers.rb index abc1234..def5678 100644 --- a/lib/rspec_api_helpers.rb +++ b/lib/rspec_api_helpers.rb @@ -6,4 +6,12 @@ require 'active_support/core_ext/object/json' require 'active_support/core_ext/hash' +module RspecApiHelpers + def self.included(base) + constants.map(&method(:const_get)).each do |const| + base.include const if const.class == Module + end + end +end + FactoryGirl.register_strategy :json, RspecApiHelpers::Strategies::JsonStrategy
Include child submodules in RspecApiHelpers
diff --git a/app/mailers/general_mailer.rb b/app/mailers/general_mailer.rb index abc1234..def5678 100644 --- a/app/mailers/general_mailer.rb +++ b/app/mailers/general_mailer.rb @@ -0,0 +1,13 @@+class GeneralMailer < ActionMailer::Base + def email(email) + from = "#{email.from_name} <#{email.from_email}>" + to = "#{email.to_name} <#{email.to_email}>" + + mail(from: from, to: to, subject: email.subject) do |format| + format.text { render text: email.plain_content } + format.html { render html: email.html_content.html_safe } + end + + email.mark_as_sent! + end +end
Add general mailer that sends out an email from the email model.
diff --git a/lib/regexp_parser/token.rb b/lib/regexp_parser/token.rb index abc1234..def5678 100644 --- a/lib/regexp_parser/token.rb +++ b/lib/regexp_parser/token.rb @@ -12,6 +12,12 @@ ].freeze Token = Struct.new(*TOKEN_KEYS) do + def initialize(*) + super + + @previous = @next = nil + end + def offset [self.ts, self.te] end
Remove uninitialized ivar warnings for Token
diff --git a/lib/puppet/parser/functions/lpad.rb b/lib/puppet/parser/functions/lpad.rb index abc1234..def5678 100644 --- a/lib/puppet/parser/functions/lpad.rb +++ b/lib/puppet/parser/functions/lpad.rb @@ -18,7 +18,7 @@ num = num.to_i count = count.to_i - format = "%0" + count + "d" + format = "%0#{String(count)}d" return format % num end end
Fix implicit conversion of Fixnum into String
diff --git a/lib/serialize/generator.rb b/lib/serialize/generator.rb index abc1234..def5678 100644 --- a/lib/serialize/generator.rb +++ b/lib/serialize/generator.rb @@ -1,15 +1,9 @@ class Serialize class Generator - instance_methods.each do |m| - undef_method m unless m =~ /^(__|object_id)/ - end - - attr :id def initialize(object, block) @object = object @block = block - @id = @object.id if @object.respond_to? :id end def to_hash
Remove more object-proxying craziness in Generator
diff --git a/lib/tasks/resources.rake b/lib/tasks/resources.rake index abc1234..def5678 100644 --- a/lib/tasks/resources.rake +++ b/lib/tasks/resources.rake @@ -41,6 +41,8 @@ desc 'Refreshes all the resources in the database' task refresh: :environment do Resource.find_each do |resource| + puts "Refreshing #{resource.name} from remote manifest..." + loader = ResourceLoader.new( resource.url, Resource, @@ -48,7 +50,7 @@ ) with_resource_errors(loader) do - loader.rerieve_and_store + loader.retrieve_and_store end end end
Fix typo + print info
diff --git a/lib/voodoo/peopletools/appengine.rb b/lib/voodoo/peopletools/appengine.rb index abc1234..def5678 100644 --- a/lib/voodoo/peopletools/appengine.rb +++ b/lib/voodoo/peopletools/appengine.rb @@ -15,8 +15,24 @@ append(:env_password => target.app_password) append(:r => '1') append(:ae_name => ae_name) - puts "Running #{ae_name}..." + #puts "Running #{ae_name}..." + LOG.info("Running #{ae_name}...") call_executable + end + + def call_executable + LOG.debug("Executable is set to #{@executable}") + LOG.debug("Command line options are set to #{@command_line_options.join(" ")}") + + #f = IO.popen(@executable + " " + @command_line_options.join(" ")) + #f.readlines.each { |line| puts ("#{line.chomp}")} + #f.close + pid = spawn("start " + @executable + " " + @command_line_options.join(" ")) + LOG.info("Created background process #{pid} for #{@executable}") + Process.detach(pid) + + @command_line_options.clear + set_base_parameters end end
Make running app engines non-blocking
diff --git a/recipes/ppa.rb b/recipes/ppa.rb index abc1234..def5678 100644 --- a/recipes/ppa.rb +++ b/recipes/ppa.rb @@ -11,6 +11,7 @@ apt_repository 'ubiquiti_unifi' do uri 'http://www.ubnt.com/downloads/unifi/debian' components %w(stable ubiquiti) + distribution nil keyserver 'keyserver.ubuntu.com' key 'C0A52C50' end
Support the new version of the apt cookbook
diff --git a/shortest_path.gemspec b/shortest_path.gemspec index abc1234..def5678 100644 --- a/shortest_path.gemspec +++ b/shortest_path.gemspec @@ -21,7 +21,6 @@ s.add_development_dependency "guard-rspec" s.add_development_dependency "rake" s.add_development_dependency "rspec" - s.add_development_dependency "rcov" s.add_dependency "pqueue"
Delete rcov gem for ruby 1.9
diff --git a/examples/select_disabled_paged.rb b/examples/select_disabled_paged.rb index abc1234..def5678 100644 --- a/examples/select_disabled_paged.rb +++ b/examples/select_disabled_paged.rb @@ -0,0 +1,22 @@+# frozen_string_literal: true + +require_relative "../lib/tty-prompt" + +prompt = TTY::Prompt.new + +numbers = [ + {name: '1', disabled: 'out'}, + '2', + {name: '3', disabled: 'out'}, + '4', + '5', + {name: '6', disabled: 'out'}, + '7', + '8', + '9', + {name: '10', disabled: 'out'} +] + +answer = prompt.select('Which letter?', numbers, per_page: 4, cycle: true) + +puts answer.inspect
Add example of selecting from a paged menu with disabled items
diff --git a/spec/controllers/comments_controller_spec.rb b/spec/controllers/comments_controller_spec.rb index abc1234..def5678 100644 --- a/spec/controllers/comments_controller_spec.rb +++ b/spec/controllers/comments_controller_spec.rb @@ -1 +1,9 @@-comments_controller_spec.rb +describe CommentsController do + let!(:comment) { Comment.create!(text: "Great game!", game_id: 4, user_id: 4) } + +describe "GET #new" do + it "assigns @comment as a new instance of Comment" do + get :new + expect(assigns(:comment).to be_a(Comment) + end +end
Create first test for the comments controller
diff --git a/spec/ruby/library/stringscanner/scan_spec.rb b/spec/ruby/library/stringscanner/scan_spec.rb index abc1234..def5678 100644 --- a/spec/ruby/library/stringscanner/scan_spec.rb +++ b/spec/ruby/library/stringscanner/scan_spec.rb @@ -28,6 +28,12 @@ @s.scan(/\w+/).should be_nil end + it "returns an empty string when the pattern matches empty" do + @s.scan(/.*/).should == "This is a test" + @s.scan(/.*/).should == "" + @s.scan(/./).should be_nil + end + it "raises a TypeError if pattern isn't a Regexp" do lambda { @s.scan("aoeu") }.should raise_error(TypeError) lambda { @s.scan(5) }.should raise_error(TypeError)
Add spec for matching an empty string
diff --git a/scripts/convert_to_open_stack.rb b/scripts/convert_to_open_stack.rb index abc1234..def5678 100644 --- a/scripts/convert_to_open_stack.rb +++ b/scripts/convert_to_open_stack.rb @@ -0,0 +1,13 @@+#!/bin/env ruby + +require './src/helpers/loader' + +if ARGV.size != 1 + puts 'bundle exec scripts/convert_to_open_stack.rb aws-template-file' + exit 1 +end + +template = JSON.load(File.open(ARGV.first)).with_indifferent_access + +converter = CloudConductor::Converters::OpenStackConverter.new +puts converter.convert(template, {}).to_json
Add script to convert template from aws format to openstack format
diff --git a/spec/lib/license_finder/package_managers/bundler_package_spec.rb b/spec/lib/license_finder/package_managers/bundler_package_spec.rb index abc1234..def5678 100644 --- a/spec/lib/license_finder/package_managers/bundler_package_spec.rb +++ b/spec/lib/license_finder/package_managers/bundler_package_spec.rb @@ -22,7 +22,7 @@ its(:name) { should == 'spec_name' } its(:version) { should == '2.1.3' } - its(:authors){should == "\"authors\""} + its(:authors){should == "\"\\\"authors\\\"\""} its(:summary) { should == "summary" } its(:description) { should == "description" } its(:homepage) { should == "homepage" }
Fix issue found by travis again
diff --git a/spec/models/league_request_spec.rb b/spec/models/league_request_spec.rb index abc1234..def5678 100644 --- a/spec/models/league_request_spec.rb +++ b/spec/models/league_request_spec.rb @@ -0,0 +1,57 @@+# frozen_string_literal: true + +require 'spec_helper' + +describe LeagueRequest do + let(:user) { create(:user, name: 'Admin') } + + describe '#search' do + it 'finds players by steam uid' do + player = create(:reservation_player, steam_uid: 'abc') + create(:reservation_player, steam_uid: 'def') + + request = LeagueRequest.new(user, steam_uid: 'abc') + results = request.search + + expect(results.size).to eql(1) + expect(results.first.id).to eql(player.id) + end + + it 'finds players by IP' do + player = create(:reservation_player, ip: '8.8.8.8') + create(:reservation_player, ip: '1.1.1.1') + + request = LeagueRequest.new(user, ip: '8.8.8.8') + results = request.search + + expect(results.size).to eql(1) + expect(results.first.id).to eql(player.id) + end + + it 'cross references players by IP' do + player = create(:reservation_player, steam_uid: 'abc', ip: '8.8.8.8') + alt = create(:reservation_player, steam_uid: 'def', ip: '8.8.8.8') + other_ip = create(:reservation_player, steam_uid: 'abc', ip: '1.1.1.1') + _other_player = create(:reservation_player, steam_uid: 'ghj', ip: '4.4.2.2') + + request = LeagueRequest.new(user, ip: '8.8.8.8', cross_reference: '1') + results = request.search + + expect(results.size).to eql(3) + expect(results.map(&:id).sort).to eql([player.id, alt.id, other_ip.id]) + end + + it 'cross references players by steam uid' do + player = create(:reservation_player, steam_uid: 'abc', ip: '8.8.8.8') + alt = create(:reservation_player, steam_uid: 'def', ip: '8.8.8.8') + other_ip = create(:reservation_player, steam_uid: 'abc', ip: '1.1.1.1') + _other_player = create(:reservation_player, steam_uid: 'ghj', ip: '4.4.2.2') + + request = LeagueRequest.new(user, steam_uid: 'abc', cross_reference: '1') + results = request.search + + expect(results.size).to eql(3) + expect(results.map(&:id).sort).to eql([player.id, alt.id, other_ip.id]) + end + end +end
Add a spec to explain how league search requests work
diff --git a/spec/lib/grim_spec.rb b/spec/lib/grim_spec.rb index abc1234..def5678 100644 --- a/spec/lib/grim_spec.rb +++ b/spec/lib/grim_spec.rb @@ -18,7 +18,7 @@ Grim::DENSITY.should == 300 end - describe "#new" do + describe "#reap" do it "should return an instance of Grim::Pdf" do Grim.reap(fixture_path("smoker.pdf")).class.should == Grim::Pdf end
Fix describe text on spec.
diff --git a/spec/ghost/cli/task/help_spec.rb b/spec/ghost/cli/task/help_spec.rb index abc1234..def5678 100644 --- a/spec/ghost/cli/task/help_spec.rb +++ b/spec/ghost/cli/task/help_spec.rb @@ -14,6 +14,7 @@ export Export all hosts in /etc/hosts format import Import hosts in /etc/hosts format list Show all (or a filtered) list of hosts + set Add a host or modify the IP of an existing host See 'ghost help <task>' for more information on a specific task. EOF
Add set output to help test
diff --git a/tara.gemspec b/tara.gemspec index abc1234..def5678 100644 --- a/tara.gemspec +++ b/tara.gemspec @@ -19,4 +19,5 @@ s.bindir = 'bin' s.executables = %w[tara] s.require_paths = %w[lib] + s.required_ruby_version = '>= 2.1.5' end
Set required Ruby version in gemspec
diff --git a/lib/twurl.rb b/lib/twurl.rb index abc1234..def5678 100644 --- a/lib/twurl.rb +++ b/lib/twurl.rb @@ -3,6 +3,7 @@ require 'optparse' require 'ostruct' require 'stringio' +require 'yaml' library_files = Dir[File.join(File.dirname(__FILE__), "/twurl/**/*.rb")] library_files.each do |file|
Add explicit require for yaml library.
diff --git a/config/initializers/s3_direct_upload.rb b/config/initializers/s3_direct_upload.rb index abc1234..def5678 100644 --- a/config/initializers/s3_direct_upload.rb +++ b/config/initializers/s3_direct_upload.rb @@ -1,7 +1,7 @@ S3DirectUpload.config do |c| c.access_key_id = ENV['AWS_ACCESS_KEY'] c.secret_access_key = ENV['AWS_SECRET_KEY'] - c.bucket = ENV['AWS_BUCKET'], + c.bucket = ENV['AWS_BUCKET'] c.region = 'sa-east-1' - c.url = "https://#{ENV['AWS_BUCKET']}.s3.amazonaws.com" + c.url = "https://#{c.bucket}.s3.amazonaws.com" end
Fix typo on S3 Direct Upload configuration An unecessary comma caused an Invalid Policy error while trying to upload files do Amazon S3.
diff --git a/bzip2-ffi.gemspec b/bzip2-ffi.gemspec index abc1234..def5678 100644 --- a/bzip2-ffi.gemspec +++ b/bzip2-ffi.gemspec @@ -18,8 +18,9 @@ Dir['test/fixtures/*'] s.platform = Gem::Platform::RUBY s.require_path = 'lib' - s.rdoc_options << '--title' << 'Bzip2::FFI' - s.extra_rdoc_files = ['LICENSE'] + s.rdoc_options << '--title' << 'Bzip2::FFI' << + '--main' << 'README.md' + s.extra_rdoc_files = ['CHANGES.md', 'LICENSE', 'README.md'] s.required_ruby_version = '>= 1.9.3' s.add_runtime_dependency 'ffi', '~> 1.0' s.requirements << 'libbz2.(so|dll|dylib) available on the library search path'
Add CHANGES.md and README.md to RDoc.
diff --git a/spec/controllers/admin/base_controller_spec.rb b/spec/controllers/admin/base_controller_spec.rb index abc1234..def5678 100644 --- a/spec/controllers/admin/base_controller_spec.rb +++ b/spec/controllers/admin/base_controller_spec.rb @@ -10,7 +10,7 @@ let(:account) { create :account } before do - controller.stub(:setup_request) + allow(controller).to receive(:setup_request) end before { @request.env['HTTPS'] = 'on' }
Fix RSpec deprecation by removing stub
diff --git a/spec/hg/workers/worker_spec_shared_examples.rb b/spec/hg/workers/worker_spec_shared_examples.rb index abc1234..def5678 100644 --- a/spec/hg/workers/worker_spec_shared_examples.rb +++ b/spec/hg/workers/worker_spec_shared_examples.rb @@ -1,7 +1,11 @@ RSpec.shared_examples 'a message processing worker' do + it 'finds the proper queue' do + expect(queue_class).to receive(:new).with(hash_including(user_id: user_id)).and_return(queue) + + subject.perform(*valid_args) + end + it "pops the latest unprocessed message from the user's queue" do - # TODO: two expectations in one it block is poor form - expect(queue_class).to receive(:new).with(hash_including(user_id: user_id)).and_return(queue) expect(queue).to receive(:pop) subject.perform(*valid_args)
Add it block to spec to separate expects
diff --git a/inch_ci-worker.gemspec b/inch_ci-worker.gemspec index abc1234..def5678 100644 --- a/inch_ci-worker.gemspec +++ b/inch_ci-worker.gemspec @@ -23,6 +23,6 @@ spec.add_development_dependency "simplecov" spec.add_development_dependency "pry" - spec.add_dependency "inch", "0.5.0.rc8" + spec.add_dependency "inch", "0.5.0.rc9" spec.add_dependency "repomen", ">= 0.2.0.rc1" end
Upgrade inch and bump version
diff --git a/pages/config/routes.rb b/pages/config/routes.rb index abc1234..def5678 100644 --- a/pages/config/routes.rb +++ b/pages/config/routes.rb @@ -6,7 +6,7 @@ namespace :admin, :path => Refinery::Core.backend_route do scope :path => :pages do post 'preview', :to => 'preview#show', :as => :preview_pages - match 'preview/*path' => 'preview#show', :as => :preview_page, :via => [:put, :patch] + patch 'preview/*path', :to => 'preview#show', :as => :preview_page end end end
Use PATCH HTTP method because Rails 4 now uses that by default over PUT.
diff --git a/0_code_wars/find_duplicated_number.rb b/0_code_wars/find_duplicated_number.rb index abc1234..def5678 100644 --- a/0_code_wars/find_duplicated_number.rb +++ b/0_code_wars/find_duplicated_number.rb @@ -0,0 +1,5 @@+# http://www.codewars.com/kata/558dd9a1b3f79dc88e000001/ +# --- iteration 1 --- +def find_dup(arr) + arr.map{ |x| [x, arr.count(x)] }.select{ |x| x[1] == 2 }[0][0] +end
Add code wars (7) - find duplicated number
diff --git a/Methods/accessModifiers.rb b/Methods/accessModifiers.rb index abc1234..def5678 100644 --- a/Methods/accessModifiers.rb +++ b/Methods/accessModifiers.rb @@ -0,0 +1,38 @@+# Access modifiers in Ruby + +class MyClass + + private # access modifier + def priv + puts("private") + end + + protected + def prot + puts("protected") + end + + public + def pub + puts("public") + end + + def useObject(obj) + obj.pub + obj.prot + obj.priv + end +end + +myObject = MyClass.new +myObject.pub +#myObject.prot # protected can't be called - NoMethodError +#myObject.priv # same as for protected method + +puts("Object of the same class passed to a method") +secondObject = MyClass.new +secondObject.useObject(myObject) + +# !!! Note that protected method call will work in this case. +# In Ruby when two objects of the same class are within the scope +# defined by that class then protected method of this class becomes visible
Access modifiers - protected method is an important example in ruby
diff --git a/test/test_abi.rb b/test/test_abi.rb index abc1234..def5678 100644 --- a/test/test_abi.rb +++ b/test/test_abi.rb @@ -0,0 +1,108 @@+require 'helper' + +module RCPU + class TestABI < TestCase + def test_call + rcpu do + block :main do + call :_library, 1, 2, 3, 4, 5 + data :done, [123] + end + + block :library do + label :crash + SET pc, :crash + end + end + + assert_equal 1, register(:A) + assert_equal 2, register(:B) + assert_equal 3, register(:C) + assert_equal 4, memory[register(:S)-2] + assert_equal 5, memory[register(:S)-1] + assert_equal 123, memory[memory[register(:SP)]+1] + end + + def test_fun + rcpu do + block :main do + call :_library, 1, 2, 3, 4, 5 + SUB pc, 1 + end + + block :library do + fun do |a1, a2, a3, a4, a5| + # a1 == a + SUB a, a2 + ADD a, a3 + SUB a, a4 + ADD a, a5 + end + end + end + + before = register(:SP) + assert_equal (1-2+3-4+5), register(:A) + assert_equal before, register(:SP) + end + + def test_fun_locals + rcpu do + block :main do + call :_library, 1, 2, 3, 4, 5 + SUB pc, 1 + end + + block :library do + fun do |a1, a2, a3, a4, a5| + locals do |l| + ADD l, a1 + SUB l, a2 + ADD l, a3 + SUB l, a4 + ADD l, a5 + SET a, l + end + end + end + end + + before = register(:SP) + assert_equal (1-2+3-4+5), register(:A) + assert_equal before, register(:SP) + end + + def test_fun_reg + # Verify that it handles input stored in A, B and C. + [1, 2, 3].permutation.each do |v1, v2, v3| + rcpu do + block :main do + args = [] + args[v1] = a + args[v2] = b + args[v3] = c + + SET a, v1 + SET b, v2 + SET c, v3 + call :_library, args[1], args[2], args[3], 4, 5 + SUB pc, 1 + end + + block :library do + fun do |a1, a2, a3, a4, a5| + # a1 == a + SUB a, a2 + ADD a, a3 + SUB a, a4 + ADD a, a5 + end + end + end + + assert_equal (1-2+3-4+5), register(:A) + end + end + end +end +
Add tests for the calling conventions
diff --git a/spec/controllers/delay_controller_spec.rb b/spec/controllers/delay_controller_spec.rb index abc1234..def5678 100644 --- a/spec/controllers/delay_controller_spec.rb +++ b/spec/controllers/delay_controller_spec.rb @@ -0,0 +1,71 @@+require 'spec_helper' + +describe Slowwly::DelayController do + context 'with a GET request' do + context 'with delay time' do + context 'with url' do + before(:each) do + get('/delay/1500/http://example.com') + end + + it 'responds with redirect' do + expect(last_response).to be_redirect + end + + it 'responds with correct header value' do + expect(last_response.location).to eq('http://example.com') + end + end + + context 'without url' do + before(:each) do + get('/delay/1500/') + end + + xit 'informs client of error with request' do + expect(last_response).to be_bad_request + end + end + end + + context 'given a request with invalid delay' do + before(:each) do + get('/delay/foo/http://example.com') + end + + it 'responds with redirect' do + expect(last_response).to be_redirect + end + + it 'responds with correct header value' do + expect(last_response.location).to eq('http://example.com') + end + end + + context 'given a request without delay time' do + context 'and url' do + before(:each) do + get('/delay//http://example.com') + end + + xit 'responds with redirect' do + expect(last_response).to be_redirect + end + + xit 'responds with correct header value' do + expect(last_response.location).to eq('http://example.com') + end + end + + context 'without url' do + before(:each) do + get('/delay/') + end + + it 'informs client of invalid path' do + expect(last_response).to be_not_found + end + end + end + end +end
Add spec for delay controller get request; cant really test the delay atm; and need to implement some
diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index abc1234..def5678 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -0,0 +1,62 @@+require 'spec_helper' + +describe UsersController do + let(:user) { FactoryGirl.create :user } + + describe "GET 'edit'" do + describe "for a signed-in user" do + before :each do + @request.env["devise.mapping"] = Devise.mappings[:users] + sign_in user + end + + describe "accessing their own account" do + before :each do + get 'edit', :id => user.id + end + + it "returns http success" do + response.should be_success + end + + it "renders the users edit view" do + response.should render_template("users/edit") + end + + it "assigns user" do + assigns(:user).should == user + end + end + + describe "accessing another user's account" do + let!(:other_user) { FactoryGirl.create :user } + + before :each do + get 'edit', :id => other_user.id + end + + it "returns http success" do + response.should be_success + end + + it "renders the users edit view" do + response.should render_template("users/edit") + end + + it "assigns user as their own account" do + assigns(:user).should == user + end + end + end + + describe "for a non signed-in user" do + before :each do + get 'edit', :id => user.id + end + + it "redirects to the sign-in page" do + response.should redirect_to(new_user_session_path) + end + end + end +end
Add Users Controller Spec for Profile Add a Users controller spec to account for editing/viewing the Users' profile pages.
diff --git a/conoha.gemspec b/conoha.gemspec index abc1234..def5678 100644 --- a/conoha.gemspec +++ b/conoha.gemspec @@ -14,14 +14,6 @@ spec.homepage = "https://github.com/kaosf/conoha" spec.license = "MIT" - # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or - # delete this section to allow pushing this gem to any host. - if spec.respond_to?(:metadata) - spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'" - else - raise "RubyGems 2.0 or newer is required to protect against public gem pushes." - end - spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } spec.bindir = "exe" spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
Remove the code to prevent pushing to a public server
diff --git a/test/integration/sign_in_test.rb b/test/integration/sign_in_test.rb index abc1234..def5678 100644 --- a/test/integration/sign_in_test.rb +++ b/test/integration/sign_in_test.rb @@ -4,14 +4,7 @@ Warden.test_mode! class SignInTest < ActionDispatch::IntegrationTest - - def setup - @user = users(:lee) + def test_sanity + #flunk "Need real tests" end - - def teardown - Warden.test_reset! - end - - end
Revert "Add basic Capybara tests for log in" This reverts commit 637e272204b80850238c64bc8042a8bc66c155d2. Conflicts: test/features/sign_in_sign_out_test.rb
diff --git a/features/support/webmock.rb b/features/support/webmock.rb index abc1234..def5678 100644 --- a/features/support/webmock.rb +++ b/features/support/webmock.rb @@ -8,6 +8,4 @@ # Mock out all publisher URLs stub_request(:get, %r{^#{Regexp.escape Plek.current.find('publisher')}/}).to_return(status: 200) - - stub_request(:get, "#{Plek.current.find('imminence')}/data_sets/public_bodies.json").to_return(body: [].to_json) end
Stop stubbing an imminence data set URL in all tests Removing the stub doesn't seem to cause a problem and it looks like this stub hasn't been needed since 2011 (see: b3e0c8aefa2cb3b6c85d67c384f31dcb746ff268).
diff --git a/test/smoke/source/source_test.rb b/test/smoke/source/source_test.rb index abc1234..def5678 100644 --- a/test/smoke/source/source_test.rb +++ b/test/smoke/source/source_test.rb @@ -1,3 +1,7 @@-describe processes('exabgp') do +describe directory('/usr/src/exabgp') do it { should exist } end + +describe file('/etc/exabgp-default/exabgp.conf') do + it { should exist } +end
Change from process to file/dir check
diff --git a/db/migrate/20200323181726_add_publish_last_version_automatically_column_to_plans.rb b/db/migrate/20200323181726_add_publish_last_version_automatically_column_to_plans.rb index abc1234..def5678 100644 --- a/db/migrate/20200323181726_add_publish_last_version_automatically_column_to_plans.rb +++ b/db/migrate/20200323181726_add_publish_last_version_automatically_column_to_plans.rb @@ -0,0 +1,7 @@+# frozen_string_literal: true + +class AddPublishLastVersionAutomaticallyColumnToPlans < ActiveRecord::Migration[5.2] + def change + add_column :gplan_plans, :publish_last_version_automatically, :boolean, null: false, default: false + end +end
Add publish_last_version_automatically column to plans
diff --git a/test/unit/recipes/resolv_spec.rb b/test/unit/recipes/resolv_spec.rb index abc1234..def5678 100644 --- a/test/unit/recipes/resolv_spec.rb +++ b/test/unit/recipes/resolv_spec.rb @@ -0,0 +1,62 @@+describe 'sys::resolv' do + + before do + stub_command("test -L /etc/resolv.conf").and_return(false) + end + + let(:chef_run) do + ChefSpec::SoloRunner.new do |node| + node.default['sys']['resolv']['servers'] = %w(8.8.4.4 8.8.8.8) + node.default['sys']['resolv']['search'] = "example.com" + end.converge(described_recipe) + end + + context "node['sys']['resolv']['servers'] is empty" do + let(:chef_run) { ChefSpec::SoloRunner.new.converge(described_recipe) } + + it 'does nothing' do + expect(chef_run.run_context.resource_collection + .to_hash.keep_if { |x| x['updated'] }).to be_empty + end + end + + context 'with basic attributes' do + it 'creates /etc/resolv.conf' do + expect(chef_run).to create_template('/etc/resolv.conf') + end + end + + context '/etc/resolv.conf is a symlink' do + before do + stub_command("test -L /etc/resolv.conf").and_return(true) + end + + let(:chef_run) do + ChefSpec::SoloRunner.new do |node| + node.default['sys']['resolv']['servers'] = %w(8.8.4.4 8.8.8.8) + end.converge(described_recipe) + end + + it 'emits a warning' do + expect(chef_run).to write_log('resolv.conf-symlink') + end + + it 'does not touch /etc/resolv.conf' do + expect(chef_run).to_not create_template('/etc/resolv.conf') + end + end + + context 'both domain and search defined' do + let(:chef_run) do + ChefSpec::SoloRunner.new do |node| + node.default['sys']['resolv']['servers'] = %w(8.8.4.4 8.8.8.8) + node.default['sys']['resolv']['search'] = "example.com t.example.com" + node.default['sys']['resolv']['domain'] = "example.com" + end.converge(described_recipe) + end + + it 'emits a warning' do + expect(chef_run).to write_log('domain+search') + end + end +end
Add unit tests for resolv recipe
diff --git a/lib/atlas/scaler/graph_scaler.rb b/lib/atlas/scaler/graph_scaler.rb index abc1234..def5678 100644 --- a/lib/atlas/scaler/graph_scaler.rb +++ b/lib/atlas/scaler/graph_scaler.rb @@ -7,8 +7,10 @@ NODE_ATTRIBUTES = [ :demand, :max_demand, - :typical_input_capacity, - :electricity_output_capacity + # Scaling of the following two attributes is disabled for the time being - + # see https://github.com/quintel/etengine/issues/901#issuecomment-274062242 + # :typical_input_capacity, + # :electricity_output_capacity ].freeze # Maps top-level keys from the dumped graph to arrays of attributes which
Disable scaling of typical_input_capacity and electricity_output_capacity
diff --git a/omnibus-software.gemspec b/omnibus-software.gemspec index abc1234..def5678 100644 --- a/omnibus-software.gemspec +++ b/omnibus-software.gemspec @@ -1,4 +1,3 @@-# -*- encoding: utf-8 -*- $:.push File.expand_path("../lib", __FILE__) require "omnibus-software/version"
Remove the redundant encoding comment The encoding is utf-8 in Ruby 2+ Signed-off-by: Tim Smith <764ef62106582a09ed09dfa0b6bff7c05fd7d1e4@chef.io>
diff --git a/recipes/configure.rb b/recipes/configure.rb index abc1234..def5678 100644 --- a/recipes/configure.rb +++ b/recipes/configure.rb @@ -22,7 +22,15 @@ template '/etc/gitlab/gitlab.rb' do variables( - external_url: node['gitlab-omnibus']['external_url'] + external_url: node['gitlab-omnibus']['external_url'], + enable_tls: node['gitlab-omnibus']['enable_tls'], + redirect_http_to_https: node['gitlab-omnibus']['nginx']['redirect_http_to_https'], + ssl_certificate: node['gitlab-omnibus']['nginx']['ssl_certificate'], + ssl_key: node['gitlab-omnibus']['nginx']['key'], + gitlab_email_from: node['gitlab-omnibus']['rails']['gitlab_email_from'], + ldap_enabled: node['gitlab-omnibus']['rails']['ldap_enabled'], + ldap_group_base: node['gitlab-omnibus']['rails']['ldap_group_base'], + ldap_user_filter: node['gitlab-omnibus']['rails']['ldap_user_filter'] ) mode 0600 notifies :run, 'execute[gitlab-ctl reconfigure]'
Add more variables to template resource for gitlab.rb.
diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index abc1234..def5678 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -15,5 +15,6 @@ publify_admin.css accounts.css bootstrap.css + user-styles.css coderay.css )
Add precompiling of user-styles.css again.
diff --git a/tests/browser_based/run_tests.rb b/tests/browser_based/run_tests.rb index abc1234..def5678 100644 --- a/tests/browser_based/run_tests.rb +++ b/tests/browser_based/run_tests.rb @@ -3,11 +3,16 @@ # make it possible to load the test cases from the local directory $:.unshift File.dirname(__FILE__) +# FIXME - should not need to list all the tests here - should be able to extract them from the directory listing instead. + require 'basics' +require 'hosting' require 'info_pages' -require 'hosting' require 'instance' require 'instance_auth' +require 'instance_info' +require 'migration' require 'person_editing' -require 'migration' -require 'instance_info' +require 'person_edit_list_details' +require 'person_photo' +require 'position_editing'
Add in Watir tests to the test runner
diff --git a/lib/brightbox-cli/config/cache.rb b/lib/brightbox-cli/config/cache.rb index abc1234..def5678 100644 --- a/lib/brightbox-cli/config/cache.rb +++ b/lib/brightbox-cli/config/cache.rb @@ -2,21 +2,17 @@ module Config module Cache def cache_path - if @cache_path - @cache_path - else - @cache_path = File.join(config_directory, 'cache') - unless File.exist? @cache_path - begin - FileUtils.mkpath @cache_path - rescue Errno::EEXIST - end - end - @cache_path - end + File.join(config_directory, "cache") end def cache_id(cid) + return if cid.nil? + unless File.exist?(cache_path) + begin + FileUtils.mkpath(cache_path) + rescue Errno::EEXIST + end + end FileUtils.touch(File.join(cache_path, cid)) unless cid.nil? end end
Fix caching attempts when directory missing Running specs in a random order could trigger a number of failures related to naughty API classes attempting to cache IDs whilst the directory used did not exist. This alters the `#cache_path` method to be read only without side effect and creates it when `#cache_id` is called and it does not exist.
diff --git a/lib/clamp/subcommand/execution.rb b/lib/clamp/subcommand/execution.rb index abc1234..def5678 100644 --- a/lib/clamp/subcommand/execution.rb +++ b/lib/clamp/subcommand/execution.rb @@ -10,7 +10,7 @@ subcommand_class = find_subcommand_class(subcommand_name) subcommand = subcommand_class.new("#{invocation_path} #{subcommand_name}", context) self.class.declared_options.each do |option| - option_set = defined?(option.ivar_name) + option_set = instance_variable_defined?(option.ivar_name) if option_set && subcommand.respond_to?(option.write_method) subcommand.send(option.write_method, self.send(option.read_method)) end
Fix check for presence of explicitly set option.
diff --git a/lib/finite_machine/async_call.rb b/lib/finite_machine/async_call.rb index abc1234..def5678 100644 --- a/lib/finite_machine/async_call.rb +++ b/lib/finite_machine/async_call.rb @@ -1,14 +1,13 @@ # encoding: utf-8 module FiniteMachine - # An asynchronouse call representation + # An immutable asynchronouse call representation that wraps + # the {Callable} object # - # Used internally by {EventQueue} to schedule events + # Used internally by {MessageQueue} to dispatch events # # @api private class AsyncCall - include Threadable - # Create asynchronous call instance # # @param [Object] context @@ -19,15 +18,12 @@ # @example # AsyncCall.new(context, Callable.new(:method), :a, :b) # - # @return [self] - # # @api public def initialize(context, callable, *args, &block) @context = context @callable = callable @arguments = args.dup @block = block - @mutex = Mutex.new freeze end @@ -37,19 +33,7 @@ # # @api private def dispatch - @mutex.synchronize do - callable.call(context, *arguments, &block) - end + @callable.call(@context, *@arguments, &@block) end - - protected - - attr_threadsafe :context - - attr_threadsafe :callable - - attr_threadsafe :arguments - - attr_threadsafe :block end # AsyncCall end # FiniteMachine
Remove async call thread syncing.
diff --git a/lib/docs/scrapers/react_native.rb b/lib/docs/scrapers/react_native.rb index abc1234..def5678 100644 --- a/lib/docs/scrapers/react_native.rb +++ b/lib/docs/scrapers/react_native.rb @@ -3,7 +3,7 @@ self.name = 'React Native' self.slug = 'react_native' self.type = 'react' - self.release = '0.40' + self.release = '0.41' self.base_url = 'https://facebook.github.io/react-native/docs/' self.root_path = 'getting-started.html' self.links = {
Update React Native documentation (0.41)
diff --git a/core/process/euid_spec.rb b/core/process/euid_spec.rb index abc1234..def5678 100644 --- a/core/process/euid_spec.rb +++ b/core/process/euid_spec.rb @@ -33,25 +33,12 @@ as_superuser do describe "if run by a superuser" do - with_feature :fork do - it "sets the effective user id for the current process if run by a superuser" do - read, write = IO.pipe - pid = Process.fork do - begin - read.close - Process.euid = 1 - write << Process.euid - write.close - rescue Exception => e - write << e << e.backtrace - end - Process.exit! - end - write.close - euid = read.gets - euid.should == "1" - Process.wait pid - end + it "sets the effective user id for the current process if run by a superuser" do + code = <<-RUBY + Process.euid = 1 + puts Process.euid + RUBY + ruby_exe(code).should == "1\n" end end end
Rewrite Process.euid= spec without fork
diff --git a/lib/knapsack/allocator_builder.rb b/lib/knapsack/allocator_builder.rb index abc1234..def5678 100644 --- a/lib/knapsack/allocator_builder.rb +++ b/lib/knapsack/allocator_builder.rb @@ -8,9 +8,9 @@ def allocator Knapsack::Allocator.new({ report: Knapsack.report.open, + spec_pattern: spec_pattern, ci_node_total: Knapsack::Config::Env.ci_node_total, - ci_node_index: Knapsack::Config::Env.ci_node_index, - spec_pattern: spec_pattern + ci_node_index: Knapsack::Config::Env.ci_node_index }) end
Change args order in allocator builder
diff --git a/CCKit.podspec b/CCKit.podspec index abc1234..def5678 100644 --- a/CCKit.podspec +++ b/CCKit.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "CCKit" - s.version = "0.0.2" + s.version = "0.0.3" s.summary = "Cliq Consulting reusable components for iOS." s.description = <<-DESC @@ -17,7 +17,7 @@ s.platform = :ios, '7.0' - s.source = { :git => "git@cliqconsulting.unfuddle.com:cliqconsulting/cckit.git", :tag => s.version.to_s } + s.source = { :git => "https://github.com/cliq/CCKit.git", :tag => s.version.to_s } s.source_files = 'CCKit/**/*.{h,m}' s.exclude_files = 'CCKit/CCTwitterLoginManager.{h,m}', 'CCKit/OAuthCore/*', 'CCKit/TWiOSReverseAuth/*' s.requires_arc = true
Update Podspec to version 0.0.3
diff --git a/config/unicorn.rb b/config/unicorn.rb index abc1234..def5678 100644 --- a/config/unicorn.rb +++ b/config/unicorn.rb @@ -1,5 +1,5 @@ preload_app true -worker_count 2 +worker_processes 2 timeout 30 check_client_connection true
Use correct Unicorn config method
diff --git a/lib/badbill/invoice_payment.rb b/lib/badbill/invoice_payment.rb index abc1234..def5678 100644 --- a/lib/badbill/invoice_payment.rb +++ b/lib/badbill/invoice_payment.rb @@ -5,5 +5,24 @@ # # See http://www.billomat.com/en/api/invoices/payments/ class InvoicePayment < BaseResource + # Create a new invoice payment. + # + # @param [String,] invoice_id The ID of the invoice + # @param [String,Numeric] amount The paid amount + # @param [Boolean] is_paid Wether the invoice should be marked as paid + # or not + # @return [InvoicePayment,Hashie::Mash] New payment with id and data set + # or hash if any error happened + def self.create invoice_id, amount, is_paid=false, params={} + params['invoice_id'] = invoice_id + params['amount'] = amount + params['mark_invoice_as_paid'] = is_paid + + res = post(resource_name, {resource_name_singular => params}) + return res if res.error + + res_data = res.__send__(resource_name_singular) + new res_data.id.to_i, res_data + end end end
Create invoice payments (to set an invoice's status to paid)
diff --git a/lib/algoliasearch/utilities.rb b/lib/algoliasearch/utilities.rb index abc1234..def5678 100644 --- a/lib/algoliasearch/utilities.rb +++ b/lib/algoliasearch/utilities.rb @@ -2,9 +2,8 @@ module Utilities class << self def get_model_classes - Rails.application.eager_load! # Ensure all models are loaded (not necessary in production when cache_classes is true). - - ActiveRecord::Base.descendants.select{ |model| model.respond_to?(:algolia_reindex) } + Rails.application.eager_load! if Rails.application # Ensure all models are loaded (not necessary in production when cache_classes is true). + AlgoliaSearch.instance_variable_get :@included_in end def clear_all_indexes
Make sure get_model_classes is not ActiveRecord compliant only
diff --git a/lib/chatrix/event_processor.rb b/lib/chatrix/event_processor.rb index abc1234..def5678 100644 --- a/lib/chatrix/event_processor.rb +++ b/lib/chatrix/event_processor.rb @@ -16,15 +16,10 @@ private def parse_event(event) - case event - when String + if event.is_a? String event - when Hash - if event.key? 'event_id' - event['event_id'] - else - raise ArgumentError, 'event hash is missing event_id value' - end + elsif event.is_a?(Hash) && event.key?('event_id') + event['event_id'] else raise ArgumentError, 'Invalid event object' end
Simplify code in event processor
diff --git a/lib/torque_box/sidekiq_service.rb b/lib/torque_box/sidekiq_service.rb index abc1234..def5678 100644 --- a/lib/torque_box/sidekiq_service.rb +++ b/lib/torque_box/sidekiq_service.rb @@ -1,6 +1,6 @@ module TorqueBox class SidekiqService - attr_accessor :config, :launcher + attr_accessor :config, :launcher, :start_failed CONFIG_OPTIONS_TO_STRIP = [:config_file, :daemon, :environment, :pidfile, :require, :tag] @@ -13,7 +13,16 @@ end def stop - launcher.stop + # Since the stop call may come before the launcher has finished starting up, try to see + # if the launcher ever gets initialized. We really don't want to orphan a Sidekiq launcher + # if we can avoid it. + Timeout::timeout(5.minutes) do + while launcher.nil? && !start_failed + sleep 1 + end + end + + launcher.stop if launcher end def run @@ -36,9 +45,15 @@ require 'sidekiq/manager' require 'sidekiq/scheduled' require 'sidekiq/launcher' + @launcher = Sidekiq::Launcher.new(Sidekiq.options) launcher.run + rescue => e + puts e.message + puts e.backtrace + + @start_failed = true end end -end+end
Handle errors during startup better and fixed a race condition with :stop being called before the Sidekiq launcher finishes booting.
diff --git a/lib/tasks/default_admin_set.rake b/lib/tasks/default_admin_set.rake index abc1234..def5678 100644 --- a/lib/tasks/default_admin_set.rake +++ b/lib/tasks/default_admin_set.rake @@ -2,7 +2,7 @@ namespace :default_admin_set do desc "Create the Default Admin Set" task create: :environment do - AdminSet.create_default! + AdminSet.find_or_create_default_admin_set_id end end -end+end
Update default admin set creation call in rake job
diff --git a/scopy.gemspec b/scopy.gemspec index abc1234..def5678 100644 --- a/scopy.gemspec +++ b/scopy.gemspec @@ -24,7 +24,6 @@ spec.add_development_dependency "bundler", "~> 1.3" spec.add_development_dependency "rake", "~> 10.1" - spec.add_development_dependency "minitest", "~> 4.7" spec.add_development_dependency "mocha", "~> 1.0" spec.add_development_dependency "sqlite3", "~> 1.3" end
Remove explicit dependency on minitest
diff --git a/db/data_migrations/20190820181152_add_organization_role_mapping_for_super_manager.rb b/db/data_migrations/20190820181152_add_organization_role_mapping_for_super_manager.rb index abc1234..def5678 100644 --- a/db/data_migrations/20190820181152_add_organization_role_mapping_for_super_manager.rb +++ b/db/data_migrations/20190820181152_add_organization_role_mapping_for_super_manager.rb @@ -0,0 +1,12 @@+class AddOrganizationRoleMappingForSuperManager < ActiveRecord::DataMigration + def up + Grantor.all.each do |g| + OrganizationRoleMapping.create!(organization_id: g.id, role_id: Role.find_by(name: :super_manager).id) + end + end + + def down + grantor_ids = Grantor.pluck(:id) + OrganizationRoleMapping.where(organization_id: grantor_ids, role_id: Role.find_by(name: :super_manager).id).destroy_all + end +end
[TTPLAT-1044] Add organization role mapping for grantors to super manager role.
diff --git a/overheard.rb b/overheard.rb index abc1234..def5678 100644 --- a/overheard.rb +++ b/overheard.rb @@ -5,7 +5,7 @@ include DataMapper::Resource property :id, Serial - property :body, Text + property :body, Text, { :required => true } property :created_at, DateTime end @@ -23,5 +23,9 @@ post '/overheards' do overheard = Overheard.create(params["overheard"]) - redirect "/" + if overheard.saved? + redirect "/" + else + erb :new_overheard + end end
Add validation that Overheard must have a body Here we're doing two things: 1. We're creating a validation that will prevent an overheard from being created if a body isn't provided 2. We're only redirecting if the creation was successful; otherwise we re-render the new overheard form
diff --git a/lib/filepicker/rails/policy.rb b/lib/filepicker/rails/policy.rb index abc1234..def5678 100644 --- a/lib/filepicker/rails/policy.rb +++ b/lib/filepicker/rails/policy.rb @@ -5,6 +5,12 @@ module Rails class Policy attr_accessor :expiry, :call, :handle, :maxsize, :minsize + + def initialize(options = {}) + [:expiry, :call, :handle, :maxsize, :minsize].each do |input| + send("#{input}=", options[input]) unless options[input].nil? + end + end def policy Base64.urlsafe_encode64(json_policy)
Add initializer to Policy class
diff --git a/lib/graphql/execution_error.rb b/lib/graphql/execution_error.rb index abc1234..def5678 100644 --- a/lib/graphql/execution_error.rb +++ b/lib/graphql/execution_error.rb @@ -11,6 +11,9 @@ hash = { "message" => message, } + + hash.merge!({ 'backtrace' => backtrace }) if self.class.backtrace_enabled + if ast_node hash["locations"] = [ { @@ -21,5 +24,9 @@ end hash end + + class << self + attr_accessor :backtrace_enabled + end end end
Add ability to dump backtrace.
diff --git a/sidekiq/recipes/default.rb b/sidekiq/recipes/default.rb index abc1234..def5678 100644 --- a/sidekiq/recipes/default.rb +++ b/sidekiq/recipes/default.rb @@ -6,7 +6,7 @@ node[:deploy].each do |application, deploy| process_name = "sidekiq_#{application}" - template "/etc/monit/#{process_name}.monitrc" do + template "/etc/monit/conf.d/#{process_name}.monitrc" do source "monitrc.conf.erb" owner 'root' group 'root'
Put monitrc files in proper folder
diff --git a/lib/generators/templates/app/initializers/link_renderer.rb b/lib/generators/templates/app/initializers/link_renderer.rb index abc1234..def5678 100644 --- a/lib/generators/templates/app/initializers/link_renderer.rb +++ b/lib/generators/templates/app/initializers/link_renderer.rb @@ -0,0 +1,51 @@+module WillPaginate + module ViewHelpers + # This class does the heavy lifting of actually building the pagination + # links. It is used by +will_paginate+ helper internally. + class LinkRenderer < LinkRendererBase + + protected + + def page_number(page) + unless page == current_page + link(page, page, :rel => rel_value(page), :class => "btn") + else + tag(:a, page, :class => 'current active btn') + end + end + + def gap + text = @template.will_paginate_translate(:page_gap) { '&hellip;' } + %(<a class="gap btn disabled">#{text}</a>) + end + + def previous_or_next_page(page, text, classname) + if page + link(text, page, :class => classname + ' btn') + else + tag(:a, text, :class => classname + ' disabled btn') + end + end + + def html_container(html) + html + end + + private + + def param_name + @options[:param_name].to_s + end + + def link(text, target, attributes = {}) + if target.is_a? Fixnum + attributes[:rel] = rel_value(target) + target = url(target) + end + attributes[:href] = target + tag(:a, text, attributes) + end + + end + end +end
Patch to render willpaginate with Twitter Bootstrap
diff --git a/app/Screens/AboutScreen.rb b/app/Screens/AboutScreen.rb index abc1234..def5678 100644 --- a/app/Screens/AboutScreen.rb +++ b/app/Screens/AboutScreen.rb @@ -9,7 +9,26 @@ def will_appear @view_loaded ||= begin set_nav_bar_right_button "Done", action: :close_modal, type: UIBarButtonItemStyleDone + + self.navigationController.setToolbarHidden(false) + self.toolbarItems = [flexible_space, made_in_label, flexible_space] + end + end + + def made_in_label + label = set_attributes UILabel.alloc.initWithFrame(CGRectZero), { + frame: CGRectMake(0.0 , 11.0, view.frame.size.width, 21.0), + font: UIFont.fontWithName("Helvetica", size:16), + background_color: UIColor.clearColor, + text: "Made in Beautiful Charlotte, NC", + text_alignment: UITextAlignmentCenter + } + UIBarButtonItem.alloc.initWithCustomView(label) + end + + def flexible_space + UIBarButtonItem.alloc.initWithBarButtonSystemItem(UIBarButtonSystemItemFlexibleSpace, target:nil, action:nil) end def close_modal
Add a "made in" label to the about view.
diff --git a/db/data_migration/20150311142732_add_missing_content_id_for_organisation.rb b/db/data_migration/20150311142732_add_missing_content_id_for_organisation.rb index abc1234..def5678 100644 --- a/db/data_migration/20150311142732_add_missing_content_id_for_organisation.rb +++ b/db/data_migration/20150311142732_add_missing_content_id_for_organisation.rb @@ -0,0 +1,5 @@+Organisation.where(content_id: nil).each do |organisation| + organisation.content_id = SecureRandom.uuid + organisation.save(validate: false) + puts "Setting content_id for #{organisation.name}" +end
Set missing content ids for organisations The previous data migration skipped over any organisations that failed validation. This meant that at least one (FCO Services) was left without a content_id as it failed validation due to not having an alternative format provider email address.
diff --git a/spec/hadoop/hbase_spec.rb b/spec/hadoop/hbase_spec.rb index abc1234..def5678 100644 --- a/spec/hadoop/hbase_spec.rb +++ b/spec/hadoop/hbase_spec.rb @@ -5,7 +5,7 @@ it { should return_exit_status 0 } end -# Make sure hbase stops without error as well -describe command('stop-hbase.sh') do +# Make sure Java process is killed off when done +describe command('pkill -9 java') do it { should return_exit_status 0 } end
Fix hbase test, makes sure to kill off java when done so test is repeatable
diff --git a/spec/locale_spec.rb b/spec/locale_spec.rb index abc1234..def5678 100644 --- a/spec/locale_spec.rb +++ b/spec/locale_spec.rb @@ -10,9 +10,9 @@ describe :model_comments do let(:result) do { + 'person' => '人', 'address' => '住所', 'email' => 'メール', - 'person' => '人', } end it{ expect(SchemaComments::SchemaComment.model_comments).to eq result } @@ -21,6 +21,10 @@ describe :attribute_comments do let(:result) do { + 'person' => { + 'name' => '名前', + 'id' => '人', + }, 'address' => { 'person' => '人', 'person_id' => '人ID', @@ -33,10 +37,6 @@ 'address' => 'アドレス', 'id' => 'メール', }, - 'person' => { - 'name' => '名前', - 'id' => '人', - } } end it{ expect(SchemaComments::SchemaComment.attribute_comments).to eq result }
Change the order of models
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index abc1234..def5678 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -11,14 +11,6 @@ add_group "Relation", "lib/data_mapper/relation" add_group "Relationship", "lib/data_mapper/relationship" add_group "Engine", "lib/data_mapper/engine" - end -end - -if RUBY_VERSION < '1.9' - class OpenStruct - def id - @table.fetch(:id) { super } - end end end
Remove duplicate OpenStruct monkey patch for specs
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index abc1234..def5678 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -16,7 +16,8 @@ #TMP_DIR = SpecHelper::TemporaryDirectory.temporary_directory #TMP_COCOA_PODS_DIR = File.join(TMP_DIR, 'cocoa-pods') -class Bacon::Context +context_class = defined?(BaconContext) ? BaconContext : Bacon::Context +context_class.class_eval do include Pod::Config::Mixin include SpecHelper::Fixture
Make the specs work with ObjectiveBacon as well.
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index abc1234..def5678 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -14,18 +14,8 @@ # class HashObject def self.new(hash) - build_class(hash.keys).new(hash) - end - - def self.build_class(attributes) - Class.new do - attr_accessor(*attributes) - - def initialize(hash) - hash.each do |attr, value| - public_send "#{attr}=", value - end - end - end + attributes = hash.keys + values = hash.values + Struct.new(*attributes).new(*values) end end
Use Struct as backend for HashObject.
diff --git a/spec/topicz_spec.rb b/spec/topicz_spec.rb index abc1234..def5678 100644 --- a/spec/topicz_spec.rb +++ b/spec/topicz_spec.rb @@ -21,8 +21,14 @@ expect(Topicz.create_command(['foo'])).to be nil end - it 'returns a command when a valid command is specificied' do - expect(Topicz.create_command(['init'])).to eq 'init' + it 'returns a command when a valid command is specified' do + class DummyCommandFactory + def create(name, config = nil, options = []) + name + end + end + cf = DummyCommandFactory.new + expect(Topicz.create_command(['init'], cf)).to eq 'init' end it 'raises an error when referring to an invalid file' do
Use dummy command factory in topicz spec.
diff --git a/lib/registrar/adapter/rails.rb b/lib/registrar/adapter/rails.rb index abc1234..def5678 100644 --- a/lib/registrar/adapter/rails.rb +++ b/lib/registrar/adapter/rails.rb @@ -7,6 +7,19 @@ def self.included(klass) klass.include InstanceMethods klass.before_action :try_to_store_registrar_profile + + klass.class_eval do + helper_method :current_profile + helper_method :current_profile? + helper_method :logged_in? + + helper_method :registrar_profile + helper_method :registrar_profile? + + helper_method :authentication_phase? + + helper_method :presentable_authentication + end end module InstanceMethods @@ -27,6 +40,11 @@ try_to_set_current_profile end + def current_profile? + !!current_profile + end + alias_method :logged_in?, :current_profile? + def try_to_set_current_profile if registrar_profile? @current_user = build_profile(registrar_profile) @@ -44,6 +62,20 @@ def build_profile(profile) ::Registrar::Profile.new(profile) end + + def authentication_phase? + params[:controller] == 'authentication' && params[:action] = 'callback' + end + + def presentable_authentication + { + 'env.omniauth.auth' => request.env['omniauth.auth'], + 'env.registrar.auth' => request.env['registrar.auth'], + 'env.registrar.profile' => request.env['registrar.profile'], + 'session.registrar_profile' => registrar_profile, + 'runtime.current_profile' => current_profile + } + end end end end
Add additional helper methods to Rails Adapter
diff --git a/app/models/edition_diff.rb b/app/models/edition_diff.rb index abc1234..def5678 100644 --- a/app/models/edition_diff.rb +++ b/app/models/edition_diff.rb @@ -1,5 +1,5 @@ class EditionDiff - TRACKABLE_FIELDS = [:title, :related_discussion_title, :related_discussion_href, :content_owner_title, :description, :body] + TRACKABLE_FIELDS = [:title, :content_owner_title, :description, :body] attr_reader :old_edition, :new_edition
Remove related discussion fields from diffs These are no longer used and are planned to be removed completely.
diff --git a/spec/valanga/music_spec.rb b/spec/valanga/music_spec.rb index abc1234..def5678 100644 --- a/spec/valanga/music_spec.rb +++ b/spec/valanga/music_spec.rb @@ -22,6 +22,12 @@ it do expect do @music.list_musics(sorttype: :music_name) + end.not_to raise_error + end + + it do + expect do + @music.list_musics(sort: :asc) end.not_to raise_error end end
Add spec the case of valid parameter
diff --git a/lib/watir-webdriver/cookies.rb b/lib/watir-webdriver/cookies.rb index abc1234..def5678 100644 --- a/lib/watir-webdriver/cookies.rb +++ b/lib/watir-webdriver/cookies.rb @@ -32,7 +32,7 @@ if t.respond_to?(:to_time) t.to_time else - Time.local t.year, t.month, t.day, t.hour, t.min, t.sec + ::Time.local t.year, t.month, t.day, t.hour, t.min, t.sec end end end
Fix incorrect constant reference on Ruby 1.8. Closes #132.