diff stringlengths 65 26.7k | message stringlengths 7 9.92k |
|---|---|
diff --git a/lib/adhearsion/twilio.rb b/lib/adhearsion/twilio.rb
index abc1234..def5678 100644
--- a/lib/adhearsion/twilio.rb
+++ b/lib/adhearsion/twilio.rb
@@ -6,9 +6,9 @@ require "active_support/core_ext/numeric/time"
require_relative "twilio/util"
-require "adhearsion/twilio/version"
-require "adhearsion/twilio/plugin"
-require "adhearsion/twilio/controller_methods"
+require_relative "twilio/version"
+require_relative "twilio/plugin"
+require_relative "twilio/controller_methods"
module Adhearsion
module Twilio
| Use require_relative instead of require
|
diff --git a/lib/columbo/db_client.rb b/lib/columbo/db_client.rb
index abc1234..def5678 100644
--- a/lib/columbo/db_client.rb
+++ b/lib/columbo/db_client.rb
@@ -17,7 +17,7 @@ end
def save(*args)
- coll.findOne *args
+ coll.save *args
end
def find(*args)
| Fix typo in DbCLient class for save (unused).
|
diff --git a/lib/glimpse/views/git.rb b/lib/glimpse/views/git.rb
index abc1234..def5678 100644
--- a/lib/glimpse/views/git.rb
+++ b/lib/glimpse/views/git.rb
@@ -24,12 +24,12 @@
# Fetch the current branch name.
def branch_name
- @branch_name ||= `git rev-parse --abbrev-ref HEAD`.chomp
+ @branch_name ||= ENV['GIT_BRANCH'] || `git rev-parse --abbrev-ref HEAD`.chomp
end
# Fetch the current sha if one isn't present.
def sha
- @sha ||= `git rev-parse HEAD`.chomp
+ @sha ||= ENV['GIT_SHA'] || `git rev-parse HEAD`.chomp
end
def short_sha
| Use ENV vars if they are set
|
diff --git a/modules/nginx/spec/defines/nginx__config__vhost__redirect_spec.rb b/modules/nginx/spec/defines/nginx__config__vhost__redirect_spec.rb
index abc1234..def5678 100644
--- a/modules/nginx/spec/defines/nginx__config__vhost__redirect_spec.rb
+++ b/modules/nginx/spec/defines/nginx__config__vhost__redirect_spec.rb
@@ -9,7 +9,7 @@ }}
it { is_expected.to contain_nginx__config__site('gruffalo.example.com').with(
- :content => /^\s+server_name gruffalo\.example\.com;$/
+ :content => /^\s+server_name gruffalo\.example\.com\ gruffalo\.example\.com\.\*;$/
)}
it { is_expected.to contain_nginx__config__site('gruffalo.example.com').with(
:content => /^\s+rewrite \^\/\(\.\*\)\ https:\/\/mouse\.example\.com\/\$1 permanent;$/
| Modify expected result for nginx__config__vhost_redirect_spec
This is what is expected following the migration to AWS.
|
diff --git a/lib/pry-state/printer.rb b/lib/pry-state/printer.rb
index abc1234..def5678 100644
--- a/lib/pry-state/printer.rb
+++ b/lib/pry-state/printer.rb
@@ -2,25 +2,32 @@ extend self
def trunc_and_print var, value, var_color, value_color
- var_name_adjusted = var.to_s.ljust(25)
- print Pry::Helpers::Text.send(var_color, truncate(var_name_adjusted, 25) )
- print_stringified_val_or_nil value, value_color
+ width = ENV['COLUMNS'] ? ENV['COLUMNS'].to_i : 80
+ # Ratios are 1:3 left:right
+ left_column_width = width / 4
+ left_column_width = left_column_width < 25 ? 25 : left_column_width
+ var_name_adjusted = var.to_s.ljust(left_column_width)
+ # Ensure at least 1 space between left and right columns
+ left_column_text = truncate(var_name_adjusted, left_column_width - 1) + ' '
+ print Pry::Helpers::Text.send(var_color, left_column_text)
+ print stringified_val_or_nil(value, value_color, width - left_column_width)
print "\n"
end
private
def truncate text, length
if text.nil? then return end
- l = length - "...".chars.to_a.size
+ l = length - "...".length
(text.chars.to_a.size > length ? text.chars.to_a[0...l].join + "..." : text).to_s
end
- def print_stringified_val_or_nil value, color
+ def stringified_val_or_nil value, color, length
value = stringify_value value
if value.empty?
- print Pry::Helpers::Text.red 'nil'
+ Pry::Helpers::Text.red 'nil'
else
- print Pry::Helpers::Text.send(color, truncate(value, 60) )
+ text = truncate(value, length)
+ Pry::Helpers::Text.send(color, text)
end
end
| Use $COLUMNS env to fill up pry-state print
1. Instead of hardcoding an arbitrary width (85 previously), use $COLUMNS, if defined. Otherwise, fall back to 80 (which is standard). We could use 85 if you want to keep backwards compatibility.
2. Leave at least one space between left and right columns
3. Clean code a bit |
diff --git a/test/integration/resource/resource_spec.rb b/test/integration/resource/resource_spec.rb
index abc1234..def5678 100644
--- a/test/integration/resource/resource_spec.rb
+++ b/test/integration/resource/resource_spec.rb
@@ -29,5 +29,5 @@ end
describe file('/usr/local/notifyTwo') do
- it { should be_a_file }
+ it { should_not be_a_file }
end
| Fix test to reflect fixed notifications
Now that notifications don’t fire on every run we shouldn’t be creating the 2nd file. There was no update.
Signed-off-by: Tim Smith <764ef62106582a09ed09dfa0b6bff7c05fd7d1e4@chef.io>
|
diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb
index abc1234..def5678 100644
--- a/config/initializers/assets.rb
+++ b/config/initializers/assets.rb
@@ -17,5 +17,5 @@ Rails.application.config.assets.precompile += %w( relaunch.css relaunch_ie.css screen.css node.css nodes.css search.css react-select.css)
# Precompile additional assets for assets pipeline (/assets/javascripts)
-Rails.application.config.assets.precompile += %w( relaunch.js modernizr.js search.js nodes.js ember.js ember-data.js app.js test.js)
+Rails.application.config.assets.precompile += %w( relaunch.js modernizr.js search.js nodes.js app.js test.js)
Rails.application.config.assets.precompile += %w( i18n/*.js react-application.js )
| Remove unused ember from to be precompiled list.
|
diff --git a/app/models/community.rb b/app/models/community.rb
index abc1234..def5678 100644
--- a/app/models/community.rb
+++ b/app/models/community.rb
@@ -4,16 +4,22 @@ has_many :groups
validates_presence_of :name
- validates :latitude, presence: true, numericality: {greater_than_or_equal_to: -180, less_than_or_equal_to: 180}
- validates :longitude, presence: true, numericality: {greater_than_or_equal_to: -180, less_than_or_equal_to: 180}
+ validate :validate_latitude_and_longitude
def existing_restaurant(yelp_url)
restaurants.where(yelp_url: yelp_url).first
end
def address=(address)
- binding.pry
self.latitude, self.longitude = Geocoder.coordinates(address)
+
end
+ private
+
+ def validate_latitude_and_longitude
+ if self.latitude == nil || self.longitude == nil
+ self.errors.add(:base, "Not a valid address")
+ end
+ end
end
| Validate that geolocation was successful
|
diff --git a/lib/syoboemon/query_generator/program_detail_search.rb b/lib/syoboemon/query_generator/program_detail_search.rb
index abc1234..def5678 100644
--- a/lib/syoboemon/query_generator/program_detail_search.rb
+++ b/lib/syoboemon/query_generator/program_detail_search.rb
@@ -16,7 +16,7 @@
def generate_query
query = {
- :Commend => "TitleLookup",
+ :Command => "TitleLookup",
:TID => @tid.to_s
}
end
| Fix name of API parameter
|
diff --git a/lib/couch_blog/engine.rb b/lib/couch_blog/engine.rb
index abc1234..def5678 100644
--- a/lib/couch_blog/engine.rb
+++ b/lib/couch_blog/engine.rb
@@ -1,7 +1,9 @@ module CouchBlog
class Engine < ::Rails::Engine
isolate_namespace CouchBlog
- initializer 'couch_blog.cmtool', after: 'cmtool.build_menu' do
+
+ #initializer 'couch_blog.cmtool', after: 'cmtool.build_menu' do
+ config.after_initialize do
if defined? Cmtool
require 'cmtool'
Cmtool::Menu.register do
| Move autoload constant using initializer to after_initialize in application load order for zeitwerj
|
diff --git a/spec/controllers/home_controller_spec.rb b/spec/controllers/home_controller_spec.rb
index abc1234..def5678 100644
--- a/spec/controllers/home_controller_spec.rb
+++ b/spec/controllers/home_controller_spec.rb
@@ -3,9 +3,7 @@ describe HomeController do
render_views
- before(:each) do
- @signup = Factory(:signup)
- end
+ let(:signup) do { email: "test@email.com", contact: true } end
describe "GET 'index'" do
it "returns http success" do
@@ -17,12 +15,12 @@
it "signs up OK" do
lambda do
- post :create, :signup => @signup
+ post :create, :signup => signup
end.should change(Signup, :count).by(1)
end
it "redirects" do
- post :create, :signup => @signup
+ post :create, :signup => signup
response.should redirect_to(root_path)
flash[:done].should == true
end
| Stop using factories in home spec.
|
diff --git a/Rakefile.rb b/Rakefile.rb
index abc1234..def5678 100644
--- a/Rakefile.rb
+++ b/Rakefile.rb
@@ -3,17 +3,17 @@
task :teamcity => [:build]
-msbuild :build do |msb|
- msb.properties :configuration => :Release
- msb.targets [:Clean, :Build]
- msb.solution = 'src/RxFileSystemWatcher.sln'
+build :build do |b|
+ b.prop 'Configuration', 'Release'
+ b.target = [:Clean, :Build]
+ b.sln = 'src/RxFileSystemWatcher.sln'
end
task :nuget => [:test] do
- sh "src/.nuget/nuget pack src/RxFileSystemWatcher/RxFileSystemWatcher.csproj /OutputDirectory " + ENV["NuGetDevFeed"] + " -Prop Configuration=Release"
+ sh "src/.nuget/nuget pack src/RxFileSystemWatcher/RxFileSystemWatcher.csproj -Prop Configuration=Release"
end
-nunit :test => [:build] do |cmd|
- cmd.command = 'src/packages/NUnit.Runners.2.6.3/tools/nunit-console.exe'
- cmd.assemblies = ['src/Tests/bin/Release/Tests.dll']
+test_runner :test => [:build] do |tests|
+ tests.exe = 'src/packages/NUnit.Runners.2.6.3/tools/nunit-console.exe'
+ tests.files = ['src/Tests/bin/Release/Tests.dll']
end | Fix build process to use new version of albacore
|
diff --git a/spec/dummy/app/models/configuration.rb b/spec/dummy/app/models/configuration.rb
index abc1234..def5678 100644
--- a/spec/dummy/app/models/configuration.rb
+++ b/spec/dummy/app/models/configuration.rb
@@ -1,7 +1,7 @@ class Configuration
- def self.fetch(key)
- end
+ def self.[](*); end
- def self.[](key)
- end
+ def self.fetch(*); end
+
+ def self.table_name(*); end
end
| Define dummy .table_name method for Configuration support class
|
diff --git a/spec/github_cli/commands/hooks_spec.rb b/spec/github_cli/commands/hooks_spec.rb
index abc1234..def5678 100644
--- a/spec/github_cli/commands/hooks_spec.rb
+++ b/spec/github_cli/commands/hooks_spec.rb
@@ -0,0 +1,45 @@+# encoding: utf-8
+
+require 'spec_helper'
+
+describe GithubCLI::Commands::Hooks do
+ let(:format) { 'table' }
+ let(:user) { 'peter-murach' }
+ let(:repo) { 'github_cli' }
+ let(:id) { 1 }
+ let(:api_class) { GithubCLI::Hook }
+
+ it "invokes hook:list" do
+ api_class.should_receive(:all).with(user, repo, {}, format)
+ subject.invoke "hook:list", [user, repo]
+ end
+
+ it "invokes hook:get" do
+ api_class.should_receive(:get).with(user, repo, id, {}, format)
+ subject.invoke "hook:get", [user, repo, id]
+ end
+
+ it "invokes hook:create --name --config" do
+ api_class.should_receive(:create).with(user, repo, {'name' => 'web',
+ "config" => { :url => "http://example.com/webhook" } }, format)
+ subject.invoke "hook:create", [user, repo], :name => 'web',
+ :config => {:url => "http://example.com/webhook" }
+ end
+
+ it "invokes hook:edit --name --config" do
+ api_class.should_receive(:edit).with(user, repo, id, {'name' => 'web',
+ "config" => { :url => "http://example.com/webhook" } }, format)
+ subject.invoke "hook:edit", [user, repo, id], :name => 'web',
+ :config => {:url => "http://example.com/webhook" }
+ end
+
+ it "invokes hook:test" do
+ api_class.should_receive(:test).with(user, repo, id, {}, format)
+ subject.invoke "hook:test", [user, repo, id]
+ end
+
+ it "invokes hook:delete" do
+ api_class.should_receive(:delete).with(user, repo, id, {}, format)
+ subject.invoke "hook:delete", [user, repo, id]
+ end
+end
| Add specs for hook commands.
|
diff --git a/spec/support/authentication_helpers.rb b/spec/support/authentication_helpers.rb
index abc1234..def5678 100644
--- a/spec/support/authentication_helpers.rb
+++ b/spec/support/authentication_helpers.rb
@@ -9,6 +9,6 @@
RSpec.configure do |config|
config.include AuthenticationHelpers, type: :feature
- config.include Devise::TestHelpers, type: :controller
- config.include Rack::Test::Methods, type: :feature
+ config.include Devise::Test::ControllerHelpers, type: :controller
+ config.include Rack::Test::Methods, type: :feature
end
| Correct Devise test helpers deprecation warning
Example deprecation warning:
DEPRECATION WARNING: [Devise] including `Devise::TestHelpers` is deprecated and will be removed from Devise.
For controller tests, please include `Devise::Test::ControllerHelpers` instead.
(called from <top (required)> at /home/andrew/dev/solidus_auth_devise/spec/controllers/spree/checkout_controller_spec.rb:1)
|
diff --git a/app/models/spree/issue.rb b/app/models/spree/issue.rb
index abc1234..def5678 100644
--- a/app/models/spree/issue.rb
+++ b/app/models/spree/issue.rb
@@ -21,4 +21,15 @@ def shipped?
!shipped_at.nil?
end
+
+ def magazine
+ # override getter method to include deleted products, as per https://github.com/radar/paranoia
+ Spree::Product.unscoped { super }
+ end
+
+ def magazine_issue
+ # override getter method to include deleted products, as per https://github.com/radar/paranoia
+ Spree::Product.unscoped { super }
+ end
+
end
| Allow Issue to get deleted Magazine and Mag_Issue
The `paranoia` gem adds a `default_scope` to `Spree::Product` that hides all deleted Products.
However, I can imagine that a site admin might want to see all the issues in a subscription even if those products are old and have been deleted.
This syntax allows the getter methods to use the unscoped versions of the Product model.
Note that this applies to `Issue.first.magazine` but does _not_ apply to `Issue.includes(:magazine).first.magazine` -- this is a known and outstanding issue in the `paranoia` gem. |
diff --git a/lib/resource_kit/action_invoker.rb b/lib/resource_kit/action_invoker.rb
index abc1234..def5678 100644
--- a/lib/resource_kit/action_invoker.rb
+++ b/lib/resource_kit/action_invoker.rb
@@ -17,7 +17,7 @@
def handle_response
if handler = action.handlers[response.status]
- handler.call(response)
+ context.instance_exec(response, &handler)
else
response.body
end
| Use instance exec for handler calls.
|
diff --git a/client/ruby/solrb/lib/solr/exception.rb b/client/ruby/solrb/lib/solr/exception.rb
index abc1234..def5678 100644
--- a/client/ruby/solrb/lib/solr/exception.rb
+++ b/client/ruby/solrb/lib/solr/exception.rb
@@ -11,18 +11,5 @@ # limitations under the License.
module Solr
-
- class Exception < Exception
- attr_reader :message
-
- def initialize(message)
- @message = message
- end
-
- def to_s
- @message
- end
-
- end
-
+ class Exception < Exception; end
end
| Simplify Solr::Exception - Exception already allows for a message
git-svn-id: 3b1ff1236863b4d63a22e4dae568675c2e247730@501318 13f79535-47bb-0310-9956-ffa450edef68
|
diff --git a/app/models/folder_node.rb b/app/models/folder_node.rb
index abc1234..def5678 100644
--- a/app/models/folder_node.rb
+++ b/app/models/folder_node.rb
@@ -3,7 +3,7 @@ belongs_to :node_object, :class_name => "TreeFolder"
def self.get(sortvar = nil,sortorder =nil,user_id = nil,show = nil,parent_id = nil,search=nil)
- includes(:tree_folders).where(['type = ? and tree_folders.parent_id is NULL',self.to_s])
+ joins(:folder).where(['type = ? and tree_folders.parent_id is NULL',self.to_s])
end
def get_name
| Fix ActiveRecord calls in FolderNode
|
diff --git a/app/models/image_asset.rb b/app/models/image_asset.rb
index abc1234..def5678 100644
--- a/app/models/image_asset.rb
+++ b/app/models/image_asset.rb
@@ -18,7 +18,7 @@ # A predicate to checks if the image is portrait i.e. taller than it is wide.
#
# @return [true, false]
- def landscape?
+ def portrait?
orientation == :portrait
end
@@ -26,12 +26,12 @@ # same.
#
# @return [true, false]
- def landscape?
+ def square?
orientation == :square
end
# Calculates the orientation of the image based on the width and height. If
- # for some reason the width/height attributes couldn't be stored, it will
+ # for some reason the width/height attributes couldn't be stored, it will
# return :unknown
#
# @return [:landscape, :portrait, :square, :unknown]
| Fix the portrait? and square? predicates
|
diff --git a/lib/mimemagic/overlay.rb b/lib/mimemagic/overlay.rb
index abc1234..def5678 100644
--- a/lib/mimemagic/overlay.rb
+++ b/lib/mimemagic/overlay.rb
@@ -1,7 +1,7 @@ # Extra magic
-[['application/vnd.openxmlformats-officedocument.presentationml.presentation', [[0..2000, 'ppt/']]],
- ['application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', [[0..2000, 'xl/']]],
- ['application/vnd.openxmlformats-officedocument.wordprocessingml.document', [[0..2000, 'word/']]]].each do |magic|
+[['application/vnd.openxmlformats-officedocument.presentationml.presentation', [[0..5000, 'ppt/']]],
+ ['application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', [[0..5000, 'xl/']]],
+ ['application/vnd.openxmlformats-officedocument.wordprocessingml.document', [[0..5000, 'word/']]]].each do |magic|
MimeMagic.add(magic[0], magic: magic[1])
end
| Extend the range we search
Sometimes the first instance of the word/ or ppt/ is not in the first 2000 bytes - 5000 should cover it. |
diff --git a/lib/mspec/helpers/tmp.rb b/lib/mspec/helpers/tmp.rb
index abc1234..def5678 100644
--- a/lib/mspec/helpers/tmp.rb
+++ b/lib/mspec/helpers/tmp.rb
@@ -1,3 +1,5 @@+require 'mspec/helpers/fs'
+
# Creates a temporary directory in the current working directory
# for temporary files created while running the specs. All specs
# should clean up any temporary files created so that the temp
@@ -8,6 +10,9 @@ SPEC_TEMP_UNIQUIFIER = "0"
SPEC_TEMP_DIR_PID = Process.pid
+
+# Clean it up when starting MSpec
+rm_r SPEC_TEMP_DIR
at_exit do
begin
| Clean SPEC_TEMP_DIR when starting mspec
* Idea by @nirvdrum.
|
diff --git a/lib/chronologic.rb b/lib/chronologic.rb
index abc1234..def5678 100644
--- a/lib/chronologic.rb
+++ b/lib/chronologic.rb
@@ -2,3 +2,14 @@ require 'chronologic/connection'
require 'chronologic/server'
require 'chronologic/version'
+
+require "active_support/core_ext/module"
+
+module Chronologic
+
+ VERSION = "0.1.0"
+
+ mattr_accessor :connection
+ mattr_accessor :client
+
+end
| Add connection (for the service) and client attributes.
|
diff --git a/lib/fat_table/patches.rb b/lib/fat_table/patches.rb
index abc1234..def5678 100644
--- a/lib/fat_table/patches.rb
+++ b/lib/fat_table/patches.rb
@@ -15,3 +15,21 @@ end
end
end
+
+unless ''.respond_to?(:match?)
+ # Add String#match? to pre-2.4 ruby
+ class String
+ def match?(re)
+ self =~ re
+ end
+ end
+end
+
+unless //.respond_to?(:match?)
+ # Add Regexp#match? to pre-2.4 ruby
+ class Regexp
+ def match?(str)
+ self =~ re
+ end
+ end
+end
| Patch pre 2.4 ruby for match? method.
|
diff --git a/lib/idnow/http_client.rb b/lib/idnow/http_client.rb
index abc1234..def5678 100644
--- a/lib/idnow/http_client.rb
+++ b/lib/idnow/http_client.rb
@@ -1,26 +1,27 @@ module Idnow
class HttpClient
- def initialize(host:)
- @uri = URI.parse(host)
+ def initialize(host:, read_timout_sec: 30)
+ @uri = URI.parse(host)
+ @read_timeout = read_timout_sec
end
def execute(request, headers = {})
headers.each do |k, v|
request[k] = v
end
- begin
- client.request(request)
- rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError,
- Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e
- raise Idnow::ConnectionException, e
- end
+
+ client.request(request)
+ rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError,
+ Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e
+ raise Idnow::ConnectionException, e
end
private
def client
Net::HTTP.new(@uri.host, @uri.port).tap do |http|
- http.use_ssl = true
+ http.read_timeout = @read_timeout
+ http.use_ssl = true
end
end
end
| Introduce 30 second default timeout
|
diff --git a/lib/rchess/board_math.rb b/lib/rchess/board_math.rb
index abc1234..def5678 100644
--- a/lib/rchess/board_math.rb
+++ b/lib/rchess/board_math.rb
@@ -16,10 +16,7 @@ end
def letter_difference(start_file, end_file)
- start_index = LETTERS.index(start_file)
- end_index = LETTERS.index(end_file)
-
- end_index - start_index
+ LETTERS.index(end_file) - LETTERS.index(start_file)
end
def rank_difference(start_rank, end_rank)
| Simplify helper function in board math
|
diff --git a/lib/regaliator/client.rb b/lib/regaliator/client.rb
index abc1234..def5678 100644
--- a/lib/regaliator/client.rb
+++ b/lib/regaliator/client.rb
@@ -2,7 +2,7 @@ class Client
attr_accessor :config
- def initialize(config)
+ def initialize(config = Regaliator.configuration)
@config = config
end
end
| Use the default configuration in Client.
|
diff --git a/lib/thailand/district.rb b/lib/thailand/district.rb
index abc1234..def5678 100644
--- a/lib/thailand/district.rb
+++ b/lib/thailand/district.rb
@@ -22,5 +22,10 @@ def self.query_collection
all
end
+
+ alias_method :tambon, :subregions
+ alias_method :tambon?, :subregions?
+ alias_method :khwaeng, :subregions
+ alias_method :khwaeng?, :subregions?
end
end
| Add alias methods for District
|
diff --git a/spec/acceptance/10_basic_ironic_spec.rb b/spec/acceptance/10_basic_ironic_spec.rb
index abc1234..def5678 100644
--- a/spec/acceptance/10_basic_ironic_spec.rb
+++ b/spec/acceptance/10_basic_ironic_spec.rb
@@ -21,20 +21,13 @@ apply_manifest(pp, :catch_changes => true)
end
- if os[:family].casecmp('RedHat') == 0
- # Ironic API port
- describe port(6385) do
- it { is_expected.to be_listening }
- end
- # Inspector API port
- describe port(5050) do
- it { is_expected.to be_listening.with('tcp') }
- end
- else # Inspector is not packaged, so only test Ironic
- # Ironic API port
- describe port(6385) do
- it { is_expected.to be_listening }
- end
+ # Ironic API port
+ describe port(6385) do
+ it { is_expected.to be_listening }
+ end
+ # Inspector API port
+ describe port(5050) do
+ it { is_expected.to be_listening.with('tcp') }
end
end
| Debian/Ubuntu: Validate inspector in acceptance test
... because now the service is enabled.
Depends-on: https://review.opendev.org/848512/
Change-Id: I41caaa22dd0f7879acac757bf695935714318fa3
|
diff --git a/spec/features/assigned_articles_spec.rb b/spec/features/assigned_articles_spec.rb
index abc1234..def5678 100644
--- a/spec/features/assigned_articles_spec.rb
+++ b/spec/features/assigned_articles_spec.rb
@@ -0,0 +1,32 @@+# frozen_string_literal: true
+
+require 'rails_helper'
+
+describe 'Assigned Articles view', type: :feature, js: true do
+ let(:course) { create(:course) }
+ let(:user) { create(:user, username: 'Ragesoss') }
+ let(:article) { create(:article, title: 'Nancy_Tuana') }
+
+ before do
+ login_as(user)
+ course.campaigns << Campaign.first
+ create(:courses_user, course: course, user: user)
+ create(:assignment, article_title: 'Nancy_Tuana',
+ course: course, article: article,
+ user: user)
+ end
+
+ it 'lets users submit feedback about articles' do
+ # Since this makes a call to the ORES API from the server,
+ # we need to use VCR to avoid getting stopped by WebMock
+ VCR.use_cassette('assigned_articles_view') do
+ visit "/courses/#{course.slug}/articles/assigned"
+ expect(page).to have_content('Nancy Tuana')
+ find('a', text: 'Feedback').click
+ find('textarea.feedback-form').fill_in with: 'This is a great article!'
+ click_button 'Add Suggestion'
+ find('a', text: 'Delete').click
+ expect(page).not_to have_content('This is a great article!')
+ end
+ end
+end
| Add spec for Assigned Articles view and Feedback feature
|
diff --git a/spec/unit/provider/user/useradd_spec.rb b/spec/unit/provider/user/useradd_spec.rb
index abc1234..def5678 100644
--- a/spec/unit/provider/user/useradd_spec.rb
+++ b/spec/unit/provider/user/useradd_spec.rb
@@ -37,11 +37,4 @@ }
include_examples "a useradd-based user provider", supported_useradd_options
-
- describe "manage_user" do
- it "should not run the command if universal_options is an empty array" do
- provider.stub!(:universal_options).and_return([])
- expect(provider.manage_user).not_to receive(:compile_command)
- end
- end
end
| Remove super random failing test cruft from previous commit
|
diff --git a/lib/jakyll-slim.rb b/lib/jakyll-slim.rb
index abc1234..def5678 100644
--- a/lib/jakyll-slim.rb
+++ b/lib/jakyll-slim.rb
@@ -14,13 +14,7 @@ end
def convert(content)
- Slim::Template.new { content }.render
- end
- end
-
- class SlimLogicLessConverter < SlimConverter
- def convert(content)
- Slime::Template.new(:logic_less => true) { content }.render
+ Slim::Template.new(@config) { content }.render
end
end
end
| Remove SlimLogicLessConverter in favor of @config
|
diff --git a/config/initializers/restrict_parsers.rb b/config/initializers/restrict_parsers.rb
index abc1234..def5678 100644
--- a/config/initializers/restrict_parsers.rb
+++ b/config/initializers/restrict_parsers.rb
@@ -0,0 +1,4 @@+# Turn off XML parsing:
+# https://groups.google.com/forum/#!topic/rubyonrails-security/61bkgvnSGTQ/discussion
+ActionDispatch::ParamsParser::DEFAULT_PARSERS.delete(Mime::XML)
+ActionDispatch::ParamsParser::DEFAULT_PARSERS.delete(Mime::JSON) | Disable param parsers we don't use
These parsers have security vulnerabilities.
|
diff --git a/rb/spec/integration/selenium/webdriver/browser_connection_spec.rb b/rb/spec/integration/selenium/webdriver/browser_connection_spec.rb
index abc1234..def5678 100644
--- a/rb/spec/integration/selenium/webdriver/browser_connection_spec.rb
+++ b/rb/spec/integration/selenium/webdriver/browser_connection_spec.rb
@@ -3,16 +3,16 @@ describe "Driver" do
context "browser connection" do
- compliant_on :browser => nil do
- it "can set the browser offline and online" do
+ compliant_on :browser => :android do
+ it "can set the browser offline and online" do
driver.navigate.to url_for("html5Page.html")
driver.should be_online
driver.online = false
- driver.should_not be_online
+ wait.until { not driver.online? }
driver.online = true
- driver.should be_online
+ wait.until { driver.online? }
end
end
| JariBakken: Enable browser connection spec on Android.
git-svn-id: 4179480af2c2519a5eb5e1e9b541cbdf5cf27696@15725 07704840-8298-11de-bf8c-fd130f914ac9
|
diff --git a/lib/liquid/i18n.rb b/lib/liquid/i18n.rb
index abc1234..def5678 100644
--- a/lib/liquid/i18n.rb
+++ b/lib/liquid/i18n.rb
@@ -1,5 +1,4 @@ require 'yaml'
-require 'delegate'
module Liquid
class I18n
| Remove delegate require from localization
|
diff --git a/lib/pixi_client.rb b/lib/pixi_client.rb
index abc1234..def5678 100644
--- a/lib/pixi_client.rb
+++ b/lib/pixi_client.rb
@@ -1,4 +1,5 @@ require 'pixi_client/version'
+require 'pixi_client/error'
require 'pixi_client/configuration'
require 'pixi_client/response_parser'
require 'pixi_client/response'
| Include the error class in the client
|
diff --git a/lib/proteus/kit.rb b/lib/proteus/kit.rb
index abc1234..def5678 100644
--- a/lib/proteus/kit.rb
+++ b/lib/proteus/kit.rb
@@ -17,8 +17,12 @@ if system "git ls-remote #{url(kit_name)} #{repo_name} > /dev/null 2>&1"
puts "Starting a new proteus-#{kit_name} project in #{repo_name}"
system "git clone #{url(kit_name)}#{' ' + repo_name} && "\
- "rm -rf #{repo_name}/.git && "\
- "git init #{repo_name}"
+ "cd #{repo_name} && "\
+ "rm -rf .git && "\
+ "git init && "\
+ "git add . && "\
+ "git commit -am 'New proteus-#{kit_name} project' && "\
+ "cd -"
else
puts "A thoughtbot repo doesn't exist with that name"
end
| Make a first commit for the user
|
diff --git a/lib/paypal_express/ext/active_merchant/active_merchant.rb b/lib/paypal_express/ext/active_merchant/active_merchant.rb
index abc1234..def5678 100644
--- a/lib/paypal_express/ext/active_merchant/active_merchant.rb
+++ b/lib/paypal_express/ext/active_merchant/active_merchant.rb
@@ -13,6 +13,26 @@ def successful?(response)
response[:error_codes] == DUPLICATE_REQUEST_CODE ? false : original_successful?(response)
end
+
+ # Note: ActiveMerchant is missing InvoiceID in RefundTransactionReq.
+ # See https://github.com/activemerchant/active_merchant/blob/v1.48.0/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb#L314
+ def build_refund_request(money, identification, options)
+ xml = Builder::XmlMarkup.new
+
+ xml.tag! 'RefundTransactionReq', 'xmlns' => PAYPAL_NAMESPACE do
+ xml.tag! 'RefundTransactionRequest', 'xmlns:n2' => EBAY_NAMESPACE do
+ xml.tag! 'n2:Version', API_VERSION
+ xml.tag! 'TransactionID', identification
+ xml.tag! 'Amount', amount(money), 'currencyID' => (options[:currency] || currency(money)) if money.present?
+ xml.tag! 'RefundType', (options[:refund_type] || (money.present? ? 'Partial' : 'Full'))
+ xml.tag! 'Memo', options[:note] unless options[:note].blank?
+ xml.tag! 'InvoiceID', (options[:order_id] || options[:invoice_id]) unless (options[:order_id] || options[:invoice_id]).blank?
+ end
+ end
+
+ xml.target!
+ end
+
end
end
end
| Add invoice_id in refund call
|
diff --git a/app/controllers/georgia/users_controller.rb b/app/controllers/georgia/users_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/georgia/users_controller.rb
+++ b/app/controllers/georgia/users_controller.rb
@@ -22,12 +22,12 @@ end
def create
- @user = User.new(params[:user])
+ @user = User.new(user_params)
if @user.save
redirect_to users_url, notice: "User was successfully created."
else
- render 'new'
+ render :new
end
end
@@ -35,10 +35,10 @@ @user = User.find(params[:id])
params[:user].delete(:password) if params[:user][:password].blank?
params[:user].delete(:password_confirmation) if params[:user][:password].blank? and params[:user][:password_confirmation].blank?
- if @user.update_attributes(params[:user])
+ if @user.update(user_params)
redirect_to users_url, notice: "User was successfully updated."
else
- render 'edit'
+ render :edit
end
end
@@ -48,6 +48,12 @@ redirect_to users_url, notice: "User was successfully deleted."
end
+ private
+
+ def user_params
+ params.require(:user).permit(:first_name, :last_name, :email, :password, :password_confirmation, :role_id, :receives_notifications)
+ end
+
end
end | Add strong parameters users controller
|
diff --git a/lib/ssrs/report.rb b/lib/ssrs/report.rb
index abc1234..def5678 100644
--- a/lib/ssrs/report.rb
+++ b/lib/ssrs/report.rb
@@ -22,7 +22,7 @@ document = self.document
REXML::XPath.each(document.root, "//Report/DataSources/DataSource/DataSourceReference") do |element|
text_node = element.get_text
- text_node.value = "#{SSRS.upload_prefix}/#{DataSource::BASE_PATH}/#{text_node.value}"
+ text_node.value = "#{SSRS::Config.upload_prefix}/#{DataSource::BASE_PATH}/#{text_node.value}"
end
document
end
| Use config to get upload prefix
|
diff --git a/lib/tasks/iso.rake b/lib/tasks/iso.rake
index abc1234..def5678 100644
--- a/lib/tasks/iso.rake
+++ b/lib/tasks/iso.rake
@@ -1,4 +1,26 @@ namespace :iso do
+ namespace :maintenance do
+ task :repair_image_permissions => :environment do
+ bucket = $s3_client.buckets.find(ENV['S3_BUCKET'])
+ to_fix = []
+ Photograph.find_each do |p|
+ #if p.image_uid =~ /2013\//
+ to_fix << p
+ #end
+ end
+
+ to_fix.each do |p|
+ begin
+ obj = bucket.objects.find(p.image_uid)
+ obj.copy(key: p.image_uid, bucket: bucket, acl: :private)
+ puts "Updated ACL for ##{p.id}: #{p.image_uid}"
+ rescue S3::Error::NoSuchKey
+ puts "No such key ##{p.id}: #{p.image_uid}"
+ end
+ end
+ end
+ end
+
namespace :rankings do
task :adjust_scores => :environment do
Photograph.adjust_scores
| Add photo maintenance rake task for repairing permissions
|
diff --git a/lib/twitter_api.rb b/lib/twitter_api.rb
index abc1234..def5678 100644
--- a/lib/twitter_api.rb
+++ b/lib/twitter_api.rb
@@ -8,7 +8,7 @@ end
def self.rorjobs_tweets
- client.user_timeline('rorjobs', count: 10, exclude_replies: true, include_rts: false)
+ client.user_timeline('rorjobs', count: 20, exclude_replies: true, include_rts: false)
end
def self.client
| Increase number of ROR jobs tweets on home page to 20 at a time.
|
diff --git a/metasploit-erd.gemspec b/metasploit-erd.gemspec
index abc1234..def5678 100644
--- a/metasploit-erd.gemspec
+++ b/metasploit-erd.gemspec
@@ -4,21 +4,22 @@ require 'metasploit/erd/version'
Gem::Specification.new do |spec|
- spec.name = "metasploit-erd"
+ spec.name = 'metasploit-erd'
spec.version = Metasploit::ERD::VERSION
- spec.authors = ["Luke Imhoff"]
- spec.email = ["luke_imhoff@rapid7.com"]
- spec.summary = %q{TODO: Write a short summary. Required.}
- spec.description = %q{TODO: Write a longer description. Optional.}
- spec.homepage = ""
+ spec.authors = ['Luke Imhoff']
+ spec.email = ['luke_imhoff@rapid7.com']
+ spec.summary = 'Extensions to rails-erd to find clusters of models to generate subdomains specific to each model'
+ spec.description = 'Traces the belongs_to associations on ActiveRecord::Base descendants to find the minimum ' \
+ 'cluster in which all foreign keys are fulfilled in the Entity-Relationship Diagram.'
+ spec.homepage = 'https://github.com/rapid7/metasploit-erd'
spec.license = "MIT"
spec.files = `git ls-files -z`.split("\x0")
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
- spec.require_paths = ["lib"]
+ spec.require_paths = ['lib']
- spec.add_development_dependency "bundler", "~> 1.5"
- spec.add_development_dependency "rake"
- spec.add_development_dependency "rspec"
+ spec.add_development_dependency 'bundler', '~> 1.5'
+ spec.add_development_dependency 'rake', '~> 10.3'
+ spec.add_development_dependency 'rspec', '~> 2.14'
end
| Add semantic version restrictions to gemspec
MSP-9815
Add `~>` versions to eliminate warnings from `gem build`.
|
diff --git a/controller.rb b/controller.rb
index abc1234..def5678 100644
--- a/controller.rb
+++ b/controller.rb
@@ -12,6 +12,9 @@ end
end
+ignore *%w{.gitignore LICENSE Gemfile Gemfile.lock Rakefile}
+ignore(/\.swp$/, %r{/\.git/}, %r{/\.sass-cache/})
+
before 'index.html.haml' do
@buttons = %w{Buttoner HidingButtoner}.map do |func_name|
Button.new func_name
| Exclude some junk from output directory
|
diff --git a/lib/apns-s3.rb b/lib/apns-s3.rb
index abc1234..def5678 100644
--- a/lib/apns-s3.rb
+++ b/lib/apns-s3.rb
@@ -24,7 +24,7 @@ bucketname: nil,
filename: nil
)
- unless pemfile_exist? filename
+ unless File.exist? filename
credentials = Aws::Credentials.new(
aws_access_key_id, aws_secret_access_key
)
@@ -34,8 +34,4 @@ end
APNS.pem = filename
end
-
- def self.pemfile_exist? filename
- File.exist? filename
- end
end
| Revert the commit that modifies to pemfile_exist? method
|
diff --git a/lib/bouvier.rb b/lib/bouvier.rb
index abc1234..def5678 100644
--- a/lib/bouvier.rb
+++ b/lib/bouvier.rb
@@ -4,14 +4,14 @@ module Bouvier
class Client
-
+
include HTTParty
format :xml
- base_uri "http://www.eot.state.ma.us"
+ base_uri "http://www.massdot.state.ma.us"
# Bouvier::Client.branches
def self.branches
- response = get('/developers/downloads/qmaticXML.aspx')
+ response = get('/feeds/qmaticxml/qmaticXML.aspx')
Hashie::Mash.new(response['branches']).branch
end
| Update to use new URLs. |
diff --git a/lib/caprese.rb b/lib/caprese.rb
index abc1234..def5678 100644
--- a/lib/caprese.rb
+++ b/lib/caprese.rb
@@ -23,7 +23,7 @@ config.only_path_links ||= true
# If true, relationship data will not be serialized unless it is in `include`
- config.optimize_relationships ||= true
+ config.optimize_relationships ||= false
# Defines the translation scope for model and controller errors
config.i18n_scope ||= '' # 'api.v1.errors'
| Remove relationship optimization by default
Mostly because it is not JSON API compliant and that should be opt-in
|
diff --git a/refinerycms-acts-as-indexed.gemspec b/refinerycms-acts-as-indexed.gemspec
index abc1234..def5678 100644
--- a/refinerycms-acts-as-indexed.gemspec
+++ b/refinerycms-acts-as-indexed.gemspec
@@ -13,7 +13,7 @@
s.files = `git ls-files -- app/* lib/*`.split("\n")
- s.add_dependency 'refinerycms-core', ['>= 3.0.0', '< 4.0']
+ s.add_dependency 'refinerycms-core', ['>= 3.0.0', '< 5.0']
s.add_dependency 'acts_as_indexed', '~> 0.8.0'
s.add_dependency 'decorators', '~> 2.0.0'
s.add_dependency 'stringex', '~> 2.5.2'
| Allow refinerycms-core version from >= 3.0.0 to < 5.0 |
diff --git a/lib/instana.rb b/lib/instana.rb
index abc1234..def5678 100644
--- a/lib/instana.rb
+++ b/lib/instana.rb
@@ -19,8 +19,14 @@ def start
@agent = Instana::Agent.new
@collectors = []
+
@logger = Logger.new(STDOUT)
- @logger.info "Stan is on the scene. Starting Instana instrumentation."
+ if ENV.key?('INSTANA_GEM_TEST') || ENV.key?('INSTANA_GEM_DEV')
+ @logger.level = Logger::DEBUG
+ else
+ @logger.level = Logger::WARN
+ end
+ @logger.unknown "Stan is on the scene. Starting Instana instrumentation."
# Store the current pid so we can detect a potential fork
# later on
| Set log level according to environment
|
diff --git a/lib/rdg/cfg.rb b/lib/rdg/cfg.rb
index abc1234..def5678 100644
--- a/lib/rdg/cfg.rb
+++ b/lib/rdg/cfg.rb
@@ -31,6 +31,7 @@ def vertices
@context.graph.each_vertex.to_a
end
+ alias_method :nodes, :vertices
def successors(v)
@context.graph.each_adjacent(v).to_a
| Add nodes as an alias for vertices.
|
diff --git a/lib/tachyon.rb b/lib/tachyon.rb
index abc1234..def5678 100644
--- a/lib/tachyon.rb
+++ b/lib/tachyon.rb
@@ -13,30 +13,8 @@ end
def self.insert_record(klass, data)
- if klass.has_attribute?(:created_at) && klass.has_attribute?(:updated_at)
- defaults = { created_at: Time.now, updated_at: Time.now }.with_indifferent_access
- data = defaults.merge(data.with_indifferent_access)
- end
-
- table = klass.arel_table
- mapped_data = data.map do |key, value|
- [table[key], value]
- end
-
-
- insert = Arel::InsertManager.new
- insert.into(table)
- insert.insert(mapped_data)
-
begin
- begin
- klass.connection.execute(insert.to_sql)
- rescue ArgumentError
- # If we can't generate the insert using Arel (likely because
- # of an issue with a serialized attribute) then fall back
- # to safe but slow behaviour.
klass.new(data).save(validate: false)
- end
rescue ActiveRecord::RecordNotUnique
end
end
| Revert to naive implementation as existing implementation does not work.
|
diff --git a/lib/bra/model/view.rb b/lib/bra/model/view.rb
index abc1234..def5678 100644
--- a/lib/bra/model/view.rb
+++ b/lib/bra/model/view.rb
@@ -21,7 +21,7 @@ def_delegator :@root, :deregister_from_updates
# Logs an error message in the bra log
- #
+ #
# @api public
# @example Log an error.
# view.log(:error, 'The system is down!')
@@ -43,7 +43,7 @@ #
# @return [ModelObject] The found model object.
def find(url, &block)
- Compo::UrlFinder.find(@root, url, &block)
+ Compo::Finders::Url.find(@root, url, &block)
end
end
end
| Update compo URL finder use.
This moved in a recent version of compo.
|
diff --git a/nexmo.gemspec b/nexmo.gemspec
index abc1234..def5678 100644
--- a/nexmo.gemspec
+++ b/nexmo.gemspec
@@ -11,5 +11,6 @@ s.required_ruby_version = '>= 1.9.3'
s.add_development_dependency('rake', '~> 10.1')
s.add_development_dependency('webmock', '~> 1.18')
+ s.add_development_dependency('minitest', '~> 5.0')
s.require_path = 'lib'
end
| Add minitest as a development dependency
|
diff --git a/lib/features2cards.rb b/lib/features2cards.rb
index abc1234..def5678 100644
--- a/lib/features2cards.rb
+++ b/lib/features2cards.rb
@@ -15,30 +15,55 @@ require "cucumber"
require "cucumber/treetop_parser/feature_en"
Cucumber.load_language("en")
+
+ Cucumber::Tree::Feature.class_eval do
+ attr_reader :scenarios
+ end
end
def execute
file = ARGV.first
- parser = ::Cucumber::TreetopParser::FeatureParser.new
+ parser = Cucumber::TreetopParser::FeatureParser.new
+
features = parser.parse_feature(file)
- generate_pdf
+ generate_pdf(features)
end
- def generate_pdf
+ def generate_pdf(features)
Prawn::Document.generate("cards.pdf", :page_layout => :landscape) do
- columns = 2
- rows = 2
height = 72 * 3
width = 72 * 5
- rows.downto(1) do |row|
- columns.times do |col|
- bounding_box [width * col, height * row], :width => width, :height => height do
- stroke_rectangle [bounds.left, bounds.top], bounds.width, bounds.height
+ card_margin = 18
+ card_margin2 = 36
+ row = 2
+ col = 0
+
+ features.scenarios.first(4).each do |scenario|
+ bounding_box [width * col, height * row], :width => width, :height => height do
+ stroke_rectangle bounds.top_left, bounds.width, bounds.height
+
+ bounding_box [bounds.left + card_margin, bounds.top - card_margin],
+ :width => width - (card_margin * 2), :height => height - (card_margin * 2) do
+
+ text "Scenario: ", :size => 14
+
+ bounding_box [bounds.left + card_margin2, bounds.top - card_margin2],
+ :width => bounds.width - (card_margin2 * 2), :height => bounds.height - (card_margin2 * 2) do
+ text scenario.name, :size => 16, :align => :center
+ end
end
+ end
+
+ col += 1
+
+ if col > 1
+ col = 0
+ row -= 1
end
end
end
+
end
end | Print scenario titles on cards
|
diff --git a/app/forms/create_taxon.rb b/app/forms/create_taxon.rb
index abc1234..def5678 100644
--- a/app/forms/create_taxon.rb
+++ b/app/forms/create_taxon.rb
@@ -13,7 +13,7 @@ title: title,
content_id: content_id,
publishing_app: 'collections-publisher',
- rendering_app: 'collections-publisher',
+ rendering_app: 'collections',
public_updated_at: Time.now,
routes: [
{ path: base_path, type: "exact" },
| Use `collections` as rendering app for taxons
This app will return 404.
|
diff --git a/app/models/application.rb b/app/models/application.rb
index abc1234..def5678 100644
--- a/app/models/application.rb
+++ b/app/models/application.rb
@@ -22,8 +22,7 @@
INTEREST_OPTIONS = [
'Shaolin Cosmos Chi Kung',
- 'Shaolin Kung Fu',
- 'Tai Chi Chuan'
+ 'Shaolin Kung Fu'
]
def interests_to_a
| Remove Tai Chi Chuan from interests
Since I don't currently teach it
|
diff --git a/spec/transactions_spec.rb b/spec/transactions_spec.rb
index abc1234..def5678 100644
--- a/spec/transactions_spec.rb
+++ b/spec/transactions_spec.rb
@@ -15,5 +15,13 @@
transaction.should be == ["OK", "OK", ["1", "2"]]
end
+
+ it "should execute all command after multi" do
+ @client.multi
+ @client.set("key1", "1")
+ @client.set("key2", "2")
+ @client.mget("key1", "key2")
+ @client.exec.should be == ["OK", "OK", ["1", "2"]]
+ end
end
end
| Add tests for `multi` command without block given.
|
diff --git a/lib/wakame/command.rb b/lib/wakame/command.rb
index abc1234..def5678 100644
--- a/lib/wakame/command.rb
+++ b/lib/wakame/command.rb
@@ -17,8 +17,8 @@ }
end
- def initialize(option)
- @options = option
+ def options=(path)
+ @options = path
end
def parse(args)
| Change parameter passing to WEB API
|
diff --git a/rails/benchmarks/bm_activerecord_create_string_columns.rb b/rails/benchmarks/bm_activerecord_create_string_columns.rb
index abc1234..def5678 100644
--- a/rails/benchmarks/bm_activerecord_create_string_columns.rb
+++ b/rails/benchmarks/bm_activerecord_create_string_columns.rb
@@ -0,0 +1,31 @@+require 'bundler/setup'
+require 'active_record'
+require_relative 'support/benchmark_rails'
+
+ActiveRecord::Base.establish_connection(ENV['DATABASE_URL'])
+
+ActiveRecord::Migration.verbose = false
+
+COUNT = 25
+
+ActiveRecord::Schema.define do
+ create_table :users, force: true do |t|
+ COUNT.times do |i|
+ t.string :"column#{i}"
+ end
+
+ t.timestamps null: false
+ end
+end
+
+class User < ActiveRecord::Base; end
+
+attributes = {}
+
+COUNT.times do |i|
+ attributes[:"column#{i}"] = "Some string #{i}"
+end
+
+Benchmark.rails("activerecord/#{db_adapter}_create_string_columns", time: 5) do
+ User.create!(attributes)
+end
| FEATURE: Add new benchmark for Active Record.
* Creating a record with many string columns.
|
diff --git a/api/v3/routes/problems.rb b/api/v3/routes/problems.rb
index abc1234..def5678 100644
--- a/api/v3/routes/problems.rb
+++ b/api/v3/routes/problems.rb
@@ -2,24 +2,24 @@ module Routes
class Problems < Core
get '/problems/data-todos' do
- problems = ::Xapi.problems.select { |problem|
+ problems = Trackler.problems.select { |problem|
problem.json_url.nil?
}
pg :"problems/data_todos", locals: {
problems: problems,
- implementations: ::Xapi.implementations,
+ implementations: Trackler.implementations,
}
end
get '/problems/:slug/todo' do |slug|
- implementations = ::Xapi.implementations[slug]
- todos = ::Xapi.tracks.reject { |track|
+ implementations = Trackler.implementations[slug]
+ todos = Trackler.tracks.reject { |track|
track.slugs.include?(slug)
}.map(&:id)
pg :"problem/todos", locals: {
- problem: ::Xapi.problems[slug],
+ problem: Trackler.problems[slug],
todos: todos,
implementations: implementations,
}
| Swap trackler into v3 problem routes
|
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -12,7 +12,13 @@ end
def default_url_options(*)
- { locale: I18n.locale == I18n.default_locale ? nil : I18n.locale }
+ { locale:
+ if !I18n.locale || !available_language?(I18n.locale) ||
+ I18n.locale == I18n.default_locale # omit when default
+ nil
+ else
+ I18n.locale
+ end, }
end
def after_sign_in_path_for(_resource)
| Update lang selection logic for locale param
Signed-off-by: Hiroshi Miura <ff6fb3ed059786151e736af13627c08d24e9f922@linux.com>
|
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -1,3 +1,22 @@+# frozen_string_literal: true
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
+
+ helper_method :current_user, :logged_in?
+
+ before_action :authenticate_user!
+
+ private
+
+ def authenticate_user!
+ redirect_to login_path unless logged_in?
+ end
+
+ def current_user
+ @current_user ||= User.find_by(id: session[:user_id])
+ end
+
+ def logged_in?
+ !current_user.nil?
+ end
end
| Add helpers and before_action for ApplicationController
|
diff --git a/app/controllers/instruments_controller.rb b/app/controllers/instruments_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/instruments_controller.rb
+++ b/app/controllers/instruments_controller.rb
@@ -26,7 +26,7 @@
def update
@instrument = Instrument.find(params[:id])
- if @instrument.update_attributes(instrument_params)
+ if @instrument.update_attributes!(instrument_params)
redirect_to @instrument, notice: "Successfully updated instrument."
else
render :edit
@@ -43,6 +43,6 @@
def instrument_params
params.require(:instrument).permit(:title, questions_attributes: [:text, :question_type,
- :question_identifier, :instrument_id])
+ :question_identifier, :instrument_id, options_attributes: [:question_id, :text]])
end
end
| Add options attributes for nest attributes in instrument controller
|
diff --git a/app/controllers/links/pages_controller.rb b/app/controllers/links/pages_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/links/pages_controller.rb
+++ b/app/controllers/links/pages_controller.rb
@@ -1,6 +1,6 @@ class Links::PagesController < PagesController
def index
- pages = Comfy::Cms::Page.includes(:site).published.filter(params.slice(:category))
+ pages = Comfy::Cms::Page.includes(:site).where('state != ?', 'unpublished').filter(params.slice(:category))
pages = Comfy::Cms::Search.new(pages, params[:search]).results if params[:search].present?
@pages = PageMirror.collect(pages)
| Return anything but unpublished articles through the article link search api |
diff --git a/app/controllers/sales_pages_controller.rb b/app/controllers/sales_pages_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/sales_pages_controller.rb
+++ b/app/controllers/sales_pages_controller.rb
@@ -1,5 +1,6 @@ class SalesPagesController < ApplicationController
before_filter :authenticate_user!, :except => [ :show ]
+ before_filter :get_club_and_sales_page, :only => [ :edit, :update ]
def show
@club = Club.find params[:club_id]
@@ -9,9 +10,21 @@ end
def edit
+ authorize! :update, @sales_page
+ end
+
+ def update
+ authorize! :update, @sales_page
+
+ @sales_page.update_attributes params[:sales_page]
+
+ respond_with_bip @sales_page
+ end
+
+ private
+
+ def get_club_and_sales_page
@sales_page = SalesPage.find params[:id]
@club = @sales_page.club
-
- authorize! :update, @sales_page
end
end
| Update SalesPages Controller for update Action
Add the update action to the SalesPages controller.
|
diff --git a/app/controllers/v1/webhooks_controller.rb b/app/controllers/v1/webhooks_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/v1/webhooks_controller.rb
+++ b/app/controllers/v1/webhooks_controller.rb
@@ -1,3 +1,5 @@+require 'shellwords'
+
module V1
class WebhooksController < BaseController
# No authorization necessary for webhook
| Add missing require for 'shellwords'
|
diff --git a/app/models/translation.rb b/app/models/translation.rb
index abc1234..def5678 100644
--- a/app/models/translation.rb
+++ b/app/models/translation.rb
@@ -26,10 +26,12 @@
def self.data_type(text)
case text
- when Array then 'array'
- when String then 'string'
- when Float then 'float'
- when Integer then 'integer'
+ when Array then 'array'
+ when String then 'string'
+ when Float then 'float'
+ when Integer then 'integer'
+ when TrueClass then 'boolean'
+ when FalseClass then 'boolean'
else nil
end
end
| Set valid type for boolean values
|
diff --git a/app/controllers/analytics_controller.rb b/app/controllers/analytics_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/analytics_controller.rb
+++ b/app/controllers/analytics_controller.rb
@@ -24,4 +24,4 @@ params.permit(users: []).to_h.symbolize_keys
end
-end+end
| Add missing trailing newline in the AnalyticsController
|
diff --git a/app/controllers/favorites_controller.rb b/app/controllers/favorites_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/favorites_controller.rb
+++ b/app/controllers/favorites_controller.rb
@@ -2,12 +2,11 @@ def create
@topic = Topic.find(params[:topic_id])
@post = @topic.posts.find(params[:post_id])
+ favorite = current_user.favorites.build(post: @post)
- authorize Favorite.new
+ authorize favorite
- favorite = current_user.favorites.create(post: @post)
-
- if favorite.valid?
+ if favorite.save
flash[:notice] = "Favorited post"
redirect_to [@topic, @post]
else
| Change favorites controller to be more in line with the roadmap text.
|
diff --git a/app/models/spree/log_entry_decorator.rb b/app/models/spree/log_entry_decorator.rb
index abc1234..def5678 100644
--- a/app/models/spree/log_entry_decorator.rb
+++ b/app/models/spree/log_entry_decorator.rb
@@ -34,7 +34,8 @@ Braintree::Transaction::GooglePayDetails,
Braintree::Transaction::VenmoAccountDetails,
Braintree::Transaction::VisaCheckoutCardDetails,
- Braintree::Transaction::SamsungPayCardDetails
+ Braintree::Transaction::SamsungPayCardDetails,
+ Thread::Mutex,
])
end
end
| Add Thread::Mutex to the safe_load classes
|
diff --git a/config/initializers/cve_2015_3226_fix.rb b/config/initializers/cve_2015_3226_fix.rb
index abc1234..def5678 100644
--- a/config/initializers/cve_2015_3226_fix.rb
+++ b/config/initializers/cve_2015_3226_fix.rb
@@ -0,0 +1,13 @@+raise "Check monkey patch for CVE-2015-3226 is still needed" unless Rails::VERSION::STRING == '3.2.22'
+module ActiveSupport
+ module JSON
+ module Encoding
+ private
+ class EscapedString
+ def to_s
+ self
+ end
+ end
+ end
+ end
+end
| Patch Rails security issue as there's not a 3.2.x fix yet
|
diff --git a/app/uploaders/preview_image_uploader.rb b/app/uploaders/preview_image_uploader.rb
index abc1234..def5678 100644
--- a/app/uploaders/preview_image_uploader.rb
+++ b/app/uploaders/preview_image_uploader.rb
@@ -12,7 +12,7 @@ end
# Process files as they are uploaded:
- process resize_to_fit: [150, 100]
+ process resize_to_limit: [150, 100]
def extension_white_list
%w(jpg jpeg gif png)
| Save aspect ratio of uploaded preview images
|
diff --git a/app/models/instance_user.rb b/app/models/instance_user.rb
index abc1234..def5678 100644
--- a/app/models/instance_user.rb
+++ b/app/models/instance_user.rb
@@ -3,7 +3,7 @@ include InstanceUserSearchConcern
acts_as_tenant :instance, inverse_of: :instance_users
- enum role: { normal: 0, instructor: 1, administrator: 2, auto_grader: 3 }
+ enum role: { normal: 0, instructor: 1, administrator: 2 }
belongs_to :user, inverse_of: :instance_users
scope :ordered_by_username, -> { joins(:user).merge(User.order(name: :asc)) }
| Remove auto_grader role from instance user.
|
diff --git a/app/models/liquid_layout.rb b/app/models/liquid_layout.rb
index abc1234..def5678 100644
--- a/app/models/liquid_layout.rb
+++ b/app/models/liquid_layout.rb
@@ -10,6 +10,9 @@ validates :experimental, inclusion: {in: [true, false]}
scope :campaigner_friendly, -> { where(experimental: false) }
+ scope :with_default_layouts, -> { where.not(default_follow_up_layout: nil) }
+ scope :primary_layouts, -> {where(primary_layout: true)}
+ scope :post_action_layouts, -> { where(post_action_layout: true)}
def plugin_refs
# pass depth of -1 to allow layouts one more level of nesting than partials
| Add new scopes for liquid layouts
|
diff --git a/test/unitwise/expression/matcher_test.rb b/test/unitwise/expression/matcher_test.rb
index abc1234..def5678 100644
--- a/test/unitwise/expression/matcher_test.rb
+++ b/test/unitwise/expression/matcher_test.rb
@@ -15,8 +15,8 @@ it "must be an Alternative list of names" do
subject.must_be_instance_of Parslet::Atoms::Alternative
end
- it "must parse 'Joule'" do
- subject.parse('Joule').must_equal('Joule')
+ it "must parse 'joule'" do
+ subject.parse('joule').must_equal('joule')
end
end
@@ -39,4 +39,4 @@ subject.parse('h').must_equal('h')
end
end
-end+end
| Adjust matcher name expectation to support updated units
|
diff --git a/lib/logplex/publisher.rb b/lib/logplex/publisher.rb
index abc1234..def5678 100644
--- a/lib/logplex/publisher.rb
+++ b/lib/logplex/publisher.rb
@@ -7,7 +7,7 @@ class Publisher
def initialize(token, logplex_url=nil)
@token = token
- @logplex_url = logplex_url || 'https://logplex.heroku.com'
+ @logplex_url = logplex_url || 'https://east.logplex.io'
end
def publish(messages, opts={})
| Use actual logplex production host by default
|
diff --git a/lib/pry-vterm_aliases.rb b/lib/pry-vterm_aliases.rb
index abc1234..def5678 100644
--- a/lib/pry-vterm_aliases.rb
+++ b/lib/pry-vterm_aliases.rb
@@ -25,6 +25,6 @@ end
case ENV['SHELL']
- when '/bin/bash' then require 'pry/aliases/bash'
+ when %r!/bash\Z! then require 'pry/aliases/bash'
end
end
| Use a regex to detect bash.
|
diff --git a/lib/rspec_ssltls/util.rb b/lib/rspec_ssltls/util.rb
index abc1234..def5678 100644
--- a/lib/rspec_ssltls/util.rb
+++ b/lib/rspec_ssltls/util.rb
@@ -24,7 +24,7 @@ if options[:proxy]
proxy_uri = build_uri(options[:proxy])
proxy_server = Net::SSH::Proxy::HTTP.new(proxy_uri.host,
- proxy_uri.host,
+ proxy_uri.port,
user: proxy_uri.user,
password: proxy_uri.password)
proxy_server.open(uri.host, uri.port)
| Fix to use proxy_uri.port not proxy_uri.host |
diff --git a/lib/see_your_requests.rb b/lib/see_your_requests.rb
index abc1234..def5678 100644
--- a/lib/see_your_requests.rb
+++ b/lib/see_your_requests.rb
@@ -7,7 +7,7 @@
route :get, :post, :put, :delete, :head, :options, '/' do
content_type :text
- ap request.env.reject { |k, v| k =~ /^rack.*/ }
+ ap request.env
if request.body.size > 0
ap request.body.read
end
| Print full request for now.
|
diff --git a/spec/lib/addic7ed/show_list_spec.rb b/spec/lib/addic7ed/show_list_spec.rb
index abc1234..def5678 100644
--- a/spec/lib/addic7ed/show_list_spec.rb
+++ b/spec/lib/addic7ed/show_list_spec.rb
@@ -23,6 +23,10 @@ expect(Addic7ed::ShowList.find("Legacy.2013.UK")).to eq "Legacy_(2013)_(UK)"
end
+ it "handles when show name contains a quote" do
+ expect(Addic7ed::ShowList.find("Grey's Anatomy")).to eq "Grey's_Anatomy"
+ end
+
it "raises a ShowNotFound error when no matching show is found" do
expect{Addic7ed::ShowList.find("Not an existing show")}.to raise_error Addic7ed::ShowNotFound
end
| Add a test for shows containing a quote.
|
diff --git a/spec/syoboi_calendar/client_spec.rb b/spec/syoboi_calendar/client_spec.rb
index abc1234..def5678 100644
--- a/spec/syoboi_calendar/client_spec.rb
+++ b/spec/syoboi_calendar/client_spec.rb
@@ -0,0 +1,22 @@+require "spec_helper"
+
+describe "SyoboiCalendar::Client" do
+ before do
+ user = "testuserforruby"
+ pass = user
+ @client = SyoboiCalendar::Client.new(:user => user, :pass => pass)
+ @guest = SyoboiCalendar::Client.new
+ end
+
+ describe "#login?" do
+ context "logined user" do
+ subject { @client }
+ it { should be_login }
+ end
+
+ context "guest user" do
+ subject { @guest }
+ it { should_not be_login }
+ end
+ end
+end
| Add spec for Client login
|
diff --git a/Casks/gog-galaxy.rb b/Casks/gog-galaxy.rb
index abc1234..def5678 100644
--- a/Casks/gog-galaxy.rb
+++ b/Casks/gog-galaxy.rb
@@ -1,8 +1,8 @@ cask :v1 => 'gog-galaxy' do
- version '1.0.0.836'
- sha256 '878319173e0f157981fd3d5009e451653024bdb8e3b4f0ff5565c491ba815f4d'
+ version '1.0.2.939'
+ sha256 '2c46d7aafe862bc0b2aa6b4bc95490683f8ec80f96feffb7c6f7918e2203e4e7'
- url "http://cdn.gog.com/open/galaxy/client/galaxy_client_#{version}.pkg"
+ url "http://cdn.gog.com/open/galaxy/client/installers/galaxy_client_#{version}.pkg"
name 'GOG Galaxy Client'
homepage 'http://www.gog.com/galaxy'
license :gratis
| Upgrade GOG.com Galaxy Client to v1.0.2.939
|
diff --git a/Casks/nodeclipse.rb b/Casks/nodeclipse.rb
index abc1234..def5678 100644
--- a/Casks/nodeclipse.rb
+++ b/Casks/nodeclipse.rb
@@ -2,12 +2,13 @@ version '0.11-preview'
sha256 '01f630446313cb981ce2ee9b934977cfdbf318e09761dee244a3256f9a559003'
- url 'https://downloads.sourceforge.net/sourceforge/nodeclipse/Enide-Studio-2014-011-20140228-macosx-cocoa-x86_64.zip'
+ url "http://downloads.sourceforge.net/project/nodeclipse/Enide-Studio-2014/#{version}/Enide-Studio-2014-011-20140228-macosx-cocoa-x86_64.zip"
+ name 'Nodeclipse'
homepage 'http://www.nodeclipse.org/'
license :oss
- preflight do
- system '/bin/mv', '--', staged_path.join('eclipse/Eclipse.app'), staged_path.join('eclipse/Nodeclipse.app')
- end
- app 'eclipse/Nodeclipse.app'
+ # Renamed for clarity: app name is inconsistent with its branding.
+ # Also renamed to avoid conflict with other eclipse Casks.
+ # Original discussion: https://github.com/caskroom/homebrew-cask/pull/8183
+ app 'eclipse/Eclipse.app', :target => 'Nodeclipse.app'
end
| Replace preflight stanza with target rename
Use `:target` key to rename app for `nodeclipse` to `Nodeclipse.app`
rather than making a system call to `/bin/mv` in preflight.
Also update url to use `version`.
|
diff --git a/Casks/sassquatch.rb b/Casks/sassquatch.rb
index abc1234..def5678 100644
--- a/Casks/sassquatch.rb
+++ b/Casks/sassquatch.rb
@@ -2,6 +2,7 @@ version '1.5.0'
sha256 '9f9c688e473cc8fdffbee38c5d8f876726620a42dacdd6c2996faadfab714612'
+ # thoughtbot.github.io/sassquatch was verified as official when first introduced to the cask
url "https://thoughtbot.github.io/sassquatch/download/v#{version}/Sassquatch.zip"
appcast 'https://thoughtbot.github.io/sassquatch/feed.xml',
checkpoint: 'fd579aaf6f76be00a8d491628e99027fa0a4b033eb8d759fda2837c5536b4258'
| Fix `url` stanza comment for Sassquatch.
|
diff --git a/Casks/sql-editor.rb b/Casks/sql-editor.rb
index abc1234..def5678 100644
--- a/Casks/sql-editor.rb
+++ b/Casks/sql-editor.rb
@@ -1,7 +1,7 @@ class SqlEditor < Cask
- url 'http://www.malcolmhardie.com/sqleditor/releases/2.2/SQLEditor-2-2.zip'
+ url 'http://www.malcolmhardie.com/sqleditor/releases/2.2.1/SQLEditor-2-2-1.zip'
homepage 'http://www.malcolmhardie.com/sqleditor/'
- version '2.2'
- sha1 '8416e78d8c4189df55ceeecabf4d4b07695e17ad'
+ version '2.2.1'
+ sha1 '13010c875e706fd09206152993769b0a048c03a6'
link 'SQLEditor.app'
end
| Update SQLEditor to v. 2.2.1
|
diff --git a/Casks/torbrowser.rb b/Casks/torbrowser.rb
index abc1234..def5678 100644
--- a/Casks/torbrowser.rb
+++ b/Casks/torbrowser.rb
@@ -6,7 +6,7 @@ gpg "#{url}.asc",
:key_id => '4e2c6e8793298290'
homepage 'https://www.torproject.org/projects/torbrowser.html'
- license :unknown # todo: change license and remove this comment; ':unknown' is a machine-generated placeholder
+ license :oss
app 'TorBrowser.app'
end
| Update TorBrowser license to OSS |
diff --git a/cookbooks/yournavigation/recipes/default.rb b/cookbooks/yournavigation/recipes/default.rb
index abc1234..def5678 100644
--- a/cookbooks/yournavigation/recipes/default.rb
+++ b/cookbooks/yournavigation/recipes/default.rb
@@ -46,4 +46,4 @@ libicu-dev
]
-apache_module "php7.0"
+apache_module "php7.2"
| Use PHP 7.2 on 18.04
|
diff --git a/tools/snippet-testing/language_handler/python_6.rb b/tools/snippet-testing/language_handler/python_6.rb
index abc1234..def5678 100644
--- a/tools/snippet-testing/language_handler/python_6.rb
+++ b/tools/snippet-testing/language_handler/python_6.rb
@@ -23,8 +23,9 @@
def replace_twilio_client_initialization(file_content)
cert_path = ENV['FAKE_CERT_PATH']
- file_content.gsub! 'Client(account_sid, auth_token)',
- 'Client(account_sid, auth_token, http_client=FakerHttpClient())' || file_content
+ updated_file_content = file_content.gsub! 'Client(account_sid, auth_token)',
+ 'Client(account_sid, auth_token, http_client=FakerHttpClient())'
+ updated_file_content == nil ? file_content : updated_file_content
end
end
end
| Fix replace_twilio_client_initialization method return value
|
diff --git a/core/app/models/spree/payment_method.rb b/core/app/models/spree/payment_method.rb
index abc1234..def5678 100644
--- a/core/app/models/spree/payment_method.rb
+++ b/core/app/models/spree/payment_method.rb
@@ -23,7 +23,11 @@ end
def self.available(display_on = 'both')
- all.select { |p| p.active && (p.display_on == display_on.to_s || p.display_on.blank?) && (p.environment == Rails.env || p.environment.blank?) }
+ all.select do |p|
+ p.active &&
+ (p.display_on == display_on.to_s || p.display_on.blank?) &&
+ (p.environment == Rails.env || p.environment.blank?)
+ end
end
def self.active?
| Cut down PaymentMethod.available to be more readable
|
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -1,10 +1,19 @@ class ApplicationController < ActionController::Base
- # Prevent CSRF attacks by raising an exception.
- # For APIs, you may want to use :null_session instead.
- protect_from_forgery with: :exception
+ protect_from_forgery
+ after_filter :set_csrf_cookie_for_ng
def angular
render 'layouts/application'
end
+ def set_csrf_cookie_for_ng
+ cookies['XSRF-TOKEN'] = form_authenticity_token if protected_against_forgery?
+ end
+
+ protected
+
+ def verified_request?
+ super || valid_authenticity_token?(session, request.headers['X-XSRF-TOKEN'])
+ end
+
end
| Set CSRF token for Angular requests
|
diff --git a/test/integration/charge_flow_test.rb b/test/integration/charge_flow_test.rb
index abc1234..def5678 100644
--- a/test/integration/charge_flow_test.rb
+++ b/test/integration/charge_flow_test.rb
@@ -0,0 +1,24 @@+require 'test_helper'
+
+class ChargeFlowTest < ActionDispatch::IntegrationTest
+ # test "the truth" do
+ # assert true
+ # end
+ setup do
+ @round = rounds(:one)
+ end
+
+ test "charge and status don't show payment form after payment" do
+ get '/round_status/' + @round.url
+ @response_json = JSON.parse(@response.body)
+ assert_match '<form', @response_json['payment_info_template']
+
+ post '/charge', stripeToken: 'token', round_id: @round.url, name: 'Test User', email: 'test.email@example.com'
+ @response_json = JSON.parse(@response.body)
+ assert_no_match /<form/, @response_json['payment_info_template']
+
+ get '/round_status/' + @round.url
+ @response_json = JSON.parse(@response.body)
+ assert_no_match /<form/, @response_json['payment_info_template']
+ end
+end
| Test payment form not displayed after payment made
|
diff --git a/test/integration/rack_attack_test.rb b/test/integration/rack_attack_test.rb
index abc1234..def5678 100644
--- a/test/integration/rack_attack_test.rb
+++ b/test/integration/rack_attack_test.rb
@@ -0,0 +1,57 @@+require 'test_helper'
+
+## SLOW TESTS ##
+class RackAttackTest < ActionDispatch::IntegrationTest
+ setup do
+ @user = create(:user, email: "nick@example.com", password: "secret123")
+ @limit = 100
+ end
+
+ context 'requests is lower than limit' do
+ should 'allow sign in' do
+ 10.times do
+ post_via_redirect '/session', session: { who: @user.email, password: @user.password }
+ assert_equal @response.status, 200
+ end
+ end
+
+ should 'allow sign up' do
+ 10.times do
+ user = build(:user)
+ post_via_redirect '/users', user: { email: user.email, password: user.password }
+ assert_equal @response.status, 200
+ end
+ end
+
+ should 'allow forgot password' do
+ 10.times do
+ post '/passwords', password: { email: @user.email }
+ assert_equal @response.status, 200
+ end
+ end
+ end
+
+ context 'requests is higher than limit' do
+ should 'throttle sign in' do
+ (@limit + 1).times do |i|
+ post_via_redirect '/session', session: { who: @user.email, password: @user.password }
+ assert_equal @response.status, 429 if i > @limit
+ end
+ end
+
+ should 'throttle sign up' do
+ (@limit + 1).times do |i|
+ user = build(:user)
+ post_via_redirect '/users', user: { email: user.email, password: user.password }
+ assert_equal @response.status, 429 if i > @limit
+ end
+ end
+
+ should 'throttle forgot password' do
+ (@limit + 1).times do |i|
+ post '/passwords', password: { email: @user.email }
+ assert_equal @response.status, 429 if i > @limit
+ end
+ end
+ end
+end
| Add integration tests for rack attack
|
diff --git a/app/models/renalware/hd/preference_set.rb b/app/models/renalware/hd/preference_set.rb
index abc1234..def5678 100644
--- a/app/models/renalware/hd/preference_set.rb
+++ b/app/models/renalware/hd/preference_set.rb
@@ -15,9 +15,14 @@ has_paper_trail class_name: "Renalware::HD::Version"
validates :patient, presence: true
- validates :other_schedule, presence: true,
- if: ->(o) { o.schedule.try(:text) =~ /specify/ }
+ validates :other_schedule, presence: true, if: :other_schedule_required?
validates :entered_on, timeliness: { type: :date, allow_blank: true }
+
+ private
+
+ def other_schedule_required?
+ schedule.try(:text) =~ /specify/
+ end
end
end
end
| Make validation condition more obvious
|
diff --git a/db/migrate/029_add_user_foreign_keys.rb b/db/migrate/029_add_user_foreign_keys.rb
index abc1234..def5678 100644
--- a/db/migrate/029_add_user_foreign_keys.rb
+++ b/db/migrate/029_add_user_foreign_keys.rb
@@ -0,0 +1,18 @@+class AddUserForeignKeys < ActiveRecord::Migration
+ def self.up
+ add_foreign_key :changesets, [:user_id], :users, [:id]
+ add_foreign_key :diary_comments, [:user_id], :users, [:id]
+ add_foreign_key :diary_entries, [:user_id], :users, [:id]
+ add_foreign_key :friends, [:user_id], :users, [:id]
+ add_foreign_key :friends, [:friend_user_id], :users, [:id]
+ add_foreign_key :gpx_files, [:user_id], :users, [:id]
+ add_foreign_key :messages, [:from_user_id], :users, [:id]
+ add_foreign_key :messages, [:to_user_id], :users, [:id]
+ add_foreign_key :user_preferences, [:user_id], :users, [:id]
+ add_foreign_key :user_tokens, [:user_id], :users, [:id]
+ end
+
+ def self.down
+ raise IrreversibleMigration.new
+ end
+end
| Add foreign key constraints for users.
|
diff --git a/lib/tasks/deployment/20210715123116_baseload_variation_alerts.rake b/lib/tasks/deployment/20210715123116_baseload_variation_alerts.rake
index abc1234..def5678 100644
--- a/lib/tasks/deployment/20210715123116_baseload_variation_alerts.rake
+++ b/lib/tasks/deployment/20210715123116_baseload_variation_alerts.rake
@@ -0,0 +1,34 @@+namespace :after_party do
+ desc 'Deployment task: baseload_variation_alerts'
+ task baseload_variation_alerts: :environment do
+ puts "Running deploy task 'baseload_variation_alerts'"
+
+ AlertType.create!(
+ frequency: :weekly,
+ fuel_type: :electricity,
+ sub_category: :electricity_use,
+ title: "Variation in Seasonal Baseload",
+ class_name: 'AlertSeasonalBaseloadVariation',
+ source: :analytics,
+ has_ratings: true,
+ benchmark: true
+ ) unless AlertType.find_by_class_name('AlertSeasonalBaseloadVariation')
+
+ AlertType.create!(
+ frequency: :weekly,
+ fuel_type: :electricity,
+ sub_category: :electricity_use,
+ title: "Variation in Baseload between Days of the Week",
+ class_name: 'AlertIntraweekBaseloadVariation',
+ source: :analytics,
+ has_ratings: true,
+ benchmark: true
+ ) unless AlertType.find_by_class_name('AlertIntraweekBaseloadVariation')
+
+
+ # Update task as completed. If you remove the line below, the task will
+ # run with every deploy (or every time you call after_party:run).
+ AfterParty::TaskRecord
+ .create version: AfterParty::TaskRecorder.new(__FILE__).timestamp
+ end
+end
| Add 2 new alert types
|
diff --git a/test/unit/release/processors_test.rb b/test/unit/release/processors_test.rb
index abc1234..def5678 100644
--- a/test/unit/release/processors_test.rb
+++ b/test/unit/release/processors_test.rb
@@ -1,47 +1,55 @@ require "test_helper"
require "./lib/roger/release"
-# Test Roger processors
-class ProcessorsTest < ::Test::Unit::TestCase
- def setup
- Roger::Release::Processors.map.clear
- end
-
- def test_register_processor
- processor = ->(_e) { fail "ProcessorName" }
- assert Roger::Release::Processors.register(:name, processor)
- assert_equal Roger::Release::Processors.map, name: processor
- end
-
- def test_register_processor_with_symbol_only_name
- processor = ->(_e) { fail "ProcessorName" }
-
- assert_raise(ArgumentError) do
- Roger::Release::Processors.register("name", processor)
+module Roger
+ # Test Roger processors
+ class ProcessorsTest < ::Test::Unit::TestCase
+ def setup
+ @origmap = Roger::Release::Processors.map.dup
+ Roger::Release::Processors.map.clear
end
- assert_raise(ArgumentError) do
- Roger::Release::Processors.register("name", processor)
+ def teardown
+ Roger::Release::Processors.map.clear
+ Roger::Release::Processors.map.update(@origmap)
+ end
+
+ def test_register_processor
+ processor = ->(_e) { fail "ProcessorName" }
+ assert Roger::Release::Processors.register(:name, processor)
+ assert_equal Roger::Release::Processors.map, name: processor
+ end
+
+ def test_register_processor_with_symbol_only_name
+ processor = ->(_e) { fail "ProcessorName" }
+
+ assert_raise(ArgumentError) do
+ Roger::Release::Processors.register("name", processor)
+ end
+
+ assert_raise(ArgumentError) do
+ Roger::Release::Processors.register("name", processor)
+ end
+ end
+
+ def test_register_processor_with_same_name
+ processor = ->(_e) { fail "ProcessorName" }
+ Roger::Release::Processors.register(:name, processor)
+
+ assert_raise(ArgumentError) do
+ Roger::Release::Processors.register(:name, processor)
+ end
+ end
+
+ def test_register_processor_with_same_contents
+ processor = ->(_e) { fail "ProcessorName" }
+ Roger::Release::Processors.register(:name, processor)
+
+ assert_nothing_raised do
+ Roger::Release::Processors.register(:name2, processor)
+ end
+
+ assert_equal Roger::Release::Processors.map, name: processor, name2: processor
end
end
-
- def test_register_processor_with_same_name
- processor = ->(_e) { fail "ProcessorName" }
- Roger::Release::Processors.register(:name, processor)
-
- assert_raise(ArgumentError) do
- Roger::Release::Processors.register(:name, processor)
- end
- end
-
- def test_register_processor_with_same_contents
- processor = ->(_e) { fail "ProcessorName" }
- Roger::Release::Processors.register(:name, processor)
-
- assert_nothing_raised do
- Roger::Release::Processors.register(:name2, processor)
- end
-
- assert_equal Roger::Release::Processors.map, name: processor, name2: processor
- end
end
| Make sure we reset the situation after we meddled with Processors.map
|
diff --git a/config/deploy/production.rb b/config/deploy/production.rb
index abc1234..def5678 100644
--- a/config/deploy/production.rb
+++ b/config/deploy/production.rb
@@ -5,3 +5,11 @@ role :web, domain
role :app, domain
role :db, domain, :primary => true
+
+namespace :deploy do
+ desc "Create newrelic symlink"
+ task :newrelic_symlink, :role => :app, :except => { :no_release => true } do
+ run "ln -sfn #{shared_path}/newrelic.yml #{current_path}/config/newrelic.yml"
+ end
+ before [:"deploy:start", :"deploy:restart"], :"deploy:newrelic_symlink"
+end
| Add task to create newrelic symlink
|
diff --git a/config/initializers/sass.rb b/config/initializers/sass.rb
index abc1234..def5678 100644
--- a/config/initializers/sass.rb
+++ b/config/initializers/sass.rb
@@ -3,7 +3,7 @@ module Sass::Script::Functions
def settings_style(setting)
assert_type setting, :String
- return_value = ActiveRecord::Base.connection.table_exists?('settings') ? Setting["#{ setting.value }"].to_s : 'NOT_SET'
+ return_value = ActiveRecord::Base.connection.table_exists?('settings') ? Setting["#{ setting.value }"].to_s : Constant["#{ setting.value }"].to_s
Sass::Script::Parser.parse(return_value, 0, 0)
end
declare :settings_style, args: [:setting]
| Use defaults if table doesn't exist
|
diff --git a/roles/ic.rb b/roles/ic.rb
index abc1234..def5678 100644
--- a/roles/ic.rb
+++ b/roles/ic.rb
@@ -28,6 +28,15 @@ }
}
}
+ },
+ :sysfs => {
+ :cpufreq_ondemand_low => {
+ :comment => "Tune the ondemand CPU frequency governor for reduced scaling",
+ :parameters => {
+ "devices/system/cpu/cpufreq/ondemand/up_threshold" => "95",
+ "devices/system/cpu/cpufreq/ondemand/sampling_down_factor" => "1"
+ }
+ }
}
)
| Reduce CPU up scaling for IC systems due to cooling pressure
|
diff --git a/spec/acceptance/adjunto_imagenes_spec.rb b/spec/acceptance/adjunto_imagenes_spec.rb
index abc1234..def5678 100644
--- a/spec/acceptance/adjunto_imagenes_spec.rb
+++ b/spec/acceptance/adjunto_imagenes_spec.rb
@@ -0,0 +1,24 @@+# encoding: utf-8
+
+require File.expand_path(File.dirname(__FILE__) + '/acceptance_helper')
+
+feature "Subir imágenes", %q{
+ Para meter imágenes en el texto
+ Como administrador
+ Quiero poder adjuntarlas desde la edición de páginas
+} do
+
+ background do
+ crea_paginas_con_titulos %w(Prueba)
+ login
+ end
+
+ scenario "Adjuntar una imagen", js: true do
+ visit edit_pagina_path(Pagina.first)
+ within("#fotos") do
+ attach_file "nueva imagen", Rails.root.join("spec", "images", "blank.png")
+ end
+
+ page.should have_selector "#galeria .foto", count: 1
+ end
+end
| Test de adjunto de imágenes.
En Chromium falla porque no dispara bien el evento, pero en realidad
funciona.
En Firefox falla porque en Firefox efectivamente el proceso falla, pero
sí dispara el evento. Así que vale para lo que quiero.
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.