diff
stringlengths
65
26.7k
message
stringlengths
7
9.92k
diff --git a/lib/ffi/gphoto2_port/gp_port_result.rb b/lib/ffi/gphoto2_port/gp_port_result.rb index abc1234..def5678 100644 --- a/lib/ffi/gphoto2_port/gp_port_result.rb +++ b/lib/ffi/gphoto2_port/gp_port_result.rb @@ -2,7 +2,34 @@ module GPhoto2Port # libgphoto2_port/gphoto2/gphoto2-port-result.h GP_OK = 0 - # ... + + GP_ERROR = -1 + GP_ERROR_BAD_PARAMETERS = -2 + GP_ERROR_NO_MEMORY = -3 + GP_ERROR_LIBRARY = -4 + GP_ERROR_UNKNOWN_PORT = -5 + GP_ERROR_NOT_SUPPORTED = -6 + GP_ERROR_IO = -7 + GP_ERROR_FIXED_LIMIT_EXCEEDED = -8 + + GP_ERROR_TIMEOUT = -10 + + GP_ERROR_IO_SUPPORTED_SERIAL = -20 + GP_ERROR_IO_SUPPORTED_USB = -21 + + GP_ERROR_IO_INIT = -31 + GP_ERROR_IO_READ = -34 + GP_ERROR_IO_WRITE = -35 + GP_ERROR_IO_UPDATE = -37 + + GP_ERROR_IO_SERIAL_SPEED = -41 + + GP_ERROR_IO_USB_CLEAR_HALT = -51 + GP_ERROR_IO_USB_FIND = -52 GP_ERROR_IO_USB_CLAIM = -53 + + GP_ERROR_IO_LOCK = -60 + + GP_ERROR_HAL = -70 end end
Add all return code constants
diff --git a/lib/generators/templates/carpetbomb.rb b/lib/generators/templates/carpetbomb.rb index abc1234..def5678 100644 --- a/lib/generators/templates/carpetbomb.rb +++ b/lib/generators/templates/carpetbomb.rb @@ -12,6 +12,8 @@ markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, :autolink => true, + :tables => true, + :footnotes => true, :space_after_headers => true, :fenced_code_blocks => true)
Enable tables and footnotes options in redcarpet
diff --git a/lib/myplaceonline_execution_context.rb b/lib/myplaceonline_execution_context.rb index abc1234..def5678 100644 --- a/lib/myplaceonline_execution_context.rb +++ b/lib/myplaceonline_execution_context.rb @@ -29,11 +29,11 @@ def self.permission_target=(x); self[:permission_target] = x; end def self.browser - result = self[:permission_target] + result = self[:browser] if result.nil? if !self.request.nil? && !self.request.user_agent.blank? result = Browser.new(self.request.user_agent, accept_language: self.request.env["HTTP_ACCEPT_LANGUAGE"]) - self[:permission_target] = result + self[:browser] = result end end result
Fix bug caching browser detection object
diff --git a/script/cruise_build.rb b/script/cruise_build.rb index abc1234..def5678 100644 --- a/script/cruise_build.rb +++ b/script/cruise_build.rb @@ -11,7 +11,7 @@ when "racing_on_rails" exec "rake cruise" when "aba", "atra", "obra", "wsba" - exec "git clone git@butlerpress.com:#{project_name}.git local && rake cruise" + exec "rm -rf local && git clone git@butlerpress.com:#{project_name}.git local && rake cruise" else raise "Don't know how to build project named: '#{project_name}'" end
Drop local dir before fetching local
diff --git a/lib/transam_core/transam_object_key.rb b/lib/transam_core/transam_object_key.rb index abc1234..def5678 100644 --- a/lib/transam_core/transam_object_key.rb +++ b/lib/transam_core/transam_object_key.rb @@ -0,0 +1,30 @@+#------------------------------------------------------------------------------ +# +# TransamObjectKey +# +# Adds a unique object key to a model +# +#------------------------------------------------------------------------------ +module TransamObjectKey + extend ActiveSupport::Concern + + included do + # Always generate a unique object key before saving to the database + before_validation(:on => :create) do + generate_object_key(:object_key) + end + + validates :object_key, :presence => true, :uniqueness => true, :length => { is: 12 } + end + + def generate_object_key(column) + begin + self[column] = (Time.now.to_f * 10000000).to_i.to_s(24).upcase + end #while self.exists?(column => self[column]) + end + + def to_param + object_key + end + +end
Refactor object_key logic to a real plugin. This deprecates the unique_key mixin
diff --git a/lib/twitter_cldr/timezones/location.rb b/lib/twitter_cldr/timezones/location.rb index abc1234..def5678 100644 --- a/lib/twitter_cldr/timezones/location.rb +++ b/lib/twitter_cldr/timezones/location.rb @@ -14,6 +14,12 @@ def resource @resource ||= TwitterCldr.get_locale_resource(tz.locale, :timezones)[tz.locale] end + + private + + def get_period_for_naming(date) + tz.period_for_local(date, &:first) + end end end end
Add helper for getting correct period when getting a TZ name
diff --git a/knife-ec-backup.gemspec b/knife-ec-backup.gemspec index abc1234..def5678 100644 --- a/knife-ec-backup.gemspec +++ b/knife-ec-backup.gemspec @@ -19,7 +19,7 @@ # s.add_dependency "mixlib-cli", ">= 1.2.2" s.add_dependency "sequel" s.add_dependency "pg" - s.add_dependency "chef", "~> 11.8" + s.add_dependency "chef", ">= 11.8" s.add_development_dependency 'rspec' s.add_development_dependency 'rake' s.add_development_dependency 'simplecov'
Allow us to use chef 12
diff --git a/lib/dimples/renderer.rb b/lib/dimples/renderer.rb index abc1234..def5678 100644 --- a/lib/dimples/renderer.rb +++ b/lib/dimples/renderer.rb @@ -10,7 +10,9 @@ callback = proc { @source.contents } @engine = if @source.path - Tilt.new(@source.path, {}, &callback) + ext = File.extname(@source.path)[1..-1] + options = @site.config['rendering'][ext] || {} + Tilt.new(@source.path, options, &callback) else Tilt::StringTemplate.new(&callback) end
Implement passing rendering options to Tilt
diff --git a/lib/nehm/http_client.rb b/lib/nehm/http_client.rb index abc1234..def5678 100644 --- a/lib/nehm/http_client.rb +++ b/lib/nehm/http_client.rb @@ -14,8 +14,32 @@ # Exception classes class Status404 < StandardError; end + class ConnectionError < StandardError; end def get(api_version, uri_string) + uri = form_uri(api_version, uri_string) + get_hash(uri) + end + + def resolve(url) + response = get(1, "/resolve?url=#{url}") + + errors = response['errors'] + if errors + if errors[0]['error_message'] =~ /404/ + raise Status404 + else + raise ConnectionError # HACK + end + end + + if response['status'] =~ /302/ + get_hash(response['location']) + end + end + + private + def form_uri(api_version, uri_string) uri = case api_version when 1 @@ -26,28 +50,11 @@ uri += uri_string uri += "&client_id=#{CLIENT_ID}" if api_version == 1 - get_hash(uri) + URI(uri) end - def resolve(url) - response = get(1, "/resolve?url=#{url}") - - errors = response['errors'] - if errors - if errors[0]['error_message'] =~ /404/ - raise Status404 - end - end - - if response['status'] =~ /302/ - get_hash(response['location']) - end - end - - private - def get_hash(uri) - response = Net::HTTP.get_response(URI(uri)) + response = Net::HTTP.get_response(uri) JSON.parse(response.body) end
Move code with URI forming to separate method Add ConnectionError exception class
diff --git a/app/models/person_edition.rb b/app/models/person_edition.rb index abc1234..def5678 100644 --- a/app/models/person_edition.rb +++ b/app/models/person_edition.rb @@ -2,7 +2,7 @@ require 'attachable' class PersonEdition < Edition - include Attachable + include AttachableWithMetadata # type (Staff / Trainer / Member / Start-up / Artist): applied by tag field :honorific_prefix, type: String @@ -11,13 +11,14 @@ # name: uses artefact name field :role, type: String field :description, type: String - attaches :image field :url, type: String field :telephone, type: String field :email, type: String field :twitter, type: String field :linkedin, type: String field :github, type: String + + attaches_with_metadata :image GOVSPEAK_FIELDS = Edition::GOVSPEAK_FIELDS + [:description]
Make PersonEdition attach with metadata
diff --git a/lib/bonsai/webserver.rb b/lib/bonsai/webserver.rb index abc1234..def5678 100644 --- a/lib/bonsai/webserver.rb +++ b/lib/bonsai/webserver.rb @@ -13,7 +13,7 @@ get '/' do begin Page.find("index").render - rescue + rescue Exception => e @error = e.message erb :error end @@ -22,7 +22,7 @@ get '/*' do begin Page.find(params[:splat].to_s).render - rescue + rescue Exception => e @error = e.message erb :error end
Fix missing explicit exception assignments
diff --git a/lib/tasks/comments.rake b/lib/tasks/comments.rake index abc1234..def5678 100644 --- a/lib/tasks/comments.rake +++ b/lib/tasks/comments.rake @@ -5,7 +5,6 @@ with_indifferent_access[ENV["RAILS_ENV"] || 'development'] conn = Bunny.new(host: config[:host], - port: config[:port], user: config[:user], password: config[:password])
Remove port from bunny initilization
diff --git a/week-4/largest-integer/my_solution.rb b/week-4/largest-integer/my_solution.rb index abc1234..def5678 100644 --- a/week-4/largest-integer/my_solution.rb +++ b/week-4/largest-integer/my_solution.rb @@ -13,4 +13,5 @@ # Your Solution Below def largest_integer(list_of_nums) # Your code goes here! + list_of_nums.max end
Add solution file for challenge 4.6
diff --git a/lib/sensu-plugin/cli.rb b/lib/sensu-plugin/cli.rb index abc1234..def5678 100644 --- a/lib/sensu-plugin/cli.rb +++ b/lib/sensu-plugin/cli.rb @@ -6,9 +6,15 @@ class CLI include Mixlib::CLI + # Implementing classes should override this to produce appropriate + # output for their handler. + def format_output(status, output) output end + + # This will define 'ok', 'warning', 'critical', and 'unknown' + # methods, which the plugin should call to exit. Sensu::Plugin::EXIT_CODES.each do |status, code| define_method(status.downcase) do |*args| @@ -17,9 +23,15 @@ end end + # Implementing classes must override this. + def run unknown "Not implemented! You should override Sensu::Plugin::CLI#run." end + + # Behind-the-scenes stuff below. If you do something crazy like + # define two plugins in one script, the last one will 'win' in + # terms of what gets auto-run. @@autorun = self class << self
Add some comments to the base CLI class
diff --git a/spec/pacts/content_store/delete_endpoint_spec.rb b/spec/pacts/content_store/delete_endpoint_spec.rb index abc1234..def5678 100644 --- a/spec/pacts/content_store/delete_endpoint_spec.rb +++ b/spec/pacts/content_store/delete_endpoint_spec.rb @@ -0,0 +1,48 @@+require "rails_helper" + +RSpec.describe "DELETE endpoint pact with the Content Store", pact: true do + include Pact::Consumer::RSpec + + let(:client) { ContentStoreWriter.new("http://localhost:3093") } + + context "when the content item exists in the content store" do + before do + content_store + .given("a content item exists with base path /vat-rates") + .upon_receiving("a request to delete the content item") + .with( + method: :delete, + path: "/content/vat-rates", + ) + .will_respond_with( + status: 200, + ) + end + + it "responds with a 200 status code" do + response = client.delete_content_item("/vat-rates") + expect(response.code).to eq(200) + end + end + + context "when the content item does not exist in the content store" do + before do + content_store + .given("no content item exists with base path /vat-rates") + .upon_receiving("a request to delete the content item") + .with( + method: :delete, + path: "/content/vat-rates", + ) + .will_respond_with( + status: 404, + ) + end + + it "responds with a 404 status code" do + expect { + client.delete_content_item("/vat-rates") + }.to raise_error(GdsApi::HTTPNotFound) + end + end +end
Add pacts for deleting from content store.
diff --git a/app/resources/api/conversion_resource.rb b/app/resources/api/conversion_resource.rb index abc1234..def5678 100644 --- a/app/resources/api/conversion_resource.rb +++ b/app/resources/api/conversion_resource.rb @@ -10,7 +10,7 @@ ## # Properties # - attributes :status + attributes :status, :created_at has_one :deck has_one :user @@ -24,5 +24,8 @@ ## # Methods # + def created_at + @model.created_at.to_i.to_s + end end end
Add createdAt attribute to Conversion API
diff --git a/features/step_definitions/merge_steps.rb b/features/step_definitions/merge_steps.rb index abc1234..def5678 100644 --- a/features/step_definitions/merge_steps.rb +++ b/features/step_definitions/merge_steps.rb @@ -0,0 +1,73 @@+Given /^the articles are set up$/ do + + user_one = User.new + user_one.name = "Fulano" + user_one.login = "Fulano" + user_one.password = "Fulano" + user_one.email = "fulano@fulano.com" + user_one.profile_id = 2 + user_one.save + + user_two = User.new + user_two.name = "Mengano" + user_two.login = "Mengano" + user_two.password = "Mengano" + user_two.email = "mengano@mengano.com" + user_two.profile_id = 3 + user_two.save + + article_one = Article.new + article_one.title = "Article One" + article_one.author = "Fulano" + article_one.body = "<p>Hello</p>" + article_one.allow_comments = true + article_one.published = true + article_one.user_id = user_one.id + article_one.save # id 3 + + article_two = Article.new + article_two.title = "Article Two" + article_two.author = "Mengano" + article_two.body = "<p>Goodbye</p>" + article_two.allow_comments = true + article_two.published = true + article_two.user_id = user_two.id + article_two.save # id 4 + + comment_one = Comment.new + comment_one.article_id = article_one.id + comment_one.author = "Robin" + comment_one.body = "Comment One" + comment_one.save + + comment_two = Comment.new + comment_two.article_id = article_two.id + comment_two.author = "Daniel" + comment_two.body = "Comment Two" + comment_two.save + +end + +And /^I am logged with a normal user$/ do + visit '/accounts/login' + fill_in 'user_login', :with => 'Fulano' + fill_in 'user_password', :with => 'Fulano' + click_button 'Login' + if page.respond_to? :should + page.should have_content('Login successful') + else + assert page.has_content?('Login successful') + end +end + +Then /"(.*)" should be the author of article (\d+)$/ do |author, id| + article = Article.find(id) + article.author.should be == author +end + +Given /^I merge article (\d+) and (\d+)$/ do |one, two| + article = Article.find(one) + article.merge_with(two) +end + +
Set up with users and articles for Merge Similar Articles
diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb index abc1234..def5678 100644 --- a/config/initializers/session_store.rb +++ b/config/initializers/session_store.rb @@ -1,3 +1,3 @@ # Be sure to restart your server when you modify this file. -Rails.application.config.session_store :cookie_store, key: '_specialist-publisher_session' +Rails.application.config.session_store :cookie_store, key: '_specialist_publisher_rebuild_session'
Update the cookie key to not clash with Specialist Publisher
diff --git a/spec/api_class_spec.rb b/spec/api_class_spec.rb index abc1234..def5678 100644 --- a/spec/api_class_spec.rb +++ b/spec/api_class_spec.rb @@ -15,7 +15,7 @@ end it "should respond to unrestricted methods" do - LastFM.should_receive(:send_api_request).with("apiclass.foo", {:bar => :baz}).and_return({}) + LastFM.should_receive(:send_api_request).with("apiclass.foo", {:bar => :baz}, :get).and_return({}) LastFM::APIClass.foo(:bar => :baz).should be_a(Hash) end @@ -27,7 +27,7 @@ end it "should respond to restricted methods" do - LastFM.should_receive(:send_api_request).with("apiclass.foo1", {:bar => :baz, :api_sig => true}).and_return({}) + LastFM.should_receive(:send_api_request).with("apiclass.foo1", {:bar => :baz, :api_sig => true}, :get).and_return({}) LastFM::APIClass.foo1(:bar => :baz).should be_a(Hash) end end
Add request_method param to send_api_request
diff --git a/Casks/beyond-compare.rb b/Casks/beyond-compare.rb index abc1234..def5678 100644 --- a/Casks/beyond-compare.rb +++ b/Casks/beyond-compare.rb @@ -1,6 +1,6 @@ cask 'beyond-compare' do - version '4.1.3.20814' - sha256 '3f2dac1ce5273bf0e9c973e7ee7f82c6ee3720546cabcfc4b2b0017fab561f4c' + version '4.1.5.21031' + sha256 '37cd69eb05de84766f21afcaeebe2b31b6c7002688a10aab1e1139fe1581a52d' url "http://www.scootersoftware.com/BCompareOSX-#{version}.zip" name 'Beyond Compare'
Update Beyond Compare to 4.1.5.21031
diff --git a/lib/sastrawi/stop_word_remover/stop_word_remover.rb b/lib/sastrawi/stop_word_remover/stop_word_remover.rb index abc1234..def5678 100644 --- a/lib/sastrawi/stop_word_remover/stop_word_remover.rb +++ b/lib/sastrawi/stop_word_remover/stop_word_remover.rb @@ -6,6 +6,9 @@ def initialize(dictionary) @dictionary = dictionary end + + ## + # Remove stop words def remove(text) words = text.split(' ')
Add comment to "StopWordRemover" class
diff --git a/lib/dropbox_api/authenticator.rb b/lib/dropbox_api/authenticator.rb index abc1234..def5678 100644 --- a/lib/dropbox_api/authenticator.rb +++ b/lib/dropbox_api/authenticator.rb @@ -6,8 +6,8 @@ def initialize(client_id, client_secret) @auth_code = OAuth2::Client.new(client_id, client_secret, { - :authorize_url => 'https://www.dropbox.com/1/oauth2/authorize', - :token_url => 'https://api.dropboxapi.com/1/oauth2/token' + :authorize_url => 'https://www.dropbox.com/oauth2/authorize', + :token_url => 'https://api.dropboxapi.com/oauth2/token' }).auth_code end
Use API v2 endpoints rather than v1. Closes #10.
diff --git a/lib/mspec/helpers/environment.rb b/lib/mspec/helpers/environment.rb index abc1234..def5678 100644 --- a/lib/mspec/helpers/environment.rb +++ b/lib/mspec/helpers/environment.rb @@ -11,13 +11,22 @@ env end + def windows_env_echo(var) + `cmd.exe /C ECHO %#{var}%`.strip + end + def username user = "" if SpecGuard.windows? - user = `cmd.exe /C ECHO %USERNAME%`.strip + user = windows_env_echo('USERNAME') else user = `whoami`.strip end user end + + def home_directory + return ENV['HOME'] unless SpecGuard.windows? + windows_env_echo('HOMEDRIVE') + windows_env_echo('HOMEPATH') + end end
Add helper to find the user's home directory.
diff --git a/lib/nacre/concerns/searchable.rb b/lib/nacre/concerns/searchable.rb index abc1234..def5678 100644 --- a/lib/nacre/concerns/searchable.rb +++ b/lib/nacre/concerns/searchable.rb @@ -15,16 +15,22 @@ end def default_search_options + options = default_get_options + options[:pagination] = { + first_record: 1, + window: 500 + } + options + end + + def default_get_options { - pagination: { - first_record: 1, - window: 500 - }, options: [ 'customFields', 'nullCustomFields' ] } + end private
Create default get options and derive search defaults from it
diff --git a/lib/quickbooks/service_handle.rb b/lib/quickbooks/service_handle.rb index abc1234..def5678 100644 --- a/lib/quickbooks/service_handle.rb +++ b/lib/quickbooks/service_handle.rb @@ -10,11 +10,11 @@ end def access_token - @access_token ||= OAuth::AccessToken.new($qb_oauth_consumer, @intuit_token, @intuit_secret) + @access_token ||= OAuth::AccessToken.new(@oauth_consumer, @intuit_token, @intuit_secret) end - %w(account bill bill_payment company_info credit_memo customer employee -estimate invoice item payment payment_method purchase purchase_order sales_receipt service_crud + %w(account bill bill_payment company_info credit_memo customer employee +estimate invoice item payment payment_method purchase purchase_order sales_receipt service_crud tax_rate term vendor vendor_credit).each do |service_name| ivar_name = "#{service_name}_service" eval(
Correct a bug that prevented all requests I originally wrote ServiceHandle as part of a Rails application and then extracted it to this gem. I missed the change from a global to an argument here, making it impossible to make requests.
diff --git a/assignments/ruby/anagram/anagram_test.rb b/assignments/ruby/anagram/anagram_test.rb index abc1234..def5678 100644 --- a/assignments/ruby/anagram/anagram_test.rb +++ b/assignments/ruby/anagram/anagram_test.rb @@ -23,6 +23,12 @@ assert_equal ['abc', 'bac'], anagrams end + def test_does_not_confuse_different_duplicates + skip + detector = Anagram.new('abb') + assert_equal [], detector.match(['baa']) + end + def test_detect_anagram skip detector = Anagram.new('listen')
Add test to the ruby:anagram test Catch a bug that one of the students came up with today.
diff --git a/SSPPullToRefresh.podspec b/SSPPullToRefresh.podspec index abc1234..def5678 100644 --- a/SSPPullToRefresh.podspec +++ b/SSPPullToRefresh.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'SSPPullToRefresh' - s.version = '0.1.9' + s.version = '0.1.10' s.summary = 'General classes for "Pull-To-Refresh" concept customisation' s.description = <<-DESC
Update pod spec to 0.1.10
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] = "12.19.36" +default[:chef][:client][:version] = "12.20.3"
Update chef client to 12.20.3
diff --git a/SetNeedsReadable.podspec b/SetNeedsReadable.podspec index abc1234..def5678 100644 --- a/SetNeedsReadable.podspec +++ b/SetNeedsReadable.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = 'SetNeedsReadable' - s.version = '2.0' + s.version = '2.1' s.summary = 'Helpful extensions for CGFloat and UIView aimed to enhance readability of layout code.' s.homepage = 'https://github.com/rehatkathuria/SetNeedsReadable' s.license = { :type => 'MIT', :file => 'LICENSE' }
Update .podspec version to 2.1
diff --git a/Casks/little-flocker.rb b/Casks/little-flocker.rb index abc1234..def5678 100644 --- a/Casks/little-flocker.rb +++ b/Casks/little-flocker.rb @@ -1,6 +1,6 @@ cask 'little-flocker' do - version '0.99.93' - sha256 '3dd1daa8d94d8182ac6194e84d36f7cc70502e4c6db1b9a7e1508d484206f597' + version '0.99.95' + sha256 'eac6662b5c85891ebbb7920f548a65257e2f708d70767bfc0a89b4025805546d' # zdziarski.com/littleflocker was verified as official when first introduced to the cask url "https://www.zdziarski.com/littleflocker/LittleFlocker-#{version}.dmg"
Update to Little Flocker RC5 Update to Little Flocker RC5
diff --git a/Casks/one-password-3.rb b/Casks/one-password-3.rb index abc1234..def5678 100644 --- a/Casks/one-password-3.rb +++ b/Casks/one-password-3.rb @@ -0,0 +1,7 @@+class OnePassword3 < Cask + url 'https://d13itkw33a7sus.cloudfront.net/dist/1P/mac/1Password-3.8.21.zip' + homepage 'https://agilebits.com/onepassword' + version '3.8.21' + sha1 '5ead1fcfeaca615c8b7ed3ca5c5ff681edb9ef56' + link '1Password.app' +end
Add cask for 1Password 3
diff --git a/Casks/radiant-player.rb b/Casks/radiant-player.rb index abc1234..def5678 100644 --- a/Casks/radiant-player.rb +++ b/Casks/radiant-player.rb @@ -1,8 +1,8 @@ cask 'radiant-player' do - version '1.5.0' - sha256 '5740a8a4f6eebadb6b961f0510120bbd225e8c7c5b94f7a8da0f6710ee5f79d8' + version '1.6.2' + sha256 '41fe94faeb571c0393a80751b15fa86b73906ada515b3c12dbd71353b4426429' - url "https://github.com/radiant-player/radiant-player-mac/releases/download/v#{version}/Radiant.Player.zip" + url "https://github.com/radiant-player/radiant-player-mac/releases/download/v#{version}/radiant-player-v#{version}.zip" appcast 'https://github.com/radiant-player/radiant-player-mac/releases.atom' name 'Radiant Player' homepage 'http://radiant-player.github.io/radiant-player-mac/'
Update Radiant Player to 1.6.2
diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb index abc1234..def5678 100644 --- a/config/initializers/sidekiq.rb +++ b/config/initializers/sidekiq.rb @@ -11,3 +11,5 @@ config.redis = {url: "redis://#{host}:#{port}", namespace: namespace} end +Sidekiq::Logging.logger = Rails.logger +
Use Rails.logger as Sidekiq logger.
diff --git a/lib/cequel.rb b/lib/cequel.rb index abc1234..def5678 100644 --- a/lib/cequel.rb +++ b/lib/cequel.rb @@ -12,10 +12,12 @@ module Cequel def self.connect(configuration) + thrift_options = configuration[:thrift] || {} Keyspace.new( CassandraCQL::Database.new( configuration[:host] || configuration[:hosts], - :keyspace => configuration[:keyspace] + {:keyspace => configuration[:keyspace]}, + thrift_options.symbolize_keys ) ) end
Add thrift client options when setting up connection
diff --git a/week-5/nums-commas/my_solution.rb b/week-5/nums-commas/my_solution.rb index abc1234..def5678 100644 --- a/week-5/nums-commas/my_solution.rb +++ b/week-5/nums-commas/my_solution.rb @@ -8,17 +8,53 @@ # 0. Pseudocode -# What is the input? -# What is the output? (i.e. What should the code return?) +# What is the input? A positive integer +# What is the output? (i.e. What should the code return?) A string containing the integer with commas inserted # What are the steps needed to solve the problem? +=begin + If the integer is shorter than 4 characters, return it + Else, convert the integer into an array and slice that into 3 item "small arrays" within a "big array" + if the small array length ==3, insert a comma after position 0 + Flatten the big array to rejoin the small arrays with commas inserted + convert big array to a string and return it +=end # 1. Initial Solution +def separate_comma(int) + number_bucket = Array.new + if int.to_s.length < 4 + return int.to_s + else + big_array = int.to_s.reverse!.split("") + big_array.each_slice(3) do |triplet| + number_bucket.push(triplet) + end + number_bucket.each {|group| if group.size == 3; group.insert(3, ",") end } + + number_bucket.flatten! + number_bucket.reverse! + if number_bucket.first == "," + number_bucket.shift + end + return number_bucket.join.to_s + end +end + +###DRIVER CODE + +p separate_comma(139290) + # 2. Refactored Solution + + + #if triplet.size == 3 + #triplet.insert(3, ",") + #end
Complete MVP for solo challenge
diff --git a/cookbooks/goget/recipes/goget.rb b/cookbooks/goget/recipes/goget.rb index abc1234..def5678 100644 --- a/cookbooks/goget/recipes/goget.rb +++ b/cookbooks/goget/recipes/goget.rb @@ -6,6 +6,7 @@ goget 'github.com/atotto/clipboard/cmd/gopaste' do binary_name 'gopaste' end -goget 'github.com/mdempsky/gocode' +# Workarond: github.com/mdempsky/gocode is not support Go 1.11 modules +goget 'github.com/ikgo/gocode' goget 'golang.org/x/lint/golint' goget 'golang.org/x/tools/cmd/goimports'
Workaround: Use ikgo/gocode for Go 1.11 modules
diff --git a/Library/Homebrew/test/test_checksum.rb b/Library/Homebrew/test/test_checksum.rb index abc1234..def5678 100644 --- a/Library/Homebrew/test/test_checksum.rb +++ b/Library/Homebrew/test/test_checksum.rb @@ -7,16 +7,16 @@ end def test_equality - a = Checksum.new(:sha1, 'deadbeef'*5) - b = Checksum.new(:sha1, 'deadbeef'*5) + a = Checksum.new(:sha1, TEST_SHA1) + b = Checksum.new(:sha1, TEST_SHA1) assert_equal a, b - a = Checksum.new(:sha1, 'deadbeef'*5) - b = Checksum.new(:sha1, 'feedface'*5) + a = Checksum.new(:sha1, TEST_SHA1) + b = Checksum.new(:sha1, TEST_SHA1.reverse) refute_equal a, b - a = Checksum.new(:sha1, 'deadbeef'*5) - b = Checksum.new(:sha256, 'deadbeef'*5) + a = Checksum.new(:sha1, TEST_SHA1) + b = Checksum.new(:sha256, TEST_SHA256) refute_equal a, b end end
Use TEST_SHA1 constant in checksum tests
diff --git a/gimlet-model.gemspec b/gimlet-model.gemspec index abc1234..def5678 100644 --- a/gimlet-model.gemspec +++ b/gimlet-model.gemspec @@ -20,6 +20,7 @@ spec.add_development_dependency "bundler", "~> 1.3" spec.add_development_dependency "rake" + spec.add_development_dependency "rspec" spec.add_dependency "gimlet", "~> 0.0.2" end
Add rspec as a development dependency
diff --git a/examples/show_experiences.rb b/examples/show_experiences.rb index abc1234..def5678 100644 --- a/examples/show_experiences.rb +++ b/examples/show_experiences.rb @@ -1,8 +1,56 @@+require 'csv' + module ShowExperiences + CREATE_CSV = true + + # Show information about each experience. Also creates a CSV file def ShowExperiences.run(client, org) - client.experiences.get(org).each_with_index do |exp, i| - puts " %s. Experience name[%s] key[%s] region[%s]" % [i, exp.name, exp.key, exp.region.id] + csv_file = CREATE_CSV ? "/tmp/ruby-sdk-experiences.#{Process.pid}.csv" : nil + + client.experiences.get(org, :limit => 100).each_with_index do |exp, i| + puts " %s. Experience %s" % [i, exp.key] + + region = client.regions.get_by_id(exp.region.id) + puts " - name: " + exp.name + puts " - region: " + exp.region.id + puts " - default_currency: " + exp.currency + puts " - countries: " + region.countries.join(", ") + + pricing = client.experiences.get_pricing_by_key(org, exp.key) + puts " - vat: #{pricing.vat.value}" + puts " - duty: #{pricing.duty.value}" + if rounding = pricing.rounding + puts " - rounding:" + puts " - type: #{rounding.type.value}" + puts " - rounding_method: #{rounding.method.value}" + puts " - rounding_value: #{rounding.value.to_f}" + else + puts " - rounding: none" + end + + if CREATE_CSV + CSV.open(csv_file, "ab") do |csv| + if i == 0 + csv << %w(id key name region_id default_currency countries pricing_vat pricing_duty pricing_rounding_type pricing_rounding_method pricing_rounding_value) + end + data = [exp.id, exp.key, exp.name, exp.region.id, exp.currency, region.countries.join(" "), pricing.vat.value, pricing.duty.value] + if rounding + data << rounding.type.value + data << rounding.method.value + data << rounding.value.to_f + else + data << "" + data << "" + data << "" + end + csv << data + end + end + end + + if CREATE_CSV + puts "CSV output available at %s" % csv_file end end
Add more detail to experience example, including csv export
diff --git a/ruby/rna-transcription/complement.rb b/ruby/rna-transcription/complement.rb index abc1234..def5678 100644 --- a/ruby/rna-transcription/complement.rb +++ b/ruby/rna-transcription/complement.rb @@ -1,24 +1,20 @@ class Complement - def self.of_dna(dna_str) - dna_str.gsub(/[#{dna_to_rna.keys.join}]/, dna_to_rna) - end - - def self.of_rna(rna_str) - rna_str.gsub(/[#{rna_to_dna.keys.join}]/, rna_to_dna) - end - - def self.dna_to_rna - { + DNA_TO_RNA = { 'G' => 'C', 'C' => 'G', 'T' => 'A', 'A' => 'U' } + + RNA_TO_DNA = DNA_TO_RNA.invert + + def self.of_dna(dna_str) + dna_str.gsub(/[#{DNA_TO_RNA.keys.join}]/, DNA_TO_RNA) end - def self.rna_to_dna - dna_to_rna.invert + def self.of_rna(rna_str) + rna_str.gsub(/[#{RNA_TO_DNA.keys.join}]/, RNA_TO_DNA) end end
Change methods to class constants
diff --git a/app/models/floating_ip.rb b/app/models/floating_ip.rb index abc1234..def5678 100644 --- a/app/models/floating_ip.rb +++ b/app/models/floating_ip.rb @@ -12,13 +12,10 @@ belongs_to :cloud_network belongs_to :network_port belongs_to :network_router + alias_attribute :name, :address def self.available where(:vm_id => nil, :network_port_id => nil) - end - - def name - address end def self.class_by_ems(ext_management_system)
Use alias_attribute instead of using a method for name
diff --git a/app/models/councillor.rb b/app/models/councillor.rb index abc1234..def5678 100644 --- a/app/models/councillor.rb +++ b/app/models/councillor.rb @@ -3,5 +3,6 @@ has_and_belongs_to_many :committees has_many :motions + has_many :councillor_vote has_many :items, as: :origin end
Fix Councillor Vote Not Deleting Because a councillor association for has_many which is not been set up.
diff --git a/app/models/repository.rb b/app/models/repository.rb index abc1234..def5678 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -20,10 +20,10 @@ def next_pending sha = nil query = commits.pending.order("commited_at ASC") - if sha && commit = Commit.find_by_sha(sha) - query = query.where(["commited_at > ?", commit.commited_at]) + next_commit = if sha && commit = Commit.find_by_sha(sha) + query.where(["commited_at > ?", commit.commited_at]).first end - query.first + next_commit || query.first end def to_s
Improve next pending commit method
diff --git a/app/models/spree/user.rb b/app/models/spree/user.rb index abc1234..def5678 100644 --- a/app/models/spree/user.rb +++ b/app/models/spree/user.rb @@ -0,0 +1,80 @@+module Spree + class User < ActiveRecord::Base + include Core::UserBanners + + devise :database_authenticatable, :token_authenticatable, :registerable, :recoverable, + :rememberable, :trackable, :validatable, :encryptable, :encryptor => 'authlogic_sha512' + + has_many :orders + belongs_to :ship_address, :foreign_key => 'ship_address_id', :class_name => 'Spree::Address' + belongs_to :bill_address, :foreign_key => 'bill_address_id', :class_name => 'Spree::Address' + + before_validation :set_login + before_destroy :check_completed_orders + + # Setup accessible (or protected) attributes for your model + attr_accessible :email, :password, :password_confirmation, :remember_me, :persistence_token, :login + + users_table_name = User.table_name + roles_table_name = Role.table_name + + scope :admin, lambda { includes(:spree_roles).where("#{roles_table_name}.name" => "admin") } + scope :registered, where("#{users_table_name}.email NOT LIKE ?", "%@example.net") + + class DestroyWithOrdersError < StandardError; end + + # Creates an anonymous user. An anonymous user is basically an auto-generated +User+ account that is created for the customer + # behind the scenes and its completely transparently to the customer. All +Orders+ must have a +User+ so this is necessary + # when adding to the "cart" (which is really an order) and before the customer has a chance to provide an email or to register. + def self.anonymous! + token = User.generate_token(:persistence_token) + User.create(:email => "#{token}@example.net", :password => token, :password_confirmation => token, :persistence_token => token) + end + + def self.admin_created? + User.admin.count > 0 + end + + def admin? + has_spree_role?('admin') + end + + def anonymous? + email =~ /@example.net$/ ? true : false + end + + def send_reset_password_instructions + generate_reset_password_token! + UserMailer.reset_password_instructions(self.id).deliver + end + + protected + def password_required? + !persisted? || password.present? || password_confirmation.present? + end + + private + + def check_completed_orders + raise DestroyWithOrdersError if orders.complete.present? + end + + def set_login + # for now force login to be same as email, eventually we will make this configurable, etc. + self.login ||= self.email if self.email + end + + # Generate a friendly string randomically to be used as token. + def self.friendly_token + SecureRandom.base64(15).tr('+/=', '-_ ').strip.delete("\n") + end + + # Generate a token by looping and ensuring does not already exist. + def self.generate_token(column) + loop do + token = friendly_token + break token unless find(:first, :conditions => { column => token }) + end + end + end +end
Add User class from spree_auth_devise as is
diff --git a/publify_core/app/models/trackback.rb b/publify_core/app/models/trackback.rb index abc1234..def5678 100644 --- a/publify_core/app/models/trackback.rb +++ b/publify_core/app/models/trackback.rb @@ -4,14 +4,6 @@ class Trackback < Feedback content_fields :excerpt validates :title, :excerpt, :url, presence: true - - # attr_accessible :url, :blog_name, :title, :excerpt, :ip, :published, :article_id - - def initialize(*args, &block) - super(*args, &block) - self.title ||= url - self.blog_name ||= '' - end before_create :process_trackback
Remove superfluous initializer from Trackback No new Trackback objects should be stored in the database, and also no tests fail when this code is removed.
diff --git a/lib/samuel.rb b/lib/samuel.rb index abc1234..def5678 100644 --- a/lib/samuel.rb +++ b/lib/samuel.rb @@ -15,6 +15,7 @@ end def logger + @logger = nil if !defined?(@logger) return @logger if !@logger.nil? if defined?(RAILS_DEFAULT_LOGGER)
Fix "instance variable @logger not initialized" warning
diff --git a/Casks/acquia-dev-desktop.rb b/Casks/acquia-dev-desktop.rb index abc1234..def5678 100644 --- a/Casks/acquia-dev-desktop.rb +++ b/Casks/acquia-dev-desktop.rb @@ -0,0 +1,19 @@+cask :v1 => 'acquia-dev-desktop' do + version '2-2015-04-03' + sha256 '958d23385827695f3bc79d3d5b78995fdb9c5dfa5528d2b03efe321aa8fb008b' + + url "http://www.acquia.com/sites/default/files/downloads/dev-desktop/AcquiaDevDesktop-#{version}.dmg" + name 'Acquia Dev Desktop' + homepage 'https://www.acquia.com/products-services/dev-desktop' + license :gratis + + installer :script => 'Acquia Dev Desktop Installer.app/Contents/MacOS/installbuilder.sh', + :args => ['--mode' , 'unattended', '--unattendedmodeui', 'none'], + :sudo => true + + uninstall :script => { + :executable => '/Applications/DevDesktop/uninstall.app/Contents/MacOS/installbuilder.sh', + :args => ['--mode' , 'unattended', '--unattendedmodeui', 'none'], + :sudo => true, + } +end
Add Acquia Dev Desktop 2. Acquia Dev Desktop 2 is a free app that allows you to run and develop Drupal sites locally on your computer and optionally hos them using Acquia Cloud. Use Acquia Dev Desktop to evaluate Drupal, add and test other Drupak modules, and develop sites while on a plane or away from an internet connection. Add version and sha256 to DevDesktop. The current version of Acquia Dev Desktop is 2-2015-04-03. Also was added the uninstall script.
diff --git a/spec/features/deleting_files_spec.rb b/spec/features/deleting_files_spec.rb index abc1234..def5678 100644 --- a/spec/features/deleting_files_spec.rb +++ b/spec/features/deleting_files_spec.rb @@ -9,6 +9,5 @@ instance.store!(image) end - it 'deletes the image when assigned a `nil` value' do - end + it 'deletes the image when assigned a `nil` value' end
Mark unimplemented spec as pending
diff --git a/lib/gir_ffi-gnome_keyring/found.rb b/lib/gir_ffi-gnome_keyring/found.rb index abc1234..def5678 100644 --- a/lib/gir_ffi-gnome_keyring/found.rb +++ b/lib/gir_ffi-gnome_keyring/found.rb @@ -4,6 +4,9 @@ load_class :Found class Found + remove_method :attributes + remove_method :attributes= + def attributes struct = GnomeKeyring::Found::Struct.new(@struct.to_ptr) GnomeKeyring::AttributeList.wrap(struct[:attributes])
Remove old methods before redefining
diff --git a/lib/miq_tools_services/bugzilla.rb b/lib/miq_tools_services/bugzilla.rb index abc1234..def5678 100644 --- a/lib/miq_tools_services/bugzilla.rb +++ b/lib/miq_tools_services/bugzilla.rb @@ -14,7 +14,11 @@ def service @service ||= begin require 'active_bugzilla' - bz = ActiveBugzilla::Service.new(*credentials.values_at("bugzilla_uri", "username", "password")) + bz = ActiveBugzilla::Service.new( + credentials["bugzilla_uri"], + credentials["username"], + credentials["password"] + ) ActiveBugzilla::Base.service = bz end end
Support RailsConfig objects for credentials
diff --git a/spec/magic-equals-multi-via-query.rb b/spec/magic-equals-multi-via-query.rb index abc1234..def5678 100644 --- a/spec/magic-equals-multi-via-query.rb +++ b/spec/magic-equals-multi-via-query.rb @@ -0,0 +1,18 @@+require_relative 'spec_helper' +require 'uri' + +describe 'Noodle' do + it "should allow finding by 'TERM1=VALUE1 TERM2=VALUE2' via query (nodes/_/?blah blah)" do + put '/nodes/kiki.example.com', params = '{"ilk":"host","status":"enabled","params":{"site":"pluto"}}' + assert_equal last_response.status, 201 + put '/nodes/cici.example.com', params = '{"ilk":"host","status":"enabled","params":{"site":"pluto","prodlevel":"prod"}}' + assert_equal last_response.status, 201 + + Node.gateway.refresh_index! + + get "/nodes/_/?site=pluto#{URI.escape(' ')}prodlevel=prod" + assert_equal last_response.status, 200 + assert_equal last_response.body, "cici.example.com\n" + end +end +
Add query test (/nodes/_/?blah blah)
diff --git a/spec/providers/service_runit_spec.rb b/spec/providers/service_runit_spec.rb index abc1234..def5678 100644 --- a/spec/providers/service_runit_spec.rb +++ b/spec/providers/service_runit_spec.rb @@ -2,9 +2,11 @@ describe 'service_runit provider' do let(:runner) do - ChefSpec::Runner.new(step_into: ['graphite_service']) do |node| - node.automatic["platform_family"] = "debian" - end + ChefSpec::Runner.new( + platform: "ubuntu", + version: "12.04", + step_into: ['graphite_service'] + ) end let(:node) { runner.node } let(:chef_run) { runner.converge("graphite_fixtures::graphite_service_runit_enable") }
Refactor graphite_service_runit provider spec to use fauxhai data.
diff --git a/lib/str_sanitizer/html_entities.rb b/lib/str_sanitizer/html_entities.rb index abc1234..def5678 100644 --- a/lib/str_sanitizer/html_entities.rb +++ b/lib/str_sanitizer/html_entities.rb @@ -0,0 +1,38 @@+require 'htmlentities' + +class StrSanitizer + module HtmlEntities + + # Instantiate htmlentities class to use it for encoding and decoding html entities + # + # Params: + # +none+ + def initizalize + @coder = HTMLEntities.new + end + + # Encodes the HTML entities of the given string + # + # Params: + # +str+:: A +string+ which needs to be escaped from html entities + # + # Returns: + # +string+:: An HTML entities escaped +string+ + def encode(string) + @coder = HTMLEntities.new + @coder.encode(string) + end + + # Decodes the HTML entities of the given string + # + # Params: + # +str+:: A +string+ which needs to be decoded to html entities + # + # Returns: + # +string+:: A string with decoded HTML entities +string+ + def decode(string) + @coder = HTMLEntities.new + @coder.decode(string) + end + end +end
Add HtmlEntities module which encodes and decodes HTML entities
diff --git a/lib/travis/addons/handlers/base.rb b/lib/travis/addons/handlers/base.rb index abc1234..def5678 100644 --- a/lib/travis/addons/handlers/base.rb +++ b/lib/travis/addons/handlers/base.rb @@ -19,7 +19,10 @@ def data @data ||= Serializer::Generic.const_get(object_type.camelize).new(object).data end - alias payload data + + def payload + Travis::SecureConfig.decrypt(data, secure_key) + end def config @config ||= Config.new(data, secure_key)
Decrypt payload for all event handlers When handing off notification payload to travis-tasks, ensure that the payload is decrypted. This caused https://github.com/travis-ci/travis-ci/issues/2813 (Notice that encrypted 'channels' were fine, because it was passed on separately by the IRC event handler.)
diff --git a/lib/omniauth/strategies/wordpress_hosted.rb b/lib/omniauth/strategies/wordpress_hosted.rb index abc1234..def5678 100644 --- a/lib/omniauth/strategies/wordpress_hosted.rb +++ b/lib/omniauth/strategies/wordpress_hosted.rb @@ -32,7 +32,7 @@ end def raw_info - @raw_info ||= access_token.get('/oauth/me').parsed + @raw_info ||= access_token.get('http://brandpage.net/oauth/me').parsed end end end
Update endpoints used by WP OAuth Server 3.1.3
diff --git a/lib/piggybak_braintree/payment_decorator.rb b/lib/piggybak_braintree/payment_decorator.rb index abc1234..def5678 100644 --- a/lib/piggybak_braintree/payment_decorator.rb +++ b/lib/piggybak_braintree/payment_decorator.rb @@ -7,7 +7,7 @@ validates :payment_method_nonce, presence: true - [:month, :year].each do |field| + [:month, :year, :number, :verification_value].each do |field| _validators.reject!{ |key, _| key == field } _validate_callbacks.reject! do |callback|
Remove validations for number and cvv if nonce presence
diff --git a/lib/pronto/rake_task/travis_pull_request.rb b/lib/pronto/rake_task/travis_pull_request.rb index abc1234..def5678 100644 --- a/lib/pronto/rake_task/travis_pull_request.rb +++ b/lib/pronto/rake_task/travis_pull_request.rb @@ -31,19 +31,19 @@ end def run_task(verbose) - return if pull_request == 'false' + return if pull_request_number == 'false' client = Octokit::Client.new - pull_request = client.pull_request(repo_slug, pull_request) - formatter = GithubFormatter.new + pull_request = client.pull_request(repo_slug, pull_request_number) + formatter = ::Pronto::Formatter::GithubFormatter.new ::Pronto.run(pull_request.base.sha, '.', formatter) end private - def pull_request + def pull_request_number ENV['TRAVIS_PULL_REQUEST'] end
Rename method to avoid name collision
diff --git a/test/fixtures/cookbooks/jenkins_server_wrapper/attributes/default.rb b/test/fixtures/cookbooks/jenkins_server_wrapper/attributes/default.rb index abc1234..def5678 100644 --- a/test/fixtures/cookbooks/jenkins_server_wrapper/attributes/default.rb +++ b/test/fixtures/cookbooks/jenkins_server_wrapper/attributes/default.rb @@ -1,5 +1,4 @@ # make sure we get the correct version of java installed -default['java']['install_flavor'] = 'oracle' +default['java']['install_flavor'] = 'adoptopenjdk' default['java']['jdk_version'] = '8' default['java']['set_etc_environment'] = true -default['java']['oracle']['accept_oracle_download_terms'] = true
Switch to openjdk since Oracle jdk artifacts have been removed Signed-off-by: Richard Baker <43588b937db6c0a9556777fbd43852676d68c9bf@digital.cabinet-office.gov.uk>
diff --git a/app/metrics/beeminder/compose_goals.rb b/app/metrics/beeminder/compose_goals.rb index abc1234..def5678 100644 --- a/app/metrics/beeminder/compose_goals.rb +++ b/app/metrics/beeminder/compose_goals.rb @@ -7,7 +7,7 @@ Array(options[slug_key]).flat_map do |slug, factor| next [] if factor.blank? adapter.recent_datapoints(slug).map do |dp| - [dp.timestamp, dp.value * Float(factor) ] + [dp.timestamp.utc, dp.value * Float(factor) ] end end.group_by(&:first).map do |ts, values| Datapoint.new(
Use utc timestamp in beeminder compose metric
diff --git a/spec/lib/github-backup/backup_spec.rb b/spec/lib/github-backup/backup_spec.rb index abc1234..def5678 100644 --- a/spec/lib/github-backup/backup_spec.rb +++ b/spec/lib/github-backup/backup_spec.rb @@ -0,0 +1,86 @@+require File.expand_path('../../../spec_helper', __FILE__) + +describe GithubBackup::Backup do + + describe :new do + + # username + it 'requires a username' do + proc { GithubBackup::Backup.new }. + must_raise ArgumentError + end + + it 'initializes an Octokit client' do + backup = GithubBackup::Backup.new('ddollar', :backup_root => '/tmp') + backup.client.must_be_instance_of ::Octokit::Client + end + + it 'configures the backup' do + skip('Define GithubBackup::Config#==') + + opts = { :backup_root => '/tmp', :token => 'S3CR3T' } + config = GithubBackup::Config.new(opts) + backup = GithubBackup::Backup.new('ddollar', opts) + backup.config.must_equal config + end + + # :token + describe 'with a token' do + + it 'will configure the client with an OAuth access token' do + opts = { :backup_root => '/tmp', :token => 'S3CR3T' } + backup = GithubBackup::Backup.new('ddollar', opts) + backup.client.access_token.must_equal opts[:token] + end + + end + + describe 'without a token' do + + it 'will not configure the client with an OAuth access token' do + opts = { :backup_root => '/tmp' } + backup = GithubBackup::Backup.new('ddollar', opts) + backup.client.access_token.must_be_nil + end + + end + + end + + describe :username do + + it 'returns the username of the GitHub account to back up' do + backup = GithubBackup::Backup.new('ddollar', :backup_root => '/tmp') + backup.username.must_equal 'ddollar' + end + + end + + describe :client do + + it 'returns the Octokit client' do + backup = GithubBackup::Backup.new('ddollar', :backup_root => '/tmp') + backup.client.must_be_instance_of ::Octokit::Client + end + + end + + describe :config do + + it 'returns the backup configuration' do + backup = GithubBackup::Backup.new('ddollar', :backup_root => '/tmp') + backup.config.must_be_instance_of GithubBackup::Config + end + + end + + describe :debug do + + it 'returns false' do + backup = GithubBackup::Backup.new('ddollar', :backup_root => '/tmp') + backup.debug.must_equal false + end + + end + +end
Add basic specs for Backup Covers most of the initialization of a Backup object. TODO: Define GithubBackup::Config#== Set default backup directory to Dir.pwd
diff --git a/spec/plugins/last_modified_at_spec.rb b/spec/plugins/last_modified_at_spec.rb index abc1234..def5678 100644 --- a/spec/plugins/last_modified_at_spec.rb +++ b/spec/plugins/last_modified_at_spec.rb @@ -9,7 +9,7 @@ it "has last revised date" do setup("1984-03-06-last-modified-at.md", "last_modified_at.html") - expect(@post.output).to match /Article last updated on 03-Jan-14/ + expect(@post.output).to match /Article last updated on 04-Jan-14/ end it "passes along last revised date format" do
Set fixture date to 04, not 03
diff --git a/spec/support/test/resource_service.rb b/spec/support/test/resource_service.rb index abc1234..def5678 100644 --- a/spec/support/test/resource_service.rb +++ b/spec/support/test/resource_service.rb @@ -0,0 +1,14 @@+require ::File.expand_path('../resource.pb', __FILE__) + +module Test + class ResourceService + + # request -> Test::ResourceFindRequest + # response -> Test::Resource + def find + response.name = request.name + response.status = request.active ? 1 : 0 + end + + end +end
Add back in ResourceService implementation for spec
diff --git a/lib/chef/provider/template_finder.rb b/lib/chef/provider/template_finder.rb index abc1234..def5678 100644 --- a/lib/chef/provider/template_finder.rb +++ b/lib/chef/provider/template_finder.rb @@ -29,15 +29,31 @@ def find(template_name, options = {}) if options[:local] - return options[:source] ? options[:source] : template_name + return local_template_source(template_name, options) end - cookbook_name = options[:cookbook] ? options[:cookbook] : @cookbook_name - + cookbook_name = find_cookbook_name(options) cookbook = @run_context.cookbook_collection[cookbook_name] cookbook.preferred_filename_on_disk_location(@node, :templates, template_name) end + + protected + def local_template_source(name, options) + if options[:source] + options[:source] + else + name + end + end + + def find_cookbook_name(options) + if options[:cookbook] + options[:cookbook] + else + @cookbook_name + end + end end end end
[CHEF-3249] Replace ternary operators with more explicit conditionals; split them out to separate methods for ease of maintenance.
diff --git a/lib/electric_sheep/transports/scp.rb b/lib/electric_sheep/transports/scp.rb index abc1234..def5678 100644 --- a/lib/electric_sheep/transports/scp.rb +++ b/lib/electric_sheep/transports/scp.rb @@ -1,6 +1,21 @@ module ElectricSheep module Transports - module SCP + class SCP + include ElectricSheep::Transport + + register as: "scp" + + def copy + logger.info "Will copy #{resource.basename} " + + "from #{resource.host} " + + "to #{option(:to).to_s}" + end + + def move + logger.info "Will move #{resource.basename}" + + "from #{resource.host} " + + "to #{option(:to).to_s}" + end end end
Add a skeleton for SCP transport.
diff --git a/app/controllers/spree/chimpy/subscribers_controller.rb b/app/controllers/spree/chimpy/subscribers_controller.rb index abc1234..def5678 100644 --- a/app/controllers/spree/chimpy/subscribers_controller.rb +++ b/app/controllers/spree/chimpy/subscribers_controller.rb @@ -11,7 +11,8 @@ flash[:error] = Spree.t(:failure, scope: [:chimpy, :subscriber]) end - respond_with @subscriber, location: request.referer + referer = request.referer || root_url # Referer is optional in request. + respond_with @subscriber, location: referer end private
Use root_url as referer if missing Otherwise, respond_to will try to generate a URL for the resource and fail (no route for it)
diff --git a/sprout-osx-apps/attributes/hipchat.rb b/sprout-osx-apps/attributes/hipchat.rb index abc1234..def5678 100644 --- a/sprout-osx-apps/attributes/hipchat.rb +++ b/sprout-osx-apps/attributes/hipchat.rb @@ -1,4 +1,4 @@-default['sprout']['hipchat']['url'] = "http://downloads.hipchat.com.s3.amazonaws.com/osx/HipChat-2.0.zip" +default['sprout']['hipchat']['url'] = "http://downloads.hipchat.com.s3.amazonaws.com/osx/HipChat-2.4.zip" default['sprout']['hipchat']['app'] = "HipChat.app" default['sprout']['hipchat']['settings'] = [ ['disableSounds', 'bool', 'true']
Update HipChat recipe to install newer version
diff --git a/app/serializers/endpoint_serializer.rb b/app/serializers/endpoint_serializer.rb index abc1234..def5678 100644 --- a/app/serializers/endpoint_serializer.rb +++ b/app/serializers/endpoint_serializer.rb @@ -1,3 +1,4 @@ class EndpointSerializer < ActiveModel::Serializer attributes :name, :public, :certificate_id + belongs_to :district end
Add district association to endpoint serializer
diff --git a/app/controllers/articles_controller.rb b/app/controllers/articles_controller.rb index abc1234..def5678 100644 --- a/app/controllers/articles_controller.rb +++ b/app/controllers/articles_controller.rb @@ -7,11 +7,6 @@ return redirect_to(home_path) end - if @article_category.nil? - # No flash because homepages are page cached - return redirect_to(home_path) - end - render layout: !request.xhr? end end
Remove stray article catgory check
diff --git a/app/controllers/feedback_controller.rb b/app/controllers/feedback_controller.rb index abc1234..def5678 100644 --- a/app/controllers/feedback_controller.rb +++ b/app/controllers/feedback_controller.rb @@ -35,7 +35,8 @@ comment: { value: feedback_comment }, - submitter_id: client.current_user.id + submitter_id: client.current_user.id, + tags: %w(online_booking) ) end
Tag tickets created from feedback form with `online_booking` So the feedback can easily be identified in Zendesk.
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 @@ -3,6 +3,7 @@ class SessionsController < Devise::OmniauthCallbacksController skip_before_action :verify_authenticity_token skip_before_action :authenticate_user! + skip_before_action :redirect_if_country_banned include Devise::Controllers::Rememberable
Allow current users from banned countries
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index abc1234..def5678 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -4,6 +4,9 @@ get '/users/:id' do + if session[:user_id] != params[:id].to_i + halt 401, "Not authorized to view user #{params[:id]}.\n" + end @user = User.find_by(id: params[:id]) @surveys = @user.surveys erb :'user/show'
Add 401 stat page to deny users access to other user's profiles.
diff --git a/lib/shard_handler/thread_registry.rb b/lib/shard_handler/thread_registry.rb index abc1234..def5678 100644 --- a/lib/shard_handler/thread_registry.rb +++ b/lib/shard_handler/thread_registry.rb @@ -7,6 +7,7 @@ # the current thread and not on process or other threads. # # @see ActiveSupport::PerThreadRegistry + # @api private class ThreadRegistry extend ActiveSupport::PerThreadRegistry attr_accessor :current_shard
Mark ThreadRegistry as a private api
diff --git a/config/unicorn/production.rb b/config/unicorn/production.rb index abc1234..def5678 100644 --- a/config/unicorn/production.rb +++ b/config/unicorn/production.rb @@ -7,8 +7,6 @@ timeout 180 listen "127.0.0.1:8080" -# Spawn unicorn master worker for user apps (group: apps) -user 'apps', 'apps' # Fill path to your app working_directory app_path
Remove user setting for Unicorn
diff --git a/lib/tritium/parser/macros/asset.2.rb b/lib/tritium/parser/macros/asset.2.rb index abc1234..def5678 100644 --- a/lib/tritium/parser/macros/asset.2.rb +++ b/lib/tritium/parser/macros/asset.2.rb @@ -3,23 +3,24 @@ ->(args) do file_name, type = args location = "" - puts "DEPRECATION WARNING: Don't use asset.2 anymore! Will be gone in 1.0" + output = [] + output << "log('DEPRECATION WARNING: Do not use asset.2 anymore! Will be gone in 1.0')" if type.value == "stylesheet" location = "stylesheets/.css/" if file_name.respond_to?("value") - puts "DEPRECATION WARNING: Please use sass('#{file_name.value[0..-5]}') instead" unless ENV["TEST"] + output << "log('DEPRECATION WARNING: Please use sass(\"#{file_name.value[0..-5]}\") instead')" #unless ENV["TEST"] end elsif type.value == "js" location = "javascript/" if file_name.respond_to?("value") - puts "DEPRECATION WARNING: Please use asset(\"javascripts/#{file_name.value}\") instead" unless ENV["TEST"] + output << "log('DEPRECATION WARNING: Please use asset(\"javascripts/#{file_name.value}\") instead')" #unless ENV["TEST"] end elsif type.value == "image" location = "images/" if file_name.respond_to?("value") - puts "DEPRECATION WARNING: Please use asset(\"images/#{file_name.value}\") instead" unless ENV["TEST"] + output << "log('DEPRECATION WARNING: Please use asset(\"images/#{file_name.value}\") instead')" #unless ENV["TEST"] end end - "asset(concat(#{location.inspect}, #{file_name.to_script})) { yield() }" + "asset(concat(#{location.inspect}, #{file_name.to_script})) { #{output.join("\n")}\n yield() }" end
Use the log() function in tritium for the warnings
diff --git a/lib/underskog/response/parse_json.rb b/lib/underskog/response/parse_json.rb index abc1234..def5678 100644 --- a/lib/underskog/response/parse_json.rb +++ b/lib/underskog/response/parse_json.rb @@ -14,7 +14,9 @@ when 'false' false else - MultiJson.load(body) + json = MultiJson.load(body) + return json['data'] if json.is_a?(Hash) and json['data'] + json end end
Use data field in json response as data
diff --git a/app/interactors/api/compound_events.rb b/app/interactors/api/compound_events.rb index abc1234..def5678 100644 --- a/app/interactors/api/compound_events.rb +++ b/app/interactors/api/compound_events.rb @@ -34,14 +34,17 @@ end def courses - course_ids = events.distinct.select(:course_id) + # SELECT id, name FROM courses + # WHERE id IN (SELECT course_id FROM events WHERE ...) + course_ids = events.select(:course_id) Course.where(id: course_ids).select(:id, :name) end def teachers - # SELECT id, full_name FROM people WHERE id IN (SELECT DISTINCT unnest(teacher_ids) FROM EVENTS) + # SELECT id, full_name FROM people + # WHERE id IN (SELECT unnest(teacher_ids) FROM events WHERE ...) array_op = Sequel.pg_array(:teacher_ids) - teacher_ids = events.select(array_op.unnest).distinct + teacher_ids = events.select(array_op.unnest) Person.where(id: teacher_ids).select(:id, :full_name) end
Remove unnecessary DISTINCT from compound queries
diff --git a/app/presenters/respondent_presenter.rb b/app/presenters/respondent_presenter.rb index abc1234..def5678 100644 --- a/app/presenters/respondent_presenter.rb +++ b/app/presenters/respondent_presenter.rb @@ -10,9 +10,10 @@ end def acas_early_conciliation_certificate_number - if target.acas_early_conciliation_certificate_number? + case + when target.acas_early_conciliation_certificate_number? target.acas_early_conciliation_certificate_number - else + when target.no_acas_number_reason I18n.t "simple_form.options.respondent.no_acas_number_reason.#{target.no_acas_number_reason}" end end
Fix edge case on review page Manually navigating to the review page before filling in respondent details causes all I18n values for no acas number reason. This fixes that.
diff --git a/chef-repo/site-cookbooks/sysbench/recipes/configure.rb b/chef-repo/site-cookbooks/sysbench/recipes/configure.rb index abc1234..def5678 100644 --- a/chef-repo/site-cookbooks/sysbench/recipes/configure.rb +++ b/chef-repo/site-cookbooks/sysbench/recipes/configure.rb @@ -13,6 +13,6 @@ cli_options: node['sysbench']['cli_options'], repetitions: node['sysbench']['repetitions'], threads: node['cpu']['total'] || node['sysbench']['default_threads'], - cpu_model: node['cpu']['model_name'], + cpu_model: node['cpu']['0']['model_name'], ) end
Fix CPU model name detection
diff --git a/core/string/shared/to_sym.rb b/core/string/shared/to_sym.rb index abc1234..def5678 100644 --- a/core/string/shared/to_sym.rb +++ b/core/string/shared/to_sym.rb @@ -7,6 +7,26 @@ "abc=".send(@method).should == :abc= end + it "special cases !@ and ~@" do + "!@".to_sym.should == :"!" + "~@".to_sym.should == :~ + end + + it "special cases !(unary) and ~(unary)" do + "!(unary)".to_sym.should == :"!" + "~(unary)".to_sym.should == :~ + end + + it "special cases +(binary) and -(binary)" do + "+(binary)".to_sym.should == :+ + "-(binary)".to_sym.should == :- + end + + it "special cases +(unary) and -(unary)" do + "+(unary)".to_sym.should == :"+@" + "-(unary)".to_sym.should == :"-@" + end + ruby_version_is ""..."1.9" do it "raises an ArgumentError when self can't be converted to symbol" do lambda { "".send(@method) }.should raise_error(ArgumentError)
Add specs for special operator's symbol values
diff --git a/MetaData/HTMLDOMKit.podspec b/MetaData/HTMLDOMKit.podspec index abc1234..def5678 100644 --- a/MetaData/HTMLDOMKit.podspec +++ b/MetaData/HTMLDOMKit.podspec @@ -2,7 +2,6 @@ s.name = "HTMLDOMKit" s.version = "0.0.1" s.summary = "An HTML DOM generation tool written in Swift" - s.description = <<-DESC HTMLDOMKit allows the creation of HTML DOMs for the building of web pages. HTML pages are built using the DOM Elements and DOM Attributes, or just as a simple Dictionary. Either method can then be converted using the toHTML() method. @@ -14,13 +13,9 @@ s.source = { :git => "https://github.com/MadApper/HTMLDOMKit.git", :branch => "master", :tag => s.version.to_s } s.social_media_url = 'https://twitter.com/madapperapps' -<<<<<<< HEAD:MetaData/HTMLDOMKit.podspec s.ios.deployment_target = '8.3' s.osx.deployment_target = '10.9' s.tvos.deployment_target = '9.0' -======= - s.ios.deployment_target = '8.0' ->>>>>>> parent of af682e9... updated pod spec with deployment targets:HTMLDOMKit.podspec s.source_files = 'HTMLDOMKit/Classes/**/*' end
Revert "reverted pod spec change" This reverts commit 03640ec187f3fefa188c0e83cd30529b58576319.
diff --git a/db/migrate/20190626175626_add_group_creation_level_to_namespaces.rb b/db/migrate/20190626175626_add_group_creation_level_to_namespaces.rb index abc1234..def5678 100644 --- a/db/migrate/20190626175626_add_group_creation_level_to_namespaces.rb +++ b/db/migrate/20190626175626_add_group_creation_level_to_namespaces.rb @@ -0,0 +1,20 @@+# frozen_string_literal: true + +class AddGroupCreationLevelToNamespaces < ActiveRecord::Migration[5.1] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + disable_ddl_transaction! + + def up + unless column_exists?(:namespaces, :subgroup_creation_level) + add_column_with_default(:namespaces, :subgroup_creation_level, :integer, default: 0) + end + end + + def down + if column_exists?(:namespaces, :subgroup_creation_level) + remove_column(:namespaces, :subgroup_creation_level) + end + end +end
Add a subgroup_creation_level column to the namespaces table
diff --git a/app/controllers/answers_controller.rb b/app/controllers/answers_controller.rb index abc1234..def5678 100644 --- a/app/controllers/answers_controller.rb +++ b/app/controllers/answers_controller.rb @@ -1,6 +1,7 @@ class AnswersController < ApplicationController before_filter :authenticate_user! before_filter :find_question + before_filter :require_question_user!, :only => [:accept] def new @@ -17,7 +18,21 @@ end end + def accept + @answer = @question.answers.find(params[:id]) + if @answer.accept! + redirect_to @question, :notice => 'Answer marked as accepted!' + else + redirect_to @question, :notice => 'Answer could not be marked as accepted, please try again.' + end + end + + private + + def require_question_user! + raise Inquest::MustOwnQuestionException unless current_user == @question.user + end def find_question @question ||= Question.find(params[:question_id])
Add accept action to AnswersController
diff --git a/app/controllers/kaizens_controller.rb b/app/controllers/kaizens_controller.rb index abc1234..def5678 100644 --- a/app/controllers/kaizens_controller.rb +++ b/app/controllers/kaizens_controller.rb @@ -20,8 +20,11 @@ else @kaizen.user = user end - @kaizen.save - redirect_to @kaizen + if @kaizen.save + redirect_to @kaizen + else + render :edit + end end def edit
Add logic to render edit on Kaizen save failure
diff --git a/app/controllers/schools_controller.rb b/app/controllers/schools_controller.rb index abc1234..def5678 100644 --- a/app/controllers/schools_controller.rb +++ b/app/controllers/schools_controller.rb @@ -27,14 +27,15 @@ end def districts - results = School.search_schools("District "); + districts_num_list = School.districts_num_arr @json = Array.new - results.each do |district| + districts_num_list.each do |d| + schools_in_district = School.district_schools(d) @json << { - code: district.dbn, - district: district.school, - total_enrollment: district.total_enrollment, - amount_owed: district.amount_owed + code: School.get_district_code(schools_in_district), + district: School.get_district_name(schools_in_district), + total_enrollment: School.district_enrollment_sum(schools_in_district), + amount_owed: School.district_owed_sum(schools_in_district) } end respond_to do |format|
Change districts method to create a json with calculated totals per district for amoutn owed and enrollment - uses methods from School model.
diff --git a/app/controllers/surveys_controller.rb b/app/controllers/surveys_controller.rb index abc1234..def5678 100644 --- a/app/controllers/surveys_controller.rb +++ b/app/controllers/surveys_controller.rb @@ -21,7 +21,7 @@ redirect '/questions/new' end else - redirect '/?errors=unable_to_create_survey' + erb :'/survey/new', locals: { errors: @survey.errors.full_messages } end end
Fix bug where new survey title doesn't meet min. 5 char validation
diff --git a/app/views/api/v1/places/show.json.rabl b/app/views/api/v1/places/show.json.rabl index abc1234..def5678 100644 --- a/app/views/api/v1/places/show.json.rabl +++ b/app/views/api/v1/places/show.json.rabl @@ -2,5 +2,6 @@ child :ownerships do attributes :user_id, :name + attributes :contact_by_phone, :contact_by_email attributes :email, :phone, :if => lambda { |o| o.place.authorized? current_user } -end+end
Add new flags to API response.
diff --git a/add_all.rb b/add_all.rb index abc1234..def5678 100644 --- a/add_all.rb +++ b/add_all.rb @@ -5,6 +5,7 @@ sources = JSON.parse(File.read(File.join(File.dirname($0), 'ubuntu.json'))) successes = sources.select do |src| + puts "-------------------\nAdding #{src.inspect}\n" if src['key_url'] system("curl -sSL #{src['key_url'].untaint.inspect} | sudo -E apt-key add -") && system("sudo -E apt-add-repository -y #{src['sourceline'].untaint.inspect}") else
Add dividers for prettier output
diff --git a/app/helpers/bootstrap_flash_helper.rb b/app/helpers/bootstrap_flash_helper.rb index abc1234..def5678 100644 --- a/app/helpers/bootstrap_flash_helper.rb +++ b/app/helpers/bootstrap_flash_helper.rb @@ -5,7 +5,7 @@ # includes ................................................................... # constants .................................................................. - ALERT_TYPES = [:error, :info, :success, :warning] unless const_defined?(:ALERT_TYPES) + ALERT_TYPES = [ :success, :info, :warning, :danger ] unless const_defined?(:ALERT_TYPES) # additional config .......................................................... # class methods .............................................................. @@ -19,7 +19,7 @@ type = type.to_sym type = :success if type == :notice - type = :error if type == :alert + type = :danger if type == :alert next unless ALERT_TYPES.include?(type) Array(message).each do |msg| @@ -29,6 +29,7 @@ flash_messages << text if msg end end + flash_messages.join("\n").html_safe end
Tweak bootstrap flash helper a bit to use danger instead of error alert class
diff --git a/spec/github-pages-dependencies_spec.rb b/spec/github-pages-dependencies_spec.rb index abc1234..def5678 100644 --- a/spec/github-pages-dependencies_spec.rb +++ b/spec/github-pages-dependencies_spec.rb @@ -3,7 +3,7 @@ describe(GitHubPages::Dependencies) do CORE_DEPENDENCIES = %w( jekyll kramdown liquid rouge rdiscount redcarpet RedCloth - jekyll-sass-converter github-pages-health-check + jekyll-sass-converter github-pages-health-check listen ).freeze PLUGINS = described_class::VERSIONS.keys - CORE_DEPENDENCIES
Add 'listen' to core dependencies.
diff --git a/metadata.rb b/metadata.rb index abc1234..def5678 100644 --- a/metadata.rb +++ b/metadata.rb @@ -4,4 +4,4 @@ license "Apache 2.0" description "A cookbook used to set up a Flume agent." long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version "1.0" +version "1.1"
Increase to 1.1 for next release development
diff --git a/metadata.rb b/metadata.rb index abc1234..def5678 100644 --- a/metadata.rb +++ b/metadata.rb @@ -21,6 +21,9 @@ supports 'redhat' supports 'smartos' supports 'scientific' +supports 'suse' +supports 'opensuse' +supports 'opensuseleap' supports 'ubuntu' supports 'windows'
Add suse to the readme Signed-off-by: Tim Smith <764ef62106582a09ed09dfa0b6bff7c05fd7d1e4@chef.io>
diff --git a/spec/suby/downloader/addict7ed_spec.rb b/spec/suby/downloader/addict7ed_spec.rb index abc1234..def5678 100644 --- a/spec/suby/downloader/addict7ed_spec.rb +++ b/spec/suby/downloader/addict7ed_spec.rb @@ -1,12 +1,12 @@ require_relative '../../spec_helper' describe Suby::Downloader::Addic7ed do - file = Path('The Glee Project 01x03.avi') + file = Path('The Big Bang Theory 01x01.avi') downloader = Suby::Downloader::Addic7ed.new file it 'finds the right subtitles' do begin - downloader.subtitles[0..100].should include "Ellis, best first kiss?" + downloader.subtitles[0..100].should include "If a photon is directed through a plane" rescue Suby::NotFoundError => e if e.message == "download exceeded" pending e.message @@ -22,7 +22,7 @@ end it 'fails gently when there is no subtitles available' do - d = Suby::Downloader::Addic7ed.new(file, :es) - -> { p d.download_url }.should raise_error(Suby::NotFoundError, "no subtitles available") + d = Suby::Downloader::Addic7ed.new(file, :zh) + -> { p d.download_url.body }.should raise_error(Suby::NotFoundError, "no subtitles available") end end
Use another example for addic7ed
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 @@ -1,10 +1,10 @@ class CommentsController < ApplicationController expose(:campaign) expose(:game) - expose(:post) - expose(:comments) { post.comments } + expose(:subject) { subject_from_params } expose(:comment, attributes: :comment_params) before_action :authenticate_user! + before_action :add_subject, only: [:new, :edit, :create, :update] respond_to :html @@ -41,4 +41,16 @@ def comment_params params.require(:comment).permit(:content) end + + def subject_from_params + if params.key?(:post_id) + Post.find(params[:post_id]) + elsif params.key?(:idea_id) + Idea.find(params[:idea_id]) + end + end + + def add_subject + comment.subject = subject + end end
Use subject in comments controller
diff --git a/lib/brexit_checker/action.rb b/lib/brexit_checker/action.rb index abc1234..def5678 100644 --- a/lib/brexit_checker/action.rb +++ b/lib/brexit_checker/action.rb @@ -1,3 +1,5 @@+require "addressable/uri" + class BrexitChecker::Action include ActiveModel::Validations @@ -8,12 +10,14 @@ validates_presence_of :guidance_link_text, if: :guidance_url validates_numericality_of :priority, only_integer: true - attr_reader :id, :title, :consequence, :exception, :title_url, + attr_reader :id, :title, :consequence, :exception, :title_url, :title_path, :lead_time, :criteria, :audience, :guidance_link_text, - :guidance_url, :guidance_prompt, :priority + :guidance_url, :guidance_path, :guidance_prompt, :priority def initialize(attrs) attrs.each { |key, value| instance_variable_set("@#{key}", value) } + @title_path = path_from_url(title_url) if title_url + @guidance_path = path_from_url(guidance_url) if guidance_url validate! end @@ -29,4 +33,15 @@ @load_all = nil if Rails.env.development? @load_all ||= YAML.load_file(CONFIG_PATH)["actions"].map { |a| new(a) } end + +private + + def path_from_url(full_url) + url = Addressable::URI.parse(full_url) + if url.host == "www.gov.uk" + url.path + else + full_url + end + end end
Send path instead of full URL in ecommerce tracking This is so performance analysts can more easily compare data across different reports (as standard GOV.UK tracking/reports uses paths rather than full URLs)
diff --git a/app/controllers/products_controller.rb b/app/controllers/products_controller.rb index abc1234..def5678 100644 --- a/app/controllers/products_controller.rb +++ b/app/controllers/products_controller.rb @@ -39,6 +39,6 @@ private def product_params - params.require(:product).permit! + params.require(:product).permit(:code, :name, :purchase_price, :sales_price, :points, :product_type, :status, :request_id, :consultant_id, :sale_id) end end
Fix params.permit for Products Controller
diff --git a/lib/sastrawi/morphology/disambiguator/disambiguator_prefix_rule3.rb b/lib/sastrawi/morphology/disambiguator/disambiguator_prefix_rule3.rb index abc1234..def5678 100644 --- a/lib/sastrawi/morphology/disambiguator/disambiguator_prefix_rule3.rb +++ b/lib/sastrawi/morphology/disambiguator/disambiguator_prefix_rule3.rb @@ -0,0 +1,19 @@+module Sastrawi + module Morphology + module Disambiguator + class DisambiguatorPrefixRule3 + def disambiguate(word) + contains = /^ber([bcdfghjklmnpqrstvwxyz])([a-z])er([aiueo])(.*)$/.match(word) + + if contains + matches = contains.captures + + return if matches[0] == 'r' + + return matches[0] << matches[1] << 'er' << matches[2] << matches[3] + end + end + end + end + end +end
Add implementation of third rule of disambiguator prefix
diff --git a/app/models/virtual_machine_instance.rb b/app/models/virtual_machine_instance.rb index abc1234..def5678 100644 --- a/app/models/virtual_machine_instance.rb +++ b/app/models/virtual_machine_instance.rb @@ -1,8 +1,8 @@ class VirtualMachineInstance < ActiveRecord::Base belongs_to :benchmark_execution validates :benchmark_execution, presence: true - has_many :nominal_metric_observations - has_many :ordered_metric_observations + has_many :nominal_metric_observations, dependent: :destroy + has_many :ordered_metric_observations, dependent: :destroy def complete_benchmark(continue, success = true) if success
Fix missing dependent destroy behavior that prevented metric observations from deletion
diff --git a/app/presenters/field/file_presenter.rb b/app/presenters/field/file_presenter.rb index abc1234..def5678 100644 --- a/app/presenters/field/file_presenter.rb +++ b/app/presenters/field/file_presenter.rb @@ -6,7 +6,7 @@ def input(form, method, options={}) form.form_group(method, :label => { :text => label }) do - html = [existing_file(form)] + html = [existing_file(form) || unsaved_file] html << form.attachment_field(method, options.merge(:direct => true)) html.compact.join.html_safe end @@ -14,7 +14,12 @@ def value return nil unless attachment_present?(item) - info = [attachment_filename(item)] + file_info + end + + def file_info + return unless (name = attachment_filename(item)) + info = [name] info << number_to_human_size(attachment_size(item), :prefix => :si) info.join(", ") end @@ -26,4 +31,9 @@ form.check_box("remove_#{uuid}", :label => "Remove this file") ].join.html_safe end + + def unsaved_file + return unless (info = file_info) + content_tag(:p, info) + end end
Maintain uploaded file when validation fails
diff --git a/spec-tests/spec/localhost/tor_spec.rb b/spec-tests/spec/localhost/tor_spec.rb index abc1234..def5678 100644 --- a/spec-tests/spec/localhost/tor_spec.rb +++ b/spec-tests/spec/localhost/tor_spec.rb @@ -6,5 +6,10 @@ describe file('/etc/tor/torrc') do it { should be_file } - its(:content) { should match /SocksPort 0/ } + its(:content) { should contain 'ReachableAddresses *:80,*:8080,*:443,*:8443,*:9001,*:9030' } end + +describe command('service tor status') do + it { should return_exit_status 0 } +end +
Improve tor spect test slightly
diff --git a/spec/features/user_management_spec.rb b/spec/features/user_management_spec.rb index abc1234..def5678 100644 --- a/spec/features/user_management_spec.rb +++ b/spec/features/user_management_spec.rb @@ -0,0 +1,94 @@+require 'spec_helper' + +RSpec.feature "User management" do + let(:campus) { create(:campus) } + let(:user) { build(:user) } + before(:each) { campus } + + feature "create user" do + + context "With correct information" do + scenario "Creates a new User" do + visit "/signup" + + fill_in 'First name', with: user.first_name + fill_in 'Last name', with: user.last_name + fill_in 'Email', with: user.email + select campus.name, from: 'Campus' + fill_in 'Department', with: user.department + fill_in 'Password', with: user.password + fill_in 'Password confirmation', with: user.password_confirmation + click_button 'Create Account' + expect(page).to have_text("Thank you for signing up!") + end + end + + context "With incorrect information" do + scenario "Halts user creation, displays error explanations" do + visit "/signup" + + fill_in 'First name', with: '' + fill_in 'Last name', with: user.first_name + fill_in 'Email', with: user.email + select campus.name, from: 'Campus' + fill_in 'Department', with: user.department + fill_in 'Password', with: user.password + fill_in 'Password confirmation', with: user.password_confirmation + click_button 'Create Account' + expect(page).to have_css("#error_explanation", "prohibited this user from being saved:") + end + end + end + + feature "edit one's user profile" do + let(:user) { create(:user) } + context "while logged in" do + scenario "Edit user profile" do + visit "/login" + fill_in 'Email', with: user.email + fill_in 'Password', with: user.password + click_button 'Log In' + + visit "/profiles/#{user.id}/edit" + fill_in 'First name', with: "NewFirstName" + fill_in 'Last name', with: "NewLastName" + fill_in 'Email', with: "new_email@example.com" + click_button "Update Account" + expect(page).to have_css("h1","NewFirstName NewLastName") + end + end + context "while not logged in" do + scenario "Edit user profile" do + visit "/profiles/#{user.id}/edit" + expect(page).to have_text("Log In") + end + end + end + + feature "View user index" do + let(:admin) { create(:admin_user) } + let(:user) { create(:user) } + context "With correct authorization" do + scenario "User logs in and views Users index" do + visit "/login" + fill_in 'Email', with: admin.email + fill_in 'Password', with: admin.password + click_button 'Log In' + + visit "/users" + expect(page).to have_css("h1", "Users") + end + end + context "Without correct authorization" do + scenario "User logs in and views Users index" do + visit "/login" + fill_in 'Email', with: user.email + fill_in 'Password', with: user.password + click_button 'Log In' + + visit "/users" + expect(page).to_not have_text("Users") + end + end + end +end
Add User Management feature spec A first pass at a feature spec for user management tasks.