diff
stringlengths 65
26.7k
| message
stringlengths 7
9.92k
|
|---|---|
diff --git a/spec/models/review_spec.rb b/spec/models/review_spec.rb
index abc1234..def5678 100644
--- a/spec/models/review_spec.rb
+++ b/spec/models/review_spec.rb
@@ -0,0 +1,13 @@+require 'rails_helper'
+
+RSpec.describe Review, type: :model do
+ before(:each) do
+ @stub_post = build_stubbed(:post)
+ @stub_review = build_stubbed(:review)
+ end
+
+ it "belongs to a user" do
+ expect(@stub_review.user).to be_kind_of(User)
+ end
+
+end
|
Test if a review belongs to a user
|
diff --git a/spec/rspec_matcher_spec.rb b/spec/rspec_matcher_spec.rb
index abc1234..def5678 100644
--- a/spec/rspec_matcher_spec.rb
+++ b/spec/rspec_matcher_spec.rb
@@ -7,29 +7,32 @@ @black_box = 'black.png'
@ref_path = Gatling::Configuration.reference_image_path = File.join(spec_support_root, 'ref_path')
create_images_for_web_page
- create_square_image(@ref_path, 'black')
end
after(:each) do
+ ENV['GATLING_TRAINER'] = 'false'
remove_refs(@ref_path)
end
- it 'should initialize and run gatling' do
- visit('/fruit_app.html')
+ describe 'initializing and runnin gatling' do
- black_element = page.find(:css, "#black")
+ it 'will pass if images matches refernce' do
+ create_square_image(@ref_path, 'black')
+ black_element = element_for_spec("#black")
+ black_element.should look_like(@black_box)
+ end
- black_element.should look_like(@black_box)
+ it 'will fail if images dosent matches refernce' do
+ create_square_image(@ref_path, 'black')
+ red_element = element_for_spec("#red")
+ expect{red_element.should look_like(@black_box)}.should raise_error
+ end
+
+ it 'will return true if it makes a new image in trainer mode' do
+ ENV['GATLING_TRAINER'] = 'true'
+ black_element = element_for_spec("#black")
+ black_element.should look_like(@black_box)
+ end
+
end
-
- it 'should initialize and run training mode when GATLING_TRAINER is toggled' do
- ENV['GATLING_TRAINER'] = 'true'
- visit('/fruit_app.html')
- black_element = page.find(:css, "#black")
-
- black_element.should look_like(@black_box)
-
- File.exists?(File.join(@ref_path,@black_box)).should be_true
- end
-
end
|
Add test to check rspec matcher can fail
|
diff --git a/spec/sara/callback_spec.rb b/spec/sara/callback_spec.rb
index abc1234..def5678 100644
--- a/spec/sara/callback_spec.rb
+++ b/spec/sara/callback_spec.rb
@@ -8,9 +8,9 @@
describe ".on_xxx" do
it "should store given block as callback" do
- expect do
- instance.on_xxx {}
- end.to change { instance.list_xxx.size }.by(1)
+ callback = proc {}
+ instance.on_xxx(&callback)
+ instance.list_xxx.should == [callback]
end
end
|
Refactor test for more redability
|
diff --git a/app/helpers/keywording_helper.rb b/app/helpers/keywording_helper.rb
index abc1234..def5678 100644
--- a/app/helpers/keywording_helper.rb
+++ b/app/helpers/keywording_helper.rb
@@ -6,7 +6,7 @@ unless on_parent
link += link_to_delete (fa_icon 'remove'), keywording, method: :delete
end
- bootstrap_label_with_tooltip(link, type: :primary, title: keywording.keyword.description, id: "keywording-#{keywording.id}")
+ content_tag(:span, bootstrap_label_with_tooltip(link, type: :primary, title: keywording.keyword.description, id: "keywording-#{keywording.id}"))
end
end
|
Stop keywords from fluttering about
|
diff --git a/app/jobs/release_episodes_job.rb b/app/jobs/release_episodes_job.rb
index abc1234..def5678 100644
--- a/app/jobs/release_episodes_job.rb
+++ b/app/jobs/release_episodes_job.rb
@@ -2,14 +2,16 @@
queue_as :feeder_default
- def perform
+ def perform(reschedule = false)
ActiveRecord::Base.connection_pool.with_connection do
begin
podcasts_to_release.tap do |podcasts|
podcasts.each { |p| p.publish! }
end
ensure
- ReleaseEpisodesJob.set(wait: release_check_delay).perform_later
+ if reschedule
+ ReleaseEpisodesJob.set(wait: release_check_delay).perform_later(true)
+ end
end
end
end
|
Add param to control rescheduling the same job
|
diff --git a/app/presenters/user_presenter.rb b/app/presenters/user_presenter.rb
index abc1234..def5678 100644
--- a/app/presenters/user_presenter.rb
+++ b/app/presenters/user_presenter.rb
@@ -1,3 +1,8 @@ class UserPresenter < Presenter
attribute :id, :name, :email, :api_token, :created_at
+ attribute :feeds_count
+
+ def feeds_count
+ record.feeds.count
+ end
end
|
Include feeds_count into user presenter
|
diff --git a/app/serializers/me_serializer.rb b/app/serializers/me_serializer.rb
index abc1234..def5678 100644
--- a/app/serializers/me_serializer.rb
+++ b/app/serializers/me_serializer.rb
@@ -1,6 +1,6 @@ class MeSerializer < UserSerializer
- attributes :total_clouds, :read_terms, :using_default_avatar, :notifications
+ attributes :total_clouds, :read_terms, :using_default_avatar, :notifications, :email, :email_verified
def total_clouds
object.cloud_ids.try(:size) || 0
@@ -18,4 +18,8 @@ 0
end
+ def email_verified
+ object.email_verified_at.present?
+ end
+
end
|
Include user email data in /me resource.
|
diff --git a/spec/cc/engine/analyzers/php/main_spec.rb b/spec/cc/engine/analyzers/php/main_spec.rb
index abc1234..def5678 100644
--- a/spec/cc/engine/analyzers/php/main_spec.rb
+++ b/spec/cc/engine/analyzers/php/main_spec.rb
@@ -0,0 +1,65 @@+require 'spec_helper'
+require 'cc/engine/analyzers/php/main'
+require 'flay'
+require 'tmpdir'
+
+module CC::Engine::Analyzers::Javascript
+ describe Main do
+ before { @code = Dir.mktmpdir }
+
+ describe "#run" do
+ it "prints an issue" do
+
+ create_source_file("foo.php", <<-EOPHP)
+ <?php
+ function hello($name) {
+ if (empty($name)) {
+ echo "Hello World!";
+ } else {
+ echo "Hello $name!";
+ }
+ }
+
+ function hi($name) {
+ if (empty($name)) {
+ echo "Hi World!";
+ } else {
+ echo "Hi $name!";
+ }
+ }
+ EOPHP
+
+ assert_equal run_engine(engine_conf), printed_issues
+ end
+
+ def create_source_file(path, content)
+ File.write(File.join(@code, path), content)
+ end
+
+ def run_engine(config = nil)
+ io = StringIO.new
+
+ flay = ::CC::Engine::Analyzers::Php::Main.new(directory: @code, engine_config: config, io: io)
+ flay.run
+
+ io.string
+ end
+
+ def first_issue
+ {"type":"issue","check_name":"Identical code","description":"Duplication found in function","categories":["Duplication"],"location":{"path":"#{@code}/foo.php","lines":{"begin":2,"end":2}},"remediation_points":440000,"other_locations":[{"path":"#{@code}/foo.php","lines":{"begin":10,"end":10}}],"content":{"body": read_up}}
+ end
+
+ def second_issue
+ {"type":"issue","check_name":"Identical code","description":"Duplication found in function","categories":["Duplication"],"location":{"path":"#{@code}/foo.php","lines":{"begin":10,"end":10}},"remediation_points":440000,"other_locations":[{"path":"#{@code}/foo.php","lines":{"begin":2,"end":2}}],"content":{"body": read_up}}
+ end
+
+ def printed_issues
+ first_issue.to_json + "\0\n" + second_issue.to_json + "\0\n"
+ end
+
+ def engine_conf
+ { 'config' => { 'php' => { 'mass_threshold' => 5 } } }
+ end
+ end
+ end
+end
|
Add a spec for php analyzer
|
diff --git a/spec/controllers/pages_controller_spec.rb b/spec/controllers/pages_controller_spec.rb
index abc1234..def5678 100644
--- a/spec/controllers/pages_controller_spec.rb
+++ b/spec/controllers/pages_controller_spec.rb
@@ -14,4 +14,11 @@ it { should respond_with(200) }
it { should render_template('application') }
end
+
+ describe "GET #studio" do
+ before { get :studio }
+
+ it { should respond_with(200) }
+ it { should render_template('application') }
+ end
end
|
Add test for pages studio
|
diff --git a/spec/features/user_creates_a_post_spec.rb b/spec/features/user_creates_a_post_spec.rb
index abc1234..def5678 100644
--- a/spec/features/user_creates_a_post_spec.rb
+++ b/spec/features/user_creates_a_post_spec.rb
@@ -22,8 +22,8 @@
feature 'Auto generate post slug' do
scenario 'user types on title field', js: true do
- fill_model_field(Tingui::Post, :title, with: 'T')
- expect(find_field(Tingui::Post.human_attribute_name(:slug)).value).to eql('t')
+ fill_model_field(Tingui::Post, :title, with: 'Teste')
+ expect(page).to have_field(Tingui::Post.human_attribute_name(:slug), with: "teste")
end
end
end
|
Fix capybara waits for ajax
|
diff --git a/spec/request/request_create_async_spec.rb b/spec/request/request_create_async_spec.rb
index abc1234..def5678 100644
--- a/spec/request/request_create_async_spec.rb
+++ b/spec/request/request_create_async_spec.rb
@@ -0,0 +1,20 @@+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe 'RubyRabbitmqJanus::RRJ' do
+ describe '.response', type: :request_async, name: :create do
+ let(:transaction) { RubyRabbitmqJanus::RRJ.new }
+
+ # Request type create
+ let(:create) { transaction.ask_sync('create') }
+
+ # Request type destroy
+ let(:destroy) { transaction.ask_sync('destroy', create) }
+
+ it 'type create ASYNC' do
+ expect(create).to match_json_schema(:create)
+ expect(destroy).to match_json_schema(:destroy)
+ end
+ end
+end
|
Add test ASYNC with create
|
diff --git a/lib/active_touch/define_touch.rb b/lib/active_touch/define_touch.rb
index abc1234..def5678 100644
--- a/lib/active_touch/define_touch.rb
+++ b/lib/active_touch/define_touch.rb
@@ -23,8 +23,11 @@
@klass.send :define_method, @touch_method do |*args|
changed_attributes = self.previous_changes.keys.map(&:to_sym)
+ watched_changes = (options[:watch] & changed_attributes)
- if (options[:watch] & changed_attributes).any?
+ # watched values changed and conditional procs evaluate to true
+ if watched_changes.any? && options[:if].call(self) && !options[:unless].call(self)
+ Rails.logger.debug "Touch: #{self.class}(#{self.id}) => #{association} due to changes in #{watched_changes}"
if options[:async]
TouchJob.perform_later(self, association.to_s, options[:after_touch].to_s)
@@ -45,7 +48,9 @@ {
async: false,
watch: @klass.column_names.map(&:to_sym) - ActiveTouch.configuration.ignored_attributes,
- after_touch: nil
+ after_touch: nil,
+ if: Proc.new { true },
+ unless: Proc.new { false }
}
end
|
Add if and unless conditional procs to touch options.
|
diff --git a/lib/checkout/pricing_strategy.rb b/lib/checkout/pricing_strategy.rb
index abc1234..def5678 100644
--- a/lib/checkout/pricing_strategy.rb
+++ b/lib/checkout/pricing_strategy.rb
@@ -6,16 +6,15 @@ end
def calculate_price(product, quantity)
- product_rules = @rules.fetch(product) do
+ product_rules = rules.fetch(product) do
raise NoRulesForProductError.new(product)
end
- best_offer = product_rules.fetch(:offers){ [] }.select do |o|
- o[:discount_quantity] <= quantity
- end.max{|a, b| a[:discount_quantity] <=> b[:discount_quantity] }
+ best_offer = best_offer_from(product_rules, quantity)
if best_offer
- best_offer.fetch(:discount_price) + calculate_price(product, quantity - best_offer[:discount_quantity])
+ remaining_quantity = quantity - best_offer[:discount_quantity]
+ best_offer.fetch(:discount_price) + calculate_price(product, remaining_quantity)
elsif product_rules[:deal_name] == "2x1"
product_rules.fetch(:unit_price)
else
@@ -23,5 +22,16 @@ end
end
+ private
+ attr_reader :rules
+
+ def best_offer_from(product_rules, quantity)
+ product_rules.fetch(:offers){ [] }.select do |o|
+ o[:discount_quantity] <= quantity
+ end.max do |a, b|
+ a[:discount_quantity] <=> b[:discount_quantity]
+ end
+ end
+
end
end
|
Add a bit of readability
|
diff --git a/features/lib/step_definitions/profile_steps.rb b/features/lib/step_definitions/profile_steps.rb
index abc1234..def5678 100644
--- a/features/lib/step_definitions/profile_steps.rb
+++ b/features/lib/step_definitions/profile_steps.rb
@@ -0,0 +1,15 @@+Given /^the following profiles? (?:are|is) defined:$/ do |profiles|
+ create_file('cucumber.yml', profiles)
+end
+
+Then /^the (.*) profile should be used$/ do |profile|
+ last_stdout.should =~ /Using the #{profile} profile/
+end
+
+Then /^exactly these files should be loaded:\s*(.*)$/ do |files|
+ last_stdout.scan(/^ \* (.*\.rb)$/).flatten.should == files.split(/,\s+/)
+end
+
+Then /^exactly these features should be ran:\s*(.*)$/ do |files|
+ last_stdout.scan(/^ \* (.*\.feature)$/).flatten.should == files.split(/,\s+/)
+end
|
Add the necessary profile steps
|
diff --git a/db/initialize.rb b/db/initialize.rb
index abc1234..def5678 100644
--- a/db/initialize.rb
+++ b/db/initialize.rb
@@ -1,3 +1,8 @@+# Heroku uses DATABASE_URL environment variable to pass database path to the app
+if ENV['DATABASE_URL']
+ @config['database'] = ENV['DATABASE_URL']
+end
+
case @config['db_adapter']
when 'sqlite3'
DataMapper.setup(:default, "sqlite:///#{APP_PATH}/#{@config['database']}")
|
Add DATABASE_URL environment variable processing
|
diff --git a/spec/features/items/visitor_visits_items_index_spec.rb b/spec/features/items/visitor_visits_items_index_spec.rb
index abc1234..def5678 100644
--- a/spec/features/items/visitor_visits_items_index_spec.rb
+++ b/spec/features/items/visitor_visits_items_index_spec.rb
@@ -0,0 +1,18 @@+require 'rails_helper'
+
+feature 'Items Index' do
+ scenario 'visitor visits the items index page' do
+ item_1 = create(:item)
+ item_2 = create(:item)
+ # Our factories will have to create unique items with a sequence
+
+ visit items_path
+ expect(page).to have_content(item_1.title)
+ expect(page).to have_content(item_1.description)
+ expect(page).to have_content(item_1.price)
+ # For now, the image is untested.
+ expect(page).to have_content(item_2.title)
+ expect(page).to have_content(item_2.description)
+ expect(page).to have_content(item_2.price)
+ end
+end
|
Add spec for items index
|
diff --git a/app/models/record.rb b/app/models/record.rb
index abc1234..def5678 100644
--- a/app/models/record.rb
+++ b/app/models/record.rb
@@ -5,8 +5,7 @@ has_many :comments
validate :date_from_lesser_than_date_to
- validate :dates_cannot_be_in_the_past unless proc { |record| record.is_a? Worktime}
- validate :emails_should_be_valid
+ validate :dates_cannot_be_in_the_past, :emails_should_be_valid unless proc { |record| record.is_a? Worktime}
after_save :send_notifications
|
Remove emails validation for Worktimes
|
diff --git a/features/step_definitions/basic.rb b/features/step_definitions/basic.rb
index abc1234..def5678 100644
--- a/features/step_definitions/basic.rb
+++ b/features/step_definitions/basic.rb
@@ -10,6 +10,9 @@ create_dir 'working-repository'
cd 'working-repository'
run_simple 'git init'
+ # Configure Git username & email to unclutter console output
+ run_simple 'git config user.name Cucumber'
+ run_simple 'git config user.email cucumber@`hostname --fqdn`'
write_file('README', 'Lorem ipsum dolor sit amet')
write_file('Vendorfile', vendorfile_contents)
run_simple 'git add .'
|
Configure Git username and email on the cucumber's working repo to unclutter console output.
|
diff --git a/Casks/appcode-eap.rb b/Casks/appcode-eap.rb
index abc1234..def5678 100644
--- a/Casks/appcode-eap.rb
+++ b/Casks/appcode-eap.rb
@@ -1,6 +1,6 @@ cask 'appcode-eap' do
- version '145.256.45'
- sha256 '2e33648bfda807f2d8e1cf8eea96a169ad420a31b36250030c5414fee5c30f05'
+ version '2016.1-RC2'
+ sha256 'dec7447da549f6c2033e6bea8587413888e881f0019a436a711ed07fc42c2b58'
url "https://download.jetbrains.com/objc/AppCode-#{version}.dmg"
name 'AppCode'
@@ -9,13 +9,12 @@
conflicts_with cask: 'appcode'
- app 'AppCode EAP.app'
+ app 'AppCode.app'
zap delete: [
- '~/Library/Preferences/com.jetbrains.AppCode-EAP.plist',
- '~/Library/Preferences/AppCode34',
- '~/Library/Application Support/AppCode34',
- '~/Library/Caches/AppCode34',
- '~/Library/Logs/AppCode34',
+ '~/Library/Preferences/AppCode2016.1',
+ '~/Library/Application Support/AppCode2016.1',
+ '~/Library/Caches/AppCode2016.1',
+ '~/Library/Logs/AppCode2016.1',
]
end
|
Update AppCode EAP to version 2016.1-RC2
This commit updates the version and sha256 stanzas. It also changes
the app name, as the RC versions drop the EAP from the app name.
Also updated the zap stanza.
|
diff --git a/Casks/iterm2-beta.rb b/Casks/iterm2-beta.rb
index abc1234..def5678 100644
--- a/Casks/iterm2-beta.rb
+++ b/Casks/iterm2-beta.rb
@@ -1,8 +1,8 @@ cask 'iterm2-beta' do
- version '2.9.20151111'
- sha256 'fb1c566412656c4e9f5cfdc892a1ea960d0b3124479fd4c60dc65ce48ee37c2e'
+ version '2.9.20160102'
+ sha256 '239ee19a0dce38cd95735fb29b901d80c340eb41e9c8282109ba2d224496ee07'
- url 'https://iterm2.com/downloads/beta/iTerm2-2_9_20151111.zip'
+ url "https://iterm2.com/downloads/beta/iTerm2-#{version.dots_to_underscores}.zip"
name 'iTerm2'
homepage 'https://www.iterm2.com/'
license :gpl
|
Upgrade iTerm2 Beta to 2.9.20160102
update version
add version substitution for the url
|
diff --git a/lib/dizby/utility/timed_state.rb b/lib/dizby/utility/timed_state.rb
index abc1234..def5678 100644
--- a/lib/dizby/utility/timed_state.rb
+++ b/lib/dizby/utility/timed_state.rb
@@ -8,7 +8,7 @@
def update
previous = @last_update
- @last_update = Time.now
+ @last_update = Time.now.utc
timediff = (@last_update - previous) * 1000
@time += timediff
@@ -22,7 +22,7 @@ def revive
@state = :active
@time = 0
- @last_update = Time.now
+ @last_update = Time.now.utc
end
private
|
Fix styling error and possible error when dealing with DST.
|
diff --git a/lib/dry/types/builder_methods.rb b/lib/dry/types/builder_methods.rb
index abc1234..def5678 100644
--- a/lib/dry/types/builder_methods.rb
+++ b/lib/dry/types/builder_methods.rb
@@ -1,26 +1,71 @@ module Dry
module Types
module BuilderMethods
+ # Build an array type.
+ # It is a shortcut for Array.of
+ #
+ # @example
+ # Types::Strings = Types.Array(Types::String)
+ #
+ # @param [Dry::Types::Type] type
+ #
+ # @return [Dry::Types::Array]
def Array(type)
self::Array.of(type)
end
+ # Build a hash schema
+ #
+ # @param [Symbol] schema Schema type
+ # @param [Hash{Symbol => Dry::Types::Type}] type_map
+ #
+ # @return [Dry::Types::Array]
+ # @api public
def Hash(schema, type_map)
self::Hash.public_send(schema, type_map)
end
+ # Build a type which values are instances of a given class
+ # Values are checked using `is_a?` call
+ #
+ # @param [Class,Module] klass Class or module
+ #
+ # @return [Dry::Types::Type]
+ # @api public
def Instance(klass)
Definition.new(klass).constrained(type: klass)
end
+ # Build a type with a single value
+ # The equality check done with `eql?`
+ #
+ # @param [Object] value
+ #
+ # @return [Dry::Types::Type]
+ # @api public
def Value(value)
Definition.new(value.class).constrained(eql: value)
end
+ # Build a type with a single value
+ # The equality check done with `equal?`
+ #
+ # @param [Object] object
+ #
+ # @return [Dry::Types::Type]
+ # @api public
def Constant(object)
Definition.new(object.class).constrained(equal: object)
end
+ # Build a constructor type
+ #
+ # @param [Class] klass
+ # @param [#call,nil] cons Value constructor
+ # @param [#call,nil] block Value constructor
+ #
+ # @return [Dry::Types::Type]
+ # @api public
def Constructor(klass, cons = nil, &block)
Definition.new(klass).constructor(cons || block)
end
|
Add YARD for type constructores [skip ci]
|
diff --git a/lib/govuk_seed_crawler/seeder.rb b/lib/govuk_seed_crawler/seeder.rb
index abc1234..def5678 100644
--- a/lib/govuk_seed_crawler/seeder.rb
+++ b/lib/govuk_seed_crawler/seeder.rb
@@ -1,18 +1,21 @@ module GovukSeedCrawler
class Seeder
def self.seed(options = {})
- amqp_connection_options = options.reject do |key, _value|
- %w{:amqp_host :amqp_port :amqp_username :amqp_password}.include?(key) == false
- end
+ amqp_connection_options = self.extract_amqp_connect_options(options)
urls = Indexer.new(options[:site_root]).urls
url_publisher = UrlPublisher.new(amqp_connection_options)
-
url_publisher.exchange_name = options[:amqp_exchange]
url_publisher.topic_name = options[:amqp_topic]
url_publisher.publish_urls(urls)
url_publisher.close
end
+
+ def self.extract_amqp_connect_options(options)
+ amqp_connection_options = options.reject do |key, _value|
+ %w{:amqp_host :amqp_port :amqp_username :amqp_password}.include?(key) == false
+ end
+ end
end
end
|
Move extraction of AMQP config to separate method
Move the logic that extracts the AMQP connection options into its own
method for readability.
|
diff --git a/Formula/redis-php.rb b/Formula/redis-php.rb
index abc1234..def5678 100644
--- a/Formula/redis-php.rb
+++ b/Formula/redis-php.rb
@@ -1,4 +1,8 @@ require 'formula'
+
+def redis_installed?
+ `which redis-server`.length > 0
+end
class RedisPhp < Formula
homepage 'https://github.com/nicolasff/phpredis'
@@ -7,6 +11,7 @@ head 'https://github.com/nicolasff/phpredis.git'
depends_on 'autoconf' => :build
+ depends_on 'redis' => :recommended unless redis_installed?
fails_with :clang do
build 318
|
Make php-redis depend upon redis
|
diff --git a/app/controllers/admin/settings_controller.rb b/app/controllers/admin/settings_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/admin/settings_controller.rb
+++ b/app/controllers/admin/settings_controller.rb
@@ -11,7 +11,7 @@
def cache_clear
Rails.cache.clear
- render nothing: true
+ head :ok
end
private
|
Remove deprecated render nothing: true
|
diff --git a/week-6/attr/my_solution.rb b/week-6/attr/my_solution.rb
index abc1234..def5678 100644
--- a/week-6/attr/my_solution.rb
+++ b/week-6/attr/my_solution.rb
@@ -0,0 +1,102 @@+#Attr Methods
+
+# I worked on this challenge by myself.
+
+# I spent [#] hours on this challenge.
+
+# NameData will initialize a @name variable with your name.
+# Greetings will initialize an instance of NameData and include a method to display a salutation to the console.
+
+# Pseudocode
+
+# NameData#initialize
+# Input: String representing a name.
+# Output: None.
+# Steps:
+# Declare instance variable to store name and set it equal to the name passed in.
+
+# Greetings#initialize
+# Input: None.
+# Output: None.
+# Steps:
+# Create new NameData object and assign it to new instance variable.
+
+# Greetings#hello
+# Input: None.
+# Output: Print salutation including name to console.
+# Steps:
+# Print salutation including name to console.
+
+class NameData
+
+ attr_reader :name
+
+ def initialize(name)
+ @name = name
+ end
+
+end
+
+
+class Greetings
+
+ def initialize
+ @name_data = NameData.new("Buck")
+ end
+
+ def hello
+ puts "Bom dia, " + @name_data.name + ", quanto português você escreve hoje?"
+ end
+
+end
+
+greet = Greetings.new
+greet.hello
+
+# Reflection
+=begin
+
+- What is a reader method?
+
+ A reader method (often called a getter method in other languages)
+ returns the current value of an instance variable.
+
+- What is a writer method?
+
+ A writer method (often called a setter method in other languages)
+ sets the value of an instance variable to the value passed in to the method.
+
+- What do the attr methods do for you?
+
+ They provide a handy readable shortcut to defining and using reader and writer methods.
+
+- Should you always use an accessor to cover your bases? Why or why not?
+
+ No. Two important purposes of a class are to hide implementation details and to
+ restrict access. If you willy-nilly define readers and writers for all your
+ instance variables, you are frittering away those advantages, potentially giving
+ internal access to instance variables that are best protected from view/modification.
+
+- What is confusing to you about these methods?
+
+ I don't quite get why or how a symbol is necessary to identify the variable name
+ that the accessor is being defined for. E.g. if you are defining a reader for
+ the instance variable '@price', why is it
+
+ attr_reader :price
+
+ instead of
+
+ attr_reader price
+
+ or
+
+ attr_reader @price
+
+ or
+
+ attr_reader "price"
+
+ ?
+
+=end
|
Add my solution for Challenge 6.4 - Accessing Attributes
|
diff --git a/lib/rspec/collection_matchers.rb b/lib/rspec/collection_matchers.rb
index abc1234..def5678 100644
--- a/lib/rspec/collection_matchers.rb
+++ b/lib/rspec/collection_matchers.rb
@@ -1,4 +1,5 @@+require 'rspec/expectations'
require 'rspec/collection_matchers/version'
require 'rspec/collection_matchers/matchers'
require 'rspec/collection_matchers/have'
-require 'rspec/collection_matchers/rails_extensions'
+require 'rspec/collection_matchers/rails_extensions'
|
Fix bug of uninitialized constant RSpec::Expectations
|
diff --git a/lib/vines/stream/server/start.rb b/lib/vines/stream/server/start.rb
index abc1234..def5678 100644
--- a/lib/vines/stream/server/start.rb
+++ b/lib/vines/stream/server/start.rb
@@ -15,9 +15,10 @@ stream.start(node)
doc = Document.new
features = doc.create_element('stream:features') do |el|
- #el << doc.create_element('starttls') do |tls|
- # tls.default_namespace = NAMESPACES[:tls]
- #end
+ el << doc.create_element('starttls') do |tls|
+ tls.default_namespace = NAMESPACES[:tls]
+ tls << doc.create_element('required') if force_s2s_encryption?
+ end unless stream.dialback_retry?
el << doc.create_element('dialback') do |db|
db.default_namespace = NAMESPACES[:dialback]
end
@@ -25,6 +26,12 @@ stream.write(features)
advance
end
+
+ private
+
+ def force_s2s_encryption?
+ stream.vhost.force_s2s_encryption?
+ end
end
end
end
|
Add tls flag to stream:features if forcing encryption
|
diff --git a/lib/tasks/shapes/make_valid.rake b/lib/tasks/shapes/make_valid.rake
index abc1234..def5678 100644
--- a/lib/tasks/shapes/make_valid.rake
+++ b/lib/tasks/shapes/make_valid.rake
@@ -0,0 +1,70 @@+# Tenant tasks
+namespace :shapes do
+ desc 'Find invalid productions support shapes (resolve GEOSUnaryUnion: TopologyException error)'
+ task find_invalid_productions: :environment do
+ tenant = ENV['TENANT']
+
+ raise 'Need TENANT variable' unless tenant
+
+ puts "Switch to tenant #{ tenant }"
+ Ekylibre::Tenant.switch(tenant) do
+ invalid_productions_ids = find_invalid_productions
+
+ puts "Invalid productions count : #{ invalid_productions_ids.count }"
+ puts "Invalid productions ids : #{ invalid_productions_ids.to_s }"
+ end
+ end
+
+ desc 'Make valid invalid productions support shapes (resolve GEOSUnaryUnion: TopologyException error)'
+ task make_valid_productions: :environment do
+ tenant = ENV['TENANT']
+
+ raise 'Need TENANT variable' unless tenant
+
+ puts "Switch to tenant #{ tenant }"
+ Ekylibre::Tenant.switch(tenant) do
+ invalid_productions_ids = find_invalid_productions
+
+ puts "Invalid productions count : #{ invalid_productions_ids.count }"
+
+ make_valid_productions(invalid_productions_ids)
+
+ puts "Task finished!"
+ end
+ end
+
+
+ def find_invalid_productions
+ not_valid_production_ids = []
+ valid_activity_productions_ids = []
+
+ activity_productions_ids = ActivityProduction.all.map(&:id)
+
+ (1...ActivityProduction.count).each do |index|
+ production_ids = ActivityProduction.first(index).map(&:id)
+ activity_production_id = production_ids.last
+
+ not_valid_production_ids.each do |production_id|
+ production_ids.delete_at(production_ids.index(production_id))
+ end
+
+ request = "SELECT ST_AsEWKT(ST_Union(support_shape)) FROM activity_productions WHERE id IN (#{ production_ids.join(',') })"
+
+ begin
+ ActiveRecord::Base.connection.execute(request)
+ rescue => exception
+ not_valid_production_ids << activity_production_id
+ end
+ end
+
+ not_valid_production_ids
+ end
+
+ def make_valid_productions(production_ids)
+ production_ids.each do |production_id|
+ request = "UPDATE activity_productions SET support_shape = ST_MakeValid(support_shape) WHERE id = #{ production_id }"
+
+ ActiveRecord::Base.connection.execute(request)
+ end
+ end
+end
|
Add rake task for resolve support shape error
|
diff --git a/lib/dry/types/constructor.rb b/lib/dry/types/constructor.rb
index abc1234..def5678 100644
--- a/lib/dry/types/constructor.rb
+++ b/lib/dry/types/constructor.rb
@@ -4,8 +4,6 @@ module Types
class Constructor < Definition
include Dry::Equalizer(:type)
-
- undef_method :primitive
attr_reader :fn
|
Remove redundant call to undef_method
|
diff --git a/ducktrap.gemspec b/ducktrap.gemspec
index abc1234..def5678 100644
--- a/ducktrap.gemspec
+++ b/ducktrap.gemspec
@@ -13,7 +13,7 @@ gem.files = `git ls-files`.split("\n")
gem.test_files = `git ls-files -- spec`.split("\n")
gem.extra_rdoc_files = %w[TODO]
- gem.license = %w[MIT]
+ gem.license = 'MIT'
gem.add_runtime_dependency('adamantium', '~> 0.1.0')
gem.add_runtime_dependency('equalizer', '~> 0.0.7')
|
Fix gem.license setting in the gemspec
|
diff --git a/lib/frizz/middleman/tasks.rb b/lib/frizz/middleman/tasks.rb
index abc1234..def5678 100644
--- a/lib/frizz/middleman/tasks.rb
+++ b/lib/frizz/middleman/tasks.rb
@@ -25,6 +25,7 @@ relevant_environments.each do |name, env|
desc "Build #{env.name}"
task env.name do
+ FileUtils.rm_rf(Dir[".cache"])
CmdHelper.run_with_live_output "FRIZZ_ENV=#{env.name} middleman build"
end
end
@@ -57,4 +58,4 @@ end
end
-Frizz::Middleman::Tasks.install!+Frizz::Middleman::Tasks.install!
|
Remove middleman-sprocket's file cache (pre-3.3.2) before building to ensure any erb assets use correct environment's frizz.yml values
|
diff --git a/dynosaur.gemspec b/dynosaur.gemspec
index abc1234..def5678 100644
--- a/dynosaur.gemspec
+++ b/dynosaur.gemspec
@@ -23,6 +23,6 @@ spec.add_development_dependency 'bundler', '~> 1.8'
spec.add_development_dependency 'codeclimate-test-reporter', '~> 0.4'
spec.add_development_dependency 'pry-byebug', '~> 3'
- spec.add_development_dependency 'rake', '~> 10.0'
+ spec.add_development_dependency 'rake', '~> 13.0'
spec.add_development_dependency 'rspec', '~> 3'
end
|
Update rake requirement from ~> 10.0 to ~> 13.0
Updates the requirements on [rake](https://github.com/ruby/rake) to permit the latest version.
- [Release notes](https://github.com/ruby/rake/releases)
- [Changelog](https://github.com/ruby/rake/blob/master/History.rdoc)
- [Commits](https://github.com/ruby/rake/compare/rake-10.0.0...v13.0.0)
Signed-off-by: dependabot-preview[bot] <5bdcd3c0d4d24ae3e71b3b452a024c6324c7e4bb@dependabot.com>
|
diff --git a/Casks/mapbox-studio.rb b/Casks/mapbox-studio.rb
index abc1234..def5678 100644
--- a/Casks/mapbox-studio.rb
+++ b/Casks/mapbox-studio.rb
@@ -1,10 +1,10 @@ class MapboxStudio < Cask
- version '0.1.0'
- sha256 'c36455cfa938c957cb08acd04281a5104702ab3b6ba0c76ae38bb6a55910296d'
+ version '0.1.5'
+ sha256 '5da396ebd7bde39d211d0edf2de1b27bfe974c33e7edd0c27966053df6055ab0'
url "https://mapbox.s3.amazonaws.com/mapbox-studio/mapbox-studio-darwin-x64-v#{version}.zip"
homepage 'https://www.mapbox.com/mapbox-studio/'
- license :unknown
+ license :bsd
app "mapbox-studio-darwin-x64-v#{version}/Mapbox Studio.app"
end
|
Upgrade Mapbox Studio to v0.1.5
The latest version addresses bugs
related to atom-shell integration.
For a full list of changes, see
https://github.com/mapbox/mapbox-studio/blob/mb-pages/CHANGELOG.md#changelog
|
diff --git a/test/airbrussh/log_file_formatter_test.rb b/test/airbrussh/log_file_formatter_test.rb
index abc1234..def5678 100644
--- a/test/airbrussh/log_file_formatter_test.rb
+++ b/test/airbrussh/log_file_formatter_test.rb
@@ -1,5 +1,6 @@ require "minitest_helper"
require "airbrussh/log_file_formatter"
+require "fileutils"
require "tempfile"
class Airbrussh::LogFileFormatterTest < Minitest::Test
@@ -30,7 +31,7 @@ end
def test_creates_log_directory_and_file
- Dir.mktmpdir("airbrussh-test-") do |dir|
+ with_tempdir do |dir|
log_file = File.join(dir, "log", "capistrano.log")
Airbrussh::LogFileFormatter.new(log_file)
assert(File.exist?(log_file))
@@ -42,4 +43,11 @@ def output
@output ||= IO.read(@file.path)
end
+
+ def with_tempdir
+ dir = Dir.mktmpdir("airbrussh-test-")
+ yield(dir)
+ ensure
+ FileUtils.rm_rf(dir)
+ end
end
|
Work around Dir.mktmpdir problems on Windows
|
diff --git a/lib/how_is/sources/github.rb b/lib/how_is/sources/github.rb
index abc1234..def5678 100644
--- a/lib/how_is/sources/github.rb
+++ b/lib/how_is/sources/github.rb
@@ -11,24 +11,20 @@ class ConfigError < StandardError
end
- def initialize(global_config)
- raise ConfigError, "Expected Hash, got #{global_config.class}." unless \
- global_config.is_a?(Hash)
+ def initialize(config)
+ must_have_key!(config, "sources/github")
- raise ConfigError, "No config for sources/github." unless \
- global_config.has_key?("sources/github")
+ @config = config["sources/github"]
- config = global_config["sources/github"]
+ must_have_key!(@config, "username")
+ must_have_key!(@config, "token")
+ end
- raise ConfigError, "No username provided for sources/github." unless \
- config.has_key?("username") && config["username"]
-
- raise ConfigError, "No token provided for sources/github." unless \
- config.has_key?("token") && config["token"]
-
- @global_config = global_config
- @config = config
+ def must_have_key!(hash, key)
+ raise ConfigError, "Expected Hash, got #{hash.class}" unless hash.is_a?(Hash)
+ raise ConfigError, "Expected key `#{key}'" unless hash.has_key?(key)
end
+ private :must_have_key!
# The GitHub username used for authenticating with GitHub.
def username
|
Clean up Sources::Github.new by adding a helper method.
|
diff --git a/test/controllers/items_controller_test.rb b/test/controllers/items_controller_test.rb
index abc1234..def5678 100644
--- a/test/controllers/items_controller_test.rb
+++ b/test/controllers/items_controller_test.rb
@@ -4,4 +4,9 @@ # test "the truth" do
# assert true
# end
+
+ test "should get new item form page" do
+ get new_item_path
+ assert_response :success
+ end
end
|
Write test for clicking on a new item link
|
diff --git a/lib/nehm/playlist_manager.rb b/lib/nehm/playlist_manager.rb
index abc1234..def5678 100644
--- a/lib/nehm/playlist_manager.rb
+++ b/lib/nehm/playlist_manager.rb
@@ -5,7 +5,7 @@
def self.set_playlist
loop do
- playlist = HighLine.new.ask('Enter name of default iTunes playlist to which you want add tracks (press Enter to set it to default Music library)')
+ playlist = HighLine.new.ask('Enter name of default iTunes playlist to which you want add tracks (press Enter to set it to default iTunes Music library)')
if playlist == ''
Cfg[:playlist] = nil
puts Paint['Default iTunes playlist unset', :green]
|
Edit message when set the iTunes playlist
|
diff --git a/lib/24_seven_office/services/authentication.rb b/lib/24_seven_office/services/authentication.rb
index abc1234..def5678 100644
--- a/lib/24_seven_office/services/authentication.rb
+++ b/lib/24_seven_office/services/authentication.rb
@@ -27,7 +27,7 @@ end
def self.login(username, password, application_id)
- super Request.new(username, password, application_id)
+ super message: Request.new(username, password, application_id)
end
end
|
Add missing hash key in call to super
|
diff --git a/actionpack/test/controller/new_base/render_context_test.rb b/actionpack/test/controller/new_base/render_context_test.rb
index abc1234..def5678 100644
--- a/actionpack/test/controller/new_base/render_context_test.rb
+++ b/actionpack/test/controller/new_base/render_context_test.rb
@@ -0,0 +1,54 @@+require 'abstract_unit'
+
+module RenderContext
+ class BasicController < ActionController::Base
+ self.view_paths = [ActionView::FixtureResolver.new(
+ "render_context/basic/hello_world.html.erb" => "<%= @value %> from <%= self.__controller_method__ %>",
+ "layouts/basic.html.erb" => "?<%= yield %>?"
+ )]
+
+ # Include ViewContext
+ include ActionView::Context
+
+ # And initialize the required variables
+ before_filter do
+ @output_buffer = nil
+ @virtual_path = nil
+ @view_flow = ActionView::OutputFlow.new
+ end
+
+ def hello_world
+ @value = "Hello"
+ render :action => "hello_world", :layout => false
+ end
+
+ def with_layout
+ @value = "Hello"
+ render :action => "hello_world", :layout => "basic"
+ end
+
+ protected
+
+ def view_context
+ self
+ end
+
+ def __controller_method__
+ "controller context!"
+ end
+ end
+
+ class RenderContextTest < Rack::TestCase
+ test "rendering using the controller as context" do
+ get "/render_context/basic/hello_world"
+ assert_body "Hello from controller context!"
+ assert_status 200
+ end
+
+ test "rendering using the controller as context with layout" do
+ get "/render_context/basic/with_layout"
+ assert_body "?Hello from controller context!?"
+ assert_status 200
+ end
+ end
+end
|
Add a test for rendering from the controller context.
|
diff --git a/lib/aaa_sfu_misc/request_throttle_whitelist.rb b/lib/aaa_sfu_misc/request_throttle_whitelist.rb
index abc1234..def5678 100644
--- a/lib/aaa_sfu_misc/request_throttle_whitelist.rb
+++ b/lib/aaa_sfu_misc/request_throttle_whitelist.rb
@@ -1,5 +1,5 @@ class RequestThrottle
- alias_method :whitelisted_original?, :whitelisted?
+ alias_method :whitelisted_original?, :approved?
def whitelisted?(request)
if request.fullpath.to_s.start_with?("/health_check") &&
request.headers['User-Agent'].to_s.include?("Hobbit")
@@ -8,4 +8,4 @@ whitelisted_original?(request)
end
end
-end+end
|
Fix call to changed method name.
|
diff --git a/spec/overcommit/hook/commit_msg/spellcheck_spec.rb b/spec/overcommit/hook/commit_msg/spellcheck_spec.rb
index abc1234..def5678 100644
--- a/spec/overcommit/hook/commit_msg/spellcheck_spec.rb
+++ b/spec/overcommit/hook/commit_msg/spellcheck_spec.rb
@@ -0,0 +1,76 @@+# encoding: utf-8
+require 'spec_helper'
+
+describe Overcommit::Hook::CommitMsg::Spellcheck do
+ let(:config) { Overcommit::ConfigurationLoader.default_configuration }
+ let(:context) { double('context') }
+ subject { described_class.new(config, context) }
+
+ before do
+ subject.stub(:update_commit_message)
+ subject.stub(:commit_message)
+ subject.stub(:commit_message_file)
+ subject.stub(:execute).and_return(result)
+ end
+
+ context 'when hunspell exits successfully' do
+ let(:result) { double('result') }
+
+ before do
+ result.stub(:success?).and_return(true)
+ end
+
+ context 'with no misspellings' do
+ before do
+ result.stub(:stdout).and_return(<<-EOS)
+@(#) International Ispell Version 3.2.06 (but really Hunspell 1.3.3)
+*
+*
+*
+ EOS
+ end
+
+ it { should pass }
+ end
+
+ context 'with misspellings' do
+ context 'with suggestions' do
+ before do
+ result.stub(:stdout).and_return(<<-EOS)
+@(#) International Ispell Version 3.2.06 (but really Hunspell 1.3.3)
+*
+& msg 10 4: MSG, mag, ms, mg, meg, mtg, mug, mpg, mfg, ms g
+*
+ EOS
+ end
+
+ it { should warn(/^Potential misspelling: \w+. Suggestions: .+$/) }
+ end
+
+ context 'with no suggestions' do
+ before do
+ result.stub(:stdout).and_return(<<-EOS)
+@(#) International Ispell Version 3.2.06 (but really Hunspell 1.3.3)
+*
+# supercalifragilisticexpialidocious 4
+*
+ EOS
+ end
+
+ it { should warn(/^Potential misspelling: \w+.$/) }
+ end
+ end
+ end
+
+ context 'when hunspell exits unsuccessfully' do
+ let(:result) { double('result') }
+
+ before do
+ result.stub(success?: false, stderr: <<-EOS)
+Can't open affix or dictionary files for dictionary named "foo".
+ EOS
+ end
+
+ it { should fail_hook }
+ end
+end
|
Add spec for Spellcheck commit-msg hook
|
diff --git a/lib/volunteermatch/api/search_organizations.rb b/lib/volunteermatch/api/search_organizations.rb
index abc1234..def5678 100644
--- a/lib/volunteermatch/api/search_organizations.rb
+++ b/lib/volunteermatch/api/search_organizations.rb
@@ -4,7 +4,6 @@ def search_organizations(parameters = {})
raise ArgumentError, 'location needs to be defined' if parameters[:location].nil? || parameters[:location].empty?
parameters[:location] = parameters[:location] || nil
- parameters[:fieldsToDisplay] = parameters[:fieldsToDisplay => ["name", "location"]]
call(:searchOrganizations, parameters.to_json)
end
end
|
Remove default text to display in parameters
|
diff --git a/app/init_sidekiq.rb b/app/init_sidekiq.rb
index abc1234..def5678 100644
--- a/app/init_sidekiq.rb
+++ b/app/init_sidekiq.rb
@@ -1,6 +1,3 @@ require "./app/boot"
require "./app/workers/dependency_file_fetcher"
-require "./app/workers/dependency_file_parser"
-require "./app/workers/update_checker"
-require "./app/workers/dependency_file_updater"
-require "./app/workers/pull_request_creator"
+require "./app/workers/dependency_updater"
|
Remove nonexistent requires from sidekiq_init
|
diff --git a/config/application.rb b/config/application.rb
index abc1234..def5678 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -13,7 +13,7 @@ # you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
-module Opencampground
+module OpenCampground
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
|
Rename app from Opencampground to OpenCampground
|
diff --git a/config/application.rb b/config/application.rb
index abc1234..def5678 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -23,6 +23,9 @@ raise '$ORBIT_HOME not set' unless ENV['ORBIT_HOME']
raise '$ORBIT_HOME not a dir' unless File.directory? ENV['ORBIT_HOME']
+raise '$ORBIT_KEY not set' unless ENV['ORBIT_KEY']
+raise '$ORBIT_KEY not a file' unless File.file? ENV['ORBIT_KEY']
+
Yeah.application.configure do
enable :nonblock
document_root File.join(ENV['ORBIT_HOME'], 'public'), urls: ['/iss']
|
Make sure that $ORBIT_KEY is set
|
diff --git a/StringStylizer.podspec b/StringStylizer.podspec
index abc1234..def5678 100644
--- a/StringStylizer.podspec
+++ b/StringStylizer.podspec
@@ -22,5 +22,5 @@
s.ios.deployment_target = '8.0'
- s.source_files = 'StringStylizer/*'
+ s.source_files = 'StringStylizer/*.swift'
end
|
Fix `podspec` to not include Info.plist
Fixes building via CocoaPods in Xcode 10
|
diff --git a/db/migrate/20140617193351_add_post_id_index_on_topic_links.rb b/db/migrate/20140617193351_add_post_id_index_on_topic_links.rb
index abc1234..def5678 100644
--- a/db/migrate/20140617193351_add_post_id_index_on_topic_links.rb
+++ b/db/migrate/20140617193351_add_post_id_index_on_topic_links.rb
@@ -0,0 +1,9 @@+class AddPostIdIndexOnTopicLinks < ActiveRecord::Migration
+ def up
+ add_index :topic_links, :post_id
+ end
+
+ def down
+ remove_index :topic_links, :post_id
+ end
+end
|
Add post_id index to topic_links
|
diff --git a/core/file/fixtures/file_types.rb b/core/file/fixtures/file_types.rb
index abc1234..def5678 100644
--- a/core/file/fixtures/file_types.rb
+++ b/core/file/fixtures/file_types.rb
@@ -57,8 +57,11 @@ name = tmp("ftype_socket.socket")
rm_r name
socket = UNIXServer.new name
- yield name
- socket.close
- rm_r name
+ begin
+ yield name
+ ensure
+ socket.close
+ rm_r name
+ end
end
end
|
Add missing ensure in FileSpecs.socket
|
diff --git a/test/integration/default/serverspec/spec_helper.rb b/test/integration/default/serverspec/spec_helper.rb
index abc1234..def5678 100644
--- a/test/integration/default/serverspec/spec_helper.rb
+++ b/test/integration/default/serverspec/spec_helper.rb
@@ -18,8 +18,7 @@
require 'serverspec'
-include SpecInfra::Helper::Exec
-include SpecInfra::Helper::DetectOS
+set :backend, :exec
RSpec.configure do |c|
if ENV['ASK_SUDO_PASSWORD']
|
Upgrade serverspec helper to latets notation
|
diff --git a/core/objectspace/_id2ref_spec.rb b/core/objectspace/_id2ref_spec.rb
index abc1234..def5678 100644
--- a/core/objectspace/_id2ref_spec.rb
+++ b/core/objectspace/_id2ref_spec.rb
@@ -6,4 +6,21 @@ r = ObjectSpace._id2ref(s.object_id)
r.should == s
end
+
+ it "retrieves a Fixnum by object_id" do
+ f = 1
+ r = ObjectSpace._id2ref(f.object_id)
+ r.should == f
+ end
+
+ it "retrieves a Symbol by object_id" do
+ s = :sym
+ r = ObjectSpace._id2ref(s.object_id)
+ r.should == s
+ end
+
+ it "raises a RangeError for invalid immediate object_id" do
+ lambda { ObjectSpace._id2ref(1073741822) }.should raise_error(RangeError)
+ end
+
end
|
Add specs for ObjectSpace._id2ref and immediates
|
diff --git a/week-6/die-2/my_solution.rb b/week-6/die-2/my_solution.rb
index abc1234..def5678 100644
--- a/week-6/die-2/my_solution.rb
+++ b/week-6/die-2/my_solution.rb
@@ -1,26 +1,47 @@ # Die Class 2: Arbitrary Symbols
-# I worked on this challenge [by myself, with: ].
+# I worked on this challenge by myself.
# I spent [#] hours on this challenge.
# Pseudocode
-# Input:
-# Output:
+# Input: an array of either strings or numbers.
+# Output: from sides: a number coresponding to the number of sides on the die. from roll: a random side of the die. (different every time it's called)
# Steps:
+
+# Create a Die class
+# Create a new method, initialize, that takes in one variable that is an array called labels.
+# if labels is an empty array return an artument error.
+# store the new variable labels as an instance variable
+# end method initialize
+# Create a new method sides
+# create an instance variable, sides
+# set sides equal to the size of the array, labels
+# return the instance variable sides
+# end method sides
+# Create a new method roll
+# generate a random number, corresponding to each location in the array
+# return the element corresponding to the random location in the array
+# end method roll
+# end Die Class
# Initial Solution
class Die
def initialize(labels)
+ raise ArgumentError.new("Need to provide an array...") if labels.empty?
+ @labels = labels
+ @sides = @labels.length
end
def sides
+ return @sides
end
def roll
+ return @labels[rand(0...@sides)]
end
end
@@ -28,11 +49,27 @@
# Refactored Solution
+# Couldn't find any methods to improve upon the code.
+
+# Reflection
+=begin
+- What were the main differences between this die class and the last one you created in terms of implementation? Did you need to change much logic to get this to work?
+There wasn't much of a difference, biggest difference is instead of taking in an integer like last time it's taking in an array. Some of the logic was a little different, like to figure out the number of sides or how to output a random side... but the structure was fundamentally the same.
+- What does this exercise teach you about making code that is easily changeable or modifiable?
+It will save you lots of time if you can have code that can easily be changed instead of code that is very specific and only able to be used for one case.
-# Reflection
+- What new methods did you learn when working on this challenge, if any?
+
+I did not use any new methods when writing this class.
+
+- What concepts about classes were you able to solidify in this challenge?
+
+When I was initially writing the code, I didn't declare @sides in my initialize method, only in the sides method. Then when I was testing .roll I couldn't figure out at first why I was getting errors. Took me a minute to figure out that if I hadn't called sides it didn't have a value stored yet for the @sides variable.
+
+=end
|
Create class with methods to output the number of sides on a die and a random position in an array, corresponding to a side on the die.
|
diff --git a/db/migrate/20140602152302_remove_rpa_specialist_sectors.rb b/db/migrate/20140602152302_remove_rpa_specialist_sectors.rb
index abc1234..def5678 100644
--- a/db/migrate/20140602152302_remove_rpa_specialist_sectors.rb
+++ b/db/migrate/20140602152302_remove_rpa_specialist_sectors.rb
@@ -0,0 +1,41 @@+class RemoveRpaSpecialistSectors < Mongoid::Migration
+ TAG_TYPE = "specialist-sector"
+
+ def self.up
+ tags_to_remove.each do |tag_id, _, _|
+ tag = Tag.by_tag_id(tag_id, TAG_TYPE)
+
+ if tag.present?
+ if tag.destroy
+ puts "Deleted specialist sector: #{tag_id}"
+ else
+ puts "Could not delete specialist sector: #{tag_id}"
+ end
+ else
+ puts "Could not find specialist sector: #{tag_id}"
+ end
+ end
+ end
+
+ def self.down
+ tags_to_remove.each do |tag_id, title, parent_id|
+ tag = Tag.by_tag_id(tag_id, TAG_TYPE)
+
+ if tag.present?
+ puts "Specialist sector #{tag_id} already exists"
+ else
+ Tag.create!(tag_id: tag_id, title: title, parent_id: parent_id, tag_type: TAG_TYPE)
+ puts "Created specialist sector: #{title} (#{tag_id})"
+ end
+ end
+ end
+
+private
+ def self.tags_to_remove
+ [
+ ["working-at-sea/fishing", "Fishing", "working-at-sea"],
+ ["producing-distributing-food/inspections", "Inspections", "producing-distributing-food"],
+ ["keeping-farmed-animals/inspections", "Inspections", "keeping-farmed-animals"],
+ ]
+ end
+end
|
Add migration to delete three RPA specialist sectors
This migration deletes three specialist sector tags if they exist.
These have never been populated on GOV.UK, nor are they currently
linked to, so it is not necessary to add redirects for these.
|
diff --git a/lib/devise_jwt/jwt_failure_app.rb b/lib/devise_jwt/jwt_failure_app.rb
index abc1234..def5678 100644
--- a/lib/devise_jwt/jwt_failure_app.rb
+++ b/lib/devise_jwt/jwt_failure_app.rb
@@ -14,12 +14,19 @@ return i18n_message unless request_format
method = "to_#{request_format}"
if method == 'to_xml'
- { messsage: i18n_message }.to_xml(root: 'errors')
+ {messsage: i18n_message}.to_xml(root: 'errors')
elsif {}.respond_to?(method)
- {status: :error, errors: [{messsage: i18n_message}]}.send(method)
+ {status: :error, errors: [{id: warden.message, messsage: i18n_message}]}.send(method)
else
i18n_message
end
+ end
+
+ protected
+
+ def i18n_options(options)
+ options[:scope] = 'devise_jwt.failure'
+ options
end
private
|
Redefine scope property of i18n options from devise.failure to devise_jwt.failure
|
diff --git a/app/api/shopt/api.rb b/app/api/shopt/api.rb
index abc1234..def5678 100644
--- a/app/api/shopt/api.rb
+++ b/app/api/shopt/api.rb
@@ -16,6 +16,12 @@ route_param :id do
get do
Customer.find(params[:id])
+ end
+
+ route_param :orders do
+ get do
+ Customer.find(params[:id]).orders
+ end
end
end
end
|
Add endpoint for a customer's orders
|
diff --git a/app/jobs/notifier.rb b/app/jobs/notifier.rb
index abc1234..def5678 100644
--- a/app/jobs/notifier.rb
+++ b/app/jobs/notifier.rb
@@ -18,7 +18,7 @@ 'Authorization' => authorization
end
true
- rescue *(HTTP_ERRORS + [RestClient::Exception, SocketError]) => e
+ rescue *(HTTP_ERRORS + [RestClient::Exception, SocketError, SystemCallError]) => e
WebHook.find_by_url(url).try(:increment!, :failure_count)
false
end
|
Include all Errnos as failures
|
diff --git a/app_prototype/lib/templates/rspec/scaffold/show_spec.rb b/app_prototype/lib/templates/rspec/scaffold/show_spec.rb
index abc1234..def5678 100644
--- a/app_prototype/lib/templates/rspec/scaffold/show_spec.rb
+++ b/app_prototype/lib/templates/rspec/scaffold/show_spec.rb
@@ -0,0 +1,15 @@+require 'spec_helper'
+
+<% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
+describe "<%= ns_table_name %>/show" do
+ before(:each) do
+ @<%= ns_file_name %> = assign(:<%= ns_file_name %>, build_stubbed(:<%= class_name.underscore %>))
+ end
+
+ it "renders attributes" do
+ render
+<% for attribute in output_attributes -%>
+ expect(rendered).to match(/<%= eval(value_for(attribute)) %>/)
+<% end -%>
+ end
+end
|
Use the expect() syntax when generating view specs for :show. Use factory_girl's build_stubbed instead of rspec's stub_model.
|
diff --git a/lib/rails/deprecated_sanitizer.rb b/lib/rails/deprecated_sanitizer.rb
index abc1234..def5678 100644
--- a/lib/rails/deprecated_sanitizer.rb
+++ b/lib/rails/deprecated_sanitizer.rb
@@ -39,5 +39,5 @@ end
ActiveSupport.on_load(:action_view) do
- ActionView::SanitizeHelper.sanitizer_vendor = Rails::Deprecated::Sanitizer
+ ActionView::SanitizeHelper.sanitizer_vendor = Rails::DeprecatedSanitizer
end
|
Set sanitizer_vendor to correct constant.
|
diff --git a/lib/generators/templates/plans.rb b/lib/generators/templates/plans.rb
index abc1234..def5678 100644
--- a/lib/generators/templates/plans.rb
+++ b/lib/generators/templates/plans.rb
@@ -11,7 +11,7 @@ # # amount in cents. This is 6.99
# plan.amount = 699
#
-# # interval must be either 'month' or 'year'
+# # interval must be either 'week', 'month' or 'year'
# plan.interval = 'month'
#
# # only bill once every three months (default 1)
@@ -26,4 +26,4 @@ # rake stripe:prepare
#
# This will export any new plans to stripe.com so that you can
-# begin using them in your API calls.+# begin using them in your API calls.
|
Update template to include 'week'.
|
diff --git a/lib/tasks/analyse_javascript.rake b/lib/tasks/analyse_javascript.rake
index abc1234..def5678 100644
--- a/lib/tasks/analyse_javascript.rake
+++ b/lib/tasks/analyse_javascript.rake
@@ -1,5 +1,7 @@+require 'English'
+
desc 'Analyse Javascript with JSHint and Javascript Code Style checker'
task :analyse_javascript do
puts 'Running Javascript code analysis...'
- system('npm run js') || raise('Javascript analysis failed')
+ system('npm run js') || exit($CHILD_STATUS.exitstatus)
end
|
Exit with correct exit code
Returns the correct exit code, rather than raising an exception.
|
diff --git a/db/data_migration/20181004172520_update_drafts_for_scheduled_content_to_resolve_first_published_at_issue.rb b/db/data_migration/20181004172520_update_drafts_for_scheduled_content_to_resolve_first_published_at_issue.rb
index abc1234..def5678 100644
--- a/db/data_migration/20181004172520_update_drafts_for_scheduled_content_to_resolve_first_published_at_issue.rb
+++ b/db/data_migration/20181004172520_update_drafts_for_scheduled_content_to_resolve_first_published_at_issue.rb
@@ -0,0 +1,8 @@+Document.where(
+ id: Edition.where(state: :scheduled).select(:document_id)
+).all.each do |document|
+ next unless document.published_edition.nil?
+
+ puts "Saving draft for #{document.id} (content_id: #{document.content_id})"
+ Whitehall::PublishingApi.save_draft(document.pre_publication_edition)
+end
|
Add data migration to fix first_published_at values
Along with the first_public_at values for scheduled content which
hasn't been published yet.
This is necessary, as Whitehall has been sending the
first_published_at values for content which hasn't been published
yet... and it didn't even get them right for scheduled content (even
though the value would have been in the future!).
This is a copy of the previous
20181002120423_create_publishing_api_drafts_for_scheduled_content.rb
migration to do the same thing for a different reason.
|
diff --git a/test/readers/fgdc/tc_fgdc_lineage.rb b/test/readers/fgdc/tc_fgdc_lineage.rb
index abc1234..def5678 100644
--- a/test/readers/fgdc/tc_fgdc_lineage.rb
+++ b/test/readers/fgdc/tc_fgdc_lineage.rb
@@ -0,0 +1,37 @@+# MdTranslator - minitest of
+# readers / fgdc / module_lineage
+
+# History:
+# Stan Smith 2017-08-31 original script
+
+require 'nokogiri'
+require 'adiwg/mdtranslator/internal/internal_metadata_obj'
+require 'adiwg/mdtranslator/readers/fgdc/modules/module_fgdc'
+require_relative 'fgdc_test_parent'
+
+class TestReaderFgdcLineage < TestReaderFGDCParent
+
+ @@xDoc = TestReaderFGDCParent.get_XML('lineage.xml')
+ @@NameSpace = ADIWG::Mdtranslator::Readers::Fgdc::Lineage
+
+ def test_lineage_complete
+
+ intMetadataClass = InternalMetadata.new
+ hResourceInfo = intMetadataClass.newResourceInfo
+
+ TestReaderFGDCParent.set_xDoc(@@xDoc)
+ TestReaderFGDCParent.set_intObj
+ xIn = @@xDoc.xpath('./metadata/dataqual/lineage')
+
+ hLineage = @@NameSpace.unpack(xIn, hResourceInfo,@@hResponseObj)
+
+ refute_nil hLineage
+ assert_equal 2, hLineage[:dataSources].length
+ assert_equal 2, hLineage[:processSteps].length
+
+ assert @@hResponseObj[:readerExecutionPass]
+ assert_empty @@hResponseObj[:readerExecutionMessages]
+
+ end
+
+end
|
Add fgdc reader module 'lineage'
include minitest
|
diff --git a/attributes/exabgp.rb b/attributes/exabgp.rb
index abc1234..def5678 100644
--- a/attributes/exabgp.rb
+++ b/attributes/exabgp.rb
@@ -1,5 +1,5 @@-default[:exabgp][:local_as] = 0
-default[:exabgp][:peer_as] = 0
+default[:exabgp][:local_as] = 12345
+default[:exabgp][:peer_as] = 12345
default[:exabgp][:community] = [0]
default[:exabgp][:hold_time] = 20
|
Put something other than 0 for local and peer as
This will allow it to fully start up for now.
|
diff --git a/app/models/sentence.rb b/app/models/sentence.rb
index abc1234..def5678 100644
--- a/app/models/sentence.rb
+++ b/app/models/sentence.rb
@@ -8,6 +8,8 @@ default_scope where(imported: false)
attr_accessible :locid
+
+ delegate :repository, to: :ontology
def self.find_with_locid(locid, _iri = nil)
where(locid: locid).first
|
Make repository available from Sentence.
|
diff --git a/app/plugins/weather.rb b/app/plugins/weather.rb
index abc1234..def5678 100644
--- a/app/plugins/weather.rb
+++ b/app/plugins/weather.rb
@@ -1,6 +1,6 @@ # encoding: utf-8
class Wearther < Base
- match /^[zurg].+como.+tempo.+em\s(.+)[?]$/, :use_prefix => false, :method => :weather
+ match /^[zurg].+como.+tempo.+em\s(.+)[?]$/i, :use_prefix => false, :method => :weather
def initialize(*args)
super
@@ -15,7 +15,7 @@ if result.document_root.to_s =~ /Error/
m.reply "Infelizmente rolou algum erro na sua solicitação.", true
else
- m.reply "Está fazendo em #{result.location["city"]}, #{result.condition["temp"]} °C", true
+ m.reply "Está fazendo em #{result.location["city"]} #{result.condition["temp"]} °C", true
end
else
m.reply "Não existe esse lugar cara", true
|
Fix regexp and remove , from the answer
|
diff --git a/fdic.gemspec b/fdic.gemspec
index abc1234..def5678 100644
--- a/fdic.gemspec
+++ b/fdic.gemspec
@@ -6,7 +6,7 @@ Gem::Specification.new do |spec|
spec.name = "fdic"
spec.version = FDIC::VERSION
- spec.authors = ["Thomas Reznick", "Dan Bernier"]
+ spec.authors = ["Tom Reznick", "Dan Bernier"]
spec.email = ["treznick@continuity.net", "dbernier@continuity.net"]
spec.summary = %q{A Ruby client to the FDIC's BankFind API}
|
Rename Thomas to Tom in the .gemspec.
:bowtie:
|
diff --git a/app/models/category_topic.rb b/app/models/category_topic.rb
index abc1234..def5678 100644
--- a/app/models/category_topic.rb
+++ b/app/models/category_topic.rb
@@ -16,6 +16,8 @@
validate :category_and_topic_must_belong_to_same_user
+ private
+
def category_and_topic_must_belong_to_same_user
if category && topic && category.game.user != topic.user
errors.add(:topic, "can't belong to a different user than game")
|
Make custom validation method private
|
diff --git a/app/models/org_identifier.rb b/app/models/org_identifier.rb
index abc1234..def5678 100644
--- a/app/models/org_identifier.rb
+++ b/app/models/org_identifier.rb
@@ -34,7 +34,8 @@ validates :identifier_scheme_id, uniqueness: { scope: :org_id,
message: UNIQUENESS_MESSAGE }
- validates :identifier, presence: { message: PRESENCE_MESSAGE }
+ validates :identifier, presence: { message: PRESENCE_MESSAGE },
+ uniqueness: { message: UNIQUENESS_MESSAGE }
validates :org, presence: { message: PRESENCE_MESSAGE }
|
Add uniqueness validation to OrgIdentifier
|
diff --git a/lib/frecon/controllers/records_controller.rb b/lib/frecon/controllers/records_controller.rb
index abc1234..def5678 100644
--- a/lib/frecon/controllers/records_controller.rb
+++ b/lib/frecon/controllers/records_controller.rb
@@ -13,8 +13,8 @@
module FReCon
class RecordsController < Controller
- def self.create(request, params)
- super(request, params, match_number_and_competition_to_match_id(team_number_to_team_id(process_json_request(request))))
+ def self.create(request, params, post_data = nil)
+ super(request, params, post_data || match_number_and_competition_to_match_id(team_number_to_team_id(process_json_request(request))))
end
def self.competition(params)
|
Make RecordsController allow three arguments
|
diff --git a/spec/features/acceptance/login_as_user_spec.rb b/spec/features/acceptance/login_as_user_spec.rb
index abc1234..def5678 100644
--- a/spec/features/acceptance/login_as_user_spec.rb
+++ b/spec/features/acceptance/login_as_user_spec.rb
@@ -14,4 +14,9 @@ end
end
+ scenario "Change button layout after applying" do
+ Click "Berwerben"
+ expect(page).to have_content("Gestellt")
+ end
+
end
|
Add test for changing label after applying
|
diff --git a/spec/lib/request_started_on_middleware_spec.rb b/spec/lib/request_started_on_middleware_spec.rb
index abc1234..def5678 100644
--- a/spec/lib/request_started_on_middleware_spec.rb
+++ b/spec/lib/request_started_on_middleware_spec.rb
@@ -1,8 +1,7 @@-describe RequestStartedOnMiddleware do
+RSpec.describe RequestStartedOnMiddleware do
context ".long_running_requests" do
before do
allow(described_class).to receive(:relevant_thread_list) { fake_threads }
- allow(described_class).to receive(:request_timeout).and_return(2.minutes)
end
let(:fake_threads) { [@fake_thread] }
|
Remove unused partial in RequestStartedOnMiddleware specs.
Added RSpec to outer describe block.
|
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index abc1234..def5678 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -5,13 +5,9 @@
class HTMLwithPygments < Redcarpet::Render::HTML
def block_code(code, language)
- if Pygments::Lexer.find_by_alias(language)
- sha = Digest::SHA1.hexdigest(code)
- Rails.cache.fetch ["code", language, sha].join('-') do
- Pygments.highlight(code, lexer: language)
- end
- else
- "Error: Invalid language in your code block, buddy."
+ sha = Digest::SHA1.hexdigest(code)
+ Rails.cache.fetch ["code", language, sha].join('-') do
+ Pygments.highlight(code, lexer: language)
end
end
end
|
Stop displaying errors for code blocks with no language.
|
diff --git a/test/factories/accounts.rb b/test/factories/accounts.rb
index abc1234..def5678 100644
--- a/test/factories/accounts.rb
+++ b/test/factories/accounts.rb
@@ -5,7 +5,7 @@ nature { 'general' }
sequence(:name) { |n| "Compte 801 - #{n}" }
sequence(:number) { |n| (801000 + n).to_s }
- number_is_valid { true }
+ already_existing { true }
trait :client do
sequence(:name) { |n| "Compte client #{n}" }
|
Change old field by new one
|
diff --git a/test/metrics-rails_test.rb b/test/metrics-rails_test.rb
index abc1234..def5678 100644
--- a/test/metrics-rails_test.rb
+++ b/test/metrics-rails_test.rb
@@ -8,6 +8,11 @@
test 'client is available' do
assert_kind_of Librato::Metrics::Client, Metrics::Rails.client
+ end
+
+ test '#increment exists' do
+ assert Metrics::Rails.respond_to?(:increment)
+ Metrics::Rails.increment :baz, 5
end
test 'flush sends data' do
@@ -31,6 +36,12 @@ assert_equal 2, bar['unassigned'][0]['value']
end
+ test 'counters should persist through flush' do
+ Metrics::Rails.increment 'knightrider'
+ Metrics::Rails.flush
+ assert_equal 1, Metrics::Rails.counters['knightrider']
+ end
+
private
def delete_all_metrics
|
Add coverage for counters persisting between flushes
|
diff --git a/app/models/question_permission.rb b/app/models/question_permission.rb
index abc1234..def5678 100644
--- a/app/models/question_permission.rb
+++ b/app/models/question_permission.rb
@@ -11,7 +11,7 @@
def after_initialize
return unless question = Question.find(:secret => secret)
- return if question.group && current_user && !question.group.has_member?(current_user)
+ return if question.group && current_user && !current_user.superuser_enabled? && !question.group.has_member?(current_user)
self.question = question
self.user = current_user
end
|
Allow superusers to access private questions w/ a group
|
diff --git a/event_store-entity_store.gemspec b/event_store-entity_store.gemspec
index abc1234..def5678 100644
--- a/event_store-entity_store.gemspec
+++ b/event_store-entity_store.gemspec
@@ -1,7 +1,7 @@ # -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = 'event_store-entity_store'
- s.version = '0.1.1.0'
+ s.version = '0.2.0.0'
s.summary = 'Store of entities that are projected from EventStore streams'
s.description = ' '
|
Package version is increased from 0.1.1.0 to 0.2.0.0
|
diff --git a/claim_token.gemspec b/claim_token.gemspec
index abc1234..def5678 100644
--- a/claim_token.gemspec
+++ b/claim_token.gemspec
@@ -6,8 +6,8 @@ Gem::Specification.new do |spec|
spec.name = "claim_token"
spec.version = ClaimToken::VERSION
- spec.authors = ["Daniel Zollinger"]
- spec.email = ["daniel.zollinger@crichq.com"]
+ spec.authors = ["CricHQ"]
+ spec.email = ["ben.greville@crichq.com"]
spec.description = %q{ClaimToken encrypts and signs tokens to be used in a claim-based authentication system}
spec.summary = %q{Encrypt heem! Sign heem! Claim heem!}
spec.homepage = "http://github.com/NuffieProductions/ClaimToken"
|
Update authors list in gemspec
|
diff --git a/spec/controllers/settings/export_controller_spec.rb b/spec/controllers/settings/export_controller_spec.rb
index abc1234..def5678 100644
--- a/spec/controllers/settings/export_controller_spec.rb
+++ b/spec/controllers/settings/export_controller_spec.rb
@@ -0,0 +1,20 @@+# frozen_string_literal: true
+
+require "rails_helper"
+
+describe Settings::ExportController, type: :controller do
+ describe "#index" do
+ subject { get :index }
+
+ context "user signed in" do
+ let(:user) { FactoryBot.create(:user) }
+
+ before { sign_in user }
+
+ it "renders the index template" do
+ subject
+ expect(response).to render_template(:index)
+ end
+ end
+ end
+end
|
Add test for `Settings::ExportController` index view
|
diff --git a/delayed_constraint.rb b/delayed_constraint.rb
index abc1234..def5678 100644
--- a/delayed_constraint.rb
+++ b/delayed_constraint.rb
@@ -13,11 +13,11 @@
alias_method :_always, :always
def always(constraint_name, bindings, context)
- DelayedConstraint.send constraint_name.to_sym, bindings, context, :_always
+ DelayedConstraint.new(@@constraints[constraint_name.to_sym]).bind(bindings, context, :_always)
end
def once(constraint_name, bindings, context)
- DelayedConstraint.send constraint_name.to_sym, bindings, context, :_once
+ DelayedConstraint.new(@@constraints[constraint_name.to_sym]).bind(bindings, context, :_once)
end
def _once(*args, &block)
@@ -27,14 +27,6 @@ end
class DelayedConstraint
- def self.method_missing(name, bindings, context, type)
- unless @@constraints.key?(name.to_sym)
- raise ArgumentError, "Constraint does not exist"
- end
-
- self.new(@@constraints[name]).bind(bindings, context, type)
- end
-
attr_reader :constraint
def initialize(constraint_definition)
@constraint = constraint_definition
|
Make DelayedConstraint class simple again
|
diff --git a/rspec-retry.gemspec b/rspec-retry.gemspec
index abc1234..def5678 100644
--- a/rspec-retry.gemspec
+++ b/rspec-retry.gemspec
@@ -15,6 +15,7 @@ gem.require_paths = ["lib"]
gem.version = RSpec::Retry::VERSION
gem.add_runtime_dependency %{rspec-core}
+ gem.add_development_dependency %q{rspec}
gem.add_development_dependency %q{guard-rspec}
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2')
gem.add_development_dependency %q{pry-debugger}
|
Add rspec to development dependency
|
diff --git a/lib/dynosaur/process/heroku.rb b/lib/dynosaur/process/heroku.rb
index abc1234..def5678 100644
--- a/lib/dynosaur/process/heroku.rb
+++ b/lib/dynosaur/process/heroku.rb
@@ -4,12 +4,14 @@ module Dynosaur
class Process
class Heroku < Process
- # Valid dyno sizes under Heroku's new pricing model
module Size
STANDARD_1X = 'standard-1X'.freeze
STANDARD_2X = 'standard-2X'.freeze
PERFORMANCE_M = 'performance-m'.freeze
PERFORMANCE_L = 'performance-l'.freeze
+ PRIVATE_S = 'Private-S'.freeze
+ PRIVATE_M = 'Private-M'.freeze
+ PRIVATE_L = 'Private-L'.freeze
end
# Valid dyno sizes under Heroku's old pricing model
|
Add private dyno size constants
|
diff --git a/lib/field_attribute_builder.rb b/lib/field_attribute_builder.rb
index abc1234..def5678 100644
--- a/lib/field_attribute_builder.rb
+++ b/lib/field_attribute_builder.rb
@@ -28,7 +28,7 @@ end
def install_methods
- @model.class_eval <<-HERE
+ @model.class_eval <<-HERE, __FILE__, __LINE__
def new_#{@singular_name}_attributes=(attribute_groups)
attribute_groups.each { |attrs| #{@association_name}.build(attrs) }
end
|
Add file and line numbers when class_eval'ing
|
diff --git a/lib/count_gen.rb b/lib/count_gen.rb
index abc1234..def5678 100644
--- a/lib/count_gen.rb
+++ b/lib/count_gen.rb
@@ -0,0 +1,10 @@+module CountGen
+
+ # Generates an array of numbers, counting by how many player records
+ # are on each HTML page. Allows other methods to paginate through the
+ # stat pages and collect them all.
+ def generate_count(step_size=40)
+ counts = (1..921).step(step_size) { |i| @array_of_count.push(i) }
+ @array_of_count
+ end
+end
|
Add CountGen module for mixin
|
diff --git a/lib/ruboty/slack_rtm/client.rb b/lib/ruboty/slack_rtm/client.rb
index abc1234..def5678 100644
--- a/lib/ruboty/slack_rtm/client.rb
+++ b/lib/ruboty/slack_rtm/client.rb
@@ -21,11 +21,24 @@ end
def main_loop
+ keep_connection
+
loop do
message = @queue.deq
@client.send(message)
end
end
+
+ private
+
+ def keep_connection
+ Thread.start do
+ loop do
+ sleep(30)
+ @client.send(type: 'ping')
+ end
+ end
+ end
end
end
end
|
Send ping every 30 seconds
|
diff --git a/lib/tasks/replace_textile.rake b/lib/tasks/replace_textile.rake
index abc1234..def5678 100644
--- a/lib/tasks/replace_textile.rake
+++ b/lib/tasks/replace_textile.rake
@@ -0,0 +1,17 @@+# frozen_string_literal: true
+
+namespace :publify do
+ desc "Convert content in Textile format to Markdown"
+ task textile_to_markdown: :environment do
+ Content.find_each do |content|
+ content.text_filter_name == "textile" or next
+
+ body_html = content.html(:body)
+ content.body = ReverseMarkdown.convert body_html
+ extended_html = content.html(:extended)
+ content.extended = ReverseMarkdown.convert extended_html
+ content.text_filter_name = "markdown"
+ content.save!
+ end
+ end
+end
|
Add task to convert Textile content to Markdown
|
diff --git a/lib/tasks/reset_sequences.rake b/lib/tasks/reset_sequences.rake
index abc1234..def5678 100644
--- a/lib/tasks/reset_sequences.rake
+++ b/lib/tasks/reset_sequences.rake
@@ -1,17 +1,17 @@ namespace :db do
desc "Reset all sequences. Run after data imports"
- task :reset_sequences, [:model_class] => :environment do |t, args|
- if args[:model_class]
- classes = Array(eval args[:model_class])
- else
- puts "using all defined active_record models"
- classes = []
- Dir.glob(Rails.root + '/app/models/**/*.rb').each { |file| require file }
- ActiveRecord::Base.subclasses.select { |c|c.base_class == c}.sort_by(&:name).each do |klass|
- classes << klass
- end
- end
- #classes = [Authorization]
+ task :reset_sequences => :environment do |t, args|
+ #if args[:model_class]
+ #classes = Array(eval args[:model_class])
+ #else
+ #puts "using all defined active_record models"
+ #classes = []
+ #Dir.glob(Rails.root + '/app/models/**/*.rb').each { |file| require file }
+ #ActiveRecord::Base.subclasses.select { |c|c.base_class == c}.sort_by(&:name).each do |klass|
+ #classes << klass
+ #end
+ #end
+ classes = [Configuration, Category, State, PressAsset, OauthProvider, User, Authorization, Project, Reward, Backer, Update, ProjectFaq, ProjectDocument]
classes.each do |klass|
puts "reseting sequence on #{klass.table_name}"
ActiveRecord::Base.connection.reset_pk_sequence!(klass.table_name) rescue puts("#{klass.table_name} --- THIS TABLE HAS AN ERROR --- Check if necessary")
|
Add ti reset sequesces the tables that we migrated
|
diff --git a/lib/turbo-sprockets/railtie.rb b/lib/turbo-sprockets/railtie.rb
index abc1234..def5678 100644
--- a/lib/turbo-sprockets/railtie.rb
+++ b/lib/turbo-sprockets/railtie.rb
@@ -21,7 +21,8 @@
if File.exist?(manifest_path)
manifest = YAML.load_file(manifest_path)
- config.assets.digest_files = manifest[:digest_files] || {}
+ # Set both digest keys for backwards compatibility
+ config.assets.digests = config.assets.digest_files = manifest[:digest_files] || {}
config.assets.source_digests = manifest[:source_digests] || {}
end
end
|
Set both digest keys for backwards compatibility
|
diff --git a/lib/vagrant-triggers/plugin.rb b/lib/vagrant-triggers/plugin.rb
index abc1234..def5678 100644
--- a/lib/vagrant-triggers/plugin.rb
+++ b/lib/vagrant-triggers/plugin.rb
@@ -23,8 +23,10 @@
action_hook(:trigger, Plugin::ALL_ACTIONS) do |hook|
require_relative "action"
- hook.prepend(Action.action_trigger(:before))
- hook.append(Action.action_trigger(:after))
+ unless ENV["VAGRANT_NO_TRIGGERS"]
+ hook.prepend(Action.action_trigger(:before))
+ hook.append(Action.action_trigger(:after))
+ end
end
config(:trigger) do
|
Allow skipping triggers for a single run
Triggers won't run if VAGRANT_NO_TRIGGERS environment variable is set
|
diff --git a/lib/veeqo/resources/company.rb b/lib/veeqo/resources/company.rb
index abc1234..def5678 100644
--- a/lib/veeqo/resources/company.rb
+++ b/lib/veeqo/resources/company.rb
@@ -30,8 +30,8 @@ get path.build, params
end
- def self.check_connection
- info
+ def self.check_connection(params = {})
+ info(params)
true
rescue Veeqo::Unauthorized
false
|
Change check connection to receive connection on params
|
diff --git a/UPCarouselFlowLayout.podspec b/UPCarouselFlowLayout.podspec
index abc1234..def5678 100644
--- a/UPCarouselFlowLayout.podspec
+++ b/UPCarouselFlowLayout.podspec
@@ -1,6 +1,6 @@ Pod::Spec.new do |s|
s.name = "UPCarouselFlowLayout"
- s.version = "1.0.0"
+ s.version = "1.1.0"
s.summary = "A fancy carousel flow layout for UICollectionView."
s.description = "UPCarouselFlowLayout is a fancy carousel flow layout for UICollectionView. It comes with a paginated effect and it shrinks and makes transparent the side items."
|
Update pod version to 1.1
|
diff --git a/lib/webtrends.rb b/lib/webtrends.rb
index abc1234..def5678 100644
--- a/lib/webtrends.rb
+++ b/lib/webtrends.rb
@@ -1,5 +1,6 @@ require "rest_client"
require "webtrends/version"
+require "webtrends/service"
require "webtrends/event"
require "webtrends/configuration"
|
Include parent class into the module
|
diff --git a/actionpack/test/lib/fixture_template.rb b/actionpack/test/lib/fixture_template.rb
index abc1234..def5678 100644
--- a/actionpack/test/lib/fixture_template.rb
+++ b/actionpack/test/lib/fixture_template.rb
@@ -6,10 +6,6 @@ end
private
-
- def or_extensions(array)
- "(?:" << array.map {|e| e && Regexp.escape(".#{e}")}.join("|") << ")"
- end
def query(path, exts)
query = Regexp.escape(path)
|
Remove a useless method in the fixture template class
|
diff --git a/aloha-rails-improved.gemspec b/aloha-rails-improved.gemspec
index abc1234..def5678 100644
--- a/aloha-rails-improved.gemspec
+++ b/aloha-rails-improved.gemspec
@@ -7,6 +7,7 @@ gem.description = 'Aloha Editor in Rails'
gem.summary = 'Provides the Aloha Editor for your Rails app'
gem.homepage = 'https://github.com/kuraga/aloha-rails-improved'
+ gem.license = 'MIT'
gem.required_ruby_version = '>= 1.9.3'
gem.files = `git ls-files`.split("\n")
|
Add License information to gemspec
|
diff --git a/table.rb b/table.rb
index abc1234..def5678 100644
--- a/table.rb
+++ b/table.rb
@@ -15,8 +15,8 @@ self.class.mtime(@name)
end
- def self.exists? table_name, schema_names = ['public']
- Db.table_exists?(table_name, schema_names)
+ def self.exists? table_name, options={}
+ Db.table_exists?(table_name, options)
end
self.singleton_class.send(:alias_method, :exist?, :exists?)
|
Fix crash on bad argument to Table.exists?
|
diff --git a/app/controllers/publications_controller.rb b/app/controllers/publications_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/publications_controller.rb
+++ b/app/controllers/publications_controller.rb
@@ -5,10 +5,8 @@ if edition.persisted?
UpdateWorker.perform_async(edition.id.to_s)
redirect_with_return_to(edition)
- return
else
render_new_form(edition)
- return
end
end
|
Remove some redundant return statements
|
diff --git a/app/controllers/questions_controller.rb b/app/controllers/questions_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/questions_controller.rb
+++ b/app/controllers/questions_controller.rb
@@ -9,7 +9,7 @@ end
def show
- @user = User.new
+ @user = @question.user
end
def create
|
Update show method with correct user
|
diff --git a/app/controllers/voicemail_controller.rb b/app/controllers/voicemail_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/voicemail_controller.rb
+++ b/app/controllers/voicemail_controller.rb
@@ -1,4 +1,6 @@ class VoicemailController < ApplicationController
+ skip_before_action :verify_authenticity_token
+
layout 'twilio_xml'
def prompt
|
Remove cr0sskrypt proteccion for now
|
diff --git a/spec/controllers/spree/admin/reports_controller_spec.rb b/spec/controllers/spree/admin/reports_controller_spec.rb
index abc1234..def5678 100644
--- a/spec/controllers/spree/admin/reports_controller_spec.rb
+++ b/spec/controllers/spree/admin/reports_controller_spec.rb
@@ -0,0 +1,57 @@+require 'spec_helper'
+
+describe Spree::Admin::ReportsController do
+
+ # Given two distributors
+ let (:ba) { create(:address) }
+ let (:da) { create(:address, :address1 => "distributor address", :city => 'The Shire', :zipcode => "1234") }
+ let (:si) { "pick up on thursday please" }
+ let (:d1) { create(:distributor_enterprise, address: da) }
+ let (:d2) { create(:distributor_enterprise, address: da) }
+ let (:p1) { create(:product, price: 12.34, distributors: [d1]) }
+ let (:p2) { create(:product, price: 23.45, distributors: [d2]) }
+
+ # Given two order cycles with both distributors
+ let (:ocA) { create(:order_cycle, distributors: [d1, d2], variants:[p1.master]) }
+ let (:ocB) { create(:order_cycle, distributors: [d1, d2], variants: [p2.master]) }
+
+ let (:orderA1) do
+ order = create(:order, distributor: d1, bill_address: ba, special_instructions: si, order_cycle: ocA)
+ order.line_items << create(:line_item, variant: p1.master)
+ order.finalize!
+ order
+ end
+ let (:orderA2) do
+ order = create(:order, distributor: d2, bill_address: ba, special_instructions: si, order_cycle: ocA)
+ order.line_items << create(:line_item, variant: p2.master)
+ order.finalize!
+ order
+ end
+ let (:orderB1) do
+ order = create(:order, distributor: d1, bill_address: ba, special_instructions: si, order_cycle: ocB)
+ order.line_items << create(:line_item, variant: p1.master)
+ order.finalize!
+ order
+ end
+ let (:orderB2) do
+ order = create(:order, distributor: d2, bill_address: ba, special_instructions: si, order_cycle: ocB)
+ order.line_items << create(:line_item, variant: p2.master)
+ order.finalize!
+ order
+ end
+
+ # Given Distributor Enterprise user for d1
+ let (:user) do
+ user = create(:user)
+ user.spree_roles = []
+ s1.enterprise_roles.build(user: user, enterprises: [d1]).save
+ user
+ end
+
+ describe 'Orders and Distributors' do
+ spree_get :orders_and_distributors
+
+ controller.search.result.should_include [orderA1, orderB1]
+ # assigns(:search).result.should_include [orderA1, orderB1]
+ end
+end
|
WIP: Test for enterprise user access in reports
|
diff --git a/songkick-oauth2-provider.gemspec b/songkick-oauth2-provider.gemspec
index abc1234..def5678 100644
--- a/songkick-oauth2-provider.gemspec
+++ b/songkick-oauth2-provider.gemspec
@@ -19,6 +19,7 @@
s.add_development_dependency("appraisal", "~> 0.4.0")
s.add_development_dependency("activerecord", "~> 3.2.0") # The SQLite adapter in 3.1 is broken
+ s.add_development_dependency("mysql") if ENV["DB"] == "mysql"
s.add_development_dependency("rspec")
s.add_development_dependency("sqlite3")
s.add_development_dependency("sinatra", ">= 1.3.0")
|
Add mysql dependency when running tests on MySQL.
|
diff --git a/spec/knapsack_pro/runners/queue/minitest_runner_spec.rb b/spec/knapsack_pro/runners/queue/minitest_runner_spec.rb
index abc1234..def5678 100644
--- a/spec/knapsack_pro/runners/queue/minitest_runner_spec.rb
+++ b/spec/knapsack_pro/runners/queue/minitest_runner_spec.rb
@@ -0,0 +1,47 @@+describe KnapsackPro::Runners::Queue::MinitestRunner do
+ describe '.run' do
+ let(:test_suite_token_minitest) { 'fake-token' }
+ let(:queue_id) { 'fake-queue-id' }
+ let(:test_dir) { 'fake-test-dir' }
+ let(:runner) do
+ instance_double(described_class, test_dir: test_dir)
+ end
+
+ subject { described_class.run(args) }
+
+ before do
+ expect(described_class).to receive(:require).with('minitest')
+
+ expect(KnapsackPro::Config::Env).to receive(:test_suite_token_minitest).and_return(test_suite_token_minitest)
+ expect(KnapsackPro::Config::EnvGenerator).to receive(:set_queue_id).and_return(queue_id)
+
+ expect(ENV).to receive(:[]=).with('KNAPSACK_PRO_TEST_SUITE_TOKEN', test_suite_token_minitest)
+ expect(ENV).to receive(:[]=).with('KNAPSACK_PRO_QUEUE_RECORDING_ENABLED', 'true')
+ expect(ENV).to receive(:[]=).with('KNAPSACK_PRO_QUEUE_ID', queue_id)
+
+ expect(described_class).to receive(:new).with(KnapsackPro::Adapters::MinitestAdapter).and_return(runner)
+ end
+
+ context 'when args provided' do
+ let(:args) { '--verbose --pride' }
+
+ it do
+ result = double
+ expect(described_class).to receive(:run_tests).with(runner, true, ['--verbose', '--pride'], 0, []).and_return(result)
+
+ expect(subject).to eq result
+ end
+ end
+
+ context 'when args not provided' do
+ let(:args) { nil }
+
+ it do
+ result = double
+ expect(described_class).to receive(:run_tests).with(runner, true, [], 0, []).and_return(result)
+
+ expect(subject).to eq result
+ end
+ end
+ end
+end
|
Add test for .run method
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.