diff
stringlengths 65
26.7k
| message
stringlengths 7
9.92k
|
|---|---|
diff --git a/lib/all_seeing_pi/camera.rb b/lib/all_seeing_pi/camera.rb
index abc1234..def5678 100644
--- a/lib/all_seeing_pi/camera.rb
+++ b/lib/all_seeing_pi/camera.rb
@@ -1,7 +1,13 @@ module AllSeeingPi
class Camera
+ attr_reader :script
+
+ def initialize
+ @script = File.expand_path('../../../capture.sh', __FILE__)
+ end
+
def capture
- `./capture.sh`.strip
+ `#{script}`.strip
end
end
end
|
Use relative path for capture script.
|
diff --git a/spec/factories/staff_members.rb b/spec/factories/staff_members.rb
index abc1234..def5678 100644
--- a/spec/factories/staff_members.rb
+++ b/spec/factories/staff_members.rb
@@ -1,6 +1,14 @@ FactoryGirl.define do
factory :staff_member do
-
+ sequence(:email){ |n| "member#{n}@example.com" }
+ family_name "山田#{n}"
+ given_name "太郎"
+ family_name_kana 'ヤマダ'
+ given_name_kana 'タロウ'
+ password 'pw'
+ start_date { Date.yesterdasy }
+ end_date nil
+ suspended false
end
end
|
Add staff members in factroy
|
diff --git a/lib/c2y/dsl/context/unit.rb b/lib/c2y/dsl/context/unit.rb
index abc1234..def5678 100644
--- a/lib/c2y/dsl/context/unit.rb
+++ b/lib/c2y/dsl/context/unit.rb
@@ -10,18 +10,12 @@ instance_eval(&block)
end
- private
+ [:command, :content, :enable].each do |attr|
+ define_method(attr) do |arg|
+ @result.send("#{attr}=", arg)
+ end
- def command(unit_command)
- @result.command = unit_command.to_s
- end
-
- def content(unit_content)
- @result.content = unit_content
- end
-
- def enable(unit_enable)
- @result.enable = unit_enable
+ private attr
end
end
end
|
Use dynamic method definition in Unit
|
diff --git a/spec/ruboty/dmm/ranking_spec.rb b/spec/ruboty/dmm/ranking_spec.rb
index abc1234..def5678 100644
--- a/spec/ruboty/dmm/ranking_spec.rb
+++ b/spec/ruboty/dmm/ranking_spec.rb
@@ -0,0 +1,21 @@+describe Ruboty::DMM::Ranking do
+ let(:instance) { described_class.new(command).call }
+
+ describe '#call' do
+ context 'with 24 argument' do
+ subject { instance }
+
+ let(:command) { '@ruboty dmm ranking 24' }
+
+ it { is_expected.not_to be_empty }
+ end
+
+ context 'with not registered argument' do
+ subject { -> { instance.size } }
+
+ let(:command) { '@ruboty dmm ranking hoge' }
+
+ it { is_expected.to raise_error(TypeError) }
+ end
+ end
+end
|
Add a spec for Ranking klass
|
diff --git a/spec/support/database_access.rb b/spec/support/database_access.rb
index abc1234..def5678 100644
--- a/spec/support/database_access.rb
+++ b/spec/support/database_access.rb
@@ -32,8 +32,8 @@ ##
# Resets member and admin lists for the test database to [].
def clear_security
- set_security({ 'users' => [], 'roles' => [] },
- { 'users' => [], 'roles' => [] })
+ set_security({ 'names' => [], 'roles' => [] },
+ { 'names' => [], 'roles' => [] })
end
end
|
PUT /_security messup: the key is "names", not "users".
|
diff --git a/CargoBay.podspec b/CargoBay.podspec
index abc1234..def5678 100644
--- a/CargoBay.podspec
+++ b/CargoBay.podspec
@@ -9,7 +9,6 @@ s.source_files = 'CargoBay'
s.requires_arc = true
- s.ios.deployment_target = '5.0'
s.osx.deployment_target = '10.7'
s.frameworks = 'StoreKit'
|
Remove min iOS deployment target
|
diff --git a/Casks/makemkv.rb b/Casks/makemkv.rb
index abc1234..def5678 100644
--- a/Casks/makemkv.rb
+++ b/Casks/makemkv.rb
@@ -1,8 +1,8 @@ class Makemkv < Cask
- version '1.8.11'
- sha256 '6551e167079d49c4bc414ce9494afae2857338ea5fbcd2ed63d705d2313b48a6'
+ version '1.8.12'
+ sha256 '06a7868764871cbf9b1db90def501bee1f4563a7c9bc54f2b1dab2302317aef0'
- url 'http://www.makemkv.com/download/makemkv_v1.8.11_osx.dmg'
+ url 'http://www.makemkv.com/download/makemkv_v1.8.12_osx.dmg'
homepage 'http://www.makemkv.com/'
link 'MakeMKV.app'
|
Update MakeMKV to version 1.8.12
|
diff --git a/lib/swarker/paths_merger.rb b/lib/swarker/paths_merger.rb
index abc1234..def5678 100644
--- a/lib/swarker/paths_merger.rb
+++ b/lib/swarker/paths_merger.rb
@@ -10,7 +10,7 @@ private
def merge(original_paths)
- groups = {}
+ groups = HashWithIndifferentAccess.new
original_paths.each do |path|
if groups[path_key(path)].nil?
@@ -29,7 +29,7 @@
def merge_paths(first_path, second_path)
scheme = first_path.schema.dup
- scheme.values.first['responses'].merge! second_path.schema.values.first['responses']
+ scheme.values.first[:responses].merge! second_path.schema.values.first[:responses]
Swarker::Path.new(first_path.name, scheme, true)
end
end
|
Refactor PathsMerger to store schema in HashWithIndifferentAccess
|
diff --git a/lib/wego/middleware/http.rb b/lib/wego/middleware/http.rb
index abc1234..def5678 100644
--- a/lib/wego/middleware/http.rb
+++ b/lib/wego/middleware/http.rb
@@ -19,7 +19,7 @@ if env[:status].to_s =~ /2\d\d/
env[:body] = Hashie::Rash.new(MultiJson.decode(env[:body]))
if e = env[:body].error
- raise Wego::Error.new "#{e} - #{env[:body].details}"
+ error!(env, "#{e} - #{env[:body].details}")
end
else
error!(env)
|
Add environment output to Wego 2xx errors
|
diff --git a/app/controllers/api/json/geocodings_controller.rb b/app/controllers/api/json/geocodings_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/api/json/geocodings_controller.rb
+++ b/app/controllers/api/json/geocodings_controller.rb
@@ -22,13 +22,15 @@ end
def create
+ table = current_user.tables.where(name: params[:table_name]).first
options = {
user_id: current_user.id,
- table_id: current_user.tables.where(name: params[:table_name]).first.try(:id),
+ table_id: table.id,
formatter: params[:formatter].presence
}
geocoding = Geocoding.create(options)
+ table.automatic_geocoding.destroy if table.automatic_geocoding.present?
Resque.enqueue(Resque::GeocoderJobs, job_id: geocoding.id)
render_jsonp(geocoding.to_json)
|
Remove automatic geocodings when creating new geocoding
|
diff --git a/app/controllers/pages_core/frontend_controller.rb b/app/controllers/pages_core/frontend_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/pages_core/frontend_controller.rb
+++ b/app/controllers/pages_core/frontend_controller.rb
@@ -4,6 +4,8 @@ class PagesCore::FrontendController < ApplicationController
include ApplicationHelper
+
+ before_filter :set_i18n_locale
# Loads @root_pages and @rss_feeds. To automatically load these in your own controllers,
# add the following line to your controller definition:
@@ -15,4 +17,14 @@ @rss_feeds = Page.find( :all, :conditions => 'feed_enabled = 1 AND status = 2' ).collect{ |p| p.working_language = @language; p }
end
+ private
+
+ def set_i18n_locale
+ if @language == 'nor'
+ I18n.locale = :nb
+ else
+ I18n.locale = :en
+ end
+ end
+
end
|
Set I81n locale in FrontendController from params[:language]
|
diff --git a/YumiStartAppSDK/3.4.1/YumiStartAppSDK.podspec b/YumiStartAppSDK/3.4.1/YumiStartAppSDK.podspec
index abc1234..def5678 100644
--- a/YumiStartAppSDK/3.4.1/YumiStartAppSDK.podspec
+++ b/YumiStartAppSDK/3.4.1/YumiStartAppSDK.podspec
@@ -20,7 +20,7 @@
s.ios.deployment_target = "7.0"
- s.source = { :http => "http://ad-sdk.oss-cn-beijing.aliyuncs.com/iOS/StartApp_SDK_v#{s.version}.zip" }
+ s.source = { :http => "http://adsdk.yumimobi.com/iOS/StartApp_SDK_v#{s.version}.zip" }
src_root = "StartApp_SDK_v#{s.version}/lib"
s.vendored_frameworks = "#{src_root}/StartApp.framework"
|
Update startapp sdk source to use cdn
|
diff --git a/app/controllers/concerns/exception_handler.rb b/app/controllers/concerns/exception_handler.rb
index abc1234..def5678 100644
--- a/app/controllers/concerns/exception_handler.rb
+++ b/app/controllers/concerns/exception_handler.rb
@@ -11,8 +11,11 @@ end
def auth_error(exception)
- session[:return_to] = request.env['REQUEST_URI']
message = exception.message
+
+ unless ajax_request?
+ session[:return_to] = request.env['REQUEST_URI']
+ end
if current_user.nil?
redirect_to new_user_registration_url, alert: I18n.t('devise.failure.unauthenticated')
|
Add ajax_request verification to Pundit gem exception handler
Verification to ajax requests to avoid the update of session[:return_to] on these cases.
|
diff --git a/app/serializers/invitables/base_serializer.rb b/app/serializers/invitables/base_serializer.rb
index abc1234..def5678 100644
--- a/app/serializers/invitables/base_serializer.rb
+++ b/app/serializers/invitables/base_serializer.rb
@@ -11,20 +11,10 @@
def subtitle
raise NotImplementedError.new
- case object
- when Group then "Add all members (#{object.members.count})"
- when Contact then "<#{object.email}>"
- when User then "@#{object.username}"
- end
end
def image
raise NotImplementedError.new
- case object
- when Group then object.logo.try(:url, :original, false)
- when Contact then "http://placehold.it/40x40"
- when User then object.avatar_url
- end
end
end
|
Remove unneeded cruft from base invitable serializer
|
diff --git a/spec/features/demo_roster_spec.rb b/spec/features/demo_roster_spec.rb
index abc1234..def5678 100644
--- a/spec/features/demo_roster_spec.rb
+++ b/spec/features/demo_roster_spec.rb
@@ -14,9 +14,9 @@ it "can see risk categories" do
visit root_url
click_link "Roster Demo"
- expect(page).to have_content 'High Risk'
- expect(page).to have_content 'Low Risk'
- expect(page).to have_content 'Medium Risk'
+ expect(page).to have_content 'Demographics'
+ expect(page).to have_content 'Math'
+ expect(page).to have_content 'English'
end
end
|
Update expectations for demo page feature spec
Expecting to see risk categories isn't a good idea because sometimes those categories are empty...
...so let's expect to see fixed column categories instead.
|
diff --git a/spec/github/paged_request_spec.rb b/spec/github/paged_request_spec.rb
index abc1234..def5678 100644
--- a/spec/github/paged_request_spec.rb
+++ b/spec/github/paged_request_spec.rb
@@ -15,15 +15,15 @@ it 'sets default per_page when only custom page passed' do
Github.stub_chain(:api_client, :per_page).and_return nil
Github.stub_chain(:api_client, :get).and_return nil
- Github::PagedRequest.page_request path, {'page' => 3}
+ Github::PagedRequest.page_request path, {'page' => 3, 'per_page' => -1}
Github::PagedRequest.page.should eq 3
- Github::PagedRequest.per_page.should eq 25
+ Github::PagedRequest.per_page.should eq 30
end
it 'sets default page when only custom per_page passed' do
Github.stub_chain(:api_client, :page).and_return nil
Github.stub_chain(:api_client, :get).and_return nil
- Github::PagedRequest.page_request path, {'per_page' => 33}
+ Github::PagedRequest.page_request path, {'per_page' => 33, 'page' => -1}
Github::PagedRequest.page.should eq 1
Github::PagedRequest.per_page.should eq 33
end
|
Update specs to account for fix.
|
diff --git a/spec/odata/query/criteria_spec.rb b/spec/odata/query/criteria_spec.rb
index abc1234..def5678 100644
--- a/spec/odata/query/criteria_spec.rb
+++ b/spec/odata/query/criteria_spec.rb
@@ -0,0 +1,12 @@+require 'spec_helper'
+
+describe OData::Query::Criteria do
+ let(:subject) { OData::Query::Criteria.new(property: :Name) }
+
+ it { expect(subject).to respond_to(:property) }
+ it { expect(subject.property).to eq(:Name)}
+
+ it { expect(subject).to respond_to(:operator) }
+ it { expect(subject).to respond_to(:value) }
+ it { expect(subject).to respond_to(:to_s) }
+end
|
Set up initial specs around OData::Query::Criteria.
|
diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/comments_controller.rb
+++ b/app/controllers/comments_controller.rb
@@ -21,16 +21,20 @@
def destroy
@comment = Comment.find(params[:id])
- @comment.destroy
- redirect_to :back, :notice => "Your post has been deleted"
+ if current_user == @comment.user || current_user == @comment.post.user
+ @comment.destroy
+ redirect_to :back, :notice => "Your post has been deleted"
+ end
end
def update
@comment = Comment.find(params[:id])
- if @comment.update_attributes(user_params)
- redirect_to :back, :notice => "Your comment was updated"
- else
- render "edit"
+ if @comment.user == current_user
+ if @comment.update_attributes(user_params)
+ redirect_to :back, :notice => "Your comment was updated"
+ else
+ render "edit"
+ end
end
end
private
|
Fix update and delete operations
Fix update operation
Fix delete operation
|
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -2,7 +2,7 @@ def index
@projects = Project.by_last_updated.paginate(page: params[:page], per_page: 7)
@entry = Entry.new
- @activities = Entry.last(20).reverse
+ @activities = Entry.order("CREATED_AT DESC").limit(20)
end
def show
|
Use SQL for ordering entries
|
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/sessions_controller.rb
+++ b/app/controllers/sessions_controller.rb
@@ -21,5 +21,6 @@ end
get '/logout' do
+ session.clear
redirect '/'
end
|
Update logout route to clear session
|
diff --git a/robut_whois.gemspec b/robut_whois.gemspec
index abc1234..def5678 100644
--- a/robut_whois.gemspec
+++ b/robut_whois.gemspec
@@ -10,8 +10,8 @@
gem.add_dependency "robut", "~> 0.3"
gem.add_dependency "whois", "~> 2.1.0"
- gem.add_development_dependency "rspec"
gem.add_development_dependency "rspec", "~> 2.7.0"
+ gem.add_development_dependency "rake", "~> 0.9.2.2"
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
gem.files = `git ls-files`.split("\n")
|
Add rake to the development dependancies, for travis-ci.org
|
diff --git a/roles/teraswitch.rb b/roles/teraswitch.rb
index abc1234..def5678 100644
--- a/roles/teraswitch.rb
+++ b/roles/teraswitch.rb
@@ -2,6 +2,11 @@ description "Role applied to all servers at TeraSwitch Networks"
default_attributes(
+ :accounts => {
+ :users => {
+ :sysadmin => { :status => :administrator }
+ }
+ },
:hosted_by => "TeraSwitch Networks",
:location => "Pittsburgh, Pennsylvania",
:networking => {
|
Add remote hands account for TeraSwitch
|
diff --git a/tty-cursor.gemspec b/tty-cursor.gemspec
index abc1234..def5678 100644
--- a/tty-cursor.gemspec
+++ b/tty-cursor.gemspec
@@ -19,6 +19,8 @@ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]
+ spec.required_ruby_version = '>= 2.0.0'
+
spec.add_development_dependency 'bundler', '>= 1.6'
spec.add_development_dependency 'rspec', '~> 3.1'
spec.add_development_dependency 'rake'
|
Change to restrict to Ruby 2.0
|
diff --git a/lib/pureftpd_user_patch.rb b/lib/pureftpd_user_patch.rb
index abc1234..def5678 100644
--- a/lib/pureftpd_user_patch.rb
+++ b/lib/pureftpd_user_patch.rb
@@ -0,0 +1,19 @@+module Plugin
+ module Pureftpd
+ module User
+ def self.included(base)
+ base.send(:include, InstanceMethods)
+ base.class_eval do
+ before_save :update_pureftpd_user
+ end
+ end
+
+ module InstanceMethods
+ private
+ def update_pureftpd_user
+ PureftpdUser.update_user(self) if self.password
+ end
+ end
+ end
+ end
+end
|
Patch the redmine User model to add another before_save hook.
|
diff --git a/SSPPullToRefresh/SSPPullToRefresh.podspec b/SSPPullToRefresh/SSPPullToRefresh.podspec
index abc1234..def5678 100644
--- a/SSPPullToRefresh/SSPPullToRefresh.podspec
+++ b/SSPPullToRefresh/SSPPullToRefresh.podspec
@@ -0,0 +1,18 @@+Pod::Spec.new do |s|
+ s.name = 'SSPPullToRefresh'
+ s.version = '0.1.9'
+ s.summary = 'General classes for "Pull-To-Refresh" concept customisation'
+
+ s.description = <<-DESC
+This general classes provide for client the possbility to make own derived implementations
+ DESC
+
+ s.homepage = 'https://github.com/Sergey-Lomov/SSPPullToRefresh'
+ s.author = { 'Sergey Lomov' => 'SSpirit10000@gmail.com' }
+ s.license = { :type => 'MIT', :file => 'LICENSE' }
+ s.source = { :git => 'https://github.com/Sergey-Lomov/SSPPullToRefresh.git', :tag => s.version.to_s }
+
+ s.ios.deployment_target = '10.1'
+ s.source_files = '**/*.swift'
+
+end
|
Update pod spec to 0.1.9
|
diff --git a/lib/wptemplates/regexes.rb b/lib/wptemplates/regexes.rb
index abc1234..def5678 100644
--- a/lib/wptemplates/regexes.rb
+++ b/lib/wptemplates/regexes.rb
@@ -15,7 +15,7 @@ end
def an_equals_no_doubleclosebrace_or_pipe
- /\|(([^|=}]|}(?!}))+)=/
+ /\|(([^|=}]|}(?!}))*)=/
end
def a_pipe
|
Make Wptemplates::Regexes.an_equals_no_doubleclosebrace_or_pipe accept empty param names
|
diff --git a/lib/facebook/messenger/server.rb b/lib/facebook/messenger/server.rb
index abc1234..def5678 100644
--- a/lib/facebook/messenger/server.rb
+++ b/lib/facebook/messenger/server.rb
@@ -6,48 +6,46 @@ # This module holds the server that processes incoming messages from the
# Facebook Messenger Platform.
class Server
- class << self
- def call(env)
- @request = Rack::Request.new(env)
- @response = Rack::Response.new
+ def self.call(env)
+ new.call(env)
+ end
- case @request.request_method
- when 'GET' then verify
- when 'POST' then receive
- else method_not_allowed
- end
+ def call(env)
+ @request = Rack::Request.new(env)
+ @response = Rack::Response.new
+
+ case
+ when @request.get? then verify
+ when @request.post? then receive
+ else @response.status = 405
end
- def verify
- verify_token = Facebook::Messenger.config.verify_token
+ @response.finish
+ end
- if @request.params['hub.verify_token'] == verify_token
- @response.write @request.params['hub.challenge']
- else
- @response.write 'Error; wrong verify token'
+ def verify
+ if @request['hub.verify_token'] == verify_token
+ @response.write @request['hub.challenge']
+ else
+ @response.write 'Error; wrong verify token'
+ end
+ end
+
+ def verify_token
+ Facebook::Messenger.config.verify_token
+ end
+
+ def receive
+ hash = JSON.parse(@request.body.read)
+
+ # Facebook may batch several items in the 'entry' array during
+ # periods of high load.
+ hash['entry'].each do |entry|
+ # Facebook may batch several items in the 'messaging' array during
+ # periods of high load.
+ entry['messaging'].each do |messaging|
+ Facebook::Messenger::Bot.receive(messaging)
end
-
- @response.finish
- end
-
- def receive
- hash = JSON.parse(@request.body.read)
- # Facebook may batch several items in the 'entry' array during
- # periods of high load.
- hash['entry'].each do |entry|
- # Facebook may batch several items in the 'messaging' array during
- # periods of high load.
- entry['messaging'].each do |messaging|
- Facebook::Messenger::Bot.receive(messaging)
- end
- end
-
- @response.finish
- end
-
- def method_not_allowed
- @response.status = 405
- @response.finish
end
end
end
|
Use instance variables for request/response data.
I think this would be more friendly for threaded
servers. I don't think request/response data should
be shared.
|
diff --git a/lib/gov_kit/transparency_data.rb b/lib/gov_kit/transparency_data.rb
index abc1234..def5678 100644
--- a/lib/gov_kit/transparency_data.rb
+++ b/lib/gov_kit/transparency_data.rb
@@ -13,6 +13,13 @@ parse(response)
end
end
+
+ class Entity < TransparencyDataResource
+ def self.find_by_id(id)
+ response = get("/entities/#{id}.json")
+ parse(response)
+ end
+ end
end
end
|
Add transparencydata contribution aggregates entity support
|
diff --git a/lib/protobuf/field/enum_field.rb b/lib/protobuf/field/enum_field.rb
index abc1234..def5678 100644
--- a/lib/protobuf/field/enum_field.rb
+++ b/lib/protobuf/field/enum_field.rb
@@ -53,7 +53,7 @@ if default.is_a?(Symbol)
type_class.const_get(default)
else
- type_class.enums.first
+ type_class.fetch(default) || type_class.enums.first
end
end
|
Use type_class.fetch to get a default value if it exists
|
diff --git a/lib/serverkit/resources/goget.rb b/lib/serverkit/resources/goget.rb
index abc1234..def5678 100644
--- a/lib/serverkit/resources/goget.rb
+++ b/lib/serverkit/resources/goget.rb
@@ -12,7 +12,10 @@
# @note Override
def check
- Dir.exists?("#{ENV['GOPATH']}/src/#{url}")
+ go_package_dir_path = "#{ENV['GOPATH']}/src/#{url}"
+ check_command(
+ backend.command.get(:check_file_is_directory, go_package_dir_path)
+ )
end
end
end
|
Use SpecInfra command to check directory exists
|
diff --git a/week-6/die-2/my_solution.rb b/week-6/die-2/my_solution.rb
index abc1234..def5678 100644
--- a/week-6/die-2/my_solution.rb
+++ b/week-6/die-2/my_solution.rb
@@ -1,38 +1,94 @@ # Die Class 2: Arbitrary Symbols
-# I worked on this challenge [by myself, with: ].
+# I worked on this challenge [by myself].
# I spent [#] hours on this challenge.
# Pseudocode
-# Input:
-# Output:
+# Input: Arbetrary list of strings (array)
+# Output: a die with enough sides to hold each symbol input
# Steps:
+=begin
+1) accept an array of symbols and check if it is a legal die (>0 sides)
+2) IF the input is an array and has more than 0 sides
+ set the sides equal to the lenght of the list and set the list as a instance variable
+ ELSE Count the objects and set the die to have that many sides.it is illegal return an error
+ Also name each side with a label array.
+3) Return the number of sides of the die object if called
+4) If rolled return a random position between 0 and the number of sides -1 and return its label
+
+
+=end
# Initial Solution
+=begin
+class Die
+ def initialize(labels)
+ if labels.is_a?(Array) && labels.length > 0
+ @labels=labels
+ @sides=labels.length
+ else
+ raise ArgumentError.new("Not a leagal die")
+ end
+ end
+
+ def sides
+ @sides
+ end
+
+ def roll
+ return @labels[rand(0..@sides-1)]
+ end
+end
+=end
+
+
+# Refactored Solution
class Die
def initialize(labels)
+ if labels.is_a?(Array) && labels.length > 0
+ @labels=labels
+ @sides=labels.length
+ else
+ raise ArgumentError.new("Not a leagal die")
+ end
end
- def sides
- end
+ attr_reader :sides
def roll
+ return @labels[rand(0..@sides-1)]
end
end
-
-
-
-# Refactored Solution
+# Reflection
+=begin
+-What were the main differences between this die class and the last one you created in terms of implementation?
+-Did you need to change much logic to get this to work?
+
+The main difference is that we needed to keep track of the symbols that were passed in so we could reference
+the die roll to the symbol. It basically needed an extra instance variable set to the original array.
+
+-What does this exercise teach you about making code that is easily changeable or modifiable?
+
+Classes are powerful tools. If you know that you will make objects that behave similarly you can create
+shared code and only have to modify a little to get lots of flexiablity.
-# Reflection+What new methods did you learn when working on this challenge, if any?
+I used is_a?(Array) to ensure that the input was an array to check for a legal die. At first
+I put a space between ? (Array) it did not work so I learned it has to be right after.
+
+
+What concepts about classes were you able to solidify in this challenge?
+Mainly instance variables are required if you want to keep shared info within the class
+
+=end
|
Add solution file for 6.2
|
diff --git a/config/initializers/new_framework_defaults.rb b/config/initializers/new_framework_defaults.rb
index abc1234..def5678 100644
--- a/config/initializers/new_framework_defaults.rb
+++ b/config/initializers/new_framework_defaults.rb
@@ -9,10 +9,10 @@ Rails.application.config.action_controller.raise_on_unfiltered_parameters = true
# Enable per-form CSRF tokens. Previous versions had false.
-Rails.application.config.action_controller.per_form_csrf_tokens = false
+Rails.application.config.action_controller.per_form_csrf_tokens = true
# Enable origin-checking CSRF mitigation. Previous versions had false.
-Rails.application.config.action_controller.forgery_protection_origin_check = false
+Rails.application.config.action_controller.forgery_protection_origin_check = true
# Make Ruby 2.4 preserve the timezone of the receiver when calling `to_time`.
# Previous versions had false.
|
Improve CSRF strength through new defaults
This seems like it won't increase our current false flags,
because forms that previously would have been valid should
still be valid after this.
|
diff --git a/db/seeds.rb b/db/seeds.rb
index abc1234..def5678 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -34,4 +34,20 @@ username: "mochi",
email: "mochi@gmail.com",
password: "1234"
+})
+
+Item.create({
+ name: "Hiking Shoes",
+ description: "Going out on a hike? Take these! Waterproof, sturdy, AND comfy!",
+ image: "https://www.rei.com/media/51e99672-0a61-4a37-835c-a6aa46da7eb8",
+ quantity: 20,
+ price: 100
+})
+
+Category.create({
+ name: "Movies"
+})
+
+Category.create({
+ name: "Shoes"
})
|
Update seed file so that a few categories are created off the bat
|
diff --git a/db/seeds.rb b/db/seeds.rb
index abc1234..def5678 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -12,13 +12,13 @@ puts 1
puts 2
puts 3
-cases:
-- input: "5\\n1"
- expected_output: 25
-- input: "5\\n1"
- expected_output: 16
features: step instructions console
END
+#cases:
+#- input: "5\\n1"
+# expected_output: 25
+#- input: "5\\n1"
+# expected_output: 16
Exercise.create! path: '1.1.2',
title: 'Fix the `NoMethodError`',
|
Remove test cases for deployed version.
|
diff --git a/db/seeds.rb b/db/seeds.rb
index abc1234..def5678 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -4,8 +4,9 @@ gds_organisation_id = "af07d5a5-df63-4ddc-9383-6a666845ebe9"
User.create!(
name: "Test user",
- permissions: ["signin", "GDS Admin"],
+ permissions: ["signin", "GDS Admin", "GDS Editor"],
organisation_content_id: gds_organisation_id,
+ organisation_slug: "test-organisation"
)
end
|
Add more permissions to the seed user
As part of writing E2E tests for Whitehall we want the user to have
access to all permissions options, and to have an organisation to
edit.
|
diff --git a/DAAppsViewController.podspec b/DAAppsViewController.podspec
index abc1234..def5678 100644
--- a/DAAppsViewController.podspec
+++ b/DAAppsViewController.podspec
@@ -1,6 +1,6 @@ Pod::Spec.new do |s|
s.name = 'DAAppsViewController'
- s.version = '1.1.0'
+ s.version = '1.2.0'
s.platform = :ios
s.license = 'MIT'
s.summary = 'DAAppsViewController is a simple way of displaying apps from the App Store in an aesthetically similar manner.'
|
Update podspec version to 1.2.0
|
diff --git a/app/controllers/projects/refs_controller.rb b/app/controllers/projects/refs_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/projects/refs_controller.rb
+++ b/app/controllers/projects/refs_controller.rb
@@ -37,7 +37,7 @@ 0
end
- @limit = 10
+ @limit = 25
@path = params[:path]
|
Increase commit log amount for tree view from 10 to 25
Signed-off-by: Dmitriy Zaporozhets <be23d75b156792e5acab51b196a2deb155d35d6a@gmail.com>
|
diff --git a/app/helpers/gitlab_routing_helper.rb b/app/helpers/gitlab_routing_helper.rb
index abc1234..def5678 100644
--- a/app/helpers/gitlab_routing_helper.rb
+++ b/app/helpers/gitlab_routing_helper.rb
@@ -1,4 +1,17 @@ # Shorter routing method for project and project items
+# Since update to rails 4.1.9 we are now allowed to use `/` in project routing
+# so we use nested routing for project resources which include project and
+# project namespace. To avoid writing long methods every time we define shortcuts for
+# some of routing.
+#
+# For example instead of this:
+#
+# namespace_project_merge_request_path(merge_request.project.namespace, merge_request.projects, merge_request)
+#
+# We can simply use shortcut:
+#
+# merge_request_path(merge_request)
+#
module GitlabRoutingHelper
def project_path(project, *args)
namespace_project_path(project.namespace, project, *args)
|
Add explanation to routing method
|
diff --git a/Formula/instantclient-sqlplus.rb b/Formula/instantclient-sqlplus.rb
index abc1234..def5678 100644
--- a/Formula/instantclient-sqlplus.rb
+++ b/Formula/instantclient-sqlplus.rb
@@ -17,5 +17,8 @@ end
lib.install Dir["*.dylib"]
bin.install ["sqlplus"]
+ if MacOS.version == :catalina
+ bin.env_script_all_files(libexec, "DYLD_LIBRARY_PATH" => HOMEBREW_PREFIX/"lib")
+ end
end
end
|
Work around the Catalina issues with sqlplus
|
diff --git a/init.rb b/init.rb
index abc1234..def5678 100644
--- a/init.rb
+++ b/init.rb
@@ -1,4 +1,4 @@-if RAILS_ENV == "test"
+if RAILS_ENV.index("test")
require 'active_support/test_case'
|
Check for any environment that contains 'test'.
|
diff --git a/app/resources/pragma/devise/token/operation/create.rb b/app/resources/pragma/devise/token/operation/create.rb
index abc1234..def5678 100644
--- a/app/resources/pragma/devise/token/operation/create.rb
+++ b/app/resources/pragma/devise/token/operation/create.rb
@@ -15,9 +15,9 @@ def call
validate! OpenStruct.new
- user = self.class.model_klass.find_for_authentication(email: params[:email])
+ context.user = self.class.model_klass.find_for_authentication(email: params[:email])
- unless user && user.valid_password?(params[:password])
+ unless context.user && context.user.valid_password?(params[:password])
respond_with!(
status: :unprocessable_entity,
resource: {
@@ -27,21 +27,21 @@ )
end
- unless user.active_for_authentication?
+ unless context.user.active_for_authentication?
respond_with!(
status: :unauthorized,
resource: {
- error_type: user.inactive_message,
+ error_type: context.user.inactive_message,
error_message: I18n.t(
- "devise.failure.#{user.inactive_message}",
+ "devise.failure.#{context.user.inactive_message}",
default: 'You cannot authenticate at this moment.'
)
}
)
end
- token = Knock::AuthToken.new payload: { sub: user.id }
- respond_with status: :created, resource: { token: token.token }
+ context.token = Knock::AuthToken.new payload: { sub: context.user.id }
+ respond_with status: :created, resource: { token: context.token.token }
end
end
end
|
Save user and token in context on token creation
|
diff --git a/test/unit/raml_poliglota_test.rb b/test/unit/raml_poliglota_test.rb
index abc1234..def5678 100644
--- a/test/unit/raml_poliglota_test.rb
+++ b/test/unit/raml_poliglota_test.rb
@@ -0,0 +1,21 @@+require 'test/unit'
+require File.expand_path '../../../lib/raml_poliglota.rb', __FILE__
+require File.expand_path '../../../lib/model/execution.rb', __FILE__
+
+class RamlPoliglotaTest < Test::Unit::TestCase
+
+ include RamlPoliglota
+ include Model
+
+ def test_load
+ e = Execution.new
+ e.raml_path = File.expand_path 'test/resource/verbum-domini.raml'
+ e.output = 'tmp/generated-raml-sources'
+ e.language = 'java'
+ e.namespace = 'br.mg.gv'
+
+ api = RamlPoliglota.new { |rp| rp.execution = e }
+ api.execute
+ end
+
+end
|
Create unit test to main class.
|
diff --git a/lib/jsonapi/active_record_operations_processor.rb b/lib/jsonapi/active_record_operations_processor.rb
index abc1234..def5678 100644
--- a/lib/jsonapi/active_record_operations_processor.rb
+++ b/lib/jsonapi/active_record_operations_processor.rb
@@ -18,7 +18,7 @@ # Catch errors that should be handled before JSONAPI::Exceptions::Error
# and other unprocessed exceptions
def process_operation(operation)
- with_default_handling do
+ with_default_handling do
begin
operation.apply
rescue ActiveRecord::DeleteRestrictionError => e
@@ -26,9 +26,10 @@ return JSONAPI::ErrorsOperationResult.new(record_locked_error.errors[0].code, record_locked_error.errors)
rescue ActiveRecord::RecordNotFound
- record_not_found = JSONAPI::Exceptions::RecordNotFound.new(operation.associated_key)
+ key = operation.respond_to?(:associated_key) ? operation.associated_key : :unavailable
+ record_not_found = JSONAPI::Exceptions::RecordNotFound.new(key)
return JSONAPI::ErrorsOperationResult.new(record_not_found.errors[0].code, record_not_found.errors)
end
- end
+ end
end
end
|
Check method defined in rescue block, add fallback
|
diff --git a/lib/vagrant-proxyconf/cap/linux/npm_proxy_conf.rb b/lib/vagrant-proxyconf/cap/linux/npm_proxy_conf.rb
index abc1234..def5678 100644
--- a/lib/vagrant-proxyconf/cap/linux/npm_proxy_conf.rb
+++ b/lib/vagrant-proxyconf/cap/linux/npm_proxy_conf.rb
@@ -6,7 +6,7 @@ module NpmProxyConf
# @return [Boolean] if npm is installed
def self.npm_proxy_conf(machine)
- machine.communicate.test('which npm')
+ machine.communicate.test('which npm', sudo: true)
end
end
end
|
Test for npm availability in sudo context
npm proxy provider runs
@machine.communicate.sudo(command).
cap provider verifies availability of npm with `which' NOT
using sudo.
This may result in:
- which succeeds for the ssh user (mostly vagrant)
- machine.communicate.sudo('npm do something') does not
succeed because sudo target user does not have the same
PATH variable configured.
This may result in the following error message breaking the
Vagrant environment completely:
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
npm config set proxy http://some.configured.proxy.here:8080/
Stdout from the command:
Stderr from the command:
bash: line 2: npm: command not found
|
diff --git a/app/workers/personal_access_tokens/expiring_worker.rb b/app/workers/personal_access_tokens/expiring_worker.rb
index abc1234..def5678 100644
--- a/app/workers/personal_access_tokens/expiring_worker.rb
+++ b/app/workers/personal_access_tokens/expiring_worker.rb
@@ -3,7 +3,7 @@ module PersonalAccessTokens
class ExpiringWorker
include ApplicationWorker
- include CronjobQueue # rubocop:disable Scalability/CronWorkerContext
+ include CronjobQueue
feature_category :authentication_and_authorization
@@ -12,11 +12,13 @@ limit_date = PersonalAccessToken::DAYS_TO_EXPIRE.days.from_now.to_date
User.with_expiring_and_not_notified_personal_access_tokens(limit_date).find_each do |user|
- notification_service.access_token_about_to_expire(user)
+ with_context(user: user) do
+ notification_service.access_token_about_to_expire(user)
- Rails.logger.info "#{self.class}: Notifying User #{user.id} about expiring tokens" # rubocop:disable Gitlab/RailsLogger
+ Rails.logger.info "#{self.class}: Notifying User #{user.id} about expiring tokens" # rubocop:disable Gitlab/RailsLogger
- user.personal_access_tokens.expiring_and_not_notified(limit_date).update_all(expire_notification_delivered: true)
+ user.personal_access_tokens.expiring_and_not_notified(limit_date).update_all(expire_notification_delivered: true)
+ end
end
end
end
|
Add latest changes from gitlab-org/gitlab@master
|
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
@@ -4,14 +4,14 @@ protect_from_forgery with: :exception
rescue_from CanCan::AccessDenied do |exception|
- @item = find_action_item_type_in_item().first if @item == nil
+ @item = find_action_item_type_in_item.first if @item == nil
redirect_to item_path(@item), :notice => exception.message
end
def find_next_item(user)
if user.nil? || user.has_no_votes?
- find_action_item_type_in_item().first
+ find_action_item_type_in_item.first
else
get_items_to_vote_on(user).order(:id).first.id
end
@@ -23,11 +23,11 @@ end
def get_items_to_vote_on(user)
- find_action_item_type_in_item().where('items.id NOT IN (?)', get_item_id_from_vote(user))
+ find_action_item_type_in_item.where('items.id NOT IN (?)', get_item_id_from_vote(user))
end
private
- def find_action_item_type_in_item()
+ def find_action_item_type_in_item
Item.includes(:item_type).where(item_types: { name: "Action" })
end
end
|
Fix Coding Style For find_action_item_type_in_item
|
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,10 @@ # Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
+
+ def current_user
+ @current_user ||= User.find(session[:user_id]) if session[:user_id]
+ end
+ helper_method :current_user
+
end
|
Add current_user helper method for quick session grab
|
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,7 +1,6 @@ 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
before_filter :configure_permitted_devise_params, if: :devise_controller?
|
Stop forgery protection from raising exceptions in API calls.
API calls don't have the CSRF tokens but are legit so allow them to happen in a
null session. They are authenticated every time, so they don't need a real
session.
|
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
@@ -18,7 +18,7 @@ def check_local_only
return true if Rails.env == "test"
- if Yogo::Settings[:local_only] && !request.env["REMOTE_ADDR"].match("127.0.0.1")
+ if Yogo::Settings[:local_only] && !["127.0.0.1", "0:0:0:0:0:0:0:1%0"].include?(request.env["REMOTE_ADDR"])
# Raise a 403 exception or perhaps just redirect.
render(:text => 'This resource is forbidden.', :status => 403) and return
end
|
Check for local ipv6 address.
|
diff --git a/app/presenters/calculator_content_item.rb b/app/presenters/calculator_content_item.rb
index abc1234..def5678 100644
--- a/app/presenters/calculator_content_item.rb
+++ b/app/presenters/calculator_content_item.rb
@@ -23,7 +23,7 @@ title: calculator.title,
base_path: base_path,
schema_name: 'placeholder_calculator',
- document_type: 'calculator_document',
+ document_type: 'calculator',
details: {},
publishing_app: 'calculators',
rendering_app: 'calculators',
|
Rename document type to “calculator”
We want to start using `document_type` in place of the deprecated `format` as the value of the `govuk:format` meta tag when using `govuk_components` (https://github.com/alphagov/static/pull/841).
In order to not change the current contents of the meta tag for calculators, this commit changes the `document_type` to match the current `format`.
|
diff --git a/app/serializers/environment_serializer.rb b/app/serializers/environment_serializer.rb
index abc1234..def5678 100644
--- a/app/serializers/environment_serializer.rb
+++ b/app/serializers/environment_serializer.rb
@@ -1,3 +1,42 @@ class EnvironmentSerializer < BaseSerializer
+ Struct.new('Item', :name, :size, :id, :latest)
+
entity EnvironmentEntity
+
+ def with_folders
+ tap { @itemize = true }
+ end
+
+ def itemized?
+ @itemize
+ end
+
+ def represent(resource, opts = {})
+ # resource = paginate(resource) if paginated?
+
+ if itemized?
+ itemize(resource).map do |item|
+ { name: item.name,
+ size: item.size,
+ latest: super(item.latest, opts) }
+ end
+ else
+ super(resource, opts)
+ end
+ end
+
+ private
+
+ def itemize(resource)
+ items = resource.group(:item_name).order('item_name ASC')
+ .pluck('COALESCE(environment_type, name) AS item_name',
+ 'COUNT(*) AS environments_count',
+ 'MAX(id) AS last_environment_id')
+
+ environments = resource.where(id: items.map(&:last))
+
+ items.zip(environments).map do |item|
+ Struct::Item.new(*item.flatten)
+ end
+ end
end
|
Use serializer to group environments into folders
|
diff --git a/app/services/email_alerts_unsubscriber.rb b/app/services/email_alerts_unsubscriber.rb
index abc1234..def5678 100644
--- a/app/services/email_alerts_unsubscriber.rb
+++ b/app/services/email_alerts_unsubscriber.rb
@@ -26,7 +26,7 @@ args.merge!({ govuk_request_id: }) if govuk_request_id
end
- Services.email_alert_api.bulk_unsubscribe(args)
+ Services.email_alert_api.bulk_unsubscribe(**args)
end
private
|
Fix converting hash to keyword arguments
|
diff --git a/lib/formalist/elements/standard/text_field.rb b/lib/formalist/elements/standard/text_field.rb
index abc1234..def5678 100644
--- a/lib/formalist/elements/standard/text_field.rb
+++ b/lib/formalist/elements/standard/text_field.rb
@@ -7,6 +7,7 @@ class TextField < Field
attribute :password, Types::Bool
attribute :code, Types::Bool
+ attribute :disabled, Types::Bool
end
register :text_field, TextField
|
Add disabled as an attribute to TextField fields
|
diff --git a/db/migrate/20201219120055_add_order_to_adjustments.rb b/db/migrate/20201219120055_add_order_to_adjustments.rb
index abc1234..def5678 100644
--- a/db/migrate/20201219120055_add_order_to_adjustments.rb
+++ b/db/migrate/20201219120055_add_order_to_adjustments.rb
@@ -1,13 +1,14 @@ class AddOrderToAdjustments < ActiveRecord::Migration
+ class Spree::Adjustment < ActiveRecord::Base
+ belongs_to :adjustable, polymorphic: true
+ belongs_to :order, class_name: "Spree::Order"
+ end
+
+ class Spree::LineItem < ActiveRecord::Base
+ belongs_to :order, class_name: "Spree::Order"
+ end
+
def up
- class Spree::Adjustment < ActiveRecord::Base
- belongs_to :adjustable, polymorphic: true
- belongs_to :order, class_name: "Spree::Order"
- end
- class Spree::LineItem < ActiveRecord::Base
- belongs_to :order, class_name: "Spree::Order"
- end
-
add_column :spree_adjustments, :order_id, :integer
# Ensure migration can use the new column
|
Move class definitions in adjustment migration
|
diff --git a/omniauth-vkontakte.gemspec b/omniauth-vkontakte.gemspec
index abc1234..def5678 100644
--- a/omniauth-vkontakte.gemspec
+++ b/omniauth-vkontakte.gemspec
@@ -17,5 +17,5 @@ gem.version = OmniAuth::Vkontakte::VERSION
gem.required_ruby_version = '>= 2.6.0'
- gem.add_runtime_dependency 'omniauth-oauth2', ['>= 1.5', '<= 1.7.0']
+ gem.add_runtime_dependency 'omniauth-oauth2', ['>= 1.5', '<= 1.7.1']
end
|
Update omniauth-oauth2 to version 1.7.1
|
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index abc1234..def5678 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,4 +1,5 @@ require "bundler/setup"
+require "pry" unless ENV["CI"] && !ENV["CI"].empty?
begin
require "coveralls"
|
Make Pry available in tests when run locally
|
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index abc1234..def5678 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -7,7 +7,7 @@
def runner(attributes = {}, environment = 'test')
# A workaround so that ChefSpec can work with Chef environments (from https://github.com/acrmp/chefspec/issues/54)
- @runner ||= ChefSpec::ChefRunner.new(:platform => 'ubuntu', :version => '10.04') do |node|
+ @runner ||= ChefSpec::Runner.new(:platform => 'ubuntu', :version => '10.04') do |node|
env = Chef::Environment.new
env.name environment
node.stub(:chef_environment).and_return env.name
|
Replace deprecated ChefSpec::ChefRunner with ChefSpec::Runner
|
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index abc1234..def5678 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -5,3 +5,4 @@ Dir.glob("spec/lib/**/*_steps.rb") { |f| load f, true }
$LOAD_PATH << File.expand_path('../../lib', __FILE__) # the gem's lib dir
+$LOAD_PATH << File.expand_path('../../lib/reportability', __FILE__) # the gem's lib dir
|
Add lib/portability to search path
|
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index abc1234..def5678 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -10,6 +10,7 @@ Pathname.glob((SPEC_ROOT + 'integration/shared/**/*.rb').to_s).each { |file| require file }
DataMapper::Spec.setup
+DataMapper.finalize
Spec::Runner.configure do |config|
config.extend(DataMapper::Spec::Adapters::Helpers)
|
Call DataMapper.finalize after model definition
|
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index abc1234..def5678 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -7,4 +7,7 @@ config.run_all_when_everything_filtered = true
config.order = 'random'
config.include Griddler::Testing
+ config.expect_with(:rspec) do |c|
+ c.syntax = [:should, :expect]
+ end
end
|
Enable both `should` and `expect` in RSpec
griddler-sendgrid uses `should` everywhere, but the shared expectation from
Griddler uses `expect`. To prevent warnings in newer versions of RSpec, enable
both syntaxes.
|
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index abc1234..def5678 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -20,14 +20,6 @@ # config.mock_with :rr
config.mock_with :rspec
- # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
- config.fixture_path = "#{::Rails.root}/spec/fixtures"
-
- # If you're not using ActiveRecord, or you'd prefer not to run each of your
- # examples within a transaction, remove the following line or assign false
- # instead of true.
- config.use_transactional_fixtures = true
-
config.infer_spec_type_from_file_location!
# Don't filter backtraces
|
Fix tests by removing unused ActiveRecord fixture config settings.
This got broken in fcbc5c7279be7b03ec7c994a9061a5f98eaf5d2d since we're
no longer accidentally requiring ActiveRecord. These
ActiveRecord-specific configuration settings then broke, but since we've
never used ActiveRecord or fixtures in this app, these settings should
have been removed ages ago.
|
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index abc1234..def5678 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -37,6 +37,7 @@ }
RSpec.configure do |c|
+ c.formatter = :documentation
c.default_facts = { :augeasversion => '0.10.0' }
end
|
Use documentation output for rspec
|
diff --git a/sql-logging.gemspec b/sql-logging.gemspec
index abc1234..def5678 100644
--- a/sql-logging.gemspec
+++ b/sql-logging.gemspec
@@ -1,5 +1,4 @@ require 'rubygems'
-require 'rake'
lib = File.expand_path('../lib', __FILE__)
$:.unshift lib unless $:.include?(lib)
@@ -14,7 +13,7 @@ s.platform = Gem::Platform::RUBY
s.summary = 'Adds SQL analysis and debugging info to Rails 3 apps.'
s.description = 'Adds SQL analysis and debugging info to Rails 3 apps.'
- s.files = FileList['lib/**/*'].to_a
+ s.files = Dir.glob('lib/**/*').to_a
s.require_path = 'lib'
s.has_rdoc = true
s.extra_rdoc_files = ['README.rdoc']
|
Use Dir.glob instead of FileList
|
diff --git a/app/models/manageiq/providers/redhat/infra_manager/vm.rb b/app/models/manageiq/providers/redhat/infra_manager/vm.rb
index abc1234..def5678 100644
--- a/app/models/manageiq/providers/redhat/infra_manager/vm.rb
+++ b/app/models/manageiq/providers/redhat/infra_manager/vm.rb
@@ -47,4 +47,28 @@ def validate_smartstate_analysis
validate_supported
end
+
+ # Show Reconfigure VM task
+ def reconfigurable?
+ true
+ end
+
+ def max_total_vcpus
+ # the default value of MaxNumOfVmCpusTotal for RHEV 3.1 - 3.4
+ 160
+ end
+
+ def max_cores_per_socket
+ # the default value of MaxNumOfCpuPerSocket for RHEV 3.1 - 3.4
+ 16
+ end
+
+ def max_vcpus
+ # the default value of MaxNumofVmSockets for RHEV 3.1 - 3.4
+ 16
+ end
+
+ def max_memory_cpu
+ 2.terabyte / 1.megabyte
+ end
end
|
Add helper methods for Reconfigure VM UI.
https://bugzilla.redhat.com/show_bug.cgi?id=1065573
|
diff --git a/cookbooks/chef/attributes/default.rb b/cookbooks/chef/attributes/default.rb
index abc1234..def5678 100644
--- a/cookbooks/chef/attributes/default.rb
+++ b/cookbooks/chef/attributes/default.rb
@@ -5,4 +5,4 @@ default[:chef][:server][:version] = "12.13.0-1"
# Set the default client version
-default[:chef][:client][:version] = "13.6.4"
+default[:chef][:client][:version] = "13.8.5"
|
Update chef client to 13.8.5
|
diff --git a/cookbooks/chef/attributes/default.rb b/cookbooks/chef/attributes/default.rb
index abc1234..def5678 100644
--- a/cookbooks/chef/attributes/default.rb
+++ b/cookbooks/chef/attributes/default.rb
@@ -5,7 +5,7 @@ default[:chef][:server][:version] = "11.1.3-1"
# Set the default client version
-default[:chef][:client][:version] = "11.16.2-1"
+default[:chef][:client][:version] = "11.18.0-1"
# A list of gems needed by chef recipes
default[:chef][:gems] = []
|
Update chef client to 11.18.0-1
|
diff --git a/features/step_definitions/lockfile_steps.rb b/features/step_definitions/lockfile_steps.rb
index abc1234..def5678 100644
--- a/features/step_definitions/lockfile_steps.rb
+++ b/features/step_definitions/lockfile_steps.rb
@@ -3,6 +3,15 @@ Given a file named "#{'.'.to_lockfile_path}" with:
"""
#{expand(content)}
+ """
+ }
+end
+
+Given 'I copy a new lockfile from another machine with:' do |content|
+ steps %Q{
+ Given a lockfile with:
+ """
+ #{content}
"""
}
end
|
Add a step to emulate sharing a lockfile
|
diff --git a/lib/generators/kebapress/install/install_generator.rb b/lib/generators/kebapress/install/install_generator.rb
index abc1234..def5678 100644
--- a/lib/generators/kebapress/install/install_generator.rb
+++ b/lib/generators/kebapress/install/install_generator.rb
@@ -21,8 +21,8 @@
def create_migration_file
migration_template 'migrations/categories.rb', 'db/migrate/create_kebapress_categories.rb' rescue nil
- migration_template 'migrations/join_table_category_post.rb', 'db/migrate/create_kebapress_join_table_category_post.rb' rescue nil
- migration_template 'migrations/join_table_post_tag.rb', 'db/migrate/create_kebapress_join_table_post_tag.rb' rescue nil
+ migration_template 'migrations/join_table_category_post.rb', 'db/migrate/create_join_table_category_post.rb' rescue nil
+ migration_template 'migrations/join_table_post_tag.rb', 'db/migrate/create_join_table_post_tag.rb' rescue nil
migration_template 'migrations/photos.rb', 'db/migrate/create_kebapress_photos.rb' rescue nil
migration_template 'migrations/posts.rb', 'db/migrate/create_kebapress_posts.rb' rescue nil
migration_template 'migrations/tags.rb', 'db/migrate/create_kebapress_tags.rb' rescue nil
|
Fix join table name error on generator
|
diff --git a/test/controllers/requests_test.rb b/test/controllers/requests_test.rb
index abc1234..def5678 100644
--- a/test/controllers/requests_test.rb
+++ b/test/controllers/requests_test.rb
@@ -0,0 +1,14 @@+require 'test_helper'
+
+class RequestsTest < ActionDispatch::IntegrationTest
+ setup do
+ Peek.adapter.reset
+ Peek.reset
+ end
+
+ test "the request id is set" do
+ assert_empty Peek.adapter.requests
+ get '/'
+ assert_not_empty Peek.adapter.requests
+ end
+end
|
Add initial step for integration tests
|
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
@@ -5,4 +5,11 @@
rescue_from JSONAPI::Exceptions::Error, :with => :jsonapi_render_errors
rescue_from ActiveRecord::RecordNotFound, :with => :jsonapi_render_not_found
+
+ ##
+ # API url for link generation
+ #
+ def base_url
+ @base_url ||= "#{request.protocol}#{request.host_with_port}/api"
+ end
end
|
Fix API root url link generation
|
diff --git a/Casks/rubymine-eap-bundled-jdk.rb b/Casks/rubymine-eap-bundled-jdk.rb
index abc1234..def5678 100644
--- a/Casks/rubymine-eap-bundled-jdk.rb
+++ b/Casks/rubymine-eap-bundled-jdk.rb
@@ -0,0 +1,20 @@+cask :v1 => 'rubymine-eap-bundled-jdk' do
+ version '141.373'
+ sha256 '2605d3b61d9ae4a0590337d04bc24bf2f1c430cb5c226b1bffafcde6b61e478d'
+
+ url "https://download.jetbrains.com/ruby/RubyMine-#{version}-custom-jdk-bundled.dmg"
+ name 'RubyMine EAP'
+ homepage 'https://confluence.jetbrains.com/display/RUBYDEV/RubyMine+EAP'
+ license :commercial
+
+ app 'RubyMine EAP.app'
+
+ zap :delete => [
+ '~/Library/Preferences/com.jetbrains.rubymine-EAP.plist',
+ '~/Library/Preferences/RubyMine70',
+ '~/Library/Application Support/RubyMine70',
+ '~/Library/Caches/RubyMine70',
+ '~/Library/Logs/RubyMine70',
+ '/usr/local/bin/mine',
+ ]
+end
|
Add formula for RubyMine EAP with bundled JDK
|
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
@@ -41,7 +41,7 @@ end
def after_sign_in_path_for(resource)
- current_student.update_attributes(user_id: current_user.id) if current_student.user_id.blank?
+ current_student.update_attributes(user_id: current_user.id) if current_student.present? && current_student.user_id.blank?
schools_url
end
end
|
Remove logging from students controller
|
diff --git a/app/jobs/feed_crawler/youtube_receiver.rb b/app/jobs/feed_crawler/youtube_receiver.rb
index abc1234..def5678 100644
--- a/app/jobs/feed_crawler/youtube_receiver.rb
+++ b/app/jobs/feed_crawler/youtube_receiver.rb
@@ -11,11 +11,13 @@ id = entry.dig("data", "youtube_video_id")
if embed = embeds[id]
content = embed.data.dig("snippet", "description")
+
if content.present? && entry.dig("content").blank?
entry["content"] = content
- unless embed.duration_in_seconds == 0
- entry["embed_duration"] = embed.duration_in_seconds
- end
+ end
+
+ unless embed.duration_in_seconds == 0
+ entry["embed_duration"] = embed.duration_in_seconds
end
end
end
|
Move duration check outside of content check.
|
diff --git a/app/models/abilities/superuser_ability.rb b/app/models/abilities/superuser_ability.rb
index abc1234..def5678 100644
--- a/app/models/abilities/superuser_ability.rb
+++ b/app/models/abilities/superuser_ability.rb
@@ -12,15 +12,14 @@ can :manage, :all
cannot [:leave], Space do |space|
- space.users.include?(user) && space.users.count == 1
+ !space.users.include?(user) || space.is_last_admin?(user)
end
+ # A Superuser can't remove the last admin of a space
cannot [:destroy], Permission do |perm|
cant = false
if perm.subject_type == "Space"
- # A Superuser can't remove the last admin.
- s = perm.subject
- cant = s.is_last_admin?(perm.user)
+ cant = perm.subject.is_last_admin?(perm.user) if perm.subject.present?
end
cant
end
|
Improve verification of whether superusers can leave spaces or not
refs #1552
|
diff --git a/0_code_wars/6_autocomplete_yay.rb b/0_code_wars/6_autocomplete_yay.rb
index abc1234..def5678 100644
--- a/0_code_wars/6_autocomplete_yay.rb
+++ b/0_code_wars/6_autocomplete_yay.rb
@@ -0,0 +1,23 @@+# http://www.codewars.com/kata/5389864ec72ce03383000484
+# --- iteration 1 ---
+def autocomplete(input, dictionary)
+ input.gsub!(/[^[a-zA-Z]]/, "")
+ dictionary.select{ |word| word.downcase.start_with?(input.downcase) }.first(5)
+end
+
+# problems
+# * gsub isn't as performant as delete, etc (and we're mutating the string anyway)
+# * select is iterating through the whole dictionary every time; needs to be lazy
+# --- iteration 2 ---
+def autocomplete(input, dictionary)
+ input.delete!("^a-zA-Z")
+ dictionary.lazy.select{ |word| word.downcase.start_with?(input.downcase) }.first(5)
+end
+
+# --- iteration 3 ---
+def autocomplete(input, dictionary)
+ input.delete!("^a-zA-Z")
+ dictionary.lazy.grep(/\A#{input}/i).first(5)
+end
+
+# this is the top solution on CodeWars at the time of writing, and for good reason.
|
Add code wars (6) autocomplete yay
|
diff --git a/spec/examples_spec.rb b/spec/examples_spec.rb
index abc1234..def5678 100644
--- a/spec/examples_spec.rb
+++ b/spec/examples_spec.rb
@@ -9,6 +9,17 @@ expect(res.count).to eq(8192)
expect(res.first).to eq("Test")
end
+
+ it 'should handle many calls' do
+ results = []
+ client = Quartz::Client.new(file_path: 'spec/examples/long_json.go')
+
+ 100.times do
+ results.concat(client[:example].call('LongJson', {})['Output'])
+ end
+
+ expect(results.count).to eq(819_200)
+ end
end
end
|
Test to handle at least 100 calls
|
diff --git a/lib/dm-salesforce/types.rb b/lib/dm-salesforce/types.rb
index abc1234..def5678 100644
--- a/lib/dm-salesforce/types.rb
+++ b/lib/dm-salesforce/types.rb
@@ -4,6 +4,8 @@
module Types
end
+
+ Property = Types
end
require 'dm-salesforce/types/serial'
|
Add Property reference in DM0.10 case so DM1'ized quote_value works.
|
diff --git a/lib/mocha/return_values.rb b/lib/mocha/return_values.rb
index abc1234..def5678 100644
--- a/lib/mocha/return_values.rb
+++ b/lib/mocha/return_values.rb
@@ -23,7 +23,7 @@ end
def +(other)
- ReturnValues.new(*(@values + other.values))
+ self.class.new(*(@values + other.values))
end
end
|
Use implicit reference to class instead of explicit reference to improve maintainability.
|
diff --git a/lib/mtgox/configuration.rb b/lib/mtgox/configuration.rb
index abc1234..def5678 100644
--- a/lib/mtgox/configuration.rb
+++ b/lib/mtgox/configuration.rb
@@ -23,13 +23,6 @@ yield self
end
- # Create a hash of options and their values
- def options
- options = {}
- VALID_OPTIONS_KEYS.each{|k| options[k] = send(k)}
- options
- end
-
# Reset all configuration options to defaults
def reset
self.commission = DEFAULT_COMMISSION
|
Remove seemingly unused options hash.
|
diff --git a/lib/puppet/feature/mtik.rb b/lib/puppet/feature/mtik.rb
index abc1234..def5678 100644
--- a/lib/puppet/feature/mtik.rb
+++ b/lib/puppet/feature/mtik.rb
@@ -1,3 +1,5 @@ require 'puppet/util/feature'
-Puppet.features.add(:mtik, :libs => ["mtik"])+Puppet.features.add(:mtik) do
+ require "mtik"
+end
|
Define feature as a block
|
diff --git a/lib/river_notifications.rb b/lib/river_notifications.rb
index abc1234..def5678 100644
--- a/lib/river_notifications.rb
+++ b/lib/river_notifications.rb
@@ -13,7 +13,11 @@ end
def after_update(post)
- publish(post, :update)
+ if post.deleted?
+ publish(post, :delete)
+ else
+ publish(post, :update)
+ end
end
def after_destroy(post)
|
Tweak river-notification observer for soft-deletes
|
diff --git a/Library/Homebrew/test/test_ENV.rb b/Library/Homebrew/test/test_ENV.rb
index abc1234..def5678 100644
--- a/Library/Homebrew/test/test_ENV.rb
+++ b/Library/Homebrew/test/test_ENV.rb
@@ -23,7 +23,7 @@ def test_switching_compilers
ENV.llvm
ENV.clang
- assert_equal ENV['LD'], ENV['CC']
+ assert_nil ENV['LD']
assert_equal ENV['OBJC'], ENV['CC']
end
end
|
Adjust test expectation for 'LD'
Signed-off-by: Jack Nagel <43386ce32af96f5c56f2a88e458cb94cebee3751@gmail.com>
|
diff --git a/plugin.rb b/plugin.rb
index abc1234..def5678 100644
--- a/plugin.rb
+++ b/plugin.rb
@@ -3,6 +3,8 @@ # version: 0.6.0
# authors: Philipp Wolfer <ph.wolfer@gmail.com>
# url: https://github.com/phw/discourse-musicbrainz-onebox
+
+require 'onebox'
require_relative 'engine/musicbrainz_artist_onebox'
require_relative 'engine/musicbrainz_event_onebox'
|
Fix missing require of onebox module
With Discourse 2.8 this does not seem to happen implicitlcy anymore
|
diff --git a/Library/Homebrew/extend/ENV.rb b/Library/Homebrew/extend/ENV.rb
index abc1234..def5678 100644
--- a/Library/Homebrew/extend/ENV.rb
+++ b/Library/Homebrew/extend/ENV.rb
@@ -4,11 +4,7 @@ require "extend/ENV/super"
def superenv?
- if OS.linux?
- ARGV.env == "super" || (ENV["CI"] || ARGV.homebrew_developer?) && ARGV.env != "std"
- else
- ARGV.env != "std" && Superenv.bin
- end
+ ARGV.env != "std" && Superenv.bin
end
module EnvActivation
|
Use --env=super by default for Linuxbrew
|
diff --git a/app/reports/signatures_report.rb b/app/reports/signatures_report.rb
index abc1234..def5678 100644
--- a/app/reports/signatures_report.rb
+++ b/app/reports/signatures_report.rb
@@ -31,7 +31,7 @@ # Don't want to rely on `write_headers: true` since we want still
# header row in the CSV file even when there is no data.
csv << JOINED_HEADERS
- join.each do |record|
+ pull_join.each do |record|
csv << [
record.shift.work_site.address,
record.shift.day,
|
Fix no longer defined variable name snafu from merge
|
diff --git a/Casks/privacy-services-manager.rb b/Casks/privacy-services-manager.rb
index abc1234..def5678 100644
--- a/Casks/privacy-services-manager.rb
+++ b/Casks/privacy-services-manager.rb
@@ -1,6 +1,6 @@ cask :v1 => 'privacy-services-manager' do
- version '1.6.9'
- sha256 'd59db1d633c40f791578d7496ba3a6f94370fda24e64e6b8bafe9b4385b7a772'
+ version '1.7.2'
+ sha256 '0d7a5e7431d5a44d7b1ddcc8e59fa3672d573a9203c45b620daee695444de040'
url "https://github.com/univ-of-utah-marriott-library-apple/privacy_services_manager/releases/download/#{version}/Privacy_Services_Management_#{version}.dmg"
appcast 'https://github.com/univ-of-utah-marriott-library-apple/privacy_services_manager/releases.atom'
|
Update Privacy Services Manager to 1.7.2
|
diff --git a/lib/hache.rb b/lib/hache.rb
index abc1234..def5678 100644
--- a/lib/hache.rb
+++ b/lib/hache.rb
@@ -8,7 +8,9 @@ "/" => "/"
}
+ UNSAFE = /[&"'><\/]/
+
def self.h(str)
- str.to_s.gsub(/[&"'><\/]/, HTML_ESCAPE)
+ str.to_s.gsub(UNSAFE, HTML_ESCAPE)
end
end
|
Move unsafe regexp to a constant.
|
diff --git a/lib/emcee/processors/directive_processor.rb b/lib/emcee/processors/directive_processor.rb
index abc1234..def5678 100644
--- a/lib/emcee/processors/directive_processor.rb
+++ b/lib/emcee/processors/directive_processor.rb
@@ -5,12 +5,6 @@ # Matches the entire header/directive block. This is everything from the
# top of the file, enclosed in html comments.
HEADER_PATTERN = /\A((?m:\s*)(<!--(?m:.*?)-->))+/
-
- # Matches the an asset pipeline directive.
- #
- # *= require_tree .
- #
- DIRECTIVE_PATTERN = /^\W*=\s*(\w+.*?)$/
# Implement `render` so that it uses our own regex patterns.
def render(context, locals)
|
Remove unnecessary directive pattern regex
The default one in Sprockets works fine
|
diff --git a/app/helpers/src_images_helper.rb b/app/helpers/src_images_helper.rb
index abc1234..def5678 100644
--- a/app/helpers/src_images_helper.rb
+++ b/app/helpers/src_images_helper.rb
@@ -1,6 +1,6 @@ # encoding: UTF-8
-# Build urls for generated images.
+# Build urls for source images.
module SrcImagesHelper
def src_image_url_for(src_image)
url_for(
|
Fix source images helper comment.
|
diff --git a/lib/nodus.rb b/lib/nodus.rb
index abc1234..def5678 100644
--- a/lib/nodus.rb
+++ b/lib/nodus.rb
@@ -12,7 +12,11 @@ def self._error_msg(klass) @_error_msg_map[klass] end
end
-def error(klass, *args) raise klass, sprintf(*([Nodus._error_msg(klass)] + args)) end
+def error(klass, *args)
+ msg = Nodus._error_msg(klass)
+ msg ||= args.shift
+ raise klass, sprintf(*([msg] + args))
+end
require 'nodus/version'
require 'nodus/state_machine'
|
Allow 'error' to be used for normal non-mapped raises
|
diff --git a/metadata.rb b/metadata.rb
index abc1234..def5678 100644
--- a/metadata.rb
+++ b/metadata.rb
@@ -8,9 +8,6 @@
supports 'ubuntu', '= 13.04'
-%w{apt git build-essential user sudo}.each do |dep|
+%w{apt git build-essential user sudo nginx docker}.each do |dep|
depends dep
end
-
-depends 'nginx', '~> 2.4.4'
-depends 'docker', '>= 0.25.0'
|
Remove nginx/docker cookbook version restriction
|
diff --git a/cookbooks/travis_ci_minimal/spec/heroku_toolbelt_spec.rb b/cookbooks/travis_ci_minimal/spec/heroku_toolbelt_spec.rb
index abc1234..def5678 100644
--- a/cookbooks/travis_ci_minimal/spec/heroku_toolbelt_spec.rb
+++ b/cookbooks/travis_ci_minimal/spec/heroku_toolbelt_spec.rb
@@ -1,4 +1,4 @@ describe command('heroku version') do
- its(:stdout) { should match(/^heroku-toolbelt\/\d/) }
- its(:stdout) { should match(/^heroku-cli\/\d/) }
+ its(:stdout) { should match(%r{^heroku-toolbelt\/\d}) }
+ its(:stdout) { should match(%r{^heroku-cli\/\d}) }
end
|
Fix regexes to appease the rubocop
|
diff --git a/lib/active_decorator/decorator.rb b/lib/active_decorator/decorator.rb
index abc1234..def5678 100644
--- a/lib/active_decorator/decorator.rb
+++ b/lib/active_decorator/decorator.rb
@@ -12,7 +12,7 @@ def decorate(obj)
return if obj.nil?
- if obj.is_a? Array
+ if Array === obj
obj.each do |r|
decorate r
end
|
Use === to know whether the object is Array or not
|
diff --git a/lib/condition/condition_oracle.rb b/lib/condition/condition_oracle.rb
index abc1234..def5678 100644
--- a/lib/condition/condition_oracle.rb
+++ b/lib/condition/condition_oracle.rb
@@ -2,18 +2,24 @@ def initialize(text)
@text = text
@has_cardname = !!(@text =~ /~/)
- @normalized_text = normalize_text(@text)
+ @regexp = build_regexp(normalize_text(@text))
end
def match?(card)
if @has_cardname
- card.text.downcase.include?(@text.gsub("~", normalize_text(card.name)))
+ card.text =~ build_regexp(normalize_text(@text.gsub("~", card.name)))
else
- card.text.downcase.include?(@normalized_text)
+ card.text =~ @regexp
end
end
def to_s
"o:#{maybe_quote(@text)}"
end
+
+ private
+
+ def build_regexp(text)
+ Regexp.new(Regexp.escape(text), Regexp::IGNORECASE)
+ end
end
|
Speed up ConditionOracle to get 131ms to 125ms
|
diff --git a/lib/deploy_and_deliver/recipes.rb b/lib/deploy_and_deliver/recipes.rb
index abc1234..def5678 100644
--- a/lib/deploy_and_deliver/recipes.rb
+++ b/lib/deploy_and_deliver/recipes.rb
@@ -9,7 +9,7 @@ class Story < ActiveResource::Base ; end
protocol = self[:pivotal_tracker_ssl] ? 'https' : 'http'
- Story.site = "#{protocol}://www.pivotaltracker.com/services/v2/projects/:project_id"
+ Story.site = "#{protocol}://www.pivotaltracker.com/services/v3/projects/:project_id"
Story.headers['X-TrackerToken'] = pivotal_tracker_token
puts "* delivering tracker stories ..."
|
Switch to v3 of the API, bump version
|
diff --git a/lib/uniform_notifier/appsignal.rb b/lib/uniform_notifier/appsignal.rb
index abc1234..def5678 100644
--- a/lib/uniform_notifier/appsignal.rb
+++ b/lib/uniform_notifier/appsignal.rb
@@ -12,7 +12,7 @@ def _out_of_channel_notify(data)
opt = UniformNotifier.appsignal.is_a?(Hash) ? UniformNotifier.appsignal : {}
- exception = Exception.new(data[:title])
+ exception = Exception.new("#{data[:title]}\n#{data[:body]}")
exception.set_backtrace(data[:backtrace]) if data[:backtrace]
tags = opt.fetch(:tags, {}).merge(data.fetch(:tags, {}))
|
Add body to Appsignal error message
|
diff --git a/app/mailers/grades_mailer.rb b/app/mailers/grades_mailer.rb
index abc1234..def5678 100644
--- a/app/mailers/grades_mailer.rb
+++ b/app/mailers/grades_mailer.rb
@@ -11,16 +11,12 @@ @assignment_url = coursewareable.lecture_assignment_url(
grade.assignment.lecture, grade.assignment
)
- # Find email settings for current user
- settings = grade.receiver.memberships.where(
- :classroom_id => grade.classroom.id
- ).first
- if settings.send_grades
- subject = _("One of your responses was graded by %s") % [
- @grade.user.name
- ]
- mail(:to => grade.receiver.email, :subject => subject)
- end
+
+ receiver = grade.receiver
+ subject = _('One of your responses was graded by %s') % grade.user.name
+ opt = receiver.memberships.where(:classroom_id => grade.classroom.id).first
+
+ mail(:to => receiver.email, :subject => subject) if opt.send_grades
end
# Sends an email to user when he's grade is updated
@@ -31,15 +27,11 @@ @assignment_url = coursewareable.lecture_assignment_url(
grade.assignment.lecture, grade.assignment
)
- # Find email settings for current user
- settings = grade.receiver.memberships.where(
- :classroom_id => grade.classroom.id
- ).first
- if settings.send_grades
- subject = _("One of your assignment grades was updated by %s") % [
- @grade.user.name
- ]
- mail(:to => grade.receiver.email, :subject => subject )
- end
+
+ receiver = grade.receiver
+ opt = receiver.memberships.where(:classroom_id => grade.classroom.id).first
+ subject = _('%s updated one of your assignment grades') % grade.user.name
+
+ mail(:to => receiver.email, :subject => subject ) if opt.send_grades
end
end
|
Refactor grades mailer to use associations.
|
diff --git a/app/mailers/mail_receiver.rb b/app/mailers/mail_receiver.rb
index abc1234..def5678 100644
--- a/app/mailers/mail_receiver.rb
+++ b/app/mailers/mail_receiver.rb
@@ -17,7 +17,12 @@ comment.body = body
comment.save
- puts " ---> Added comment to Ticket \##{ticket.id}: #{ticket.subject}"
+ puts " ---> Added comment to Ticket \##{ticket.id}: "
+ puts " From: #{user.name} <#{user.email}>"
+ puts " Subject: #{ticket.subject}\n"
+ comment.body.split("\n").each do |line|
+ puts " #{line}"
+ end
end
def create_ticket(message)
|
Add more info to mailman log
|
diff --git a/app/workers/backup_worker.rb b/app/workers/backup_worker.rb
index abc1234..def5678 100644
--- a/app/workers/backup_worker.rb
+++ b/app/workers/backup_worker.rb
@@ -2,6 +2,10 @@ include Sidekiq::Worker
def perform
- PgDrive.perform
+ Timeout::timeout(120) {
+ PgDrive.perform
+ }
+ rescue Timeout::Error
+ logger.error("Backup timeout")
end
end
|
Add timeout to backup worker
|
diff --git a/spec/controllers/notifications_controller_spec.rb b/spec/controllers/notifications_controller_spec.rb
index abc1234..def5678 100644
--- a/spec/controllers/notifications_controller_spec.rb
+++ b/spec/controllers/notifications_controller_spec.rb
@@ -7,6 +7,14 @@
context 'user is signed in' do
before { sign_in(user) }
+
+ describe 'GET #count' do
+ it 'renders count template' do
+ xhr :get, :count
+ expect(response.response_code).to eq(200)
+ expect(response).to render_template(:count)
+ end
+ end
describe 'GET #index' do
it 'lists all the notification for the user' do
@@ -25,6 +33,14 @@ end
context 'user is guest' do
+ describe 'GET #count' do
+ it 'does not render count template and redirects to sign in page' do
+ xhr :get, :count
+ expect(response.response_code).to eq(401)
+ expect(response).not_to render_template(:count)
+ end
+ end
+
describe 'GET #index' do
it 'redirects to sign in page' do
get :index
|
Test for notification count action
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.