diff stringlengths 65 26.7k | message stringlengths 7 9.92k |
|---|---|
diff --git a/spec/unit/ldap/search_spec.rb b/spec/unit/ldap/search_spec.rb
index abc1234..def5678 100644
--- a/spec/unit/ldap/search_spec.rb
+++ b/spec/unit/ldap/search_spec.rb
@@ -0,0 +1,30 @@+# -*- ruby encoding: utf-8 -*-
+
+describe Net::LDAP, "search method" do
+ class FakeConnection
+ def search(args)
+ error_code = 1
+ return error_code
+ end
+ end
+
+ before(:each) do
+ @connection = Net::LDAP.new
+ @connection.instance_variable_set(:@open_connection, FakeConnection.new)
+ end
+
+ context "when returning result set" do
+ it "should return nil upon error" do
+ result_set = @connection.search(:return_result => true) do
+ end
+ result_set.should be_nil
+ end
+ end
+
+ context "when returning boolean" do
+ it "should return false upon error" do
+ success = @connection.search(:return_result => false)
+ success.should == false
+ end
+ end
+end
| Add test case showing incorrect behaviour for failed searches
|
diff --git a/core/app/controllers/users_controller.rb b/core/app/controllers/users_controller.rb
index abc1234..def5678 100644
--- a/core/app/controllers/users_controller.rb
+++ b/core/app/controllers/users_controller.rb
@@ -12,17 +12,17 @@
def activities
respond_to do |format|
+ # TODO: This needs to become much more efficient. Now all activities are
+ # returned and sliced.
+ activities = Activity::For.user(@user.graph_user).sort(order: "DESC").slice(0..6)
- # TODO: This needs to become much more efficient. Now all activities are
- # returned and sliced.
- activities = Activity::For.user(current_user.graph_user).sort(order: "DESC").slice(0..6)
format.json { render json: activities.map { |activity| Notifications::Activity.for(activity: activity, view: view_context) } }
end
end
def mark_activities_as_read
- current_user.last_read_activities_on = DateTime.now
+ @user.last_read_activities_on = DateTime.now
respond_to do |format|
if current_user.save
| Use @user instead of current_user
|
diff --git a/config/initializers/cached_settings.rb b/config/initializers/cached_settings.rb
index abc1234..def5678 100644
--- a/config/initializers/cached_settings.rb
+++ b/config/initializers/cached_settings.rb
@@ -25,7 +25,7 @@ # Rather than getting the app name, get the root folder name so that
# discrete instances of an application do not collide
# REVIEW: consider using namespace - why isn't it being used?
- "#{ File.basename(Rails.root.to_s) }_#{ Rails.env }_settings"
+ "#{ Rails.root.to_s.parameterize }_#{ Rails.env }_settings"
end
end
end
| Use entire Rails.root since we store the app in current
|
diff --git a/redmine-personal_wiki_page.gemspec b/redmine-personal_wiki_page.gemspec
index abc1234..def5678 100644
--- a/redmine-personal_wiki_page.gemspec
+++ b/redmine-personal_wiki_page.gemspec
@@ -20,6 +20,7 @@ spec.require_paths = ["lib"]
spec.add_dependency "rails", "~> 4.2.0"
+ spec.add_dependency "redmine-more_view_hooks"
spec.add_development_dependency "bundler", "~> 1.7"
spec.add_development_dependency "rake", "~> 10.0"
| Add missing dependency to redmine-more_view_hooks
|
diff --git a/app/helpers/version_helper.rb b/app/helpers/version_helper.rb
index abc1234..def5678 100644
--- a/app/helpers/version_helper.rb
+++ b/app/helpers/version_helper.rb
@@ -23,7 +23,7 @@ html << if object.persisted?
link_to object.to_s, url_for_object(object)
else
- object.to_s if object
+ object.to_s
end
html.html_safe
end
| Revert "A little failsave, which seems to be necessary in production."
This reverts commit cbf06b9f85c62b726bca093d39c4a636cb6af081.
|
diff --git a/app/mailers/noisy_workflow.rb b/app/mailers/noisy_workflow.rb
index abc1234..def5678 100644
--- a/app/mailers/noisy_workflow.rb
+++ b/app/mailers/noisy_workflow.rb
@@ -6,7 +6,7 @@ def make_noise(guide,action)
@guide = guide
@action = action
- mail(:to => "dev@alphagov.co.uk",
+ mail(:to => "eds@alphagov.co.uk",
:subject => "[GUIDES/ANSWERS] " + @action.friendly_description)
end
end
| Send notification emails to eds@
|
diff --git a/PeerTalk.podspec b/PeerTalk.podspec
index abc1234..def5678 100644
--- a/PeerTalk.podspec
+++ b/PeerTalk.podspec
@@ -1,17 +1,14 @@-{
- "name": "PeerTalk",
- "version": "0.0.1",
- "summary": "iOS and OS X Cocoa library for communicating over USB and TCP.",
- "description": " PeerTalk is a iOS and OS X Cocoa library for communicating over USB and TCP.\n\n Highlights:\n\n * Provides you with USB device attach/detach events and attached device's info\n * Can connect to TCP services on supported attached devices (e.g. an iPhone), bridging the communication over USB transport\n * Offers a higher-level API (PTChannel and PTProtocol) for convenient implementations.\n * Tested and designed for libdispatch (aka Grand Central Dispatch).\n",
- "homepage": "http://rsms.me/peertalk/",
- "license": "MIT",
- "authors": {
- "Rasmus Andersson": "rasmus@notion.se"
- },
- "source": {
- "git": "https://github.com/rsms/peertalk.git",
- "commit": "a454694e873dcb07faba2982633efbfe2779cf5b"
- },
- "source_files": "peertalk/*.{h,m}",
- "requires_arc": true
-}
+Pod::Spec.new do |spec|
+ spec.name = 'PeerTalk'
+ spec.version = '0.0.1'
+ spec.license = { :type => 'MIT' }
+ spec.homepage = 'http://rsms.me/peertalk/'
+ spec.authors = { 'Rasmus Andersson' => 'rasmus@notion.se' }
+ spec.summary = 'iOS and OS X Cocoa library for communicating over USB and TCP.'
+
+ spec.source = { :git => "https://github.com/rsms/PeerTalk.git", :commit => 'b9e59e7c55de34361a7c5ea38f1767c53b4534b8' }
+ spec.source_files = 'peertalk/*.{h,m}'
+ spec.requires_arc = true
+
+ spec.description = " PeerTalk is a iOS and OS X Cocoa library for communicating over USB and TCP.\n\n Highlights:\n\n * Provides you with USB device attach/detach events and attached device's info\n * Can connect to TCP services on supported attached devices (e.g. an iPhone), bridging the communication over USB transport\n * Offers a higher-level API (PTChannel and PTProtocol) for convenient implementations.\n * Tested and designed for libdispatch (aka Grand Central Dispatch).\n"
+end
| Convert podspec to valid syntax
|
diff --git a/chef/roles/rubygems_db_master.rb b/chef/roles/rubygems_db_master.rb
index abc1234..def5678 100644
--- a/chef/roles/rubygems_db_master.rb
+++ b/chef/roles/rubygems_db_master.rb
@@ -10,12 +10,18 @@ "postgresql" => {
"version" => "9.2",
"data_directory" => "/var/lib/pg_data",
- "listen_address" => "10.249.66.172",
+ "listen_addresses" => "10.249.66.172",
"ssl" => false,
"work_mem" => "100MB",
"shared_buffers" => "24MB",
"pg_hba" => [
- "host gemcutter_production postgres 10.249.31.114/0 md5"
+ {
+ "type" => "host",
+ "db" => "gemcutter_production",
+ "user" => "postgres",
+ "addr" => "10.249.31.114/0",
+ "method" => "md5"
+ }
]
}
)
| Put pg attributes in the correct format
|
diff --git a/simple_backend/app/controllers/auth.rb b/simple_backend/app/controllers/auth.rb
index abc1234..def5678 100644
--- a/simple_backend/app/controllers/auth.rb
+++ b/simple_backend/app/controllers/auth.rb
@@ -14,12 +14,6 @@ puts "made it to signup"
content_type :json
user = User.create(params[:user])
- session[:user_id] = user.id
return { status: "success", id: user.id, name: user.name }.to_json
end
-get '/signout' do
- session[:user_id] = nil
- content_type :json
- return { status: "success" }
-end
| Delete unneeded /signout route in Sinatra
|
diff --git a/spec/requests/catalog_controller_spec.rb b/spec/requests/catalog_controller_spec.rb
index abc1234..def5678 100644
--- a/spec/requests/catalog_controller_spec.rb
+++ b/spec/requests/catalog_controller_spec.rb
@@ -0,0 +1,37 @@+require "rails_helper"
+
+RSpec.describe CatalogController do
+ describe "RSS feed" do
+ let(:rss_path) { '/catalog.rss' }
+
+ it 'returns a valid response' do
+ get rss_path
+ expect(response).to be_success
+ expect(response.content_type).to eq("application/rss+xml")
+ end
+
+ context "with three works" do
+ before { create_list(:public_generic_work, 3) }
+
+ it 'shows three items in the feed' do
+ get rss_path
+ xml = Nokogiri::XML response.body
+ expect(xml.xpath("///channel/item").count).to be 3
+ end
+ end
+
+ context "with an image-based work" do
+ let!(:work) { create(:public_generic_work, :with_image) }
+
+ it 'the item contains a media element' do
+ get rss_path
+ xml = Nokogiri::XML response.body
+ media_elements = xml.xpath("///channel/item/media:content")
+ image_url = xml.xpath("///channel/item/media:content").first.attributes['url'].value
+
+ expect(media_elements.count).to be 1
+ expect(image_url).to include(work.file_sets.first.iiif_id)
+ end
+ end
+ end
+end
| Add spec for RSS feed
|
diff --git a/app/models/embed_stat.rb b/app/models/embed_stat.rb
index abc1234..def5678 100644
--- a/app/models/embed_stat.rb
+++ b/app/models/embed_stat.rb
@@ -13,7 +13,9 @@ def self.csv
CSV.generate(row_sep: "\r\n") do |csv|
csv << ["Dataset Name", "Dataset URL", "Referring URL", "First Detected"]
- all.each { |s| csv << [s.dataset_title, s.dataset_path, s.referer, s.created_at] }
+ includes(:dataset).find_each do |s|
+ csv << [s.dataset_title, s.dataset_path, s.referer, s.created_at]
+ end
end
end
| Improve sql query for generating report |
diff --git a/spec/features/admin/categories_spec.rb b/spec/features/admin/categories_spec.rb
index abc1234..def5678 100644
--- a/spec/features/admin/categories_spec.rb
+++ b/spec/features/admin/categories_spec.rb
@@ -22,7 +22,23 @@
click_button "Create axis"
+ expect(page).to have_content "Category created successfully."
expect(page).to have_content("1. Axis 1")
end
+ scenario "Edit an existing category", :js do
+ create(:category, name: { en: "My axis" })
+
+ visit admin_categories_path
+
+ click_link "Edit"
+
+ fill_in "name_en", with: "My edited axis"
+
+ click_button "Update axis"
+
+ expect(page).to have_content "Category updated successfully."
+ expect(page).to have_content("My edited axis")
+ end
+
end
| Add test for editing an existing category
|
diff --git a/spec/features/teams/ad_members_spec.rb b/spec/features/teams/ad_members_spec.rb
index abc1234..def5678 100644
--- a/spec/features/teams/ad_members_spec.rb
+++ b/spec/features/teams/ad_members_spec.rb
@@ -0,0 +1,54 @@+require 'spec_helper.rb'
+
+feature 'Adding and removing member of a team', js: true do
+ let(:team1) { FactoryGirl::create(:team_with_players, {players_count: 2, required_size: 4})}
+ let(:user) { FactoryGirl::create(:user) }
+ let(:players) {
+ FactoryGirl::create_list(:tournament_participation, 5, tournament: team1.tournament)
+ team1.tournament.players - team1.players
+ }
+
+ before do
+ visit "#/home"
+ visit "#/login"
+ fill_in "email", with: user.email
+ fill_in "password", with: user.password
+
+ click_on "log-in-button"
+ visit "#/home/"
+
+ TournamentAdmin.create(user_id: user.id, tournament_id: team1.tournament_id, status: :main)
+ players
+ visit "#/teams/" + team1.id.to_s
+
+ click_on "edit-team"
+ end
+
+ scenario "Add member to a team when user exists and is a tournament admin", :raceable do
+ p1 = players[0]
+
+ within('h1', text: "#{p1.name} #{p1.surname}") do
+ click_on "add-member"
+ end
+
+ within('h1', text: "#{p1.name} #{p1.surname}") do
+ expect(page).to have_button("delete-member")
+ end
+
+ expect(TeamMembership.exists?(team_id: team1.id, player_id: p1.id)).to be true
+ end
+
+ scenario "Delete member from a team when user exists and is a tournament admin", :raceable do
+ p1 = team1.players.first
+
+ within('h1', text: "#{p1.name} #{p1.surname}") do
+ click_on "delete-member"
+ end
+
+ within('h1', text: "#{p1.name} #{p1.surname}") do
+ expect(page).to have_button("add-member")
+ end
+
+ expect(TeamMembership.exists?(team_id: team1.id, player_id: p1.id)).to be false
+ end
+end
| Add team add and delete member feature spec
|
diff --git a/hexp.gemspec b/hexp.gemspec
index abc1234..def5678 100644
--- a/hexp.gemspec
+++ b/hexp.gemspec
@@ -10,16 +10,18 @@ gem.description = 'HTML expressions'
gem.summary = gem.description
gem.homepage = 'https://github.com/plexus/hexp'
+ gem.license = 'MIT'
gem.require_paths = %w[lib]
gem.files = `git ls-files`.split($/)
gem.test_files = `git ls-files -- spec`.split($/)
gem.extra_rdoc_files = %w[README.md]
- gem.add_runtime_dependency 'sass' , '~> 3.2.9'
- gem.add_runtime_dependency 'nokogiri' , '~> 1.6.0'
- gem.add_runtime_dependency 'ice_nine' , '~> 0.8.0'
- gem.add_runtime_dependency 'equalizer' , '~> 0.0.5'
+ gem.add_runtime_dependency 'sass' , '~> 3.2'
+ gem.add_runtime_dependency 'nokogiri' , '~> 1.6'
+ gem.add_runtime_dependency 'ice_nine' , '~> 0.8'
+ gem.add_runtime_dependency 'equalizer' , '~> 0.0'
- gem.add_development_dependency 'rspec', '~> 2.14.2'
+ gem.add_development_dependency 'rake', '~> 10.1'
+ gem.add_development_dependency 'rspec', '~> 2.14'
end
| Add license to gemspec, update dependencies
|
diff --git a/spec/reports/signatures_report_spec.rb b/spec/reports/signatures_report_spec.rb
index abc1234..def5678 100644
--- a/spec/reports/signatures_report_spec.rb
+++ b/spec/reports/signatures_report_spec.rb
@@ -13,6 +13,7 @@ end
it 'generates CSV' do
+ # Create a shift inside our weekly report period
FactoryGirl.create(:shift, :full, day: begin_date + 1)
round_trip = CSV.parse(report.to_csv)
expect(round_trip.size).to be > 1
| Add comment on factory call
[skip ci]
|
diff --git a/examples/roundtrip.rb b/examples/roundtrip.rb
index abc1234..def5678 100644
--- a/examples/roundtrip.rb
+++ b/examples/roundtrip.rb
@@ -28,7 +28,7 @@ puts("Plaintext:\n#{plain}")
# Perform symmetric encryption on PLAIN.
-cipher = GPGME::encrypt(nil, plain, {:armor => true
+cipher = GPGME::encrypt(nil, plain, {:armor => true,
# :passphrase_callback => method(:passfunc)
})
puts("Ciphertext:\n#{cipher}")
| Add extra "," before :passphrase_callback.
|
diff --git a/hkdf.gemspec b/hkdf.gemspec
index abc1234..def5678 100644
--- a/hkdf.gemspec
+++ b/hkdf.gemspec
@@ -4,6 +4,7 @@ s.authors = ['John Downey']
s.email = ['jdowney@gmail.com']
s.homepage = 'http://github.com/jtdowney/hkdf'
+ s.license = 'MIT'
s.summary = %q{HMAC-based Key Derivation Function}
s.description = %q{A ruby implementation of RFC5869: HMAC-based Extract-and-Expand Key Derivation Function (HKDF). The goal of HKDF is to take some source key material and generate suitable cryptographic keys from it.}
| Add MIT license to gemspec
|
diff --git a/test/cookbooks/test/recipes/default.rb b/test/cookbooks/test/recipes/default.rb
index abc1234..def5678 100644
--- a/test/cookbooks/test/recipes/default.rb
+++ b/test/cookbooks/test/recipes/default.rb
@@ -14,5 +14,5 @@ extend Apache2::Cookbook::Helpers
service_name lazy { apache_platform_service_name }
supports restart: true, status: true, reload: true
- action :nothing
+ action :start
end
| Add start action to the apache2 resource
|
diff --git a/test/validator/schema_validation_helpers.rb b/test/validator/schema_validation_helpers.rb
index abc1234..def5678 100644
--- a/test/validator/schema_validation_helpers.rb
+++ b/test/validator/schema_validation_helpers.rb
@@ -22,8 +22,11 @@ end
def generate_schema
- @id ||= 0
- @id += 1
- { 'id' => @id.to_s }
+ { 'id' => generate_schema_id }
+ end
+
+ def generate_schema_id
+ @schema_id ||= '0'
+ @schema_id = @schema_id.succ.freeze
end
end
| Rework generation of test schema ids
|
diff --git a/MNTPullToReact.podspec b/MNTPullToReact.podspec
index abc1234..def5678 100644
--- a/MNTPullToReact.podspec
+++ b/MNTPullToReact.podspec
@@ -1,11 +1,3 @@-#
-# Be sure to run `pod spec lint MNTPullToReact.podspec' to ensure this is a
-# valid spec and to remove all comments including this before submitting the spec.
-#
-# To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html
-# To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/
-#
-
Pod::Spec.new do |s|
s.name = "MNTPullToReact"
| Remove comments in the podspec
|
diff --git a/db/migrate/20161031154415_remove_redirect_capital_funding_guide.rb b/db/migrate/20161031154415_remove_redirect_capital_funding_guide.rb
index abc1234..def5678 100644
--- a/db/migrate/20161031154415_remove_redirect_capital_funding_guide.rb
+++ b/db/migrate/20161031154415_remove_redirect_capital_funding_guide.rb
@@ -1,9 +1,14 @@ require "manual_relocator"
+require "cli_manual_deleter"
+require "stringio"
class RemoveRedirectCapitalFundingGuide < Mongoid::Migration
def self.up
+ bad_manual_id = "7228d773-a416-4ec1-9549-5fb91b1caaf5"
manual_slug = "guidance/capital-funding-guide"
new_manual_slug = "#{manual_slug}-hca"
+
+ CliManualDeleter.new(manual_slug, manual_id: bad_manual_id, stdin: StringIO.new("y")).call
ManualRelocator.move(new_manual_slug, manual_slug)
end
| Remove the bad draft in our migration
As well as removing the old capital-funding-guide manual and
reslugging the new one, we also want to remove an bad draft
that has no title. We use the existing CliManualDeleter for
this purpose, and pass in a StringIO with a "y" in it to get
around the required keyboard input.
|
diff --git a/Casks/perma.rb b/Casks/perma.rb
index abc1234..def5678 100644
--- a/Casks/perma.rb
+++ b/Casks/perma.rb
@@ -2,7 +2,7 @@ version '1.0.0'
sha256 '7987bacb6852d9874d899beefed84f0f2dcbbbb2893e481a607a623c994eb62a'
- # http://perma-dl.s3.amazonaws.com twas verified as official when first introduced to the cask
+ # http://perma-dl.s3.amazonaws.com was verified as official when first introduced to the cask
url "http://perma-dl.s3.amazonaws.com/Perma-v#{version}.zip"
name 'Perma'
homepage 'https://per.ma'
| Fix `url` stanza comment for Perma.
|
diff --git a/spec/classes/ironic_client_spec.rb b/spec/classes/ironic_client_spec.rb
index abc1234..def5678 100644
--- a/spec/classes/ironic_client_spec.rb
+++ b/spec/classes/ironic_client_spec.rb
@@ -22,6 +22,20 @@
describe 'ironic::client' do
+ shared_examples_for 'ironic client' do
+
+ it { is_expected.to contain_class('ironic::deps') }
+ it { is_expected.to contain_class('ironic::params') }
+
+ it 'installs ironic client package' do
+ is_expected.to contain_package('python-ironicclient').with(
+ :ensure => 'present',
+ :name => platform_params[:client_package],
+ :tag => ['openstack', 'ironic-support-package']
+ )
+ end
+ end
+
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
@@ -30,8 +44,11 @@ facts.merge!(OSDefaults.get_facts())
end
- it { is_expected.to contain_class('ironic::client') }
+ let :platform_params do
+ { :client_package => 'python-ironicclient' }
+ end
+ it_behaves_like 'ironic client'
end
end
| Fix unit test for ironic::client class
Change-Id: Ibe49da4ba431e01822a18f5929dfa32d2544dab0
|
diff --git a/spec/nql/dependency_tables_spec.rb b/spec/nql/dependency_tables_spec.rb
index abc1234..def5678 100644
--- a/spec/nql/dependency_tables_spec.rb
+++ b/spec/nql/dependency_tables_spec.rb
@@ -21,7 +21,7 @@ end
it 'must have multiple dependency tables' do
- tree = parse 'a.b.c = 1 & d.e: 2 | f.g.h = 1 | i = 4'
+ tree = parse 'a.b.c = 1 & (d.e: 2 | f.g.h = 1) | i = 4'
tree.dependency_tables.must_equal ['a.b', 'd', 'f.g']
end
| Test using parenthesis in dependency tables spec
|
diff --git a/interview-cake/apple_stock.rb b/interview-cake/apple_stock.rb
index abc1234..def5678 100644
--- a/interview-cake/apple_stock.rb
+++ b/interview-cake/apple_stock.rb
@@ -0,0 +1,60 @@+# Writing programming interview questions hasn't made me rich. Maybe trading Apple stocks will.
+# Suppose we could access yesterday's stock prices as a list, where:
+
+# The values are the price in dollars of Apple stock.
+# A higher index indicates a later time.
+# So if the stock cost $500 at 10:30am and $550 at 11:00am, then:
+
+# stock_prices_yesterday[60] = 500
+
+# Write an efficient function that takes stock_prices_yesterday and returns the best profit I could have made from 1 purchase and 1 sale of 1 Apple stock yesterday.
+
+# For example:
+
+# stock_prices_yesterday = [10, 7, 5, 8, 11, 9]
+
+# get_max_profit(stock_prices_yesterday)
+# # returns 6 (buying for $5 and selling for $11)
+
+# No "shorting"—you must buy before you sell. You may not buy and sell in the same time step (at least 1 minute must pass).
+
+# # This is a brute force n^2 solution
+# def get_max_profit(stock_prices_yesterday)
+# current_max = 0
+# stock_prices_yesterday.each do |buy|
+# stock_prices_yesterday.each do |sell|
+# if current_max < (sell - buy)
+# current_max = (sell - buy)
+# end
+# end
+# end
+# current_max
+# end
+
+# This solution is O(n) time and O(1) space but does not handle the case of an entire day of decreasing prices correctly
+# def get_max_profit(stock_prices_yesterday)
+# current_low = stock_prices_yesterday[0]
+# current_high = stock_prices_yesterday[0]
+# max_profit = 0
+# stock_prices_yesterday.each do |price|
+# if price > current_high
+# current_high = price
+# end
+# if max_profit < price - current_low
+# max_profit = price - current_low
+# end
+# if price < current_low
+# current_low = price
+# current_high = price
+# end
+# end
+# max_profit
+# end
+
+# SOULTION
+
+
+
+prices = [10, 7, 5, 8, 11, 9]
+
+p get_max_profit(prices) | Write both n^2 and n time solution for Apple Stocks question
|
diff --git a/Framer.podspec b/Framer.podspec
index abc1234..def5678 100644
--- a/Framer.podspec
+++ b/Framer.podspec
@@ -1,6 +1,6 @@ Pod::Spec.new do |s|
s.name = 'Framer'
- s.version = '1.4.2'
+ s.version = '1.4.3'
s.summary = 'Comfortable syntax for working with frames'
s.description = <<-DESC
Framer is a good framework which wraps working with frames with a nice chaining syntax.
| Change pod spev version -> 1.4.3
|
diff --git a/railties/lib/rails/commands/application.rb b/railties/lib/rails/commands/application.rb
index abc1234..def5678 100644
--- a/railties/lib/rails/commands/application.rb
+++ b/railties/lib/rails/commands/application.rb
@@ -15,4 +15,16 @@ require 'rails/generators'
require 'rails/generators/rails/app/app_generator'
+module Rails
+ module Generators
+ class AppGenerator
+ # We want to exit on failure to be kind to other libraries
+ # This is only when accessing via CLI
+ def self.exit_on_failure?
+ true
+ end
+ end
+ end
+end
+
Rails::Generators::AppGenerator.start
| Use Thor's self.exit_on_failure? to exit whenever accessing the generators from the CLI and a Thor::Error is raised.
|
diff --git a/db/migrate/20200601185920_add_external_id_to_gp_charges.rb b/db/migrate/20200601185920_add_external_id_to_gp_charges.rb
index abc1234..def5678 100644
--- a/db/migrate/20200601185920_add_external_id_to_gp_charges.rb
+++ b/db/migrate/20200601185920_add_external_id_to_gp_charges.rb
@@ -0,0 +1,7 @@+# frozen_string_literal: true
+
+class AddExternalIdToGpCharges < ActiveRecord::Migration[5.2]
+ def change
+ add_column :gp_charges, :external_id, :string
+ end
+end
| Add migration to include external_id in charges
|
diff --git a/lib/action_mailer_queue.rb b/lib/action_mailer_queue.rb
index abc1234..def5678 100644
--- a/lib/action_mailer_queue.rb
+++ b/lib/action_mailer_queue.rb
@@ -1,4 +1,8 @@+require "mail"
require "mail/active_record"
+
+require "action_mailer"
+
require "action_mailer_queue/mailer"
require "action_mailer_queue/store"
| Add more specific require statements. |
diff --git a/lib/comma/render_as_csv.rb b/lib/comma/render_as_csv.rb
index abc1234..def5678 100644
--- a/lib/comma/render_as_csv.rb
+++ b/lib/comma/render_as_csv.rb
@@ -4,7 +4,7 @@ end
def render_with_csv(options = nil, extra_options = {}, &block)
- return render_without_csv(options, extra_options, &block) unless options.is_a?(Hash) and [:csv].present?
+ return render_without_csv(options, extra_options, &block) unless options.is_a?(Hash) and options[:csv].present?
data = options.delete(:csv)
style = options.delete(:style) || :default
send_data Array(data).to_comma(style), options.merge(:type => :csv)
| Fix for csv options being present
|
diff --git a/lib/hawk/model/querying.rb b/lib/hawk/model/querying.rb
index abc1234..def5678 100644
--- a/lib/hawk/model/querying.rb
+++ b/lib/hawk/model/querying.rb
@@ -46,6 +46,14 @@ where(offset: n)
end
+ def order(by)
+ where(order: by)
+ end
+
+ def includes(what)
+ where(includes: what)
+ end
+
# Adds a limit(1) and returns the first record
#
def first
| Add order and includes finders through query string params
|
diff --git a/Library/Contributions/examples/brew-audit.rb b/Library/Contributions/examples/brew-audit.rb
index abc1234..def5678 100644
--- a/Library/Contributions/examples/brew-audit.rb
+++ b/Library/Contributions/examples/brew-audit.rb
@@ -26,6 +26,11 @@ problems << " * Remove 'use_mirror' from url."
end
+ # 2 (or more, if in an if block) spaces before depends_on, please
+ if /^\ ?depends_on/ =~ text
+ problems << " * Check indentation of 'depends_on'."
+ end
+
if /(#\{\w+\s*\+\s*['"][^}]+\})/ =~ text
problems << " * Try not to concatenate paths in string interpolation:\n #{$1}"
end
| Add depends_on spacing checks to brew_audit
|
diff --git a/lib/opal/haml/processor.rb b/lib/opal/haml/processor.rb
index abc1234..def5678 100644
--- a/lib/opal/haml/processor.rb
+++ b/lib/opal/haml/processor.rb
@@ -4,6 +4,8 @@ module Opal
module Haml
class Processor < ::Opal::Processor
+ self.default_mime_type = 'application/javascript'
+
def evaluate(context, locals, &block)
@data = Opal::Haml.compile_haml @data, context.logical_path.sub(/^templates\//, '')
super
| Set app/js as the default mime type
As the class ivar value is not inherited.
fixes #5 (hopefully) |
diff --git a/lib/rack_request_helper.rb b/lib/rack_request_helper.rb
index abc1234..def5678 100644
--- a/lib/rack_request_helper.rb
+++ b/lib/rack_request_helper.rb
@@ -30,6 +30,7 @@ end
end
+ # for Cloudflare behind proxy
def cf_connecting_ip
@env["HTTP_CF_CONNECTING_IP"]
end
| Fix fecthing wrong ip address behind Cloudflare
|
diff --git a/lib/sass/rails/template.rb b/lib/sass/rails/template.rb
index abc1234..def5678 100644
--- a/lib/sass/rails/template.rb
+++ b/lib/sass/rails/template.rb
@@ -3,6 +3,9 @@ module Sass
module Rails
class SassTemplate < Sprockets::SassTemplate
+ def self.default_mime_type
+ 'text/css'
+ end
def evaluate(context, locals, &block)
cache_store = Sprockets::SassCacheStore.new(context.environment)
@@ -30,10 +33,6 @@ end
class ScssTemplate < SassTemplate
- def self.default_mime_type
- 'text/css'
- end
-
def syntax
:scss
end
| Add a default mime extension for .sass files
|
diff --git a/bower2gem.gemspec b/bower2gem.gemspec
index abc1234..def5678 100644
--- a/bower2gem.gemspec
+++ b/bower2gem.gemspec
@@ -9,18 +9,9 @@ spec.authors = ["Sean Collins"]
spec.email = ["sean@cllns.com"]
- spec.summary = %q{TODO: Write a short summary, because Rubygems requires one.}
- spec.description = %q{TODO: Write a longer description or delete this line.}
- spec.homepage = "TODO: Put your gem's website or public repo URL here."
+ spec.summary = %q{Install assets from bower, for gemified assets.}
+ spec.homepage = "https://github.com/cllns/"
spec.license = "MIT"
-
- # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
- # delete this section to allow pushing this gem to any host.
- if spec.respond_to?(:metadata)
- spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
- else
- raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
- end
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
spec.bindir = "exe"
| Update Gemspec, so it can be built
|
diff --git a/lib/statue/backends/udp.rb b/lib/statue/backends/udp.rb
index abc1234..def5678 100644
--- a/lib/statue/backends/udp.rb
+++ b/lib/statue/backends/udp.rb
@@ -2,10 +2,11 @@
module Statue
class UDPBackend
- attr_reader :address
+ attr_reader :host, :port
def initialize(host = nil, port = nil)
- @address = Addrinfo.udp(host || "127.0.0.1", port || 8125)
+ @host = host
+ @port = port
end
def collect_metric(metric)
@@ -18,7 +19,10 @@ private
def socket
- Thread.current[:statue_socket] ||= address.connect
+ Thread.current[:statue_socket] ||= begin
+ socket = UDPSocket.new(Addrinfo.ip(host).afamily)
+ socket.connect(host, port)
+ end
end
def send_to_socket(message)
| Change UDPBackned to be compatible with jruby.
|
diff --git a/lib/unpoly/rails/engine.rb b/lib/unpoly/rails/engine.rb
index abc1234..def5678 100644
--- a/lib/unpoly/rails/engine.rb
+++ b/lib/unpoly/rails/engine.rb
@@ -2,25 +2,31 @@ module Rails
class Engine < ::Rails::Engine
initializer 'unpoly-rails.assets' do |app|
- # The gem package has a dist folder with the pre-built unpoly.js/.css.
- # The folder may be empty in the local repository, or contain a stale build.
- dist_folder = root.join('dist')
+ # Some projects may choose to completely remove the asset pipeline from the project.
+ # In that case the config.assets accessor is not defined.
+ asset_pipeline_required = app.config.respond_to?(:assets)
- # The local repository has a lib/assets folder, but the gem package does not.
- # The Rails asset pipeline can require unpoly.js/.css from there and compile
- # it within the Rails process.
- source_folder = root.join('lib', 'assets')
+ if asset_pipeline_required
+ # The gem package has a dist folder with the pre-built unpoly.js/.css.
+ # The folder may be empty in the local repository, or contain a stale build.
+ dist_folder = root.join('dist')
- is_local_gem = source_folder.directory?
+ # The local repository has a lib/assets folder, but the gem package does not.
+ # The Rails asset pipeline can require unpoly.js/.css from there and compile
+ # it within the Rails process.
+ source_folder = root.join('lib', 'assets')
- # If someone has required the local gem (e.g. `gem 'unpoly', path: '../unpoly'`)
- # we use the local path. This way changes in the source are immediately picked
- # up by the application.
- if is_local_gem
- app.config.assets.paths << source_folder.join('javascripts').to_s
- app.config.assets.paths << source_folder.join('stylesheets').to_s
- else
- app.config.assets.paths << dist_folder.to_s
+ is_local_gem = source_folder.directory?
+
+ # If someone has required the local gem (e.g. `gem 'unpoly', path: '../unpoly'`)
+ # we use the local path. This way changes in the source are immediately picked
+ # up by the application.
+ if is_local_gem
+ app.config.assets.paths << source_folder.join('javascripts').to_s
+ app.config.assets.paths << source_folder.join('stylesheets').to_s
+ else
+ app.config.assets.paths << dist_folder.to_s
+ end
end
end
end
| Fix a bug where unpoly-rails would crash when loaded by a Rails app that has completely removed the asset pipeline
|
diff --git a/config/initializers/apipie.rb b/config/initializers/apipie.rb
index abc1234..def5678 100644
--- a/config/initializers/apipie.rb
+++ b/config/initializers/apipie.rb
@@ -2,7 +2,7 @@ config.app_name = "popHealth"
config.api_base_url = "/api"
config.doc_base_url = "/apipie"
- config.default_version = "3.0"
+ config.default_version = "5.0"
config.api_controllers_matcher = ["#{Rails.root}/app/controllers/api/*.rb", "#{Rails.root}/app/controllers/api/admin/*.rb"]
config.app_info = <<-EOS
API documentation for popHealth. This API is used by the web front end of popHealth but
| Update api version from 3.0 to 5.0 so as not to confuse users |
diff --git a/lib/dooby.rb b/lib/dooby.rb
index abc1234..def5678 100644
--- a/lib/dooby.rb
+++ b/lib/dooby.rb
@@ -3,9 +3,13 @@ #dependencies
require 'fileutils'
require 'digest/sha1'
+
+require 'redline'
+gem 'colored', '1.2'
require 'colored'
-require 'redline'
+gem 'highline', '1.6.1'
require 'highline/import'
+gem 'chronic', '0.3.0'
require 'chronic'
| Load explicit version of the gems if we need explicit version of the gems
|
diff --git a/test/routing/topic_namespacing_test.rb b/test/routing/topic_namespacing_test.rb
index abc1234..def5678 100644
--- a/test/routing/topic_namespacing_test.rb
+++ b/test/routing/topic_namespacing_test.rb
@@ -0,0 +1,65 @@+require 'test_helper'
+
+class TopicRoutingTest < ActionDispatch::IntegrationTest
+ it "routes to the topic show page" do
+ assert_recognizes({
+ controller: 'topics',
+ action: 'show',
+ topic_slug: 'foo-topic',
+ }, '/foo-topic')
+
+ assert_recognizes({
+ controller: 'topics',
+ action: 'show',
+ topic_slug: 'foo-topic',
+ }, '/topic/foo-topic')
+ end
+
+ it "routes to the subtopic show page" do
+ assert_recognizes({
+ controller: 'subtopics',
+ action: 'show',
+ topic_slug: 'foo-topic',
+ subtopic_slug: 'bar-topic',
+ }, '/foo-topic/bar-topic')
+
+ assert_recognizes({
+ controller: 'subtopics',
+ action: 'show',
+ topic_slug: 'foo-topic',
+ subtopic_slug: 'bar-topic',
+ }, '/topic/foo-topic/bar-topic')
+ end
+
+ it "routes to the subtopic latest page" do
+ assert_recognizes({
+ controller: 'subtopics',
+ action: 'latest_changes',
+ topic_slug: 'foo-topic',
+ subtopic_slug: 'bar-topic',
+ }, '/foo-topic/bar-topic/latest')
+
+ assert_recognizes({
+ controller: 'subtopics',
+ action: 'latest_changes',
+ topic_slug: 'foo-topic',
+ subtopic_slug: 'bar-topic',
+ }, '/topic/foo-topic/bar-topic/latest')
+ end
+
+ it "routes to the subtopic email signup page" do
+ assert_recognizes({
+ controller: 'email_signups',
+ action: 'new',
+ topic_slug: 'foo-topic',
+ subtopic_slug: 'bar-topic',
+ }, '/foo-topic/bar-topic/email-signup')
+
+ assert_recognizes({
+ controller: 'email_signups',
+ action: 'new',
+ topic_slug: 'foo-topic',
+ subtopic_slug: 'bar-topic',
+ }, '/topic/foo-topic/bar-topic/email-signup')
+ end
+end
| Add tests for namespaced routing
|
diff --git a/lib/asset_hosting_with_minimum_ssl.rb b/lib/asset_hosting_with_minimum_ssl.rb
index abc1234..def5678 100644
--- a/lib/asset_hosting_with_minimum_ssl.rb
+++ b/lib/asset_hosting_with_minimum_ssl.rb
@@ -6,7 +6,7 @@ end
def call(source, request)
- if request.ssl?
+ if request && request.ssl?
case
when javascript_file?(source)
ssl_asset_host(source)
| Support calling with a false request object.
|
diff --git a/lib/fund_america/selling_agreement.rb b/lib/fund_america/selling_agreement.rb
index abc1234..def5678 100644
--- a/lib/fund_america/selling_agreement.rb
+++ b/lib/fund_america/selling_agreement.rb
@@ -0,0 +1,21 @@+module FundAmerica
+ class SellingAgreement
+ class << self
+
+ # End point: https://apps.fundamerica.com/api/selling_agreements (POST)
+ # Usage: FundAmerica::SellingAgreement.create(options)
+ # Output: Creates a new rta_agreement
+ def create(options)
+ API::request(:post, 'selling_agreements', options)
+ end
+
+ # End point: https://apps.fundamerica.com/api/selling_agreements/:id (GET)
+ # Usage: FundAmerica::SellingAgreement.details(rta_agreement_id)
+ # Output: Returns the details of an rta_agreement with matching id
+ def details(rta_agreement_id)
+ API::request(:get, "selling_agreements/#{selling_agreement_id}")
+ end
+
+ end
+ end
+end
| Add Selling Agreement API points
|
diff --git a/pragma-rails.gemspec b/pragma-rails.gemspec
index abc1234..def5678 100644
--- a/pragma-rails.gemspec
+++ b/pragma-rails.gemspec
@@ -20,6 +20,9 @@ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ['lib']
+ spec.add_dependency 'pragma', '~> 0.1.0'
+ spec.add_dependency 'rails', '>= 4.2.0', '< 6'
+
spec.add_development_dependency 'bundler'
spec.add_development_dependency 'rake'
spec.add_development_dependency 'rspec'
| Add Pragma and Rails dependencies
|
diff --git a/lib/yummydata/criteria/last_update.rb b/lib/yummydata/criteria/last_update.rb
index abc1234..def5678 100644
--- a/lib/yummydata/criteria/last_update.rb
+++ b/lib/yummydata/criteria/last_update.rb
@@ -4,36 +4,64 @@ module Criteria
module LastUpdate
-
-
include Yummydata::Criteria::ServiceDescription
include Yummydata::Criteria::VoID
- COUNT_QUERY = <<-'SPARQL'
-select count (*) where {?s ?p ?o}
-SPARQL
-
-
- def initialize(uri)
- @client = ''
- @uri = uri
+ def prepare(uri)
+ @client = SPARQL::Client.new(uri, {'read_timeout': 5 * 60}) if @uri == uri && @client == nil
+ @uri = uri
end
def last_modified
sd = service_description(@uri)
- return sd.dc if sd contains last update
+ return sd.modified unless sd.modified.nil?
- void = void(@uri)
- return xxx if void contains last_update
+ void = void_on_well_known_uri(@uri)
+ return void.modified unless void.modified.nil?
- response = @client.request(MODIFIED_QUERY)
- return nil if response.nil?
-
- response[:last_update]
+ return nil
end
- def count_first_last
- # DO SOMETHING
+ def count_statements(uri)
+ self.prepare(uri)
+ result = self.query(count_query)
+ return nil if result.nil?
+ return result
+ end
+
+ def first_statement(uri)
+ self.prepare(uri)
+ result = self.query(first_statement_query)
+ return nil if result.nil?
+ return result
+ end
+
+ def last_statement(uri, count)
+ self.prepare(uri)
+ offset = count - 1
+ result = self.query(last_statement_query(offset))
+ return nil if result.nil?
+ return result
+ end
+
+ def count_query
+ return "select count (*) AS ?c where {?s ?p ?o}"
+ end
+
+ def first_statement_query
+ return "select * where {?s ?p ?o} LIMIT 1"
+ end
+
+ def offset_statement_query(offset)
+ return "select * where {?s ?p ?o} OFFSET #{offset} LIMIT 1"
+ end
+
+ def query(query)
+ begin
+ return @client.query(query)
+ rescue
+ return nil
+ end
end
end
| Add the functions that return count of statements and first of statement and arbitrary position of statement
|
diff --git a/netfox.podspec b/netfox.podspec
index abc1234..def5678 100644
--- a/netfox.podspec
+++ b/netfox.podspec
@@ -14,6 +14,7 @@ s.source = { :git => "https://github.com/kasketis/netfox.git", :tag => '1.7.2' }
s.platform = :ios, '8.0'
+ s.platform = :osx, '10.0'
s.requires_arc = true
s.source_files = "netfox"
| Update podspec to support OS X
|
diff --git a/lib/chef/knife/cloudformation_inspect.rb b/lib/chef/knife/cloudformation_inspect.rb
index abc1234..def5678 100644
--- a/lib/chef/knife/cloudformation_inspect.rb
+++ b/lib/chef/knife/cloudformation_inspect.rb
@@ -22,8 +22,17 @@ stack = provider.stacks.get(stack_name)
if(config[:attribute])
attr = config[:attribute].split('.').inject(stack) do |memo, key|
+ args = key.scan(/\(([^)]*)\)/).flatten.first.to_s
+ if(args)
+ args = args.split(',').map{|a| a.to_i.to_s == a ? a.to_i : a}
+ key = key.split('(').first
+ end
if(memo.public_methods.include?(key.to_sym))
- memo.send(key)
+ if(args.size == 1 && args.first.to_s.start_with?('&'))
+ memo.send(key, &args.first.slice(2, args.first.size).to_sym)
+ else
+ memo.send(*[key, args].flatten.compact)
+ end
else
raise NoMethodError.new "Invalid attribute requested! (#{memo.class}#{key})"
end
| Allow some ruby-isms within attribute to allow deep stack inspection
|
diff --git a/jruby-http-kit.gemspec b/jruby-http-kit.gemspec
index abc1234..def5678 100644
--- a/jruby-http-kit.gemspec
+++ b/jruby-http-kit.gemspec
@@ -20,6 +20,7 @@
spec.add_development_dependency "bundler", "~> 1.3"
spec.add_development_dependency "rake"
+ spec.add_development_dependency "rack"
spec.add_development_dependency "rspec"
spec.add_development_dependency "webmachine", "~> 1.2.1"
end
| Add rack as development dependency
|
diff --git a/site-cookbooks/backup_restore/spec/recipes/configure_mysql_spec.rb b/site-cookbooks/backup_restore/spec/recipes/configure_mysql_spec.rb
index abc1234..def5678 100644
--- a/site-cookbooks/backup_restore/spec/recipes/configure_mysql_spec.rb
+++ b/site-cookbooks/backup_restore/spec/recipes/configure_mysql_spec.rb
@@ -0,0 +1,90 @@+require_relative '../spec_helper'
+
+describe 'backup_restore::configure_mysql' do
+ let(:chef_run) do
+ runner = ChefSpec::Runner.new(
+ cookbook_path: %w(site-cookbooks cookbooks),
+ platform: 'centos',
+ version: '6.5'
+ ) do |node|
+ node.set['cloudconductor']['applications'] = {
+ dynamic_git_app: {
+ type: 'dynamic',
+ parameters: {
+ backup_directories: '/var/www/app'
+ }
+ }
+ }
+ node.set['backup_restore']['config']['use_proxy'] = 'localhost'
+ node.set['backup_restore']['sources']['mysql'] = {
+ db_user: 'root',
+ db_password: '',
+ data_dir: '/etc',
+ run_user: 'mysql',
+ run_group: 'mysql'
+ }
+ node.set['backup_restore']['destinations']['s3'] = {
+ bucket: 'cloudconductor',
+ access_key_id: '1234',
+ secret_access_key: '4321',
+ region: 'us-east-1',
+ prefix: '/backup'
+ }
+ end
+ runner.converge(described_recipe)
+ end
+
+ lsn_dir = '/tmp/backup/mysql/lsn_dir'
+
+ it 'creaet lsn directory' do
+ expect(chef_run).to create_directory(lsn_dir).with(
+ recursive: true
+ )
+ end
+
+ it 'create clon full backup' do
+ expect(chef_run).to ChefSpec::Matchers::ResourceMatcher.new(
+ :backup_model,
+ :create,
+ :mysql_full
+ ).with(
+ description: 'Full Backup MySQL database',
+ schedule: {
+ minute: '0',
+ hour: '2',
+ day: '*',
+ month: '*',
+ weekday: '0'
+ },
+ cron_options: {
+ path: ENV['PATH'],
+ output_log: '/var/log/backup/backup.log'
+ }
+ )
+ end
+
+ it 'create clon incremental backup' do
+ expect(chef_run).to ChefSpec::Matchers::ResourceMatcher.new(
+ :backup_model,
+ :create,
+ :mysql_incremental
+ ).with(
+ description: 'Incremental Backup MySQL database',
+ schedule: {
+ minute: '0',
+ hour: '2',
+ day: '*',
+ month: '*',
+ weekday: '1-6'
+ },
+ cron_options: {
+ path: ENV['PATH'],
+ output_log: '/var/log/backup/backup.log'
+ }
+ )
+ end
+
+ it 'set_proxy_env' do
+ expect(chef_run).to run_ruby_block('set_proxy_env')
+ end
+end
| Add chef-spec for configuire_mysql recipe
|
diff --git a/app/models/role.rb b/app/models/role.rb
index abc1234..def5678 100644
--- a/app/models/role.rb
+++ b/app/models/role.rb
@@ -1,21 +1,29 @@ class Role < ActiveRecord::Base
- ADMIN = 'admin'
- CONVENOR = 'convenor'
- TUTOR = 'tutor'
- STUDENT = 'student'
+
+ def self.student
+ Role.find(student_id)
+ end
- ROLES = [ADMIN, CONVENOR, TUTOR, STUDENT]
+ def self.tutor
+ Role.find(tutor_id)
+ end
+ def self.convenor
+ Role.find(convenor_id)
+ end
- scope :student, -> { Role.find(1) }
- scope :tutor, -> { Role.find(2) }
- scope :convenor, -> { Role.find(3) }
- scope :moderator, -> { Role.find(4) }
+ def self.admin
+ Role.find(admin_id)
+ end
#
# Helpers to get the role id's:
# - These could be made into DB queries, but these values should not change
#
+ def self.student_id
+ 1
+ end
+
def self.tutor_id
2
end
@@ -24,11 +32,7 @@ 3
end
- def self.student_id
- 1
- end
-
- def self.moderator_id
+ def self.admin_id
4
end
end | Change Role to use functions instead of scope queries
|
diff --git a/app/models/stop.rb b/app/models/stop.rb
index abc1234..def5678 100644
--- a/app/models/stop.rb
+++ b/app/models/stop.rb
@@ -22,7 +22,15 @@ end
def self.near(location)
- Stop.geo_near(location).max_distance(0.01)
+ if DateTime.now.wday == 0
+ service_id = 2
+ elsif Datetime.now.wday == 6
+ service_id = 1
+ else
+ service_id = 0
+ end
+ stops = Stop.geo_near(location).max_distance(0.01)
+ stops.find(service_id: service_id)
end
end
| Add narrowing functionality to api
|
diff --git a/app/models/user.rb b/app/models/user.rb
index abc1234..def5678 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -2,4 +2,12 @@ acts_as_authentic do |c|
c.login_field = 'email'
end
+
+ def generate_authentication_token
+ token = loop do
+ t = SecureRandom.base64.tr('+/=', 'Qrt')
+ break t unless User.exists?(single_access_token: t)
+ end
+ self.update_attribute(:single_access_token, token)
+ end
end
| Allow single access token requests for GET
|
diff --git a/app/models/user.rb b/app/models/user.rb
index abc1234..def5678 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -4,6 +4,11 @@ devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable,
:omniauthable, :omniauth_providers => [:facebook]
+
+ has_many :collections
+ has_many :comments
+ validates_uniqueness_of :username, :email
+ validates_presence_of :username, :name
def self.from_omniauth(auth)
where(provider: auth.provider, uid: auth.uid).first_or_create do |user|
| Add activerecord relationship and validations
|
diff --git a/app/models/user.rb b/app/models/user.rb
index abc1234..def5678 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -1,6 +1,5 @@ class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
- devise :database_authenticatable, :registerable,
- :recoverable, :rememberable, :trackable, :validatable
+ devise :database_authenticatable, :recoverable, :validatable
end
| User: Remove registerable, trackable, and rememberable
|
diff --git a/lib/active_set/adapter_activerecord.rb b/lib/active_set/adapter_activerecord.rb
index abc1234..def5678 100644
--- a/lib/active_set/adapter_activerecord.rb
+++ b/lib/active_set/adapter_activerecord.rb
@@ -6,8 +6,17 @@ class Adapter::ActiveRecord < Adapter::Base
private
- def can_process_with_active_record?
- @set.respond_to?(:to_sql) && attribute_is_field?
+ def can_query_with_active_record?
+ attribute_is_field?
+ end
+
+ def can_merge_with_active_record?
+ attribute_is_class_method? &&
+ attribute_is_method_with_params?
+ end
+
+ def arel_eager_load_associations
+ @set.eager_load(instruction.associations_hash)
end
def arel_column
@@ -25,11 +34,25 @@ .include?(instruction.attribute)
end
+ def attribute_is_class_method?
+ return false unless attribute_model
+
+ attribute_model.respond_to?(instruction.attribute)
+ end
+
+ def attribute_is_method_with_params?
+ return false unless attribute_model
+
+ attribute_model.method(instruction.attribute).arity != 0
+ end
+
def attribute_model
- instruction.associations_array
- .reduce(@set) do |obj, assoc|
- obj.reflections[assoc.to_s]&.klass
- end
+ tmp_model = instruction.associations_array
+ .reduce(@set) do |obj, assoc|
+ obj.reflections[assoc.to_s]&.klass
+ end
+ # return tmp_model.klass if tmp_model.is_a?(ActiveRecord::Relation)
+ # tmp_model
end
end
end
| Add some ActiveRecord adapter common methods for working with scopes and properly eager loading associations
|
diff --git a/clock.gemspec b/clock.gemspec
index abc1234..def5678 100644
--- a/clock.gemspec
+++ b/clock.gemspec
@@ -2,7 +2,7 @@ Gem::Specification.new do |s|
s.name = 'clock'
s.summary = 'Clock interface with support for dependency configuration for real and null object implementations'
- s.version = '0.0.3.0'
+ s.version = '0.0.3.1'
s.description = ' '
s.authors = ['Obsidian Software, Inc']
| Package version is increased from 0.0.3.0 to 0.0.3.1
|
diff --git a/spec/features/term_recap_emails_spec.rb b/spec/features/term_recap_emails_spec.rb
index abc1234..def5678 100644
--- a/spec/features/term_recap_emails_spec.rb
+++ b/spec/features/term_recap_emails_spec.rb
@@ -0,0 +1,22 @@+# frozen_string_literal: true
+
+require 'rails_helper'
+
+describe 'term recap emails page', type: :feature do
+ let(:admin) { create(:admin, email: 'admin@wikiedu.org') }
+ let(:course) { create(:course, article_count: 2) }
+
+ before do
+ course.campaigns << Campaign.first
+ JoinCourse.new(course: course, user: admin, role: CoursesUsers::Roles::INSTRUCTOR_ROLE)
+ login_as admin
+ end
+
+ it 'lets admins send term recap emails' do
+ visit '/mass_email/term_recap'
+
+ select(Campaign.first.title, from: 'campaign')
+ click_button 'Send recap emails'
+ expect(page).to have_content('Emails are going out')
+ end
+end
| Add basic spec coverage for Term Recap Emails
|
diff --git a/lib/feed2email/lazy_smtp_connection.rb b/lib/feed2email/lazy_smtp_connection.rb
index abc1234..def5678 100644
--- a/lib/feed2email/lazy_smtp_connection.rb
+++ b/lib/feed2email/lazy_smtp_connection.rb
@@ -1,10 +1,9 @@ require 'net/smtp'
+require 'feed2email/configurable'
module Feed2Email
class LazySMTPConnection
- def config
- Feed2Email.config # delegate
- end
+ include Configurable
def connect
smtp.start('localhost', config['smtp_user'], config['smtp_pass'],
| Use Configurable module in LazySMTPConnection
|
diff --git a/lib/jekyll/assets_plugin/site_patch.rb b/lib/jekyll/assets_plugin/site_patch.rb
index abc1234..def5678 100644
--- a/lib/jekyll/assets_plugin/site_patch.rb
+++ b/lib/jekyll/assets_plugin/site_patch.rb
@@ -26,15 +26,15 @@ @assets.css_compressor = assets_config.css_compressor
# bind jekyll and Sprockets context together
- @assets.context_class.instance_variable_set :@jekyll_site, self
+ @assets.context_class.instance_variable_set :@site, self
@assets.context_class.class_eval do
- def jekyll_site
- self.class.instance_variable_get :@jekyll_site
+ def site
+ self.class.instance_variable_get :@site
end
def asset_baseurl
- jekyll_site.assets_config.baseurl.chomp "/"
+ site.assets_config.baseurl.chomp "/"
end
def asset_path(path, options = {})
@@ -42,8 +42,8 @@ raise AssetFile::NotFound, "couldn't find file '#{path}'"
end
- unless jekyll_site.static_files.include? asset
- jekyll_site.static_files << AssetFile.new(jekyll_site, asset)
+ unless site.static_files.include? asset
+ site.static_files << AssetFile.new(site, asset)
end
"#{asset_baseurl}/#{asset.digest_path}".squeeze "/"
| Fix name of jekyll site getter
|
diff --git a/recipes/configure.rb b/recipes/configure.rb
index abc1234..def5678 100644
--- a/recipes/configure.rb
+++ b/recipes/configure.rb
@@ -3,7 +3,7 @@ user "root"
cwd "/tmp"
code <<-EOH
- sed -i 's|LS_HEAP_SIZE="500m"|LS_HEAP_SIZE="<%= node[:logstash][:javaheap] %>"|' /etc/init/logstash
+ sed -i 's|LS_HEAP_SIZE="500m"|LS_HEAP_SIZE="<%= node[:logstash][:javaheap] %>"|' /etc/init.d/logstash
EOH
end
| Change the java heap from 500m to 2g
|
diff --git a/lib/quickbooks/service/access_token.rb b/lib/quickbooks/service/access_token.rb
index abc1234..def5678 100644
--- a/lib/quickbooks/service/access_token.rb
+++ b/lib/quickbooks/service/access_token.rb
@@ -12,7 +12,7 @@ if response
code = response.code.to_i
if code == 200
- result = Quickbooks::Model::AccessTokenResponse.from_xml(response.body)
+ result = Quickbooks::Model::AccessTokenResponse.from_xml(response.plain_body)
end
end
@@ -26,7 +26,7 @@ if response
code = response.code.to_i
if code == 200
- result = Quickbooks::Model::AccessTokenResponse.from_xml(response.body)
+ result = Quickbooks::Model::AccessTokenResponse.from_xml(response.plain_body)
end
end
| Use respons.plain_body in AccessToken Service
|
diff --git a/lib/rspec_api_documentation/railtie.rb b/lib/rspec_api_documentation/railtie.rb
index abc1234..def5678 100644
--- a/lib/rspec_api_documentation/railtie.rb
+++ b/lib/rspec_api_documentation/railtie.rb
@@ -1,7 +1,7 @@ module RspecApiDocumentation
class Railtie < Rails::Railtie
rake_tasks do
- load "tasks/docs.rake"
+ load File.join(File.dirname(__FILE__), '../tasks/docs.rake')
end
end
end
| Use direct path to rake file
Before this, we were relying on the Gem's `lib` dir being on the
$LOAD_PATH, and thus `load` would find the `tasks/doc.rake` file. This
can break when a different gem also has a `tasks/docs.rake` file, and
it's further up in the load path. Same goes for a Rails app with a
`tasks/docs.rake` file existing. This ensures we get OUR
`tasks/docs.rake` file.
|
diff --git a/lib/rubocop/cop/mixin/unused_argument.rb b/lib/rubocop/cop/mixin/unused_argument.rb
index abc1234..def5678 100644
--- a/lib/rubocop/cop/mixin/unused_argument.rb
+++ b/lib/rubocop/cop/mixin/unused_argument.rb
@@ -7,13 +7,6 @@ module UnusedArgument
def join_force?(force_class)
force_class == VariableForce
- end
-
- def autocorrect(node)
- new_name = node.loc.expression.source.sub(/(\W?)(\w+)/, '\\1_\\2')
- @corrections << lambda do |corrector|
- corrector.replace(node.loc.expression, new_name)
- end
end
def after_leaving_scope(scope, _variable_table)
@@ -29,6 +22,12 @@ message = message(variable)
add_offense(variable.declaration_node, :name, message)
end
+
+ def autocorrect(node)
+ @corrections << lambda do |corrector|
+ corrector.insert_before(node.loc.name, '_')
+ end
+ end
end
end
end
| Correct with source location info rather than regexp in UnusedArgument
|
diff --git a/lib/wrapper/resources/search_result.rb b/lib/wrapper/resources/search_result.rb
index abc1234..def5678 100644
--- a/lib/wrapper/resources/search_result.rb
+++ b/lib/wrapper/resources/search_result.rb
@@ -11,6 +11,7 @@ :title,
:uri,
:anv,
- :summary
+ :summary,
+ :thumb
end
| Add thumb accessor to search results model
|
diff --git a/test/unit/donation_test.rb b/test/unit/donation_test.rb
index abc1234..def5678 100644
--- a/test/unit/donation_test.rb
+++ b/test/unit/donation_test.rb
@@ -1,7 +1,9 @@ require 'test_helper'
class DonationTest < ActiveSupport::TestCase
- # test "the truth" do
- # assert true
- # end
+ test "donation can return gravatar url" do
+ @d = Donation.new(email: 'test1@example.com')
+
+ assert_equal Rails.application.config.gravatar_url % "aa99b351245441b8ca95d54a52d2998c", @d.gravatar_url
+ end
end
| Test Donation generates Gravatar URL
Using app settings for the url format
|
diff --git a/spec/acceptance/alternative_pgdata_spec.rb b/spec/acceptance/alternative_pgdata_spec.rb
index abc1234..def5678 100644
--- a/spec/acceptance/alternative_pgdata_spec.rb
+++ b/spec/acceptance/alternative_pgdata_spec.rb
@@ -0,0 +1,24 @@+require 'spec_helper_acceptance'
+
+# These tests ensure that postgres can change itself to an alternative pgdata
+# location properly.
+describe 'postgres::server', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
+ it 'on an alternative pgdata location' do
+ pp = <<-EOS
+ class { 'postgresql::server': data_directory => '/var/pgsql' }
+ EOS
+
+ apply_manifest(pp, :catch_failures => true)
+ apply_manifest(pp, :catch_changes => true)
+ end
+
+ it 'can connect with psql' do
+ psql('-D /var/pgsql --command="\l" postgres', 'postgres') do |r|
+ expect(r.stdout).to match(/List of databases/)
+ end
+ end
+
+end
+
+
+
| Create acceptance test for pgdata
|
diff --git a/spec/ruby/1.8/library/matrix/clone_spec.rb b/spec/ruby/1.8/library/matrix/clone_spec.rb
index abc1234..def5678 100644
--- a/spec/ruby/1.8/library/matrix/clone_spec.rb
+++ b/spec/ruby/1.8/library/matrix/clone_spec.rb
@@ -14,8 +14,8 @@ b.class.should == Matrix
b.should == @a
b.should_not === @a
- 0.upto(2) do |i|
- 0.upto(1) do |j|
+ 0.upto(@a.row_size - 1) do |i|
+ 0.upto(@a.column_size - 1) do |j|
b[i, j].should == @a[i, j]
b[i, j].should_not === @a[i, j]
end
| Use size functions instead of constants.
Signed-off-by: Federico Builes <4398fca13d724d48186a783e21c40201bb8cf2d7@gmail.com>
|
diff --git a/spec/metadata/shared_link_spec.rb b/spec/metadata/shared_link_spec.rb
index abc1234..def5678 100644
--- a/spec/metadata/shared_link_spec.rb
+++ b/spec/metadata/shared_link_spec.rb
@@ -10,7 +10,7 @@
it "works with a hash URL" do
url = "http://www.dropbox.com/my/cats/name/s/mittens"
- shared_link = described_class.new url: url
+ shared_link = described_class.new :url => url
expect(shared_link.to_hash)
.to eq({:url => url})
| Use old style hash syntax
Just in case someone is using this library with an old Ruby version.
|
diff --git a/spec/models/study_content_spec.rb b/spec/models/study_content_spec.rb
index abc1234..def5678 100644
--- a/spec/models/study_content_spec.rb
+++ b/spec/models/study_content_spec.rb
@@ -10,10 +10,9 @@ end
context 'when patient data section does not exist' do
- it 'should return nil' do
+ it 'should return empty string for sharing ipd value' do
xml=Nokogiri::XML(File.read('spec/support/xml_data/example_study.xml'))
study=Study.new({xml: xml, nct_id: 'NCT02260193'}).create
- #binding.pry
expect(study.plan_to_share_ipd).to eq('')
end
end
| Clean up empty field test
|
diff --git a/app/controllers/api/v1/symbols_controller.rb b/app/controllers/api/v1/symbols_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/api/v1/symbols_controller.rb
+++ b/app/controllers/api/v1/symbols_controller.rb
@@ -1,7 +1,10 @@ class Api::V1::SymbolsController < Api::V1::Base
inherit_resources
defaults resource_class: OntologyMember::Symbol
- belongs_to :ontology
+
+ belongs_to :ontology do
+ belongs_to :sentence, optional: true
+ end
actions :index, :show
| Allow the API SymbolsController to belong to a sentence.
|
diff --git a/lib/catissue/domain/participant/clinical/treatment_regimen.rb b/lib/catissue/domain/participant/clinical/treatment_regimen.rb
index abc1234..def5678 100644
--- a/lib/catissue/domain/participant/clinical/treatment_regimen.rb
+++ b/lib/catissue/domain/participant/clinical/treatment_regimen.rb
@@ -0,0 +1,13 @@+module CaTissue
+ class Participant
+ module Clinical
+ # @quirk caTissue The TreatmentRegimen DE class has both a +treatmentOrder+ and a +treatmentOrderCollection+
+ # property. caRuby ignores +treatmentOrder+.
+ class TreatmentRegimen
+ if property_defined?(:treatment_order) and property_defined?(:treatment_orders) then
+ remove_attribute(:treatment_order)
+ end
+ end
+ end
+ end
+end
| Remove bogus caTissue treatment_order property.
|
diff --git a/Futility.podspec b/Futility.podspec
index abc1234..def5678 100644
--- a/Futility.podspec
+++ b/Futility.podspec
@@ -1,6 +1,6 @@ Pod::Spec.new do |s|
s.name = "Futility"
- s.version = "1.0.4"
+ s.version = "1.1"
s.summary = "Some reusable iOS goodness, brought to you by Futurice."
s.homepage = "https://github.com/futurice/Futility"
s.license = { :type => "BSD-3", :file => 'LICENSE' }
| Update podspec for version 1.1
|
diff --git a/app/controllers/api/sign_ups_controller.rb b/app/controllers/api/sign_ups_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/api/sign_ups_controller.rb
+++ b/app/controllers/api/sign_ups_controller.rb
@@ -1,6 +1,12 @@ module Api
class SignUpsController < BaseController
skip_before_action :authenticate!
+
+ def create
+ build_resource
+
+ resource.save!
+ end
private
| Fix api sign ups controller
|
diff --git a/app/controllers/es_hero/home_controller.rb b/app/controllers/es_hero/home_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/es_hero/home_controller.rb
+++ b/app/controllers/es_hero/home_controller.rb
@@ -2,7 +2,7 @@ class HomeController < ActionController::Base
layout false
- protect_from_forgery
+ protect_from_forgery with: :exception
http_basic_authenticate_with name: ENV["ESHERO_USERNAME"], password: ENV["ESHERO_PASSWORD"] if ENV["ESHERO_PASSWORD"]
@@ -10,6 +10,5 @@ @nodes = EsHero.nodes
@indices = EsHero.indices
end
-
end
end
| Set with: exception (no existing issue since only get requests)
|
diff --git a/app/controllers/static_pages_controller.rb b/app/controllers/static_pages_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/static_pages_controller.rb
+++ b/app/controllers/static_pages_controller.rb
@@ -1,5 +1,5 @@ class StaticPagesController < ApplicationController
- caches_page :accessibility, :how_it_works, :terms_and_conditions, :privacy_policy, :crown_copyright, :faq
+ caches_page :accessibility, :how_it_works, :terms_and_conditions, :privacy_policy, :crown_copyright
caches_action :home, :expires_in => 5.minutes
def home
| Remove faq from list of static pages to cache |
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
@@ -2,4 +2,12 @@ # Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
+
+ before_filter :configure_permitted_parameters, if: :devise_controller?
+
+ protected
+
+ def configure_permitted_parameters
+ devise_parameter_sanitizer.for(:sign_up) << :name
+ end
end
| Add 'name' to strong parameters for Devise
Since strong parameters are handled in the controllers in Rails 4,
devise needs to be told to allow the 'name' field in the user
registration form to be passed to the model for record creation. If
this isn't done, the field may be filled in by the user but the
parameter won't make it to the model and record creation will fail with
an empty name.
|
diff --git a/app/workers/feed_eater_schedule_worker.rb b/app/workers/feed_eater_schedule_worker.rb
index abc1234..def5678 100644
--- a/app/workers/feed_eater_schedule_worker.rb
+++ b/app/workers/feed_eater_schedule_worker.rb
@@ -1,11 +1,11 @@ require 'gtfsgraph'
class FeedEaterScheduleWorker < FeedEaterWorker
- def perform(feed_onestop_id, trip_ids, agency_map, route_map, stop_map)
+ def perform(feed_onestop_id, feed_import_id, trip_ids, agency_map, route_map, stop_map)
+ logger.info "FeedEaterScheduleWorker #{feed_onestop_id}: Importing #{trip_ids.size} trips"
feed = Feed.find_by(onestop_id: feed_onestop_id)
-
- logger.info "FeedEaterScheduleWorker #{feed_onestop_id}: Importing #{trip_ids.size} trips"
- # feed_import = FeedImport.create(feed: feed)
+ feed_import = FeedImport.find(feed_import_id)
+ feed_schedule_import = FeedScheduleImport.create(feed_import: feed_import)
graph = nil
begin
graph = GTFSGraph.new(feed.file_path, feed)
@@ -18,15 +18,14 @@ rescue Exception => e
exception_log = "\n#{e}\n#{e.backtrace}\n"
logger.error exception_log
- # feed_import.update(success: false, exception_log: exception_log)
+ feed_schedule_import.update(success: false, exception_log: exception_log)
# Raven.capture_exception(e) if defined?(Raven)
else
logger.info "FeedEaterScheduleWorker #{feed_onestop_id}: Saving successful import"
- # feed.has_been_fetched_and_imported!(on_feed_import: feed_import)
+ feed_schedule_import.update(success: true)
ensure
logger.info "FeedEaterScheduleWorker #{feed_onestop_id}: Saving log & report"
- # feed_import.update(import_log: graph.try(:import_log))
+ feed_schedule_import.update(import_log: graph.try(:import_log))
end
-
end
end
| Add feed_import_id to FESW job; Create and update FeedScheduleImport log record
|
diff --git a/muxr.gemspec b/muxr.gemspec
index abc1234..def5678 100644
--- a/muxr.gemspec
+++ b/muxr.gemspec
@@ -8,8 +8,8 @@ gem.version = Muxr::VERSION
gem.authors = ["Yehuda Katz"]
gem.email = ["wycats@gmail.com"]
- gem.description = %q{TODO: Write a gem description}
- gem.summary = %q{TODO: Write a gem summary}
+ gem.description = %q{A library that exposes a single HTTP connection that it proxies to multiple endpoints based on their Host. It is designed for use with Tokaido.}
+ gem.summary = gem.description
gem.homepage = ""
gem.files = `git ls-files`.split($/)
| Add summary/description to the gemspec.
|
diff --git a/lib/bittrex/client.rb b/lib/bittrex/client.rb
index abc1234..def5678 100644
--- a/lib/bittrex/client.rb
+++ b/lib/bittrex/client.rb
@@ -1,5 +1,6 @@ require 'faraday'
require 'base64'
+require 'json'
module Bittrex
class Client
| Add missing require 'json' to Client
|
diff --git a/lib/chaplin/server.rb b/lib/chaplin/server.rb
index abc1234..def5678 100644
--- a/lib/chaplin/server.rb
+++ b/lib/chaplin/server.rb
@@ -7,6 +7,8 @@
def self.setup(project_path)
set :public_folder, project_path + '/public'
+ set :static_cache_control, [:public, :max_age => 300]
+
set :show_exceptions, false
error do
| Set cache control for static files
|
diff --git a/db/migrate/20140703161500_migrate_bsf_locations_to_areas.rb b/db/migrate/20140703161500_migrate_bsf_locations_to_areas.rb
index abc1234..def5678 100644
--- a/db/migrate/20140703161500_migrate_bsf_locations_to_areas.rb
+++ b/db/migrate/20140703161500_migrate_bsf_locations_to_areas.rb
@@ -0,0 +1,11 @@+class MigrateBsfLocationsToAreas < Mongoid::Migration
+ def self.up
+ BusinessSupportLocationMigrator.run
+ end
+
+ def self.down
+ BusinessSupportEdition.excludes(state: 'archived').each do |bs|
+ bs.update_attribute(:areas, [])
+ end
+ end
+end
| Migrate locations to Mapit areas.
Finds the regional Mapit area identifiers for business support locations
and populates the areas array with them.
|
diff --git a/lib/dnsimple/error.rb b/lib/dnsimple/error.rb
index abc1234..def5678 100644
--- a/lib/dnsimple/error.rb
+++ b/lib/dnsimple/error.rb
@@ -9,8 +9,19 @@
def initialize(http_response)
@http_response = http_response
- super(http_response.parsed_response["message"])
+ super(message_from(http_response))
end
+
+ private
+
+ def message_from(http_response)
+ if http_response.headers["Content-Type"] == "application/json"
+ http_response.parsed_response["message"]
+ else
+ http_response.code
+ end
+ end
+
end
class NotFoundError < RequestError
| Use code as message for non JSON responses
|
diff --git a/nyny.gemspec b/nyny.gemspec
index abc1234..def5678 100644
--- a/nyny.gemspec
+++ b/nyny.gemspec
@@ -23,4 +23,5 @@ spec.add_development_dependency "bundler", "~> 1.3"
spec.add_development_dependency "rake"
spec.add_development_dependency "rspec"
+ spec.add_development_dependency "ruby-prof"
end
| Add ruby-prof as dev dependency
|
diff --git a/lib/html_processor.rb b/lib/html_processor.rb
index abc1234..def5678 100644
--- a/lib/html_processor.rb
+++ b/lib/html_processor.rb
@@ -10,6 +10,7 @@ ACTION_FORM = '//form[@class="action-form"]'.freeze
DATATABLE_DEFAULT = '//table[contains(@class, "datatable-default")]'.freeze
INTRO_IMG = '//p[@class="intro"]/img'.freeze
+ INTRO_PARAGRAPH = '//p[@class="intro"]'.freeze
VIDEO_IFRAME = '//iframe[starts-with(@src, "https://www.youtube.com/embed")]'.freeze
COLLAPSIBLE_SPAN = '//span[@class="collapse"]'.freeze
| Add xpath targeting the intro paragraph.
|
diff --git a/openshift.rb b/openshift.rb
index abc1234..def5678 100644
--- a/openshift.rb
+++ b/openshift.rb
@@ -7,7 +7,7 @@ depends_on "go" => :build
def install
- output_dir = "_output/local/go/bin"
+ output_dir = "_output/local/bin/darwin/amd64/"
system "make", "all", "WHAT=cmd/openshift", "GOFLAGS=-v"
| Update path to binary files |
diff --git a/tools/scripts/mosaic/log_to_mux.rb b/tools/scripts/mosaic/log_to_mux.rb
index abc1234..def5678 100644
--- a/tools/scripts/mosaic/log_to_mux.rb
+++ b/tools/scripts/mosaic/log_to_mux.rb
@@ -0,0 +1,35 @@+def main()
+ if ARGF.argv.empty?
+ puts "#{$PROGRAM_NAME} <log_file>"
+ return 1
+ end
+
+ logfile = ARGF.argv[0]
+ outfile = "/tmp/file.log"
+ puts "Processing: #{logfile}"
+
+ # Filter the input log -- concatenate into single lines for line-at-a-time inspection
+ `grep -B 3 "Saved.*batches" #{logfile} | tr '\n' ' ' | sed "s/--/\\n/g" > /tmp/file.log`
+
+ # Process each line, maintaining a seperate count for each table
+ mux = {}
+ File.open(outfile, "r") do |f|
+ f.each_line do |line|
+ l = line.strip.split(' ')
+ tbl = l[0].split('/')[-1][0...-4]
+ cnt = l[-2].to_i
+
+ if not mux.has_key? tbl
+ mux[tbl] = 0
+ end
+ mux[tbl] += cnt
+ end
+ end
+
+ # Display final counts per table
+ puts mux
+end
+
+if __FILE__ == $0
+ main
+end
| Add script to to parse generation logs
|
diff --git a/lib/json_serializer.rb b/lib/json_serializer.rb
index abc1234..def5678 100644
--- a/lib/json_serializer.rb
+++ b/lib/json_serializer.rb
@@ -38,8 +38,8 @@ def serializable_object
return nil unless @object
- if object.kind_of?(Enumerable)
- object.to_a.map { |item| self.class.new(item).to_hash }
+ if @object.kind_of?(Enumerable)
+ @object.to_a.map { |item| self.class.new(item).to_hash }
else
to_hash
end
@@ -47,7 +47,7 @@
def to_hash
self.class.attributes.each_with_object({}) do |(name, serializer), hash|
- data = self.class.method_defined?(name) ? self.send(name) : object.send(name)
+ data = self.class.method_defined?(name) ? self.send(name) : @object.send(name)
data = Utils.const(self.class, serializer).new(data).serializable_object if serializer
hash[name] = data
end
| Use instance variable instead of accessor method.
|
diff --git a/lib/fog/storm_on_demand.rb b/lib/fog/storm_on_demand.rb
index abc1234..def5678 100644
--- a/lib/fog/storm_on_demand.rb
+++ b/lib/fog/storm_on_demand.rb
@@ -11,6 +11,7 @@ service(:billing, 'storm_on_demand/billing', 'Billing')
service(:monitoring, 'storm_on_demand/monitoring', 'Monitoring')
service(:support, 'storm_on_demand/support', 'Support')
+ service(:account, 'storm_on_demand/account', 'Account')
end
end
| [stormondemand|account] Add Account service to the service lsit
|
diff --git a/lib/metrics/updater.rb b/lib/metrics/updater.rb
index abc1234..def5678 100644
--- a/lib/metrics/updater.rb
+++ b/lib/metrics/updater.rb
@@ -10,8 +10,12 @@ end
def self.run_child_process
- puts 'Metrics updating process started.'
@child_id = fork do
+
+ # Reconnect the database.
+ #
+ Sequel::Model.db.connect(Sequel::Model.db.opts)
+
loop do
pods = find_pods_without_github_metrics.limit(10).all
if pods.empty?
@@ -23,6 +27,7 @@ update pods
end
end
+
end
end
| [Updater] Reconnect to DB after forking.
|
diff --git a/lib/spree_fishbowl.rb b/lib/spree_fishbowl.rb
index abc1234..def5678 100644
--- a/lib/spree_fishbowl.rb
+++ b/lib/spree_fishbowl.rb
@@ -2,19 +2,13 @@ require 'spree_fishbowl/engine'
module SpreeFishbowl
-
- @@fishbowl = nil
-
- def self.connection
- @@fishbowl
- end
def self.enabled?
Spree::Config[:enable_fishbowl]
end
def self.client_from_config
- @@fishbowl ||= SpreeFishbowl::Client.from_config
+ SpreeFishbowl::Client.from_config
end
end
| Simplify Fishbowl connections - no more long-running socket connections |
diff --git a/lib/neo4j_dev_rails.rb b/lib/neo4j_dev_rails.rb
index abc1234..def5678 100644
--- a/lib/neo4j_dev_rails.rb
+++ b/lib/neo4j_dev_rails.rb
@@ -4,7 +4,7 @@ module Neo4jDevRails
require File.expand_path('../neo4j_dev_rails/railtie', __FILE__) if defined?(Rails)
- def clean_neo4j
+ def self.clean_neo4j
response = RestClient.post 'http://localhost:7574/db/data/cypher', { query: 'START n0=node(0),nx=node(*) MATCH n0-[r0?]-(),nx-[rx?]-() WHERE nx <> n0 DELETE r0,rx,nx' }.to_json, accept: :json, content_type: :json
response.code == 200
end
| Make clean_neo4j a Module method, not ment to be mixed in
|
diff --git a/lib/kippt_simple/client.rb b/lib/kippt_simple/client.rb
index abc1234..def5678 100644
--- a/lib/kippt_simple/client.rb
+++ b/lib/kippt_simple/client.rb
@@ -7,8 +7,8 @@ attr_reader :username, :token
def initialize args
- raise ArgumentError.new('Username and token required') if args[:username].nil? or args[:token].nil? or args[:username].empty? or args[:token].empty?
- @username, @token = args[:username], args[:token]
+ @username, @token = args.fetch(:username, ''), args.fetch(:token, '')
+ raise ArgumentError.new('Username and Token cannot be empty') if @username.empty? or @token.empty?
end
def connection
| Raise better error message when username or token is empty.
|
diff --git a/lib/ordinalize_full.rb b/lib/ordinalize_full.rb
index abc1234..def5678 100644
--- a/lib/ordinalize_full.rb
+++ b/lib/ordinalize_full.rb
@@ -7,8 +7,13 @@ in_full ? ordinalize_in_full : ordinalize_in_short
end
+ alias_method :ordinalize_full, \
def ordinalize_in_full
- I18n.t("ordinalize_full.n_#{self}")
+ begin
+ I18n.t("ordinalize_full.n_#{self}", throw: true)
+ rescue ArgumentError
+ raise NotImplementedError, "Unknown locale #{I18n.locale}"
+ end
end
private
| Raise NotImplementedError for unsupported locales
|
diff --git a/lib/tasks/cruise.rake b/lib/tasks/cruise.rake
index abc1234..def5678 100644
--- a/lib/tasks/cruise.rake
+++ b/lib/tasks/cruise.rake
@@ -8,7 +8,11 @@ exit_status = $?.exitstatus
puts "Stopping virtual display..."
`sh -e /etc/init.d/xvfb stop`
+ puts "Cleaning up..."
+ FileUtils.rm_rf("#{Rails.root}/public/uploads/images")
+ FileUtils.rm_rf("#{Rails.root}/public/uploads/tmp")
raise "tests failed!" unless exit_status == 0
+ puts "All tests passed!"
end
task :migrate do
| Clean up the public/uploads folder after ci runs.
|
diff --git a/lib/peddler/request.rb b/lib/peddler/request.rb
index abc1234..def5678 100644
--- a/lib/peddler/request.rb
+++ b/lib/peddler/request.rb
@@ -4,9 +4,9 @@
module Peddler
class Request
- attr :client, :headers, :last_response
+ attr :client, :headers
- attr_accessor :body
+ attr_accessor :body, :last_response
def initialize(client)
@client = client
| Add setter to last_response to fix broken test
|
diff --git a/lib/license_auto/logger.rb b/lib/license_auto/logger.rb
index abc1234..def5678 100644
--- a/lib/license_auto/logger.rb
+++ b/lib/license_auto/logger.rb
@@ -1,5 +1,6 @@ require 'log4r'
require 'license_auto/config/config'
+require 'log4r/outputter/datefileoutputter'
module LicenseAuto
def self.logger
@@ -23,7 +24,7 @@ :trunc => false,
:level => AUTO_LOG_LEVEL)
date_file_output = Log4r::DateFileOutputter.new("data_file_output",
- :dirname => File.dirname(LUTO_CONF.logger.file),
+ :dirname => File.dirname(AUTO_CONF.logger.file),
:date_pattern => '%Y%m%d%H',
:trunc => false)
formatter = Log4r::PatternFormatter.new(:pattern => "%C %.1l %d %p => %M %t")
| Modify LUTO to AUTO from config
|
diff --git a/lib/commands/place_command.rb b/lib/commands/place_command.rb
index abc1234..def5678 100644
--- a/lib/commands/place_command.rb
+++ b/lib/commands/place_command.rb
@@ -1,12 +1,12 @@ class PlaceCommand
def initialize(x, y, direction)
- @x = x
- @y = y
+ @x = x.to_i
+ @y = y.to_i
@direction = direction
end
def valid?(_, board)
- (0..board.x_size).include?(@x.to_i) && (0..board.y_size).include?(@y.to_i)
+ (0..board.x_size).include?(@x) && (0..board.y_size).include?(@y)
end
def execute(robot)
| Initialize PlaceCommand with an integer instead of string
|
diff --git a/lib/redcloth_filter.rb b/lib/redcloth_filter.rb
index abc1234..def5678 100644
--- a/lib/redcloth_filter.rb
+++ b/lib/redcloth_filter.rb
@@ -4,18 +4,27 @@ include ActionView::Helpers::UrlHelper
def initialize(text)
- @smilies = JSON.parse(Rails.cache.read('smilies_list')) || []
@text = smilize(text)
end
def smilize(text)
- @smilies.inject(text) do |text, smiley|
- text.gsub(":#{smiley.code}:", "!#{smiley.path}?#{smiley.ts}(#{smiley.code})!")
+ smilies.inject(text) do |text, smiley|
+ text.gsub(":#{smiley['code']}:", "!#{smiley['path']}?#{smiley['ts']}(#{smiley['code']})!")
end
end
def to_html
auto_link(RedCloth.new(@text).to_html(:textile))
+ end
+
+ private
+
+ def smilies
+ @smilies ||= cached.nil? ? [] : JSON.parse(cached)
+ end
+
+ def cached
+ @cached ||= Rails.cache.read('smilies_list')
end
end
| Fix textilize when smilies are empty
Signed-off-by: chatgris <f9469d12bf3d131e7aae80be27ccfe58aa9db1f1@af83.com>
|
diff --git a/lib/sermepa_web_tpv.rb b/lib/sermepa_web_tpv.rb
index abc1234..def5678 100644
--- a/lib/sermepa_web_tpv.rb
+++ b/lib/sermepa_web_tpv.rb
@@ -1,4 +1,4 @@-require 'active_support'
+require 'active_support/core_ext/module/attribute_accessors'
module SermepaWebTpv
mattr_accessor :transaction_model_transaction_number_attribute
| Load attribute accessors module only
|
diff --git a/recipes/github_ssh_keys.rb b/recipes/github_ssh_keys.rb
index abc1234..def5678 100644
--- a/recipes/github_ssh_keys.rb
+++ b/recipes/github_ssh_keys.rb
@@ -9,8 +9,14 @@ user WS_USER
end
+execute "make sure .ssh/config is owned by the user" do
+ only_if "test -e #{WS_HOME}/.ssh/config"
+ command "chown #{WS_USER} #{WS_HOME}/.ssh/config"
+end
+
execute "add Github configuration to .ssh/config" do
config = "\n\nHost github.com\n User git\n IdentityFile #{WS_HOME}/.ssh/id_github_current"
command "echo '#{config}' >> #{WS_HOME}/.ssh/config"
not_if "grep 'id_github_current' #{WS_HOME}/.ssh/config"
+ user WS_USER
end
| Correct ownership of ~/.ssh/config if it is wrong. Make sure when github is added to the config it creates the file as the user not root |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.