diff stringlengths 65 26.7k | message stringlengths 7 9.92k |
|---|---|
diff --git a/lib/torque/postgresql/adapter/quoting.rb b/lib/torque/postgresql/adapter/quoting.rb
index abc1234..def5678 100644
--- a/lib/torque/postgresql/adapter/quoting.rb
+++ b/lib/torque/postgresql/adapter/quoting.rb
@@ -31,6 +31,7 @@ lookup_cast_type_from_column(column)
end
+ puts column.inspect if type.nil?
type.nil? ? super : quote(type.serialize(value))
end
end
| Debug error in Circle CI
|
diff --git a/lib/similarweb/client.rb b/lib/similarweb/client.rb
index abc1234..def5678 100644
--- a/lib/similarweb/client.rb
+++ b/lib/similarweb/client.rb
@@ -33,7 +33,7 @@ private
def make_http_client!
- base_url = "http://api.similarweb.com/Site/"
+ base_url = "https://api.similarweb.com/Site/"
self.http_client = Faraday.new(:url => base_url)
end
| Fix to make https request
|
diff --git a/lib/sponges/commander.rb b/lib/sponges/commander.rb
index abc1234..def5678 100644
--- a/lib/sponges/commander.rb
+++ b/lib/sponges/commander.rb
@@ -14,7 +14,15 @@ if pid = @redis[:worker][@name][:supervisor].get
begin
Process.kill gracefully? ? :HUP : :QUIT, pid.to_i
- Process.waitpid pid.to_i
+ # TODO: wait for process kill. Since it's not its child, this process
+ # can't wait for it.
+ #
+ # We'll have to use a different approach. A few ideas:
+ # * check process exitence with a Process.kill 0, pid.to_i in a
+ # loop.
+ # * use messaging, we have already Redis, so blpop could be a good
+ # fit here.
+ #
rescue Errno::ESRCH => e
Sponges.logger.error e
end
| Remove Process.waitpid in rest action.
See comments in this commit for more explanations.
Signed-off-by: chatgris <f9469d12bf3d131e7aae80be27ccfe58aa9db1f1@af83.com>
|
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index abc1234..def5678 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -22,14 +22,14 @@ it "can subscribe to a comic" do
expect {
user.subscribe!(comic)
- }.to change { user.subscriptions.count }.by(1)
+ }.to change(user.subscriptions, :count).by(1)
end
it "cannot subscribe to the same comic twice" do
user.subscribe!(comic)
expect {
user.subscribe!(comic)
- }.to_not change { user.subscriptions.count }
+ }.to_not change(user.subscriptions, :count)
end
end
end
| Update syntax of expect in User spec
- This is a better way of formatting the change expectation
|
diff --git a/spec/toy/plugins_spec.rb b/spec/toy/plugins_spec.rb
index abc1234..def5678 100644
--- a/spec/toy/plugins_spec.rb
+++ b/spec/toy/plugins_spec.rb
@@ -12,16 +12,18 @@ @mod = Module.new {
extend ActiveSupport::Concern
- module ClassMethods
- def foo
- 'foo'
- end
- end
-
def bar
'bar'
end
}
+
+ class_methods_module = Module.new do
+ def foo
+ 'foo'
+ end
+ end
+
+ @mod.const_set :ClassMethods, class_methods_module
Toy.plugin(@mod)
end
| Fix tests for ruby 1.8
|
diff --git a/activejob/test/helper.rb b/activejob/test/helper.rb
index abc1234..def5678 100644
--- a/activejob/test/helper.rb
+++ b/activejob/test/helper.rb
@@ -13,6 +13,7 @@ else
ActiveJob::Base.logger = Logger.new(nil)
ActiveJob::Base.skip_after_callbacks_if_terminated = true
+ ActiveJob::Base.return_false_on_aborted_enqueue = true
require "adapters/#{@adapter}"
end
| Set AJ `return_false_on_aborted_enqueue` true in the test suite:
- Since this is going to be the default in 6.1, let's set it in the
test suite to avoid deprecation warning.
Otherwise one has to do `AS::Deprecation.silence { }` everytime we
add a new test.
Fix #38107
|
diff --git a/acts_as_paranoid.gemspec b/acts_as_paranoid.gemspec
index abc1234..def5678 100644
--- a/acts_as_paranoid.gemspec
+++ b/acts_as_paranoid.gemspec
@@ -6,7 +6,7 @@ Gem::Specification.new do |spec|
spec.name = "acts_as_paranoid"
spec.version = ActsAsParanoid::VERSION
- spec.authors = ["Zachary Scott" "Goncalo Silva", "Charles G.", "Rick Olson"]
+ spec.authors = ["Zachary Scott", "Goncalo Silva", "Charles G.", "Rick Olson"]
spec.email = ["e@zzak.io"]
spec.summary = "Active Record plugin which allows you to hide and restore records without actually deleting them."
spec.description = "Check the home page for more in-depth information."
| Fix typo in gemspec authors
|
diff --git a/db/seeds.rb b/db/seeds.rb
index abc1234..def5678 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -1,3 +1,2 @@-User.create!(username: "michael", password: "foobar")
-User.create!(username: "lee", password: "asdfasdf")
-User.create!(username: "nick", password: "fdsafdsa")+User.create!(username: "alice", password: "wonderland")
+User.create!(username: "bob", password: "asdfasdf")
| Switch to Alice & Bob
|
diff --git a/db/seeds.rb b/db/seeds.rb
index abc1234..def5678 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -1,14 +1,4 @@-puts 'Seeding initial configuration'
-puts '-- creating roles'
-Role.create([
- { :name => 'admin' },
- { :name => 'user' },
- { :name => 'superadmin'}
-], :without_protection => true)
-puts "Default roles created: #{Role.all.map(&:name)}"
-
-puts '-- setting up default users'
-
+puts 'SETTING UP DEFAULT USER LOGIN'
user = User.create! :name => 'Default User',
:email => 'user@example.com',
:password => 'password',
| Bugfix: Remove buggy role creation in seed script.
+ Additional roles without name are created by this code.
+ The method "add_role" already creates a role instance.
|
diff --git a/app.rb b/app.rb
index abc1234..def5678 100644
--- a/app.rb
+++ b/app.rb
@@ -7,6 +7,18 @@ db = SQLite3::Database.new 'db/leprosorium.db'
db.results_as_hash = true
return db
+end
+
+configure do
+ db = init_db
+ db.execute 'CREATE TABLE IF NOT EXISTS
+ "Posts"
+ (
+ "Id" INTEGER PRIMARY KEY AUTOINCREMENT,
+ "Creation_date" DATE,
+ "Content" TEXT
+ )'
+ db.close
end
before '/new' do
| Create table 'Posts' in db file
|
diff --git a/app.rb b/app.rb
index abc1234..def5678 100644
--- a/app.rb
+++ b/app.rb
@@ -58,4 +58,11 @@ @row = result[0]
erb :post
+end
+
+post '/post/:post_id' do
+ post_id = params[:post_id]
+ content = params[:content]
+
+ erb "You typed: #{content} for #{post_id}"
end | Add simple /post/ ... post handler
|
diff --git a/XYFSnowAnimation.podspec b/XYFSnowAnimation.podspec
index abc1234..def5678 100644
--- a/XYFSnowAnimation.podspec
+++ b/XYFSnowAnimation.podspec
@@ -1,18 +1,20 @@ Pod::Spec.new do |s|
+
s.name = "XYFSnowAnimation"
-s.version = "1.1.1"
-s.summary = "A category of NSTimer for showing snow animaton,which is used very simply."
-s.description = "A category of NSTimer for showing snow animaton,which is used very simply.Welcome to use!"
+
+s.version = "2.0.0"
+
+s.ios.deployment_target = '8.0'
+
+s.summary = "A category of NSTimer for showing 3D Fluttered animation, which is used very simply."
+
s.homepage = "https://github.com/CoderXYF/XYFSnowAnimation"
-
s.license = { :type => "MIT", :file => "LICENSE" }
s.author = { "CoderXYF" => "https://github.com/CoderXYF" }
-s.platform = :ios, "7.0"
-
-s.source = { :git => "https://github.com/CoderXYF/XYFSnowAnimation.git", :tag => "1.1.1" }
+s.source = { :git => "https://github.com/CoderXYF/XYFSnowAnimation.git", :tag => "2.0.0" }
s.source_files = "XYFSnowAnimationDemo/XYFSnowAnimation/*.{h,m}"
| Update cocoaPods depository to version 2.0.0
|
diff --git a/sync.gemspec b/sync.gemspec
index abc1234..def5678 100644
--- a/sync.gemspec
+++ b/sync.gemspec
@@ -6,7 +6,7 @@ s.homepage = "http://github.com/chrismccord/sync"
s.summary = "Realtime Rails Partials"
s.description = "Sync turns your Rails partials realtime with automatic updates through Faye"
- s.files = Dir["{app,lib,test}/**/*", "[A-Z]*", "init.rb"] - ["Gemfile.lock"]
+ s.files = Dir["{app,config,lib,test}/**/*", "[A-Z]*", "init.rb"] - ["Gemfile.lock"]
s.require_path = "lib"
s.add_dependency 'em-http-request'
| Include config directory when building gem.
|
diff --git a/core/db/migrate/20120228154434_lowercase_usernames.rb b/core/db/migrate/20120228154434_lowercase_usernames.rb
index abc1234..def5678 100644
--- a/core/db/migrate/20120228154434_lowercase_usernames.rb
+++ b/core/db/migrate/20120228154434_lowercase_usernames.rb
@@ -0,0 +1,13 @@+class LowercaseUsernames < Mongoid::Migration
+ def self.up
+ say_with_time "lowercasing usernames" do
+ User.all.each do |user|
+ user.username.downcase!
+ user.save
+ end
+ end
+ end
+
+ def self.down
+ end
+end | Add migration to lowercase usernames
|
diff --git a/spec/factories/images.rb b/spec/factories/images.rb
index abc1234..def5678 100644
--- a/spec/factories/images.rb
+++ b/spec/factories/images.rb
@@ -1,8 +1,7 @@
FactoryBot.define do
factory :image do
- attachment { StringIO.new(File.open("./spec/fixture.jpg").read) }
- meta {({x: 1, y: 2, z: 3})}
+ meta { ({ x: 1, y: 2, z: 3 }) }
device
end
end
| Upgrade complete, test coverage needs increase
|
diff --git a/spec/models/card_spec.rb b/spec/models/card_spec.rb
index abc1234..def5678 100644
--- a/spec/models/card_spec.rb
+++ b/spec/models/card_spec.rb
@@ -14,8 +14,53 @@ }}
describe 'Creating a new card' do
+ let(:inputs) { valid_inputs }
+
it 'can create a new card with all the required fields' do
card = Card.new(valid_inputs)
+ expect(card.save).to be true
+ end
+
+ it 'will not create a card without a card_template_id' do
+ inputs[:card_template_id] = nil
+ card = Card.new(inputs)
+ expect(card.save).to be false
+ end
+
+ it 'will not create a card without a recipient' do
+ inputs[:recipient_name] = nil
+ card = Card.new(inputs)
+ expect(card.save).to be false
+ end
+
+ it 'will not create a card without an address' do
+ inputs[:street_address] = nil
+ card = Card.new(inputs)
+ expect(card.save).to be false
+ end
+
+ it 'will not create a card without a city' do
+ inputs[:city] = nil
+ card = Card.new(inputs)
+ expect(card.save).to be false
+ end
+
+ it 'will not create a card without a state' do
+ inputs[:state] = nil
+ card = Card.new(inputs)
+ expect(card.save).to be false
+ end
+
+ it 'will not create a card without a zip code' do
+ inputs[:zip_code] = nil
+ card = Card.new(inputs)
+ expect(card.save).to be false
+ end
+
+ it 'will create a card without a custom message or signature' do
+ inputs[:custom_message] = nil
+ inputs[:signature] = nil
+ card = Card.new(inputs)
expect(card.save).to be true
end
end
| Add tests for Card creation
|
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index abc1234..def5678 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -5,9 +5,9 @@ describe ".promptable" do
it "returns promptable users for the current hour" do
Timecop.freeze(Time.utc(2014, 1, 1, 11)) do # 11AM UTC
- utc_10am = create(:user, time_zone: "UTC", prompt_delivery_hour: 10)
+ create(:user, time_zone: "UTC", prompt_delivery_hour: 10)
+ create(:user, time_zone: "UTC", prompt_delivery_hour: 12)
utc_11am = create(:user, time_zone: "UTC", prompt_delivery_hour: 11)
- utc_12pm = create(:user, time_zone: "UTC", prompt_delivery_hour: 12)
expect(User.promptable).to eq [utc_11am]
end
| Remove unused variables to appease @houndci
|
diff --git a/app/models/manageiq/providers/redhat/infra_manager/vm.rb b/app/models/manageiq/providers/redhat/infra_manager/vm.rb
index abc1234..def5678 100644
--- a/app/models/manageiq/providers/redhat/infra_manager/vm.rb
+++ b/app/models/manageiq/providers/redhat/infra_manager/vm.rb
@@ -37,4 +37,8 @@ else super
end
end
+
+ def validate_migrate
+ validate_unsupported("Migrate")
+ end
end
| Remove Migrate button for SCVMM VMs
- Added new model methods, changed code to use is_available? method to determine availability of "migrate" task for VMs similar to power buttons for VMs
- Added "validate_migrate" method to VM subclasses and have it return false for Redhat & SCVMM VMs, to hide Migrate button on appropriate VM summary screens.
- Added "batch_operation_supported?" method to determine if any of the selected VMs are not allowed to perform migrate task.
- Added spec tests around new methods.
https://bugzilla.redhat.com/show_bug.cgi?id=1221532
(transferred from ManageIQ/manageiq@283fe0819e67fbe6e48aee2df0980d4c40774b16)
|
diff --git a/db/migrate/20170201224715_add_category_id_to_items.rb b/db/migrate/20170201224715_add_category_id_to_items.rb
index abc1234..def5678 100644
--- a/db/migrate/20170201224715_add_category_id_to_items.rb
+++ b/db/migrate/20170201224715_add_category_id_to_items.rb
@@ -1,5 +1,5 @@ class AddCategoryIdToItems < ActiveRecord::Migration[5.0]
def change
- add_column :items, :category_id, :text, :array => true, :default => '{}'
+ add_column :items, :category_id, :text, :array => true, :default => [].to_yaml
end
end
| Update migration and include .to_yaml after []
|
diff --git a/lib/group_smarts/attach/sources/file.rb b/lib/group_smarts/attach/sources/file.rb
index abc1234..def5678 100644
--- a/lib/group_smarts/attach/sources/file.rb
+++ b/lib/group_smarts/attach/sources/file.rb
@@ -10,6 +10,8 @@
def store(source)
@metadata = source.metadata
+ FileUtils.mkdir_p(::File.dirname(fn))
+ # TODO: raise an exception if the file exists.
::File.cp(source.tempfile.path, fn)
end
# =Metadata=
| Create the attachment directory if it does not exist
|
diff --git a/spec/models/good_spec.rb b/spec/models/good_spec.rb
index abc1234..def5678 100644
--- a/spec/models/good_spec.rb
+++ b/spec/models/good_spec.rb
@@ -1,4 +1,4 @@-require "spec_helper"
+require "rails_helper"
describe Good, :type => :model do
before :each do
| Use rails_helper instead of spec_helper
|
diff --git a/spec/models/raid_spec.rb b/spec/models/raid_spec.rb
index abc1234..def5678 100644
--- a/spec/models/raid_spec.rb
+++ b/spec/models/raid_spec.rb
@@ -3,6 +3,7 @@ describe Raid do
before(:each) do
@valid_attributes = {
+ :date => Time.now.to_s(:db)
}
end
| Add date to Raid's valid_attributes
|
diff --git a/spec/commands/collect_all_cards_spec.rb b/spec/commands/collect_all_cards_spec.rb
index abc1234..def5678 100644
--- a/spec/commands/collect_all_cards_spec.rb
+++ b/spec/commands/collect_all_cards_spec.rb
@@ -0,0 +1,21 @@+require 'rails_helper'
+
+RSpec.describe CollectAllCards do
+ describe "#call" do
+ subject(:service) { CollectAllCards.new(game) }
+
+ let(:game) { Game.new }
+
+ it "adds one event to the game" do
+ events_count_before = game.events.size
+ service.call
+ events_count_after = game.events.size
+ expect(events_count_after).to eq (events_count_before + 1)
+ end
+
+ it "adds an AllCardsCollected event" do
+ service.call
+ expect(game.events.last).to be_instance_of AllCardsCollected
+ end
+ end
+end
| Add unit test for CollectAllCards
|
diff --git a/spec/models/file_not_found_page_spec.rb b/spec/models/file_not_found_page_spec.rb
index abc1234..def5678 100644
--- a/spec/models/file_not_found_page_spec.rb
+++ b/spec/models/file_not_found_page_spec.rb
@@ -4,7 +4,7 @@ #dataset :file_not_found
test_helper :render
- let(:file_not_found){ pages(:file_not_found) }
+ let(:file_not_found){ FactoryGirl.create(:file_not_found_page) }
its(:allowed_children){ should == [] }
| Use FactoryGirl i.o. dataset in FileNotFoundPageSpec
|
diff --git a/act.gemspec b/act.gemspec
index abc1234..def5678 100644
--- a/act.gemspec
+++ b/act.gemspec
@@ -8,7 +8,7 @@ spec.version = Act::VERSION
spec.authors = ["Fabio Pelosin"]
spec.email = ["fabiopelosin@gmail.com"]
- spec.summary = %q{Act the command line tool to act on files.}
+ spec.summary = %q{Act, the command line tool to act on files.}
spec.homepage = "https://github.com/irrationalfab/act"
spec.license = "MIT"
| [Gemspec] Make the summer flow better
|
diff --git a/lib/bubble-wrap.rb b/lib/bubble-wrap.rb
index abc1234..def5678 100644
--- a/lib/bubble-wrap.rb
+++ b/lib/bubble-wrap.rb
@@ -29,7 +29,7 @@
Motion::Project::App.setup do |app|
wrapper_files = []
- Dir.glob(File.join(File.dirname(__FILE__), 'bubble-wrap/*.rb')).each do |file|
+ Dir.glob(File.join(File.dirname(__FILE__), 'bubble-wrap/**/*.rb')).each do |file|
app.files << file
wrapper_files << file
end
| Include files from BubbleWrap sub-directories when compiling.
|
diff --git a/app/models/profile.rb b/app/models/profile.rb
index abc1234..def5678 100644
--- a/app/models/profile.rb
+++ b/app/models/profile.rb
@@ -10,7 +10,7 @@
named_scope :public, :conditions => { :exclusive => false }
named_scope :public_plus, lambda { |*profilename|
- {:conditions => "exclusive = false or name = '#{profilename}'" }
+ {:conditions => ["exclusive = ? or name = ?", false, profilename] }
}
accepts_nested_attributes_for :includes, :allow_destroy => true
| Change condition syntax to make sure ActiveRecord gets to handle the
implementation details of "false". Unbreaks sqlite3 in development mode.
|
diff --git a/spec/dm-tags/tag_spec.rb b/spec/dm-tags/tag_spec.rb
index abc1234..def5678 100644
--- a/spec/dm-tags/tag_spec.rb
+++ b/spec/dm-tags/tag_spec.rb
@@ -6,7 +6,7 @@ end
it "should have many Taggings" do
- Tag.relationships.should have_key(:taggings)
+ Tag.relationships.named?(:taggings).should be(true)
end
it "should validate the presence of name" do
| Use the new RelationshipSet API |
diff --git a/spec/support/matchers.rb b/spec/support/matchers.rb
index abc1234..def5678 100644
--- a/spec/support/matchers.rb
+++ b/spec/support/matchers.rb
@@ -1,5 +1,3 @@-require 'rspec-expectations'
-
RSpec::Matchers.define :include_method do |expected|
match do |actual|
actual.map { |m| m.to_s }.include?(expected.to_s)
| Stop requiring a file that doens't exist anymore
|
diff --git a/spec/unit/spec_helper.rb b/spec/unit/spec_helper.rb
index abc1234..def5678 100644
--- a/spec/unit/spec_helper.rb
+++ b/spec/unit/spec_helper.rb
@@ -4,9 +4,7 @@
RSpec.configure do |config|
config.platform = 'mac_os_x'
- config.version = '10.8.2' # FIXME: system ruby and fauxhai don't play nice
- # since there is no 10.9.2.json file yet. We
- # should submit a PR to fauxhai to fix this
+ config.version = '10.11.1'
config.before { stub_const('ENV', 'SUDO_USER' => 'fauxhai') }
config.after(:suite) { FileUtils.rm_r('.librarian') }
end
| Set fauxohai to latest OSX (El Capitan)
|
diff --git a/lib/redis-store.rb b/lib/redis-store.rb
index abc1234..def5678 100644
--- a/lib/redis-store.rb
+++ b/lib/redis-store.rb
@@ -27,13 +27,9 @@ end
end
+# ActionDispatch::Session
if ::Redis::Store.rails3?
- # ActionDispatch::Session
require "action_controller/session/redis_session_store"
-elsif defined?(ActiveSupport::Cache)
- # Force loading, in case you're using Bundler, without requiring the gem with:
- # config.gem "redis-store"
- require "active_support/cache/redis_store"
end
# Rack::Cache
| Revert "Force ActiveSupport cache loading for Rails 2"
This reverts commit d07c3099b0163781d1836e126bc5ded12643809b.
|
diff --git a/lib/round_robin.rb b/lib/round_robin.rb
index abc1234..def5678 100644
--- a/lib/round_robin.rb
+++ b/lib/round_robin.rb
@@ -3,7 +3,8 @@
module RoundRobin
def self.add(klass, *args)
-
+ json = {:class => klass, :args => args}.to_json
+ RoundRobin::Job.create(:handler => json)
end
def self.remove(klass, *args)
| Make tests pass by adding functionality to RoundRobin.add
|
diff --git a/lib/sfn/command.rb b/lib/sfn/command.rb
index abc1234..def5678 100644
--- a/lib/sfn/command.rb
+++ b/lib/sfn/command.rb
@@ -16,5 +16,30 @@ autoload :Update, 'sfn/command/update'
autoload :Validate, 'sfn/command/validate'
+ # Override to provide config file searching
+ def initialize(opts, args)
+ unless(opts[:config])
+ opts = opts.to_hash.to_smash(:snake)
+ discover_config(opts)
+ end
+ super
+ end
+
+ protected
+
+ # Start with current working directory and traverse to root
+ # looking for a `.sfn` configuration file
+ #
+ # @param opts [Smash]
+ # @return [Smash]
+ def discover_config(opts)
+ cwd = Dir.pwd.split(File::SEPARATOR)
+ until(cwd.empty? || File.exists?(cwd.push('.sfn').join(File::SEPARATOR)))
+ cwd.pop(2)
+ end
+ opts[:config] = cwd.join(File::SEPARATOR) unless cwd.empty?
+ opts
+ end
+
end
end
| Include helper to traverse FS for .sfn file discovery
|
diff --git a/lib/sfn/planner.rb b/lib/sfn/planner.rb
index abc1234..def5678 100644
--- a/lib/sfn/planner.rb
+++ b/lib/sfn/planner.rb
@@ -5,6 +5,9 @@ class Planner
autoload :Aws, 'sfn/planner/aws'
+
+ # Value to flag runtime modification
+ RUNTIME_MODIFIED = '__MODIFIED_REFERENCE_VALUE__'
# @return [Bogo::Ui]
attr_reader :ui
| Define modified resource flag as a constant
|
diff --git a/activerecord/test/models/admin/user.rb b/activerecord/test/models/admin/user.rb
index abc1234..def5678 100644
--- a/activerecord/test/models/admin/user.rb
+++ b/activerecord/test/models/admin/user.rb
@@ -1,10 +1,24 @@ class Admin::User < ActiveRecord::Base
+ class Coder
+ def initialize(default = {})
+ @default = default
+ end
+
+ def dump(o)
+ ActiveSupport::JSON.encode(o || @default)
+ end
+
+ def load(s)
+ s.present? ? ActiveSupport::JSON.decode(s) : @default.clone
+ end
+ end
+
belongs_to :account
store :settings, :accessors => [ :color, :homepage ]
store_accessor :settings, :favorite_food
store :preferences, :accessors => [ :remember_login ]
- store :json_data, :accessors => [ :height, :weight ], :coder => JSON
- store :json_data_empty, :accessors => [ :is_a_good_guy ], :coder => JSON
+ store :json_data, :accessors => [ :height, :weight ], :coder => Coder.new
+ store :json_data_empty, :accessors => [ :is_a_good_guy ], :coder => Coder.new
def phone_number
read_store_attribute(:settings, :phone_number).gsub(/(\d{3})(\d{3})(\d{4})/,'(\1) \2-\3')
| Remove warning by using a custom coder
The native JSON library bypasses the `to_json` overrides in
active_support/core_ext/object/to_json.rb by calling its native
implementation directly. However `ActiveRecord::Store` uses a
HWIA so `JSON.dump` will call our `to_json` instead with a
`State` object for options rather than a `Hash`. This generates
a warning when the `:encoding`, `:only` & `:except` keys are
accessed in `Hash#as_json` because the `State` object delegates
unknown keys to `instance_variable_get` in its `:[]` method.
Workaround this warning in the test by using a custom coder that
calls `ActiveSupport::JSON.encode` directly.
|
diff --git a/Library/Homebrew/cask/lib/hbc/scopes.rb b/Library/Homebrew/cask/lib/hbc/scopes.rb
index abc1234..def5678 100644
--- a/Library/Homebrew/cask/lib/hbc/scopes.rb
+++ b/Library/Homebrew/cask/lib/hbc/scopes.rb
@@ -6,8 +6,7 @@
module ClassMethods
def all
- @all_casks ||= {}
- all_tokens.map { |t| @all_casks[t] ||= load(t) }
+ all_tokens.map(&CaskLoader.public_method(:load))
end
def all_tapped_cask_dirs
| Fix `brew cask audit` not working without argument.
|
diff --git a/Casks/opera-developer.rb b/Casks/opera-developer.rb
index abc1234..def5678 100644
--- a/Casks/opera-developer.rb
+++ b/Casks/opera-developer.rb
@@ -1,6 +1,6 @@ cask :v1 => 'opera-developer' do
- version '30.0.1820.0'
- sha256 'ea0adb5c2e4c215ccdd784222b0432546137649eec3bc7c829d76662bd2326c8'
+ version '30.0.1833.0'
+ sha256 '0c79b262ec4d04324af52b6ed4550c2035fc8d8b8f978f27064f12d248cfd406'
url "http://get.geo.opera.com/pub/opera-developer/#{version}/mac/Opera_Developer_#{version}_Setup.dmg"
homepage 'http://www.opera.com/developer'
| Upgrade Opera Developer.app to v30.0.1833.0
|
diff --git a/app/models/team_fight.rb b/app/models/team_fight.rb
index abc1234..def5678 100644
--- a/app/models/team_fight.rb
+++ b/app/models/team_fight.rb
@@ -1,4 +1,7 @@ class TeamFight < ActiveRecord::Base
belongs_to :shiro_team, class_name: "Team", foreign_key: "shiro_team_id"
belongs_to :aka_team, class_name: "Team", foreign_key: "aka_team_id"
+
+ has_many :shiro_members, through: :shiro_team, source: :players
+ has_many :aka_members, through: :aka_team, source: :players
end
| Add aka and shiro members assoc to TeamFight
|
diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/search_controller.rb
+++ b/app/controllers/search_controller.rb
@@ -22,6 +22,7 @@ params[:type] = 'all'
end
end
+ @people = @people - [current_user.person]
else
params[:type] = 'all'
end
| Remove me from search results
|
diff --git a/app/uploaders/base_image_uploader.rb b/app/uploaders/base_image_uploader.rb
index abc1234..def5678 100644
--- a/app/uploaders/base_image_uploader.rb
+++ b/app/uploaders/base_image_uploader.rb
@@ -37,7 +37,7 @@
# def grayscale()
# manipulate! do |img|
- # img.combine_options { |c| c.colorspace "Gray" }
+ # img.colorspace('Gray')
# img
# end
# end
| Optimize grayscale method of base image uploader
|
diff --git a/app/uploaders/image_uploader_base.rb b/app/uploaders/image_uploader_base.rb
index abc1234..def5678 100644
--- a/app/uploaders/image_uploader_base.rb
+++ b/app/uploaders/image_uploader_base.rb
@@ -22,6 +22,11 @@ end
process(:store) do |io, _context|
+ unless io.original_filename
+ ext = MIME::Types[io.metadata["mime_type"]].first.extensions.first
+ io.data["metadata"]["filename"] = "#{io.hash}.#{ext}" if ext
+ end
+
versions = { original: io }
io.download do |original|
| Set filename if original filename is unknown
|
diff --git a/gigasecond/gigasecond.rb b/gigasecond/gigasecond.rb
index abc1234..def5678 100644
--- a/gigasecond/gigasecond.rb
+++ b/gigasecond/gigasecond.rb
@@ -1,9 +1,9 @@ class Gigasecond
- def self.from time
- time + 10**9
- end
+ def self.from time
+ time + 10**9
+ end
end
module BookKeeping
- VERSION = 6
+ VERSION = 6
end
| Fix style: tab-size (This time it will work)
|
diff --git a/Library/Formula/sshfs.rb b/Library/Formula/sshfs.rb
index abc1234..def5678 100644
--- a/Library/Formula/sshfs.rb
+++ b/Library/Formula/sshfs.rb
@@ -12,7 +12,9 @@
def install
ENV['ACLOCAL'] = "/usr/bin/aclocal -I/usr/share/aclocal -I#{HOMEBREW_PREFIX}/share/aclocal"
- system "autoreconf", "--force", "--install"
+ ENV['AUTOCONF'] = "/usr/bin/autoconf"
+ ENV['AUTOMAKE'] = "/usr/bin/automake"
+ system "/usr/bin/autoreconf", "--force", "--install"
system "./configure", "--disable-debug", "--disable-dependency-tracking",
"--prefix=#{prefix}"
| SSHFS: Use paths to OS X supplied autotools
|
diff --git a/lib/sprinkle/installers/rake.rb b/lib/sprinkle/installers/rake.rb
index abc1234..def5678 100644
--- a/lib/sprinkle/installers/rake.rb
+++ b/lib/sprinkle/installers/rake.rb
@@ -5,14 +5,12 @@ super parent, &block
@commands = commands
end
-
+
protected
-
+
def install_sequence
- if @commands
- "rake #{@commands.join(' ')}"
- end
+ "rake #{@commands.join(' ')}"
end
end
end
-end+end
| Remove unnecessary if test, @commands is set to an empty array by default
|
diff --git a/app/controllers/feedback_landing_controller.rb b/app/controllers/feedback_landing_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/feedback_landing_controller.rb
+++ b/app/controllers/feedback_landing_controller.rb
@@ -6,13 +6,13 @@ def index
flash['feedback_referer'] = request.referer
flash['feedback_source'] = params['feedback-source'].nil? ? flash['feedback_source'] : params['feedback-source']
- @feedback_landing_heading = t ( 'hub.feedback_landing.basic_heading' )
+ @feedback_landing_heading = t('hub.feedback_landing.basic_heading')
unless current_transaction_simple_id.nil?
@other_ways_heading = t('hub.feedback_landing.services.heading')
@other_ways_text = current_transaction.other_ways_text
@service_name = current_transaction.name
- @feedback_landing_heading = t( 'hub.feedback_landing.heading', service_name: @service_name )
+ @feedback_landing_heading = t('hub.feedback_landing.heading', service_name: @service_name)
end
end
end
| Tidy up some whitespace to keep Codacy happy
Remove white space inside parentheses
|
diff --git a/lib/acts_as_notifiable/couriers/email.rb b/lib/acts_as_notifiable/couriers/email.rb
index abc1234..def5678 100644
--- a/lib/acts_as_notifiable/couriers/email.rb
+++ b/lib/acts_as_notifiable/couriers/email.rb
@@ -13,7 +13,7 @@ end
def mailer
- if @notification.type == 'Notification'
+ if @notification.instance_of? Notification
notifiable_mailer
else
notification_mailer
@@ -21,7 +21,7 @@ end
def notifiable_mailer
- "#{notifiable.class}NotificationMailer".safe_constantize
+ "#{@notifiable.class}NotificationMailer".safe_constantize
end
def notification_mailer
| Fix notifiable based mailer check
|
diff --git a/lib/blockscore/error/blockscore_error.rb b/lib/blockscore/error/blockscore_error.rb
index abc1234..def5678 100644
--- a/lib/blockscore/error/blockscore_error.rb
+++ b/lib/blockscore/error/blockscore_error.rb
@@ -6,10 +6,11 @@ attr_reader :http_status
attr_reader :json_body
- def initialize(message=nil, json_body=nil, http_status="400",
+ def initialize(message=nil, json_body={}, http_status="400",
error_type="invalid_request_error")
super(message)
+ json_body["error"] ||= {}
message_desc = "#{json_body["error"]["param"]} #{json_body["error"]["code"]}"
@error_type = error_type
| Allow BlockscoreError to initialize when json_body passed in is empty
|
diff --git a/lib/dynflow/executors/parallel/worker.rb b/lib/dynflow/executors/parallel/worker.rb
index abc1234..def5678 100644
--- a/lib/dynflow/executors/parallel/worker.rb
+++ b/lib/dynflow/executors/parallel/worker.rb
@@ -9,17 +9,18 @@ end
def on_message(work_item)
- ok = false
+ already_responded = false
Executors.run_user_code do
work_item.execute
- ok = true
end
rescue Errors::PersistenceError => e
@pool.tell([:handle_persistence_error, reference, e, work_item])
- ok = false
+ already_responded = true
ensure
Dynflow::Telemetry.with_instance { |t| t.increment_counter(:dynflow_worker_events, 1, @telemetry_options) }
- @pool.tell([:worker_done, reference, work_item]) if ok
+ if !already_responded && Concurrent.global_io_executor.running?
+ @pool.tell([:worker_done, reference, work_item])
+ end
end
end
end
| Enhance fix for termination with running action
Previously, we would not respond to the pool in case of any exception
coming from the `work_item.execute`. Even though I don't think we expect
any other exceptions other than PeristenceError, it didn't feel right not to
respond on any exception that might occur.
When I looked at API of concurrent ruby, it seems like we can use check on
`global_io_executor` to check it's still operational.
See https://projects.theforeman.org/issues/25593 for reasons on why we
need this check
|
diff --git a/lib/rack-cas-rails/rails_application_additions.rb b/lib/rack-cas-rails/rails_application_additions.rb
index abc1234..def5678 100644
--- a/lib/rack-cas-rails/rails_application_additions.rb
+++ b/lib/rack-cas-rails/rails_application_additions.rb
@@ -1,7 +1,7 @@ ##
# Augments the Rails::Application class.
-class Rails::Application < Rails::Engine
+Rails::Application.class_eval do
##
# Gives the Rails::Application class a read-only class attribute to point to the CAS server URL. The URL in turn is then
| Use class_eval to extend Rails::Application also, just in case.
|
diff --git a/lib/smartdown/parser/flow_interpreter.rb b/lib/smartdown/parser/flow_interpreter.rb
index abc1234..def5678 100644
--- a/lib/smartdown/parser/flow_interpreter.rb
+++ b/lib/smartdown/parser/flow_interpreter.rb
@@ -44,7 +44,7 @@ def interpret_node(input_data)
Smartdown::Parser::NodeInterpreter.new(input_data.name, input_data.read).interpret
rescue Parslet::ParseFailed => error
- raise ParseError.new(input_data.to_s, error)
+ raise ParseError.new(input_data.name, error)
end
def pre_parse(flow_input)
| Use input data filename rather for ParseError message
|
diff --git a/lib/dotjs_sprockets/engine.rb b/lib/dotjs_sprockets/engine.rb
index abc1234..def5678 100644
--- a/lib/dotjs_sprockets/engine.rb
+++ b/lib/dotjs_sprockets/engine.rb
@@ -0,0 +1,58 @@+require "execjs"
+
+module DotjsSprockets
+
+ # The engine class is in charge to handle the template compilation
+ # via ExecJS, provides a clean interface to be used by the TiltDot class
+ #
+ # @since 0.1.0
+ class Engine
+ class << self
+
+ # Given a path to a template it returns the compiled version
+ #
+ # @param full_path [String] the template full path
+ #
+ # @return [String] JavaScript function that may be directly executed client-side
+ #
+ # @example Compiling a Template
+ # DotjsSprockets::Engine.precompile("/my/template.jst.djs")
+ # # => "function()...."
+ #
+ # @since 0.1.0
+ def precompile(full_path)
+ template = open(full_path).read.chomp
+ context.eval("doT.compile('#{template}').toString()")
+ end
+
+ private
+
+ # Stores a ExecJS context instance
+ #
+ # @return [ExecJS::ExternalRuntime::Context]
+ #
+ # @since 0.1.0
+ def context
+ @context ||= ExecJS.compile(source)
+ end
+
+ # Stores the full path of the library source (doT.js)
+ #
+ # @return [String] full path of the doT.js library
+ #
+ # @since 0.1.0
+ def path
+ @path ||= File.expand_path(DotjsSprockets::ASSETS_PATH, __FILE__)
+ end
+
+ # Stores the contents of the library source (doT.js)
+ #
+ # @return [String] full content of the doT.js library
+ #
+ # @since 0.1.0
+ def source
+ @source ||= open("#{path}/doT.js").read
+ end
+ end
+ end
+end
| Add the Engine class ( in charge of template compilation )
This class is simply a wrapper of the execjs library, providing a
clean interface for the TiltDot class
|
diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/home_controller.rb
+++ b/app/controllers/home_controller.rb
@@ -1,6 +1,10 @@ class HomeController < ApplicationController
- caches_action :index, :expires_in => 1.hour, :unless => lambda { user_signed_in? || admin_signed_in? }
+ caches_action :index, :expires_in => 1.hour,
+ :unless => lambda { user_signed_in? || admin_signed_in? },
+ :cache_path => Proc.new {|c|
+ c.params.delete_if { |k,v| %w{lat lon zoom q layers a}.include?(k) }.merge(:ab_splash_screen => ab_test("splash_screen").to_s)
+ }
def index
render
| Put ab_variant into cache key for start page.
|
diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/tags_controller.rb
+++ b/app/controllers/tags_controller.rb
@@ -0,0 +1,30 @@+class TagsController < ApplicationController
+ before_filter :authenticate_user!
+
+ def index
+ params[:limit] ||= 10
+ @tags = case params[:mode]
+ when "popular" then most_popular
+ else match_tag
+ end
+ response = @tags.map{ |t| { 'key' => t.name, 'value' => t.name } }.to_json
+ if @tags.count == 0
+ response = "[]"
+ response = "[{\"key\":\""+params[:tag]+"\" , \"value\":\""+params[:tag]+"\"}]" unless params[:tag].blank?
+ end
+
+ respond_to do |format|
+ format.json { render :text => response}
+ end
+ end
+
+ private
+
+ def match_tag
+ ActsAsTaggableOn::Tag.where('name like ?','%'+params[:tag]+'%').limit(params[:limit])
+ end
+
+ def most_popular
+ ActivityObject.tag_counts(:limit => params[:limit], :order => "count desc")
+ end
+end
| Revert "TagsController to social stream"
This reverts commit a52b5b3ea8f5b4bcc93d0f0dfb2cae3f0151ea23.
|
diff --git a/bedtools.rb b/bedtools.rb
index abc1234..def5678 100644
--- a/bedtools.rb
+++ b/bedtools.rb
@@ -4,7 +4,7 @@ url 'http://bedtools.googlecode.com/files/BEDTools.v2.12.0.tar.gz'
homepage 'http://code.google.com/p/bedtools/'
md5 'cc7839a96a7537a810bb645381a2ba8a'
- head 'git://github.com/arq5x/bedtools.git'
+ head 'https://github.com/arq5x/bedtools.git'
def install
system "make all"
| Use https for github repos.
|
diff --git a/lib/i18n_feature_additions.rb b/lib/i18n_feature_additions.rb
index abc1234..def5678 100644
--- a/lib/i18n_feature_additions.rb
+++ b/lib/i18n_feature_additions.rb
@@ -1,20 +1,9 @@ module I18n
class << self
def has_feature?(feature)
- #at the moment, only us countries can use these features
- begin
- return I18n.country.code == 'us'
- rescue
- return false
- end
-
result = self.t("features.#{feature}")
- if result === true
- result
- else
- raise MissingTranslationData.new('','','')
- end
+ result === true
end
end
-end+end
| [SCR-673] Update perform feature so that features are specified in locales
Previously, we allowed a feature only if it was for the USA.
Now, we check the locale file for that country for the feature.feature_name.
Unless the feature is set and equal to true, the feature cannot be run.
Default truevalues can be set in the en.yml locale.
|
diff --git a/lib/identity/heroku_cookie.rb b/lib/identity/heroku_cookie.rb
index abc1234..def5678 100644
--- a/lib/identity/heroku_cookie.rb
+++ b/lib/identity/heroku_cookie.rb
@@ -22,9 +22,8 @@ set_cookie(headers, "heroku_session", "1")
set_cookie(headers, "heroku_session_nonce", env[@key]["nonce"])
else
- %w(heroku_session heroku_session_nonce).each do |key|
- delete_cookie(headers, key)
- end
+ delete_cookie(headers, "heroku_session")
+ delete_cookie(headers, "heroku_session_nonce")
end
[status, headers, response]
| Make this code more symmetrical
|
diff --git a/app/controllers/admin/base_controller.rb b/app/controllers/admin/base_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/admin/base_controller.rb
+++ b/app/controllers/admin/base_controller.rb
@@ -18,7 +18,24 @@ authorise_user!(User::Permissions::IMPORT)
end
+ def can?(action, subject)
+ enforcer_for(subject).can?(action)
+ end
+ helper_method :can?
+
+ def enforce_permission!(action, subject)
+ unless can?(action, subject)
+ puts "You can't #{action} that #{subject.inspect}"
+ forbidden!
+ end
+ end
+
private
+
+ def enforcer_for(subject)
+ actor = current_user || User.new
+ enforcer = Whitehall::Authority::Enforcer.new(actor, subject)
+ end
def forbidden!
render "admin/editions/forbidden", status: 403
| Add enforcer to admin controllers
Provide enforce_permission! that renders a 403 when the current_user doesn't have permission to perform the requested action on the supplied subject. Also can? that doe the same check but returns true or false and is exposed as a helper method for use in views.
|
diff --git a/rails/app/models/user.rb b/rails/app/models/user.rb
index abc1234..def5678 100644
--- a/rails/app/models/user.rb
+++ b/rails/app/models/user.rb
@@ -11,11 +11,16 @@ User.find_by(token: token) || begin
remote = Octokit::Client.new access_token: token
user = User.create token: token, username: remote.user.login
+
remote.repositories.each do |repo|
if repo.permissions.admin
- Repo.create user_id: user.id, name: repo.name
+ Repo.create name: repo.name,
+ user_id: user.id,
+ owner: repo.owner.login
end
end
+
+ user
rescue Octokit::Unauthorized
end
end
| Set owner on repo creation
|
diff --git a/Casks/emacs.rb b/Casks/emacs.rb
index abc1234..def5678 100644
--- a/Casks/emacs.rb
+++ b/Casks/emacs.rb
@@ -8,4 +8,9 @@ license :oss
app 'Emacs.app'
+ binary 'Emacs.app/Contents/MacOS/bin/emacsclient'
+ binary 'Emacs.app/Contents/MacOS/bin/ctags'
+ binary 'Emacs.app/Contents/MacOS/bin/grep-changelog'
+ binary 'Emacs.app/Contents/MacOS/bin/ebrowse'
+ binary 'Emacs.app/Contents/MacOS/bin/etags'
end
| Install Additional Emacs Utility Binaries
|
diff --git a/Casks/ipaql.rb b/Casks/ipaql.rb
index abc1234..def5678 100644
--- a/Casks/ipaql.rb
+++ b/Casks/ipaql.rb
@@ -0,0 +1,7 @@+class Ipaql < Cask
+ url 'http://ipaql.com/site/assets/files/1006/ipaql_1-3-0.zip'
+ homepage 'http://ipaql.com/'
+ version '1.3.0'
+ sha1 'a870da34839b42945cf2334c7a27c2574d41ffcd'
+ qlplugin 'IPAQuickLook-1.3.0/IPAQuickLook.qlgenerator'
+end
| Add CocoaDeveloper Quicklook Plugin v1.3.0
|
diff --git a/app/jobs/gend_image_process_job.rb b/app/jobs/gend_image_process_job.rb
index abc1234..def5678 100644
--- a/app/jobs/gend_image_process_job.rb
+++ b/app/jobs/gend_image_process_job.rb
@@ -14,16 +14,20 @@ gend_image.src_image.image,
gend_image.captions.map(&:text_pos)).to_blob
- thumb_img = gend_image.magick_image_list
-
- thumb_img.resize_to_fit_anim!(MemeCaptainWeb::Config::THUMB_SIDE)
-
- gend_image.gend_thumb = GendThumb.new(image: thumb_img.to_blob)
-
- thumb_img.destroy!
+ gend_image.gend_thumb = make_gend_thumb(gend_image)
gend_image.work_in_progress = false
gend_image.save!
end
+
+ private
+
+ def make_gend_thumb(gend_image)
+ thumb_img = gend_image.magick_image_list
+ thumb_img.resize_to_fit_anim!(MemeCaptainWeb::Config::THUMB_SIDE)
+ gend_thumb = GendThumb.new(image: thumb_img.to_blob)
+ thumb_img.destroy!
+ gend_thumb
+ end
end
| Move thumbnail generation into separate method.
|
diff --git a/bench/bench_buffer.rb b/bench/bench_buffer.rb
index abc1234..def5678 100644
--- a/bench/bench_buffer.rb
+++ b/bench/bench_buffer.rb
@@ -0,0 +1,45 @@+require File.expand_path(File.join(File.dirname(__FILE__), "bench_helper"))
+
+require 'benchmark'
+require 'ffi'
+iter = 100_000
+
+module BufferBench
+ extend FFI::Library
+ extend FFI::Library
+ ffi_lib LIBTEST_PATH
+ attach_function :bench_s32_v, [ :int ], :void
+ attach_function :bench_buffer_in, :ptr_ret_int32_t, [ :buffer_in, :int ], :void
+ attach_function :bench_buffer_out, :ptr_ret_int32_t, [ :buffer_out, :int ], :void
+ attach_function :bench_buffer_inout, :ptr_ret_int32_t, [ :buffer_inout, :int ], :void
+end
+puts "Benchmark FFI call(MemoryPointer.new) performance, #{iter}x"
+10.times {
+ puts Benchmark.measure {
+ iter.times { BufferBench.bench_buffer_inout(FFI::MemoryPointer.new(:int, 1, false), 0) }
+ }
+}
+puts "Benchmark FFI call(0.chr * 4) performance, #{iter}x"
+10.times {
+ puts Benchmark.measure {
+ iter.times { BufferBench.bench_buffer_inout(0.chr * 4, 0) }
+ }
+}
+puts "Benchmark FFI call(Buffer.alloc_inout) performance, #{iter}x"
+10.times {
+ puts Benchmark.measure {
+ iter.times { BufferBench.bench_buffer_inout(FFI::Buffer.alloc_inout(:int, 1, false), 0) }
+ }
+}
+puts "Benchmark FFI call(Buffer.alloc_in) performance, #{iter}x"
+10.times {
+ puts Benchmark.measure {
+ iter.times { BufferBench.bench_buffer_in(FFI::Buffer.alloc_in(:int, 1, false), 0) }
+ }
+}
+puts "Benchmark FFI call(Buffer.alloc_out) performance, #{iter}x"
+10.times {
+ puts Benchmark.measure {
+ iter.times { BufferBench.bench_buffer_out(FFI::Buffer.alloc_out(:int, 1, false), 0) }
+ }
+}
| Add benchmarks for MemoryPointer vs Buffer vs 0.chr * size
|
diff --git a/bench/bench_enum_i.rb b/bench/bench_enum_i.rb
index abc1234..def5678 100644
--- a/bench/bench_enum_i.rb
+++ b/bench/bench_enum_i.rb
@@ -0,0 +1,17 @@+require File.expand_path(File.join(File.dirname(__FILE__), "bench_helper"))
+
+module LibTest
+ extend FFI::Library
+ ffi_lib LIBTEST_PATH
+ enum :foo, [ :a, :b, :c ]
+ attach_function :ffi_bench, :bench_s32_v, [ :foo ], :void, :save_errno => true
+ attach_function :ffi_bench_i, :bench_s32_v, [ :int ], :void, :save_errno => true
+ def self.rb_bench(i0); nil; end
+end
+
+puts "Benchmark [ :int ], :void performance, #{ITER}x calls"
+10.times {
+ puts Benchmark.measure {
+ ITER.times { LibTest.ffi_bench_i(1) }
+ }
+}
| Add enum bench for :int parameter types
|
diff --git a/Casks/skype.rb b/Casks/skype.rb
index abc1234..def5678 100644
--- a/Casks/skype.rb
+++ b/Casks/skype.rb
@@ -16,5 +16,11 @@
app 'Skype.app'
- zap :delete => '~/Library/Application Support/Skype'
+ zap :delete => [
+ '~/Library/Application Support/Skype',
+ '~/Library/Caches/com.plausiblelabs.crashreporter.data/com.skype.skype',
+ '~/Library/Caches/com.skype.skype',
+ '~/Library/Preferences/com.skype.skype.plist',
+ '~/Library/Preferences/com.skype.skypewifi.plist',
+ ]
end
| Add missing zap stanza for Skype
|
diff --git a/Casks/zulip.rb b/Casks/zulip.rb
index abc1234..def5678 100644
--- a/Casks/zulip.rb
+++ b/Casks/zulip.rb
@@ -2,6 +2,7 @@ version :latest
sha256 :no_check
+ # zulip.com was verified as official when first introduced to the cask
url 'https://zulip.com/dist/apps/mac/Zulip-latest.dmg'
name 'Zulip'
homepage 'https://www.zulip.org/'
| Fix `url` stanza comment for Zulip.
|
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -1,4 +1,13 @@ class UsersController < ApplicationController
+ def activate
+ if (@user = User.load_from_activation_token(params[:id]))
+ @user.activate!
+ redirect_to login_path, notice: "User was successfully activated."
+ else
+ not_authenticated
+ end
+ end
+
def show
@user = current_user
end
| Add Activate Method Action To Activated User
|
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -1,6 +1,4 @@ class UsersController < ApplicationController
-<<<<<<< HEAD
-
def create
user = User.new(user_params)
if user.save
@@ -20,20 +18,4 @@ def user_params
params.require(:user).permit(:username, :password)
end
-
-=======
- def new
- end
-
- def create
-
- end
-
- def index
- end
-
- def show
- @user = User.find(1)
- end
->>>>>>> Add users controller for dummy layout show
end | Add users show, eliminate empty routes in users controller
|
diff --git a/app/controllers/archives_controller.rb b/app/controllers/archives_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/archives_controller.rb
+++ b/app/controllers/archives_controller.rb
@@ -12,7 +12,7 @@ #TODO: check if archive belong to user
@archive.transition_to :generating
CreateArchive.perform_async(@archive.id)
- redirect_to archives_path
+ redirect_to :back
end
private
| Fix redirection after archive generation to respect previous params (and bring back to original page)
|
diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/profiles_controller.rb
+++ b/app/controllers/profiles_controller.rb
@@ -8,7 +8,7 @@ def update
respond_to do |format|
if @profile.update(profile_params)
- format.html { redirect_to @profile, notice: 'Profile was successfully updated.' }
+ format.html { redirect_to user_profile_path(@profile.user), notice: 'Profile was successfully updated.' }
format.json { render :show, status: :ok, location: @profile }
else
format.html { render :edit }
@@ -24,7 +24,6 @@ end
def profile_params
- params.require(:user).permit(:avatar)
+ params.require(:profile).permit(:avatar)
end
-
end
| Add ability to upload new profile photos
|
diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/profiles_controller.rb
+++ b/app/controllers/profiles_controller.rb
@@ -20,7 +20,7 @@
def student
if @classroom = current_user.classroom
- @units = @classroom.classroom_activities.map(&:unit).uniq
+ @units = @classroom.classroom_activities.includes(:unit).map(&:unit).uniq
@next_activity_session = ActivitySession.joins(:classroom_activity)
.where("activity_sessions.completed_at IS NULL")
| Fix one N+1 query found via bullet
|
diff --git a/app/controllers/resource_controller.rb b/app/controllers/resource_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/resource_controller.rb
+++ b/app/controllers/resource_controller.rb
@@ -1,6 +1,6 @@ class ResourceController < ApplicationController
- before_filter(:only => [:index, :show]) { set_alternate_formats [:json, :ics] }
+ before_filter(:only => [:index, :show]) { alternate_formats [:json, :ics] }
def index
@resources = Resource.where(:active => true)
| Change filter name as per new version of alternate_rails
|
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/sessions_controller.rb
+++ b/app/controllers/sessions_controller.rb
@@ -8,7 +8,9 @@
def destroy_and_redirect
sign_out current_user
- if params[:project_id]
+ if params[:redirect_to]
+ redirect_to params[:redirect_to]
+ elsif params[:project_id]
url_params = {project_id: params[:project_id].to_i, locale: ''}
url_params[:reward_id] = params[:reward_id].to_i if params[:reward_id] && params[:reward_id] != 'null'
url_params[:value] = params[:value] if params[:value]
| Add redirect_to parameter to not-my-account route
Signed-off-by: Vinicius Andrade <16687ac525c18d05db54be8266913435a820383c@gmail.com>
|
diff --git a/app/cyclid/plugins/action/cobertura.rb b/app/cyclid/plugins/action/cobertura.rb
index abc1234..def5678 100644
--- a/app/cyclid/plugins/action/cobertura.rb
+++ b/app/cyclid/plugins/action/cobertura.rb
@@ -0,0 +1,71 @@+# frozen_string_literal: true
+# Copyright 2016, 2017 Liqwyd Ltd.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+require 'nokogiri'
+
+# Top level module for the core Cyclid code.
+module Cyclid
+ # Module for the Cyclid API
+ module API
+ # Module for Cyclid Plugins
+ module Plugins
+ # Cobertura (& compatible) coverage reader plugin
+ class Cobertura < Action
+ def initialize(args = {})
+ args.symbolize_keys!
+
+ # There must be the path to the coverage report..
+ raise 'a Cobertura action requires a path' unless args.include? :path
+
+ @path = args[:path]
+ end
+
+ def perform(log)
+ # Retrieve the Cobertura XML report
+ report = StringIO.new
+ @transport.download(report, @path ** @ctx)
+
+ # Parse the report and extract the line & branch coverage.
+ xml = Nokogiri.parse(report.string)
+ coverage = xml.xpath('//coverage')
+ line_rate = coverage.attr('line-rate').value.to_i
+ branch_rate = coverage.attr('branch-rate').value.to_i
+
+ # Coverage is given as a fraction, so convert it to a percentage.
+ #
+ # Cobertura can produce oddly specific coverage metrics, so round it
+ # to only 2 decimal points...
+ line_rate_pct = (line_rate * 100).round(2)
+ branch_rate_pct = (branch_rate * 100).round(2)
+
+ log.write "Cobertura coverage line rate is #{line_rate_pct}%, " \
+ "branch rate is #{branch_rate_pct}%\n"
+
+ @ctx[:cobertura_line_rate] = "#{line_rate_pct}%"
+ @ctx[:cobertura_branch_rate] = "#{branch_rate_pct}%"
+
+ return [true, 0]
+ rescue StandardError => ex
+ log.write "Failed to read Cobertura coverage report: #{ex}"
+
+ return [false, 0]
+ end
+
+ # Register this plugin
+ register_plugin 'cobertura'
+ end
+ end
+ end
+end
| Add a Cobertura coverage plugin
The Cobertura plugin reads a Cobertura XML coverage report and adds the test
coverage metrics to the job context as a percentage under "cobertura_line_rate"
and "cobertura_branch_rate"
|
diff --git a/bible-passage.gemspec b/bible-passage.gemspec
index abc1234..def5678 100644
--- a/bible-passage.gemspec
+++ b/bible-passage.gemspec
@@ -5,7 +5,7 @@ s.authors = ["Si Wilkins"]
s.email = 'si.wilkins@gmail.com'
s.homepage = 'https://github.com/siwilkins/bible-passage'
- readmes = Dir['*'].reject{ |x| x = ~ /(^|[^.a-z])[a-z]+/ || x == "TODO" || x = ~ /\.gem$/ }
+ readmes = Dir['*'].reject{ |x| x = ~ /(^|[^.a-z])[a-z]+/ || x == "TODO" || x =~ /\.gem$/ }
s.files = Dir['lib/**/*', 'spec/**/*'] + readmes
s.has_rdoc = false
s.test_files = Dir["test/**/*_test.rb"]
| Fix gemspec to not include gem files
|
diff --git a/app/models/registerable_redirect.rb b/app/models/registerable_redirect.rb
index abc1234..def5678 100644
--- a/app/models/registerable_redirect.rb
+++ b/app/models/registerable_redirect.rb
@@ -1,9 +1,6 @@-class RegisterableRedirect < OpenStruct
- include ActiveModel::Validations
+class RegisterableRedirect < RegisterableRoute
- validates :type, inclusion: { in: %w(exact prefix), message: 'must be either "exact" or "prefix"' }
- validates :path, :destination, absolute_path: true
- validates :path, :type, :destination, presence: true
+ validates :destination, presence: true, absolute_path: true
def register!
Rails.application.router_api.add_redirect_route(path, type, destination)
| Refactor RegisterableRedirect to avoid duplication.
It shares all the validations of RegisterableRoute, so it makes sense
for it to inherit from it.
|
diff --git a/lib/polisher/targets/bodhi.rb b/lib/polisher/targets/bodhi.rb
index abc1234..def5678 100644
--- a/lib/polisher/targets/bodhi.rb
+++ b/lib/polisher/targets/bodhi.rb
@@ -5,6 +5,11 @@
# XXX issue w/ retreiving packages from pkgwat causing sporadic issues:
# https://github.com/fedora-infra/fedora-packages/issues/55
+
+# another issue seems to result in url's sometimes
+# html anchors being returned in version field, use
+# nokogiri to pull this out
+require 'nokogiri'
module Polisher
# fedora pkgwat provides a frontend to bodhi
@@ -14,8 +19,25 @@ versions = Pkgwat.get_updates("rubygem-#{name}", 'all', 'all')
.select { |update| update['stable_version'] != 'None' }
.collect { |update| update['stable_version'] }
+ versions = sanitize(versions)
bl.call(:bodhi, name, versions) unless bl.nil?
versions
end
+
+ private
+
+ def self.sanitize(versions)
+ versions.collect { |v|
+ is_url?(v) ? url2version(v) : v
+ }
+ end
+
+ def self.is_url?(version)
+ !Nokogiri::HTML(version).css('a').empty?
+ end
+
+ def self.url2version(version)
+ Nokogiri::HTML(version).text
+ end
end
end
| Handle Bodhi err where html anchor is being returned for version
|
diff --git a/app/models/untrained_students_alert.rb b/app/models/untrained_students_alert.rb
index abc1234..def5678 100644
--- a/app/models/untrained_students_alert.rb
+++ b/app/models/untrained_students_alert.rb
@@ -39,6 +39,6 @@ end
def reply_to
- from_user.email
+ from_user&.email
end
end
| Handle non-existent user for UntrainedStudentsAlert emails
|
diff --git a/app/parameters/live_time_parameters.rb b/app/parameters/live_time_parameters.rb
index abc1234..def5678 100644
--- a/app/parameters/live_time_parameters.rb
+++ b/app/parameters/live_time_parameters.rb
@@ -1,7 +1,7 @@ class LiveTimeParameters < BaseParameters
def self.permitted
- [:id, :event_id, :lap, :split_id, :sub_split_kind, :bitkey, :wave, :bib_number, :absolute_time,
+ [:id, :event_id, :lap, :split_id, :sub_split_kind, :bitkey, :wave, :bib_number, :absolute_time, :military_time,
:stopped_here, :with_pacer, :remarks, :batch, :source, :event_slug, :split_slug, :split_time_id]
end
end
| Add :military_time to LiveTimeParameters.permitted (was inadvertently deleted in a merge).
|
diff --git a/app/services/never_logged_in_notifier.rb b/app/services/never_logged_in_notifier.rb
index abc1234..def5678 100644
--- a/app/services/never_logged_in_notifier.rb
+++ b/app/services/never_logged_in_notifier.rb
@@ -5,12 +5,19 @@
Person.never_logged_in.each do |person|
person.with_lock do # use db lock in case cronjob running on two instances
- person.reload
- if person.send_never_logged_in_reminder?
- ReminderMailer.never_logged_in(person).deliver_later
- person.update(last_reminder_email_at: Time.zone.now)
- end
+ send_reminder person
end
end
end
+
+ def self.send_reminder person
+ person.reload
+ if person.send_never_logged_in_reminder?
+ ReminderMailer.never_logged_in(person).deliver_later
+ person.update(last_reminder_email_at: Time.zone.now)
+ end
+ end
+
+ private_class_method :send_reminder
+
end
| Move send reminder step into a private method
|
diff --git a/app/presenters/field/text_presenter.rb b/app/presenters/field/text_presenter.rb
index abc1234..def5678 100644
--- a/app/presenters/field/text_presenter.rb
+++ b/app/presenters/field/text_presenter.rb
@@ -19,6 +19,7 @@ end
def render_markdown(t)
+ t ||= ''
v = Redcarpet::Markdown.new(
Redcarpet::Render::HTML,
autolink: true, tables: true
| Handle empty text for formatted text field
|
diff --git a/lib/rubocop/cop/style/send.rb b/lib/rubocop/cop/style/send.rb
index abc1234..def5678 100644
--- a/lib/rubocop/cop/style/send.rb
+++ b/lib/rubocop/cop/style/send.rb
@@ -8,10 +8,13 @@ MSG = 'Prefer `Object#__send__` or `Object#public_send` to ' \
'`send`.'.freeze
+ def_node_matcher :sending?, '(send _ :send $...)'
+
def on_send(node)
- _receiver, method_name, *args = *node
- return unless method_name == :send && !args.empty?
- add_offense(node, :selector)
+ sending?(node) do |args|
+ return if args.empty?
+ add_offense(node, :selector)
+ end
end
end
end
| Modify Style/Send to use NodePattern
|
diff --git a/cookbook/recipes/build.rb b/cookbook/recipes/build.rb
index abc1234..def5678 100644
--- a/cookbook/recipes/build.rb
+++ b/cookbook/recipes/build.rb
@@ -25,6 +25,5 @@ repository 'https://github.com/HubSpot/Baragon.git'
reference node[:baragon][:git_ref]
user node[:baragon][:user]
- action :export
notifies :run, 'execute[build_baragon]', :immediately
end
| Use sync action for git instead of export
|
diff --git a/app/services/nomis/offender/details.rb b/app/services/nomis/offender/details.rb
index abc1234..def5678 100644
--- a/app/services/nomis/offender/details.rb
+++ b/app/services/nomis/offender/details.rb
@@ -6,16 +6,11 @@ attribute :given_name, :string
attribute :surname, :string
attribute :title, :string
- attribute :nationalities, :string
attribute :date_of_birth, :date
attribute :aliases
attribute :gender
- attribute :religion
- attribute :ethnicity
attribute :convicted, :boolean
attribute :imprisonment_status
- attribute :cro_number, :string
- attribute :pnc_number, :string
attribute :iep_level
attribute :api_call_successful, :boolean, default: true
| Revert "Add missing API fields"
This reverts commit a936673458370cfe0e81b428a6952d6823a21708.
|
diff --git a/lib/soapforce/query_result.rb b/lib/soapforce/query_result.rb
index abc1234..def5678 100644
--- a/lib/soapforce/query_result.rb
+++ b/lib/soapforce/query_result.rb
@@ -19,14 +19,6 @@ @result_records.each(&block)
end
- def first
- @result_records.first
- end
-
- def last
- @result_records.last
- end
-
def size
@raw_result[:size] || 0
end
@@ -38,6 +30,10 @@ def query_locator
@raw_result[:query_locator]
end
+
+ def method_missing(method, *args, &block)
+ @result_records.send(method, *args, &block)
+ end
end
end | Switch to method_missing in QueryResult to delegate calls to the internal array.
|
diff --git a/lib/tasks/data_extractor.rake b/lib/tasks/data_extractor.rake
index abc1234..def5678 100644
--- a/lib/tasks/data_extractor.rake
+++ b/lib/tasks/data_extractor.rake
@@ -0,0 +1,29 @@+namespace :data_extractor do
+ desc "Creates a CSV with with the links data of all the Whitehall items"
+ namespace :list_tagged_items do
+ task whitehall: :environment do
+ # Expected output format:
+ # format,tag_type,count
+ # content-id-0000-0001,policy_areas,10
+ # content-id-0000-0002,organisations,2
+
+ sql = "select content_items.content_id, links.link_type, count(*) " \
+ "from states " \
+ "join content_items on states.content_item_id = content_items.id " \
+ "join link_sets on ( link_sets.content_id = content_items.content_id ) " \
+ "join links on ( links.link_set_id = link_sets.id ) " \
+ "where states.name = 'published'" \
+ "and content_items.publishing_app = 'whitehall'" \
+ "group by content_items.content_id, links.link_type " \
+ "order by content_items.content_id, links.link_type DESC"
+
+ items = ActiveRecord::Base.connection.execute(sql)
+
+ csv_out = CSV.new($stdout)
+ csv_out << %w(format tag_type count)
+ items.each do |i|
+ csv_out << [i['content_id'], i['link_type'], i['count']]
+ end
+ end
+ end
+end
| Add rake task to extract links data
We are aiming at having topics tagging Whitehall in sync with publishing-api.
The output of this rake task will allow us to validate our changes.
Ticket: https://trello.com/c/mtYIToz9/527-whitehall-migration-send-topics-to-publishing-api-as-links-m
|
diff --git a/BHCDatabase/app/grids/enrolments_grid.rb b/BHCDatabase/app/grids/enrolments_grid.rb
index abc1234..def5678 100644
--- a/BHCDatabase/app/grids/enrolments_grid.rb
+++ b/BHCDatabase/app/grids/enrolments_grid.rb
@@ -36,5 +36,19 @@ link_to init.name, init
end
end
+ column(:created_at, :header => 'Enrolled', :mandatory => true) do |model|
+ format(model.created_at) do |value|
+ value
+ end
+ end
+ column(:created_at, :header => 'Un-Enrolled', :mandatory => true) do |model|
+ format(model.updated_at) do |value|
+ if value == model.created_at
+ 'Still enrolled'
+ else
+ value
+ end
+ end
+ end
end
| Add basic date information to enrolments grid.
|
diff --git a/app/controllers/api/v1/api_controller.rb b/app/controllers/api/v1/api_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/api/v1/api_controller.rb
+++ b/app/controllers/api/v1/api_controller.rb
@@ -5,6 +5,7 @@ class ApiController < ApplicationController
protect_from_forgery with: :null_session
include DeviseTokenAuth::Concerns::SetUserByToken
+ before_action :skip_session_storage
layout false
respond_to :json
@@ -33,6 +34,14 @@ logger.info(exception) # for logging
render json: { errors: exception.record.errors.as_json }, status: :bad_request
end
+
+ private
+
+ def skip_session_storage
+ # Devise stores the cookie by default, so in api requests, it is disabled
+ # http://stackoverflow.com/a/12205114/2394842
+ request.session_options[:skip] = true
+ end
end
end
end
| Remove devise cookie storage in api
|
diff --git a/rspecs/model/nodes/pool_spec.rb b/rspecs/model/nodes/pool_spec.rb
index abc1234..def5678 100644
--- a/rspecs/model/nodes/pool_spec.rb
+++ b/rspecs/model/nodes/pool_spec.rb
@@ -1,4 +1,5 @@ require 'rspec'
+require_relative '../../../domain/diagram'
describe Pool do
| Add require to load classes (in case this file gets run on its own).
|
diff --git a/ruboty-leveldb.gemspec b/ruboty-leveldb.gemspec
index abc1234..def5678 100644
--- a/ruboty-leveldb.gemspec
+++ b/ruboty-leveldb.gemspec
@@ -21,5 +21,5 @@ spec.add_dependency "leveldb"
spec.add_development_dependency "bundler", "~> 1.7"
- spec.add_development_dependency "rake", "~> 10.0"
+ spec.add_development_dependency "rake", "~> 13.0"
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.1)
Signed-off-by: dependabot-preview[bot] <5bdcd3c0d4d24ae3e71b3b452a024c6324c7e4bb@dependabot.com> |
diff --git a/spec/unit/veritas/logic/predicate/enumerable/class_methods/compare_method_spec.rb b/spec/unit/veritas/logic/predicate/enumerable/class_methods/compare_method_spec.rb
index abc1234..def5678 100644
--- a/spec/unit/veritas/logic/predicate/enumerable/class_methods/compare_method_spec.rb
+++ b/spec/unit/veritas/logic/predicate/enumerable/class_methods/compare_method_spec.rb
@@ -5,13 +5,13 @@
let(:object) { Logic::Predicate::Enumerable }
- describe 'the enumerable is a Range' do
+ context 'the enumerable is a Range' do
let(:enumerable) { 1..2 }
it { should == :cover? }
end
- describe 'the enumerable is an Array' do
+ context 'the enumerable is an Array' do
let(:enumerable) { [ 1, 2 ] }
it { should == :include? }
| Change nested describe blocks into context blocks
|
diff --git a/lib/london_bike_hire_cli/basic_renderer.rb b/lib/london_bike_hire_cli/basic_renderer.rb
index abc1234..def5678 100644
--- a/lib/london_bike_hire_cli/basic_renderer.rb
+++ b/lib/london_bike_hire_cli/basic_renderer.rb
@@ -5,22 +5,22 @@ end
def render(context)
- output.print ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"
- output.print "Feed updated: #{context.first.display_feed_time}\n"
+ print_line colourize(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>", :yellow)
+ print_line "Feed updated: #{colourize(context.first.display_feed_time, :red)}"
context.each do |station|
render_station(station)
end
- output.print ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"
+ print_line colourize(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>", :yellow)
end
def render_error(context)
- output.print ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"
- output.print "Ooops, something went wrong with the query.\n"
- output.print "The query #{context[:query].inspect}\n"
- output.print "resulted in error: #{context[:error]}\n"
- output.print "Try again?\n"
+ print_line colourize(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>", :yellow)
+ print_line colourize("Ooops, something went wrong with the query.", :red)
+ print_line colourize("The query #{context[:query].inspect}", :cyan)
+ print_line colourize("resulted in error: #{context[:error]}", :cyan)
+ print_line colourize("Try again?", :yellow)
end
private
@@ -28,11 +28,34 @@ attr_reader :output
def render_station(station)
- output.print ">>> Dock\n"
+ print_line "%s %s" % [colourize('>>>>', :yellow), colourize('Bike station', :blue)]
station.each_pair.each do |attr_name, attr_value|
- output.print "#{attr_name.capitalize}: #{attr_value}\n"
+ print_line "#{attr_name.capitalize}: #{colourize(attr_value, :cyan)}"
end
- output.print "Link to map: #{station.map_link}\n"
+ print_line "Link to map: #{colourize(station.map_link, :pink)}"
end
+
+ def print_line(text, line_ending = "\n")
+ output.print "%s %s" % [text, line_ending]
+ end
+
+ def colourize(text, color_name = :default)
+ colour_code = colour_code(color_name)
+ "\e[#{colour_code}m#{text}\e[0m"
+ end
+
+ def colour_code(name)
+ COLOUR_MAP[name]
+ end
+
+ COLOUR_MAP = {
+ default: 39,
+ red: 31,
+ green: 32,
+ yellow: 33,
+ blue: 34,
+ pink: 35,
+ cyan: 36
+ }.freeze
end
end
| Add basic colouring to terminal using ansi colours
Think this should be good on osx and linux; screw windows :|
|
diff --git a/app/controllers/main_chat_controller.rb b/app/controllers/main_chat_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/main_chat_controller.rb
+++ b/app/controllers/main_chat_controller.rb
@@ -2,6 +2,6 @@ respond_to :html, :json
def index
- respond_with Message.last_five_main_chat_messages
+ respond_with Message.last_five_chat_messages("main")
end
end
| Move MainChatController to use refactored last_five_chat_messages method
|
diff --git a/app/controllers/users/pbs_controller.rb b/app/controllers/users/pbs_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/users/pbs_controller.rb
+++ b/app/controllers/users/pbs_controller.rb
@@ -6,7 +6,7 @@ def show
if @user.patron?(tier: 3)
if params[:trailing_path].nil?
- redirect_to run_path(@user.pb_for(@category))
+ redirect_to run_path(@user.pb_for(Run::REAL, @category))
else
redirect_to "#{run_path(@user.pb_for(@category))}/#{params[:trailing_path]}"
end
| Fix a permalink redirector 500 |
diff --git a/app/controllers/validator_controller.rb b/app/controllers/validator_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/validator_controller.rb
+++ b/app/controllers/validator_controller.rb
@@ -1,3 +1,6 @@+require 'resolv'
+require 'net/smtp'
+
class ValidatorController < ApplicationController
def index
end
@@ -10,8 +13,10 @@ else
list = emails_list.split("\r\n")
list.each do |email_name|
+ domain = email_name.split('@').last
v = email_name.match(/\A([\w+\-]\.?)+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z/i).present?
- Email.create(name: email_name, email_valid: v)
+ v = v && dns_valid(domain).present?
+ Email.create(name: email_name, email_valid: v)
end
redirect_to "/validator/results"
end
@@ -21,4 +26,22 @@ @emails = Email.all
end
+ def dns_valid(domain)
+ dns = Resolv::DNS.new
+
+ mx_records = dns.getresources domain, Resolv::DNS::Resource::IN::MX
+ if mx_records.any?
+ mx_server = mx_records.first.exchange.to_s
+ return mx_server
+ else
+ return false
+ end
+
+ Net::SMTP.start mx_server, 25 do |smtp|
+ smtp.helo "loldomain.com"
+ smtp.mailfrom "test@loldomain.com"
+ end
+
+ end
+
end
| Add dns and smtp validations
|
diff --git a/app/helpers/puddy/application_helper.rb b/app/helpers/puddy/application_helper.rb
index abc1234..def5678 100644
--- a/app/helpers/puddy/application_helper.rb
+++ b/app/helpers/puddy/application_helper.rb
@@ -1,4 +1,9 @@ module Puddy
module ApplicationHelper
+ def method_missing(method, *args, &block)
+ main_app.send method, *args, &block
+ rescue NoMethodError
+ super
+ end
end
end
| Send missing helper methods to main app
|
diff --git a/spec/controllers/user_spec.rb b/spec/controllers/user_spec.rb
index abc1234..def5678 100644
--- a/spec/controllers/user_spec.rb
+++ b/spec/controllers/user_spec.rb
@@ -17,16 +17,24 @@
before :each do
allow(klass).to receive(:get).and_return(user)
+
+ cfg = instance_double(Cyclid::UI::Config)
+ allow(cfg).to receive_message_chain('api.inspect').and_return('mocked object')
+ allow(cfg).to receive_message_chain('api.host').and_return('example.com')
+ allow(cfg).to receive_message_chain('api.port').and_return(9999)
+ allow(cfg).to receive_message_chain('memcached').and_return('example.com:4242')
+ allow(Cyclid).to receive(:config).and_return(cfg)
end
before :all do
clear_cookies
end
- describe '#/user/:username' do
+ describe '#get /user/:username' do
it 'requires authentication' do
get '/user/test'
expect(last_response.status).to eq(302)
+ expect(last_response['Location']).to eq 'http://example.org/login'
end
it 'return a valid user' do
| Make the redirect test slightly more robust
|
diff --git a/lib/alf/lang/literals.rb b/lib/alf/lang/literals.rb
index abc1234..def5678 100644
--- a/lib/alf/lang/literals.rb
+++ b/lib/alf/lang/literals.rb
@@ -15,12 +15,7 @@ # Coerces `args` to a valid relation.
def Relation(first, *args)
if args.empty?
- case first
- when ::Symbol then _database.dataset(first).to_rel
- when ::Hash then ::Alf::Relation[first]
- else
- ::Kernel.raise ::ArgumentError, "Unable to coerce `#{first.inspect}` to a relation"
- end
+ first.is_a?(::Symbol) ? _database.dataset(first).to_rel : Alf::Relation(first)
else
::Alf::Relation[*args.unshift(first)]
end
| Fix Relation literal to behave the same in Ruby and in Lispy.
|
diff --git a/spec/views/users/_edittable_user.html.erb_spec.rb b/spec/views/users/_edittable_user.html.erb_spec.rb
index abc1234..def5678 100644
--- a/spec/views/users/_edittable_user.html.erb_spec.rb
+++ b/spec/views/users/_edittable_user.html.erb_spec.rb
@@ -1,28 +1,28 @@ require 'spec_helper'
-permission_regex = /<input .*user\[permission\].*>/
describe 'users/_edittable_user.html.erb' do
- describe "User permission level" do
- before :each do
- @user = User.new()
- @user.disabled = false
- end
- it "should not be updateable" do
- @controller.template.stub!(:is_admin?).and_return(false)
+ permission_regex = /<input .*user\[permission\].*>/
+ describe "User permission level" do
+ before :each do
+ @user = User.new()
+ @user.disabled = false
+ end
+ it "should not be updateable" do
+ @controller.template.stub!(:is_admin?).and_return(false)
- render :locals => { :edittable_user => @user }
+ render :locals => { :edittable_user => @user }
- permission_regex.match(response.body).to_a.each do |p|
- p.should include("disabled")
- end
- end
- it "should be allowed to be updated by admin" do
- @controller.template.stub!(:is_admin?).and_return(true)
+ permission_regex.match(response.body).to_a.each do |p|
+ p.should include("disabled")
+ end
+ end
+ it "should be allowed to be updated by admin" do
+ @controller.template.stub!(:is_admin?).and_return(true)
- render :locals => { :edittable_user => @user }
+ render :locals => { :edittable_user => @user }
- permission_regex.match(response.body).to_a.each do |p|
- p.should_not include("disabled")
- end
- end
- end
-end+ permission_regex.match(response.body).to_a.each do |p|
+ p.should_not include("disabled")
+ end
+ end
+ end
+end
| Fix scope of permission regex
|
diff --git a/rb/lib/selenium/webdriver/common/zipper.rb b/rb/lib/selenium/webdriver/common/zipper.rb
index abc1234..def5678 100644
--- a/rb/lib/selenium/webdriver/common/zipper.rb
+++ b/rb/lib/selenium/webdriver/common/zipper.rb
@@ -36,7 +36,7 @@ entry = file.sub("#{path}/", '')
zos.put_next_entry(entry)
- zos << File.read(file)
+ zos << File.read(file, "rb")
end
zos.close
| JariBakken: Make sure we properly zip binary files on Windows.
git-svn-id: 4179480af2c2519a5eb5e1e9b541cbdf5cf27696@11358 07704840-8298-11de-bf8c-fd130f914ac9
|
diff --git a/spec/models/manageiq/providers/cloud_manager/orchestration_template_runner_spec.rb b/spec/models/manageiq/providers/cloud_manager/orchestration_template_runner_spec.rb
index abc1234..def5678 100644
--- a/spec/models/manageiq/providers/cloud_manager/orchestration_template_runner_spec.rb
+++ b/spec/models/manageiq/providers/cloud_manager/orchestration_template_runner_spec.rb
@@ -4,16 +4,16 @@
context "#queue_signal" do
it "queues a signal with the queue_signal method" do
- runner = described_class.create_job(:options => {:orchestration_template_id => template.id, :zone => zone})
+ runner = described_class.create_job(:options => {:orchestration_template_id => template.id}, :zone => zone.name)
queue = runner.queue_signal
expect(queue).to have_attributes(
:class_name => described_class.name,
:method_name => 'signal',
- :instance_id => template.id,
+ :instance_id => runner.id,
:role => 'ems_operations',
:queue_name => 'generic',
- :zone => zone.id,
+ :zone => zone.name,
:priority => MiqQueue::NORMAL_PRIORITY,
:args => []
)
| Fix expected instance id, fix zone handling.
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.