diff
stringlengths
65
26.7k
message
stringlengths
7
9.92k
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 @@ -5,6 +5,11 @@ before_filter :find_page before_filter :set_host + def index + @page.selected_comment = @page.comments.find_by_id(flash[:selected_comment]) + render :text => @page.render + end + def create comment = @page.comments.build(params[:comment]) comment.request = request @@ -13,15 +18,10 @@ ResponseCache.instance.clear CommentMailer.deliver_comment_notification(comment) if Radiant::Config['comments.notification'] == "true" - redirect_to "#{@page.url}comments/#{comment.id}#comment-#{comment.id}" + flash[:selected_comment] = comment.id + redirect_to "#{@page.url}comments#comment-#{comment.id}" rescue ActiveRecord::RecordInvalid - @page.request, @page.response = request, response @page.last_comment = comment - render :text => @page.render - end - - def show - @page.selected_comment = @page.comments.find(params[:id]) render :text => @page.render end
Hide unapproved comments from url guessers and/or spiders.
diff --git a/app/controllers/services_controller.rb b/app/controllers/services_controller.rb index abc1234..def5678 100644 --- a/app/controllers/services_controller.rb +++ b/app/controllers/services_controller.rb @@ -1,6 +1,7 @@ class ServicesController < ApplicationController include ApplicationHelper + before_filter :make_cachable, :except => [:request_country] def in_area map_height = (params[:height].to_i or MAP_HEIGHT) @@ -14,6 +15,8 @@ def request_country require 'open-uri' + expires_in 1.day, :public => true + response.headers['Vary'] = '*' gaze = MySociety::Config.get('GAZE_URL', '') if gaze != '' render :text => open("#{gaze}/gaze-rest?f=get_country_from_ip;ip=#{request.remote_ip}").read.strip
Add "Vary: *" header to request_country to prevent it being cached for all users by varnish.
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 @@ -7,14 +7,7 @@ if user session[:user_id] = user.id - - if session[:return_to] - return_to = session[:return_to] - session[:return_to] = nil - else - return_to = nil - end - + return_to = session.delete(:return_to) redirect_to(return_to || my_url, notice: 'Logged in.') else flash[:error] = 'Login failed.'
Use hash delete to shorten login return to logic.
diff --git a/lib/tasks/export_trade_db.rake b/lib/tasks/export_trade_db.rake index abc1234..def5678 100644 --- a/lib/tasks/export_trade_db.rake +++ b/lib/tasks/export_trade_db.rake @@ -0,0 +1,49 @@+require 'zip' +require 'fileutils' +namespace :export do + task :trade_db => :environment do + RECORDS_PER_FILE = 500000 + ntuples = RECORDS_PER_FILE + offset = 0 + i = 0 + dir = 'tmp/trade_db_files/' + FileUtils.mkdir_p dir + begin + while(ntuples == RECORDS_PER_FILE) do + i = i + 1 + query = Trade::ShipmentReportQueries.full_db_query(RECORDS_PER_FILE, offset) + results = ActiveRecord::Base.connection.execute query + ntuples = results.ntuples + columns = results.fields + columns.map do |column| + column.capitalize! + column.gsub! '_', ' ' + end + values = results.values + Rails.logger.info("Query executed returning #{ntuples} records!") + filename = "trade_db_#{i}.csv" + Rails.logger.info("Processing batch number #{i} in #{filename}.") + File.open("#{dir}#{filename}", 'w') do |file| + file.write columns.join(',') + values.each do |record| + file.write "\n" + file.write record.join(',') + end + end + offset = offset + RECORDS_PER_FILE + end + Rails.logger.info("Trade database completely exported!") + zipfile = 'tmp/trade_db_files/trade_db.zip' + Zip::File.open(zipfile, Zip::File::CREATE) do |zipfile| + (1..i).each do |index| + filename = "trade_db_#{index}.csv" + zipfile.add(filename, dir + filename) + end + end + rescue => e + Rails.logger.info("Export aborted!") + Rails.logger.info("Caught exception #{e}") + Rails.logger.info(e.message) + end + end +end
Add rake task to export the entire trade db in csv files and then zipped
diff --git a/lib/three_dee_cart/core_ext.rb b/lib/three_dee_cart/core_ext.rb index abc1234..def5678 100644 --- a/lib/three_dee_cart/core_ext.rb +++ b/lib/three_dee_cart/core_ext.rb @@ -1,13 +1,4 @@ class Hash - - def reverse_merge(other_hash = {}) - other_hash.each_pair do |k, v| - unless self.has_key?(k) - self[k] = v - end - end - self - end def deep_has_key?(key) self.has_key?(key) || any? {|k, v| v.deep_has_key?(key) if v.is_a? Hash} @@ -25,4 +16,4 @@ self.has_value?(value) || any? {|k,v| v.deep_has_value?(value) if v.is_a? Hash} end alias :deep_value? :deep_has_value? -end+end
Remove monkey patched method from Hash
diff --git a/lib/weak_headers/controller.rb b/lib/weak_headers/controller.rb index abc1234..def5678 100644 --- a/lib/weak_headers/controller.rb +++ b/lib/weak_headers/controller.rb @@ -4,7 +4,7 @@ filter_options = {} filter_options.merge!(only: args.flatten) unless args.empty? - before_filter filter_options do + before_action filter_options do validator = WeakHeaders::Validator.new(self, &block) WeakHeaders.stats[params[:controller]][params[:action]] = validator WeakHeaders.stats[params[:controller]][params[:action]].validate
Use before_action instead of before_filter DEPRECATION WARNING: before_filter is deprecated and will be removed in Rails 5.1
diff --git a/lib/workflowmgr/cycleformat.rb b/lib/workflowmgr/cycleformat.rb index abc1234..def5678 100644 --- a/lib/workflowmgr/cycleformat.rb +++ b/lib/workflowmgr/cycleformat.rb @@ -0,0 +1,40 @@+########################################## +# +# Module WorkflowMgr +# +########################################## +module WorkflowMgr + + ########################################## + # + # Class CycleFormat + # + ########################################## + class CycleFormat + + ##################################################### + # + # initialize + # + ##################################################### + def initialize(format,offset) + + @format=format + @offset=offset + + end + + ##################################################### + # + # to_s + # + ##################################################### + def to_s(cycle) + + return (cycle.gmtime+@offset).strftime(@format) + + end + + end + +end
Add new class to represent dynamic strings whose values are evaluated based on the provided cycle time.
diff --git a/app/admin/report.rb b/app/admin/report.rb index abc1234..def5678 100644 --- a/app/admin/report.rb +++ b/app/admin/report.rb @@ -15,7 +15,8 @@ index do selectable_column id_column - column 'Picture', sortable: :image_file_name do |report| link_to report.picture.name, report.image.url end + column 'Picture', sortable: :picture_file_name do |report| link_to report.picture.name, report.picture.url end + column :picture_file_size, sortable: :picture_file_size do |firmware| "#{firmware.picture_file_size / 1024} KB" end column :created_at actions end
Replace all apparitions of image with picture.
diff --git a/app/app_delegate.rb b/app/app_delegate.rb index abc1234..def5678 100644 --- a/app/app_delegate.rb +++ b/app/app_delegate.rb @@ -1,5 +1,5 @@ class AppDelegate - attr_accessor :van_hoorden_sounds, :miller_and_heise_sounds, :window + attr_accessor :van_hoorden_sounds, :miller_and_heise_sounds, :window, :subject def application(application, didFinishLaunchingWithOptions:launchOptions) self.window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
Add subject field to app delegate
diff --git a/half-pipe.gemspec b/half-pipe.gemspec index abc1234..def5678 100644 --- a/half-pipe.gemspec +++ b/half-pipe.gemspec @@ -16,4 +16,6 @@ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) } gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) gem.require_paths = ["lib"] + + gem.add_dependency "rack-asset-compiler" end
Add asset compiler as gem dependency
diff --git a/qa/qa/specs/features/browser_ui/3_create/repository/protocol_v2_push_http_spec.rb b/qa/qa/specs/features/browser_ui/3_create/repository/protocol_v2_push_http_spec.rb index abc1234..def5678 100644 --- a/qa/qa/specs/features/browser_ui/3_create/repository/protocol_v2_push_http_spec.rb +++ b/qa/qa/specs/features/browser_ui/3_create/repository/protocol_v2_push_http_spec.rb @@ -0,0 +1,49 @@+# frozen_string_literal: true + +module QA + context 'Create' do + describe 'Push over HTTP using Git protocol version 2', :requires_git_protocol_v2 do + it 'user pushes to the repository' do + Runtime::Browser.visit(:gitlab, Page::Main::Login) + Page::Main::Login.perform(&:sign_in_using_credentials) + + # Create a project to push to + project = Resource::Project.fabricate! do |project| + project.name = 'git-protocol-project' + end + + file_name = 'README.md' + file_content = 'Test Git protocol v2' + git_protocol = '2' + git_protocol_reported = nil + + # Use Git to clone the project, push a file to it, and then check the + # supported Git protocol + Git::Repository.perform do |repository| + username = 'GitLab QA' + email = 'root@gitlab.com' + + repository.uri = project.repository_http_location.uri + repository.use_default_credentials + repository.clone + repository.configure_identity(username, email) + + git_protocol_reported = repository.push_with_git_protocol( + git_protocol, + file_name, + file_content) + end + + project.visit! + Page::Project::Show.perform(&:wait_for_push) + + # Check that the push worked + expect(page).to have_content(file_name) + expect(page).to have_content(file_content) + + # And check that the correct Git protocol was used + expect(git_protocol_reported).to eq(git_protocol) + end + end + end +end
Add e2e test of push via HTTP via Git protocol v2 Adds a new end-to-end test to check that Git protocol v2 can be used to push over HTTP
diff --git a/lib/pod/command/package.rb b/lib/pod/command/package.rb index abc1234..def5678 100644 --- a/lib/pod/command/package.rb +++ b/lib/pod/command/package.rb @@ -6,6 +6,8 @@ def initialize(argv) @name = argv.shift_argument + @spec = spec_with_path(@name) + @spec = spec_with_name(@name) unless @spec super end @@ -15,10 +17,7 @@ end def run - spec = spec_with_path(@name) - spec = spec_with_name(@name) unless spec - - if spec + if @spec # TODO perform the magic! else help! "Unable to find a podspec with path or name."
Make it actually run without errors. Now the magic can be implemented :)
diff --git a/AHKNavigationController.podspec b/AHKNavigationController.podspec index abc1234..def5678 100644 --- a/AHKNavigationController.podspec +++ b/AHKNavigationController.podspec @@ -3,7 +3,7 @@ s.version = "0.1.1" s.summary = "A UINavigationController replacement allowing interactive pop gesture when the navigation bar is hidden or a custom back button is used." - s.homepage = "http://holko.pl/ios/2014/04/06/interactive-pop-gesture/" + s.homepage = "https://github.com/fastred/AHKNavigationController" s.license = { :type => "MIT", :file => "LICENSE" } s.authors = { "Arkadiusz Holko" => "fastred@fastred.org" }
Change the homepage in the Podfile to github
diff --git a/lib/opskit/vhost.rb b/lib/opskit/vhost.rb index abc1234..def5678 100644 --- a/lib/opskit/vhost.rb +++ b/lib/opskit/vhost.rb @@ -1,6 +1,8 @@ module OpsKit class VHost PROVIDERS = [:apache, :nginx] + + attr_reader :provider, :conf def initialize( provider = nil, conf = {} ) @provider = provider
Add getters for VHost instance variables
diff --git a/lib/speedcounter.rb b/lib/speedcounter.rb index abc1234..def5678 100644 --- a/lib/speedcounter.rb +++ b/lib/speedcounter.rb @@ -2,7 +2,7 @@ def initialize(window, player) @window, @player = window, player - @speed_text = Gosu::Font.new(@window, 'media/poke.ttf', 16) + @speed_text = Gosu::Font.new(@window, 'media/poke.ttf', 18) end def update
Update position text to 18px high
diff --git a/config/initializers/active_record_data_types.rb b/config/initializers/active_record_data_types.rb index abc1234..def5678 100644 --- a/config/initializers/active_record_data_types.rb +++ b/config/initializers/active_record_data_types.rb @@ -4,12 +4,43 @@ if Gitlab::Database.postgresql? require 'active_record/connection_adapters/postgresql_adapter' - module ActiveRecord - module ConnectionAdapters - class PostgreSQLAdapter - NATIVE_DATABASE_TYPES.merge!(datetime_with_timezone: { name: 'timestamptz' }) + module ActiveRecord::ConnectionAdapters::PostgreSQL::OID + # Add the class `DateTimeWithTimeZone` so we can map `timestamptz` to it. + class DateTimeWithTimeZone < DateTime + def type + :datetime_with_timezone end end + end + + module RegisterDateTimeWithTimeZone + # Run original `initialize_type_map` and then register `timestamptz` as a + # `DateTimeWithTimeZone`. + # + # Apparently it does not matter that the original `initialize_type_map` + # aliases `timestamptz` to `timestamp`. + # + # When schema dumping, `timestamptz` columns will be output as + # `t.datetime_with_timezone`. + def initialize_type_map(mapping) + super mapping + + mapping.register_type 'timestamptz' do |_, _, sql_type| + precision = extract_precision(sql_type) + ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::OID::DateTimeWithTimeZone.new(precision: precision) + end + end + end + + class ActiveRecord::ConnectionAdapters::PostgreSQLAdapter + prepend RegisterDateTimeWithTimeZone + + # Add column type `datetime_with_timezone` so we can do this in + # migrations: + # + # add_column(:users, :datetime_with_timezone) + # + NATIVE_DATABASE_TYPES[:datetime_with_timezone] = { name: 'timestamptz' } end elsif Gitlab::Database.mysql? require 'active_record/connection_adapters/mysql2_adapter' @@ -17,7 +48,7 @@ module ActiveRecord module ConnectionAdapters class AbstractMysqlAdapter - NATIVE_DATABASE_TYPES.merge!(datetime_with_timezone: { name: 'timestamp' }) + NATIVE_DATABASE_TYPES[:datetime_with_timezone] = { name: 'timestamp' } end end end
Fix PostgreSQL schema dump for `timestamptz`
diff --git a/lib/tasks/application.rake b/lib/tasks/application.rake index abc1234..def5678 100644 --- a/lib/tasks/application.rake +++ b/lib/tasks/application.rake @@ -10,3 +10,32 @@ CampaignFinisherWorker.perform_async(project.id) end end + +desc 'Import data from YAML file for new users/projects/rewards' +task :import_projects, [:file_url] => :environment do |t, args| + require 'open-uri' + file_url = args.file_url + file = open(file_url).read + raw_data = Psych.load(file) + + raw_data.each do |element| + user = User.new(element[:issuer]) + user.autogenerated = true + user.save(validate: false) + + parse_date = ->(string) { string.present? and Date.strptime(string, '%m/%d/%Y') } + + element[:issue][:sale_date] = parse_date.call(element[:issue][:sale_date]) + element[:issue][:rewards_attributes].each do |reward_attributes| + reward_attributes[:happens_at] = parse_date.call(reward_attributes[:happens_at]) + end + if element[:issue][:name].present? + project = Project.new(element[:issue]) + project.user_id = user.id + project.state = :draft + project.goal ||= 0 + project.generate_permalink! + project.save(validate: false) + end + end +end
Create rake task to import users/projects/rewards
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 @@ -35,9 +35,9 @@ \[\[ (?<link> # ([% title-legal-chars])+ - [%!"$&'()*,\-.\/0-9:;=?@A-Z\\^_`a-z~\u0080-\uFFFF+]+ + [%\ !"$&'()*,\-.\/0-9:;=?@A-Z\\^_`a-z~\u0080-\uFFFF+]+ # ("#" [# % title-legal-chars]+)? - (\#[\#%!"$&'()*,\-.\/0-9:;=?@A-Z\\^_`a-z~\u0080-\uFFFF+]+)? + ( \# [\#%\ !"$&'()*,\-.\/0-9:;=?@A-Z\\^_`a-z~\u0080-\uFFFF+]+ )? ) ( # "|" LEGAL_ARTICLE_ENTITY*
Fix a_link regex would not accept spaces in links
diff --git a/app/models/email.rb b/app/models/email.rb index abc1234..def5678 100644 --- a/app/models/email.rb +++ b/app/models/email.rb @@ -1,11 +1,6 @@ class Email include HTTParty - - APIKEY = Setting.get(:email, :mailgunapikey) - - base_uri 'https://api.mailgun.net/v2' - basic_auth 'api', APIKEY def self.show_routes(skip: 0, limit: 1) self.get("/routes", params: {skip: skip, limit: limit}) @@ -20,7 +15,8 @@ end end if match.empty? - self.post("https://api:#{APIKEY}@api.mailgun.net/v2/routes", body: self.build_data) + key = Setting.get(:email, :mailgunapikey) + self.post("https://api:#{key}@api.mailgun.net/v2/routes", body: self.build_data) else {"message"=>"Route found."} end
Move Mailgun apikey out of class def. Fixes bug running tests some times.
diff --git a/app/helpers/versions_helper.rb b/app/helpers/versions_helper.rb index abc1234..def5678 100644 --- a/app/helpers/versions_helper.rb +++ b/app/helpers/versions_helper.rb @@ -11,6 +11,8 @@ 'Switched mapping to a Redirect' when 'archive' 'Switched mapping to an Archive' + when 'unresolved' + 'Switched mapping to Unresolved' else 'Switched mapping type' end
Add a specific message for changing a mapping type to unresolved
diff --git a/app/helpers/writable_helper.rb b/app/helpers/writable_helper.rb index abc1234..def5678 100644 --- a/app/helpers/writable_helper.rb +++ b/app/helpers/writable_helper.rb @@ -9,6 +9,6 @@ @post end return (@unread_warning = false) unless unread_reply - @unread_warning = content_tag :a, 'Post has unread replies', href: post_or_reply_link(unread_reply), class: 'unread-warning' + @unread_warning = content_tag :a, 'Post has unread replies', href: post_or_reply_link(unread_reply), class: 'unread-warning', target: '_blank' end end
Make the 'unread replies' link of the reply editor have target=_blank
diff --git a/libraries/helper.rb b/libraries/helper.rb index abc1234..def5678 100644 --- a/libraries/helper.rb +++ b/libraries/helper.rb @@ -19,7 +19,9 @@ # limitations under the License. # -require 'chef/win32/version' +if RUBY_PLATFORM =~ /mswin|mingw32|windows/ + require 'chef/win32/version' +end module Opscode::IIS class Helper @@ -35,4 +37,4 @@ win_version.windows_2000? end end -end+end
[COOK-4138] Check for RUBY_VERSION of Windows before attempting to require chef/win32/version.
diff --git a/db/migrate/20090316132151_disable_file_types.rb b/db/migrate/20090316132151_disable_file_types.rb index abc1234..def5678 100644 --- a/db/migrate/20090316132151_disable_file_types.rb +++ b/db/migrate/20090316132151_disable_file_types.rb @@ -3,7 +3,7 @@ Radiant::Config['assets.skip_filetype_validation'] = true puts "-- Setting default content types in Radiant::Config" if defined? SettingsExtension && Radiant::Config.column_names.include?('description') - Config.find(:all).each do |c| + Radiant::Config.find(:all).each do |c| description = case c.key when 'assets.skip_filetype_validations' 'When set to true, disables the filetype validations. Set to false to enable them.'
Fix migration by prefixing the Config module with Radiant Signed-off-by: Keith BIngman <keith@keithbingman.com> Signed-off-by: Aissac SRL <ef29f82a68bbcac28aaf4f4f019e2bfc7b150e76@aissac.ro>
diff --git a/db/migrate/20130621223337_create_flash_sales.rb b/db/migrate/20130621223337_create_flash_sales.rb index abc1234..def5678 100644 --- a/db/migrate/20130621223337_create_flash_sales.rb +++ b/db/migrate/20130621223337_create_flash_sales.rb @@ -4,7 +4,7 @@ t.string :name t.datetime :start_date t.datetime :end_date - t.boolean :active, default: false + t.boolean :active t.string :permalink t.belongs_to :saleable, polymorphic: true
Revert "make default value false" This reverts commit 366a8ba9c3a527e67a26b7d7068a9cc844297d16.
diff --git a/loudspeaker.podspec b/loudspeaker.podspec index abc1234..def5678 100644 --- a/loudspeaker.podspec +++ b/loudspeaker.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "loudspeaker" - s.version = "0.1.11" + s.version = "0.2.0" s.summary = "An AVQueuePlayer-backed audio player with a modern, minimal UI" s.description = <<-DESC An audio player with a modern, minimal UI. Powered by AVQueuePlayer.
Bump podspec to 0.2.0 after dropping iOS 7
diff --git a/spec/i18n/locale_name_spec.rb b/spec/i18n/locale_name_spec.rb index abc1234..def5678 100644 --- a/spec/i18n/locale_name_spec.rb +++ b/spec/i18n/locale_name_spec.rb @@ -10,9 +10,21 @@ end it "all entries in human_locale_names.yml are valid" do - YAML.load_file(Rails.root.join('config/human_locale_names.yaml'))['human_locale_names'].each do |locale_name, human_locale_name| + YAML.load_file(Rails.root.join('config', 'human_locale_names.yaml'))['human_locale_names'].each do |locale_name, human_locale_name| expect(human_locale_name).not_to be_empty expect(human_locale_name).not_to eq(locale_name) end end + + it "all languages have properly set human_locale_name" do + human_locale_names = YAML.load_file(Rails.root.join('config', 'human_locale_names.yaml'))['human_locale_names'] + locales = Vmdb::FastGettextHelper.find_available_locales + + expect(human_locale_names.keys.sort).to eq(locales.sort) + + locales.each do |locale| + expect(human_locale_names[locale]).not_to be_empty + expect(human_locale_names[locale]).not_to eq(locale) + end + end end
Test that all locales have properly set human locale name
diff --git a/db/migrate/20171024074942_convert_autograded_text_response_answers_to_plaintext.rb b/db/migrate/20171024074942_convert_autograded_text_response_answers_to_plaintext.rb index abc1234..def5678 100644 --- a/db/migrate/20171024074942_convert_autograded_text_response_answers_to_plaintext.rb +++ b/db/migrate/20171024074942_convert_autograded_text_response_answers_to_plaintext.rb @@ -0,0 +1,23 @@+class ConvertAutogradedTextResponseAnswersToPlaintext < ActiveRecord::Migration[5.0] + # For autograded text response questions, a plaintext textarea input box is shown instead of + # the rich text editor. + # + # Convert existing answers to autograded questions from HTML to plaintext. + def up + auto_gradable_tr_question_ids = Course::Assessment::Question::TextResponse.includes(:solutions). + select(&:auto_gradable?).map(&:acting_as).map(&:id) + + Course::Assessment::Answer.where(question_id: auto_gradable_tr_question_ids).includes(:actable). + find_each do |ans| + answer_text = ans.actable.answer_text + next if answer_text.empty? + sanitized_answer = Sanitize.fragment(answer_text).strip.encode(universal_newline: true) + ans.actable.update_column(:answer_text, sanitized_answer) + end + end + + # Formatting can't be restored. + def down + raise ActiveRecord::IrreversibleMigration + end +end
Convert answers for autograded text response questions to plaintext. Raise error on rollback as the formatting can't be restored. Previously stored as HTML due to richtext input.
diff --git a/spec/integration/renalware/api/ukrdc/patients_spec.rb b/spec/integration/renalware/api/ukrdc/patients_spec.rb index abc1234..def5678 100644 --- a/spec/integration/renalware/api/ukrdc/patients_spec.rb +++ b/spec/integration/renalware/api/ukrdc/patients_spec.rb @@ -10,6 +10,7 @@ describe "GET #show" do it "renders the correct UK RDC XML" do + pending ethnicity = create(:ethnicity) patient = create(:patient, ethnicity: ethnicity)
Mark ukrdc spec as pending for now
diff --git a/AFMobilePayRequestHandler.podspec b/AFMobilePayRequestHandler.podspec index abc1234..def5678 100644 --- a/AFMobilePayRequestHandler.podspec +++ b/AFMobilePayRequestHandler.podspec @@ -6,7 +6,7 @@ s.license = 'MIT' s.author = { 'Anders Fogh Eriksen' => 'andfogh@gmail.com' } s.source = { :git => 'https://github.com/Fogh/AFMobilePayRequestHandler.git', :tag => s.version.to_s } - s.platform = :ios, '6.1' + s.platform = :ios, '7.0' s.source_files = 'AFMobilePayRequestHandler/*.{h,m}' s.requires_arc = true s.social_media_url = 'https://twitter.com/f0gh'
Update platform version to 7.0
diff --git a/Library/Homebrew/tap_migrations.rb b/Library/Homebrew/tap_migrations.rb index abc1234..def5678 100644 --- a/Library/Homebrew/tap_migrations.rb +++ b/Library/Homebrew/tap_migrations.rb @@ -19,4 +19,5 @@ 'nlopt' => 'homebrew/science', 'comparepdf' => 'homebrew/boneyard', 'colormake' => 'homebrew/headonly', + 'wkhtmltopdf' => 'homebrew/boneyard', }
Move wkhtmltopdf to the boneyard Closes Homebrew/homebrew#26813.
diff --git a/resources/ingredient_config.rb b/resources/ingredient_config.rb index abc1234..def5678 100644 --- a/resources/ingredient_config.rb +++ b/resources/ingredient_config.rb @@ -21,7 +21,6 @@ provides :ingredient_config property :product_name, String, name_property: true -property :sensitive, [TrueClass, FalseClass], default: false property :config, [String, NilClass] action :render do
Remove sensitive property for Chef 13 compatibility This is provided by chef-client on all resources now. Including it here breaks runs on Chef 13 Signed-off-by: Tim Smith <764ef62106582a09ed09dfa0b6bff7c05fd7d1e4@chef.io>
diff --git a/test/schema_test.rb b/test/schema_test.rb index abc1234..def5678 100644 --- a/test/schema_test.rb +++ b/test/schema_test.rb @@ -0,0 +1,69 @@+ +require 'test/helper' +require 'ostruct' + +class MockSchema + include Paperclip::Schema + + def initialize(table_name = nil) + @table_name = table_name + @columns = {} + end + + def column(name, type) + @columns[name] = type + end + + def remove_column(table_name, column_name) + @columns.delete(column_name) + end + + def has_column?(column_name) + @columns.key?(column_name) + end + + def type_of(column_name) + @columns[column_name] + end +end + +class SchemaTest < Test::Unit::TestCase + context "Migrating up" do + setup do + @schema = MockSchema.new + @schema.has_attached_file :avatar + end + + should "create the file_name column" do + assert @schema.has_column?(:avatar_file_name) + end + + should "create the content_type column" do + assert @schema.has_column?(:avatar_content_type) + end + + should "create the file_size column" do + assert @schema.has_column?(:avatar_file_size) + end + + should "create the updated_at column" do + assert @schema.has_column?(:avatar_updated_at) + end + + should "make the file_name column a string" do + assert_equal :string, @schema.type_of(:avatar_file_name) + end + + should "make the content_type column a string" do + assert_equal :string, @schema.type_of(:avatar_content_type) + end + + should "make the file_size column an integer" do + assert_equal :integer, @schema.type_of(:avatar_file_size) + end + + should "make the updated_at column a datetime" do + assert_equal :datetime, @schema.type_of(:avatar_updated_at) + end + end +end
Add a proper test suite of the schema helper
diff --git a/test/test_helper.rb b/test/test_helper.rb index abc1234..def5678 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -3,13 +3,14 @@ require "minitest/autorun" require "minitest/reporters" -require "mocha" +require "mocha/setup" require "support/fake_environment" require "support/captain_hook" MiniTest::Unit.runner = MiniTest::SuiteRunner.new -MiniTest::Unit.runner.reporters << MiniTest::Reporters::SpecReporter.new +MiniTest::Unit.runner.reporters << MiniTest::Reporters::DefaultReporter.new +#MiniTest::Unit.runner.reporters << MiniTest::Reporters::SpecReporter.new MiniTest::Unit.runner.reporters << HttpMonkey::Support::CaptainHook.new require "minion_server"
Fix mocha warning and change to default report
diff --git a/test/test_helper.rb b/test/test_helper.rb index abc1234..def5678 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,9 +1,6 @@ require 'rubygems' require 'bundler/setup' require 'mock_redis' -require 'mock_redis/version' require 'minitest/autorun' require 'redis-breadcrumbs' - -puts "mock_redis: #{MockRedis::VERSION}"
Remove dumping of mock redis version
diff --git a/app/helpers/relations_helper.rb b/app/helpers/relations_helper.rb index abc1234..def5678 100644 --- a/app/helpers/relations_helper.rb +++ b/app/helpers/relations_helper.rb @@ -1,14 +1,7 @@ module RelationsHelper def format_date_for(relation) - if relation.from == relation.to - return "#{relation.from}" - elsif relation.from.nil? - return "… - #{relation.to}" - elsif relation.to.nil? - return "#{relation.from} - …" - else - return "#{relation.from} - #{relation.to}" - end + return relation.at if relation.transient? + "#{relation.from || '…'} - #{relation.to || '…'}" end end
Simplify formatter helper for relation dates
diff --git a/admin/test/integration/api_test.rb b/admin/test/integration/api_test.rb index abc1234..def5678 100644 --- a/admin/test/integration/api_test.rb +++ b/admin/test/integration/api_test.rb @@ -2,20 +2,6 @@ class ApiTest < ActionDispatch::IntegrationTest setup do - @coupons = "{\"coupons\":" + - "[{\"title\":\"Dummy Coupon 1\"," + - "\"description\":\"This is the dummy coupons\\ndescription!\"," + - "\"id\":\"2\"," + - "\"modified\":\"1311495190384\"," + - "\"created\":\"1311499999999\"" + - "}" + - ",{\"title\":\"Dummy Coupon 2\"," + - "\"description\":\"This is the dummy coupons\\ndescription 2!\"," + - "\"id\":\"3\"," + - "\"modified\":\"1311495190384\"," + - "\"created\":\"1311999999999\"" + - "}]" + - "}" @api = "http://localhost:3002/backend/coupons" @pubkey = "sdflkj3209ikldjf23kljsd" end @@ -33,8 +19,10 @@ body = JSON.parse(result.body) result = body["coupons"] - assert body["pubkey"].eql?(@pubkey) - result = "{\"coupons\":#{result.to_json}}" - assert result.eql?(@coupons) + #assert body["pubkey"].eql?(@pubkey) + #result = "{\"coupons\":#{result.to_json}}" + + assert result.first["title"].length > 0 + assert result.first["id"].class.eql?(Fixnum) end end
Fix api test in admin
diff --git a/vtd-xml.gemspec b/vtd-xml.gemspec index abc1234..def5678 100644 --- a/vtd-xml.gemspec +++ b/vtd-xml.gemspec @@ -21,4 +21,5 @@ gem.require_paths = ['lib'] gem.add_development_dependency 'rake' + gem.add_development_dependency 'rspec' end
Add Rspec as a development dependency
diff --git a/les_04/station.rb b/les_04/station.rb index abc1234..def5678 100644 --- a/les_04/station.rb +++ b/les_04/station.rb @@ -33,6 +33,6 @@ end def trains_by_type(type) - self.trains.select.count { |train| train.type if train.type == type} + self.trains.select { |train| train.type if train.type == type }.count end end
Fix 'trains by type' counter
diff --git a/omnibus-ctl.gemspec b/omnibus-ctl.gemspec index abc1234..def5678 100644 --- a/omnibus-ctl.gemspec +++ b/omnibus-ctl.gemspec @@ -13,7 +13,7 @@ s.required_ruby_version = ">= 2.6" - s.add_development_dependency "chefstyle", "2.1.0" + s.add_development_dependency "chefstyle", "2.1.1" s.add_development_dependency "rake" s.add_development_dependency "rspec", "~> 3.2" s.add_development_dependency "rspec_junit_formatter"
Update chefstyle requirement from = 2.1.0 to = 2.1.1 Updates the requirements on [chefstyle](https://github.com/chef/chefstyle) to permit the latest version. - [Release notes](https://github.com/chef/chefstyle/releases) - [Changelog](https://github.com/chef/chefstyle/blob/main/CHANGELOG.md) - [Commits](https://github.com/chef/chefstyle/compare/v2.1.0...v2.1.1) --- updated-dependencies: - dependency-name: chefstyle dependency-type: direct:development ... Signed-off-by: dependabot[bot] <5bdcd3c0d4d24ae3e71b3b452a024c6324c7e4bb@github.com>
diff --git a/createDB.rb b/createDB.rb index abc1234..def5678 100644 --- a/createDB.rb +++ b/createDB.rb @@ -1,5 +1,26 @@ #!/usr/bin/env ruby -w require "sqlite3" + +# Open a database +db = SQLite3::Database.new "sqlite3.db" + +# Drop old tables +rows = db.execute <<-SQL + DROP TABLE IF EXISTS user; +SQL + +rows = db.execute <<-SQL + DROP TABLE IF EXISTS processor; +SQL + +rows = db.execute <<-SQL + DROP TABLE IF EXISTS pmt_interval; +SQL + +rows = db.execute <<-SQL + DROP TABLE IF EXISTS subscription; +SQL + # Create new tables rows = db.execute <<-SQL @@ -26,6 +47,7 @@ SQL rows = db.execute <<-SQL + CREATE TABLE subscription ( id INTEGER PRIMARY KEY AUTOINCREMENT, user_id int, processor_id int,
Drop old tables for multiple executions Drop old data, each run makes a new DB.
diff --git a/test/all_basic.rb b/test/all_basic.rb index abc1234..def5678 100644 --- a/test/all_basic.rb +++ b/test/all_basic.rb @@ -31,6 +31,7 @@ require 'Image_attributes.rb' require 'Import_Export.rb' require 'Pixel.rb' +require 'Preview.rb' require 'Info.rb' require 'Magick.rb' require 'Draw.rb'
Add Preview_UT.rb to the standard list of tests
diff --git a/lib/convection/model/template/resource_group.rb b/lib/convection/model/template/resource_group.rb index abc1234..def5678 100644 --- a/lib/convection/model/template/resource_group.rb +++ b/lib/convection/model/template/resource_group.rb @@ -12,8 +12,6 @@ include DSL::Template::Resource include Mixin::Conditional - attr_reader :attributes - attr_reader :name attr_reader :parent attr_reader :template @@ -21,7 +19,6 @@ def_delegator :@template, :stack def initialize(name, parent, &definition) - @attributes = Model::Attributes.new @definition = definition @name = name @parent = parent
Remove the :attributes from ResourceGroup Users can define attributes inside of resource groups using the attribute helper method.
diff --git a/lib/gir_ffi/builders/registered_type_builder.rb b/lib/gir_ffi/builders/registered_type_builder.rb index abc1234..def5678 100644 --- a/lib/gir_ffi/builders/registered_type_builder.rb +++ b/lib/gir_ffi/builders/registered_type_builder.rb @@ -14,15 +14,19 @@ end # TODO: Rename the created method, or use a constant. - # FIXME: Only used in some of the subclases. Make mixin? def setup_gtype_getter gtype = target_gtype return if gtype.nil? klass.instance_eval " def self.get_gtype - #{gtype} + self::G_TYPE end " + end + + def setup_constants + klass.const_set :G_TYPE, target_gtype + super end # FIXME: Only used in some of the subclases. Make mixin?
Store gtype of generated classes in a constant
diff --git a/teamocil.gemspec b/teamocil.gemspec index abc1234..def5678 100644 --- a/teamocil.gemspec +++ b/teamocil.gemspec @@ -7,7 +7,7 @@ s.homepage = "http://github.com/remiprev/teamocil" s.summary = "Easy window and split layouts for tmux" s.description = "Teamocil helps you set up window and splits layouts for tmux using YAML configuration files." - s.files = Dir["lib/**/*.rb", "README.mkd", "LICENSE", "bin/*", "spec/**/*.rb"] + s.files = Dir["lib/**/*.rb", "README.md", "LICENSE", "bin/*", "spec/**/*.rb"] s.require_path = "lib" s.executables << "teamocil"
Fix typo in gemspec file
diff --git a/lib/vagrant_syllabus_provisioner/provisioner.rb b/lib/vagrant_syllabus_provisioner/provisioner.rb index abc1234..def5678 100644 --- a/lib/vagrant_syllabus_provisioner/provisioner.rb +++ b/lib/vagrant_syllabus_provisioner/provisioner.rb @@ -7,10 +7,6 @@ def error_message "Execution failed. Abort." end - end - - def finalize! - p config end def provision
Remove unnecessary method from Provisioner.
diff --git a/app/controllers/logs_controller.rb b/app/controllers/logs_controller.rb index abc1234..def5678 100644 --- a/app/controllers/logs_controller.rb +++ b/app/controllers/logs_controller.rb @@ -1,13 +1,10 @@ class LogsController < ApplicationController + before_action :setup_variables, only: [:new, :create] + def new - @project = Project.find(params[:project_id]) - @log = Log.new(worked_at: Time.zone.today) end def create - @project = Project.find(params[:project_id]) - @log = Log.new(log_params) - if @log.save track_log_creation(@log.decorate) flash[:notice] = "Logged #{@log.decorate.summary}" @@ -42,4 +39,11 @@ project_name: log.project.name, project_id: log.project.id) end + private "track_log_creation" + + def setup_variables + @project = Project.find(params[:project_id]) if params[:project_id] + @log = params[:log] ? Log.new(log_params) : Log.new(worked_at: Time.zone.today) + end + private "setup_variables" end
Reduce complexity of the create method
diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb index abc1234..def5678 100644 --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -1,7 +1,7 @@ class MainController < ApplicationController def index @components = Component.all.is_approved.by_age.reverse - @prompt = Prompt.last + @prompt = Prompt.last || Prompt.create(content: "What is a fun date idea?") end end
Add a default Prompt in order to not break the database if there aren't any prompts
diff --git a/app/jobs/extract_github_profile.rb b/app/jobs/extract_github_profile.rb index abc1234..def5678 100644 --- a/app/jobs/extract_github_profile.rb +++ b/app/jobs/extract_github_profile.rb @@ -5,7 +5,7 @@ def perform(id) client = Octokit::Client.new - if ENV['TRAVIS'].blank? || client.ratelimit[:remaining] < 1000 + if ENV['TRAVIS'].blank? && client.ratelimit[:remaining] < 1000 # If we have less than 1000 request remaining, delay this job # We leaving 1000 for more critical tasks retry_at = client.ratelimit[:resets_at] + rand(id)
[Fix] Fix profile job for travis
diff --git a/app/models/concerns/redcarpeted.rb b/app/models/concerns/redcarpeted.rb index abc1234..def5678 100644 --- a/app/models/concerns/redcarpeted.rb +++ b/app/models/concerns/redcarpeted.rb @@ -1,21 +1,48 @@ module Redcarpeted extend ActiveSupport::Concern - - class HTMLRenderer < Redcarpet::Render::HTML - include Redcarpet::Render::SmartyPants - end module ClassMethods def redcarpet(field) define_method :to_html do - extensions = { - no_intra_emphasis: true, - space_after_headers: true, - strikethrough: true - } - - Redcarpet::Markdown.new(HTMLRenderer, extensions).render(read_attribute(field)) + Redcarpeted::MarkupBuilder.new(read_attribute(field)).render end end end + + class HTMLRenderer < Redcarpet::Render::SmartyHTML + def preprocess(full_document) + full_document.gsub(/(?:\n|\A)={3,}(?:\s\[(?<precaption>.*)\])?\r?\n(?<content>.*)?\r?\n={3,}(?:\s\[(?<postcaption>.*)\])?\r?\n/m) do + "<figure> + #{render_caption($~[:precaption]) if $~[:precaption]} + #{Redcarpeted::MarkupBuilder.new($~[:content].chomp).render} + #{render_caption($~[:postcaption]) if $~[:postcaption]} + </figure>" + end + end + + private + + def render_caption(markdown) + "<figcaption>#{Redcarpeted::MarkupBuilder.new(markdown).render}</figcaption>" + end + end + + class MarkupBuilder + def initialize(markdown) + @markdown = markdown + end + + def extensions + { + fenced_code_blocks: true, + no_intra_emphasis: true, + space_after_headers: true, + strikethrough: true + } + end + + def render + Redcarpet::Markdown.new(Redcarpeted::HTMLRenderer, extensions).render(@markdown) + end + end end
Refactor Redcarpeted concern, adds support for custom Markdown for <figure> element.
diff --git a/pdf_ravager.gemspec b/pdf_ravager.gemspec index abc1234..def5678 100644 --- a/pdf_ravager.gemspec +++ b/pdf_ravager.gemspec @@ -10,7 +10,6 @@ s.summary = %q{DSL to aid filling out AcroForms PDF and XFA documents} s.description = %q{DSL to aid filling out AcroForms PDF and XFA documents} s.license = 'MIT' - s.platform = 'java' s.add_dependency "nokogiri" s.add_development_dependency "bundler", "~> 1.0"
Remove platform=java from .gemspec so RubyGems updates properly
diff --git a/app/models/query.rb b/app/models/query.rb index abc1234..def5678 100644 --- a/app/models/query.rb +++ b/app/models/query.rb @@ -6,21 +6,33 @@ FORMATS = ['article', 'book', 'other'] PUBLICATION_YEARS = [-1, 0, 1] + ACCESS = ['dtu'] - def self.common_filter_query + # Params: + # options[:formats] : which formats to search for + # options[:publication_years] : which publication years (offsets from current year) to search for + # options[:access] : which access modifiers to search for + def self.common_filter_query(options = {}) + options = { + :formats => FORMATS, + :publication_years => PUBLICATION_YEARS, + :access => ACCESS + }.merge(options) + current_year = Time.new.year + [ - "format:(#{FORMATS.join(' OR ')})", - "pub_date_tis:(#{PUBLICATION_YEARS.map {|y| current_year + y}.join(' OR ')})", - "access_ss:dtu" + "format:(#{options[:formats].join(' OR ')})", + "pub_date_tis:(#{options[:publication_years].map {|y| current_year + y}.join(' OR ')})", + "access_ss:(#{options[:access].join(' OR ')})" ] end def self.normalize(query_string) - query_string.gsub(/^\s+|\s+$/, '') - .gsub(/\s+/, ' ') + query_string.strip.squeeze end + # Combine this query and the common filter query def to_solr_query [::Query.normalize(query_string), ::Query.common_filter_query].flatten.join(' AND ') end
Add options to adjust the common filter queries
diff --git a/test/st_errors.rb b/test/st_errors.rb index abc1234..def5678 100644 --- a/test/st_errors.rb +++ b/test/st_errors.rb @@ -50,7 +50,7 @@ assert_not_nil @response.body.index( '<errors count="1">') assert_not_nil @response.body.index( - '<message>pexp : no participant named "tonto"</message>') + '<message>pexp : no participant named &quot;tonto&quot;</message>') assert_not_nil @response.headers['ETag'] assert_not_nil @response.headers['Last-Modified']
Test adapted to new quoting style for errors
diff --git a/app/models/round.rb b/app/models/round.rb index abc1234..def5678 100644 --- a/app/models/round.rb +++ b/app/models/round.rb @@ -4,8 +4,12 @@ has_many :donations after_initialize do |round| - self.url = SecureRandom.hex(3) - self.expire_time = Time.now + 1.hours + if self.url.nil? + self.url = SecureRandom.hex(3) + end + if self.expire_time.nil? + self.expire_time = Time.now + 1.hours + end self.save end end
Update Round attributes in after_initialize only if nil
diff --git a/lib/tasks/db.rake b/lib/tasks/db.rake index abc1234..def5678 100644 --- a/lib/tasks/db.rake +++ b/lib/tasks/db.rake @@ -0,0 +1,20 @@+namespace :db do + dump_file = 'tmp/latest.dump' + + def verify_exec(command) + system(command) + fail 'Command failed' unless $CHILD_STATUS.exitstatus.zero? + end + + file dump_file do + verify_exec 'heroku pg:backups capture --app novel' + verify_exec "curl -o #{dump_file} `heroku pg:backups public-url -a novel`" + end + + desc 'Download and restore prod db; requires heroku toolbelt and production db access' + task restore_production_dump: dump_file do + puts 'Restoring latest production data' + verify_exec "pg_restore --verbose --clean --no-acl --no-owner #{dump_file} | rails dbconsole" + puts 'Completed successfully!' + end +end
Add restore production dump rake task
diff --git a/lib/twitterise.rb b/lib/twitterise.rb index abc1234..def5678 100644 --- a/lib/twitterise.rb +++ b/lib/twitterise.rb @@ -36,7 +36,7 @@ end def save_number_of_followers - repository.save_number_followers(twitter_client.followers.size) + repository.save_number_followers(twitter_client.user.followers_count) end def number_to_follow
Save number of followers from user information
diff --git a/test/test_calc.rb b/test/test_calc.rb index abc1234..def5678 100644 --- a/test/test_calc.rb +++ b/test/test_calc.rb @@ -13,4 +13,9 @@ def test_complex_expression assert_equal 10, calc("2 PLUS 5 MINUS 1 PLUS 4") end + + def test_more_complex_expression + skip "not yet" + assert_equal 10, calc("10 DIV 2 PLUS 6 MINUS 1") + end end
Add division test. Not implemented.
diff --git a/lib/desktop/osx.rb b/lib/desktop/osx.rb index abc1234..def5678 100644 --- a/lib/desktop/osx.rb +++ b/lib/desktop/osx.rb @@ -0,0 +1,55 @@+require 'sqlite3' + +module Desktop + class OSX + class DesktopImagePermissionsError < StandardError; end + + def self.desktop_image=(image) + self.new.desktop_image = image + end + + def self.update_desktop_image_permissions + self.new.update_desktop_image_permissions + end + + def desktop_image=(image) + write_default_desktop image + clear_custom_desktop_image + reload_desktop + rescue Errno::EACCES => e + raise DesktopImagePermissionsError.new(e) + end + + def update_desktop_image_permissions + system "sudo chown root:staff #{desktop_image_path}" + system "sudo chmod 664 #{desktop_image_path}" + end + + private + + def write_default_desktop(image) + File.open(desktop_image_path, 'w') do |desktop| + desktop.write image.data + end + end + + def clear_custom_desktop_image + db = SQLite3::Database.new(desktop_image_db_path) + db.execute 'DELETE FROM data' + db.execute 'VACUUM data' + db.close + end + + def reload_desktop + system 'killall Dock' + end + + def desktop_image_path + '/System/Library/CoreServices/DefaultDesktop.jpg' + end + + def desktop_image_db_path + File.expand_path '~/Library/Application Support/Dock/desktoppicture.db' + end + end +end
Add Desktop::OSX for updating desktops on OSX
diff --git a/ci_environment/couchdb/recipes/ubuntu_ppa.rb b/ci_environment/couchdb/recipes/ubuntu_ppa.rb index abc1234..def5678 100644 --- a/ci_environment/couchdb/recipes/ubuntu_ppa.rb +++ b/ci_environment/couchdb/recipes/ubuntu_ppa.rb @@ -13,13 +13,13 @@ # limitations under the License. # -# https://launchpad.net/~nilya/+archive/couchdb-1.3 +# https://launchpad.net/~couchdb/+archive/stable apt_repository "couchdb-ppa" do - uri "http://ppa.launchpad.net/nilya/couchdb-1.3/ubuntu" + uri "http://ppa.launchpad.net/couchdb/stable/ubuntu" distribution node['lsb']['codename'] components ["main"] - key "A6D3315B" + key "C17EAB57" keyserver "keyserver.ubuntu.com" action :add
Use latest stable CouchDB ppa Use CouchDB 1.5
diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index abc1234..def5678 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -16,6 +16,10 @@ on(host, puppet('module', 'install', 'puppetlabs-stdlib')) on(host, puppet('module', 'install', 'stahnma-epel')) on(host, puppet('module', 'install', 'puppetlabs-apt')) + + if host.platform =~ /(debian|ubuntu)/ + apply_manifest_on(host, "package { 'net-tools': ensure => installed }") + end end end end
Install net-tools for netstat command
diff --git a/app/helpers/markdown_helper.rb b/app/helpers/markdown_helper.rb index abc1234..def5678 100644 --- a/app/helpers/markdown_helper.rb +++ b/app/helpers/markdown_helper.rb @@ -8,7 +8,11 @@ # Render markdown def render_markdown(text) - Redcarpet::Markdown.new(TargetBlankRenderer, autolink: true).render( + Redcarpet::Markdown.new( + TargetBlankRenderer, + autolink: true, + fenced_code_blocks: true + ).render( text.to_s ).html_safe end
Enable redcarpet fenced code blocks Markdown should format fenced code blocks, so enable this feature in redcarpet.
diff --git a/app/inputs/date_field_input.rb b/app/inputs/date_field_input.rb index abc1234..def5678 100644 --- a/app/inputs/date_field_input.rb +++ b/app/inputs/date_field_input.rb @@ -1,6 +1,7 @@ class DateFieldInput < SimpleForm::Inputs::StringInput def input input_html_options['date-picker'] = true + input_html_options[:type] = 'text' super end end
Use input type text instead of default date_field.
diff --git a/db/data_migration/20181002120423_create_publishing_api_drafts_for_scheduled_content.rb b/db/data_migration/20181002120423_create_publishing_api_drafts_for_scheduled_content.rb index abc1234..def5678 100644 --- a/db/data_migration/20181002120423_create_publishing_api_drafts_for_scheduled_content.rb +++ b/db/data_migration/20181002120423_create_publishing_api_drafts_for_scheduled_content.rb @@ -0,0 +1,6 @@+Document.where( + id: Edition.where(state: :scheduled).select(:document_id) +).pluck(:id).each do |document_id| + puts "Enqueuing document #{document_id}" + PublishingApiDocumentRepublishingWorker.perform_async(document_id) +end
Create Publishing API drafts for scheduled content This avoids issues with this content being publishing on schedule, resulting from changing what Whitehall sends to the Publishing API when publishing content. Previously, Whitehall created or updated the draft edition, and then published that, now Whitehall just publishes the existing draft edition (this changed in 6ea0aca7e55bfd5a2451ca96928252de41007c6c). Unfortunately, this caused issues with scheduling new content to be published, due to the use of 'Coming soon' placeholder content. This approach for mitigating caching issues meant that there wasn't actually a draft edition in the Publishing API to publish when the scheduled time arrived. This 'Coming soon' behaviour has now been removed, as this bit of forgotten about technical debt has now been payed down, and there's now a proper approach for dealing with cache invalidation. However, to ensure publishing the already scheduled content happens without incident, drafts need to exist in the Publishing API to publish. This data migration creates those drafts for scheduled content.
diff --git a/app/policies/sponsor_policy.rb b/app/policies/sponsor_policy.rb index abc1234..def5678 100644 --- a/app/policies/sponsor_policy.rb +++ b/app/policies/sponsor_policy.rb @@ -1,4 +1,12 @@ class SponsorPolicy < ApplicationPolicy + + def index? + create? + end + + def show? + create? + end def create? super || (user && user.committees_include_any?(Sponsor.sponsor_admins))
Hide sponsors page from !sponsor_admins
diff --git a/spec/defines/interface_spec.rb b/spec/defines/interface_spec.rb index abc1234..def5678 100644 --- a/spec/defines/interface_spec.rb +++ b/spec/defines/interface_spec.rb @@ -1,6 +1,10 @@ require 'spec_helper' describe 'networkmanager::interface' do + let :facts do + { :concat_basedir => '/dne' } + end + let(:title) { 'interface1' } let(:params) { {:device => 'eth0'} }
Check if this suggestion solves the error of not defined
diff --git a/spec/identity/identity_spec.rb b/spec/identity/identity_spec.rb index abc1234..def5678 100644 --- a/spec/identity/identity_spec.rb +++ b/spec/identity/identity_spec.rb @@ -15,6 +15,10 @@ it { should be_listening.with('tcp') } end +describe port(35357) do + it { should be_listening.with('tcp') } +end + describe command('sh -c \'echo "show tables;"|mysql keystone\'') do its(:stdout) { should match /.*endpoint.*/ } end
Check admin port is listening
diff --git a/spec/libs/query_parser_spec.rb b/spec/libs/query_parser_spec.rb index abc1234..def5678 100644 --- a/spec/libs/query_parser_spec.rb +++ b/spec/libs/query_parser_spec.rb @@ -0,0 +1,49 @@+require 'spec_helper' +require 'query_parser' + +describe QueryParser do + + include QueryParser + + { + + '10kg of beef' => { + :inputs => ['10.0 kg'], + :terms => ['beef'] + }, + '10 kg beef' => { + :inputs => ['10.0 kg'], + :terms => ['beef'] + }, + '100km in a car' => { + :inputs => ['100.0 km'], + :terms => ['car'] + }, + '42kWh of electricity in the UK' => { + :inputs => ['42.0 kWh'], + :terms => ['electricity', 'UK'] + }, + '10 cows' => { + :inputs => ['10.0 '], + :terms => ['cows'] + }, + '1 long haul flight' => { + :inputs => ['1.0 '], + :terms => ['long', 'haul', 'flight'] + }, + + }.each_pair do |query, results| + + it "should parse '#{query}' correctly" do + # Parse string + inputs, terms = parse_query(query) + # Check inputs are parsed correctly + inputs.map{|x| x.to_s}.sort.should eql results[:inputs].sort + # Check remaining terms are correct + terms.sort.should eql results[:terms].sort + end + + end + + +end
Add spec test for query parser
diff --git a/spec/license_spec.rb b/spec/license_spec.rb index abc1234..def5678 100644 --- a/spec/license_spec.rb +++ b/spec/license_spec.rb @@ -2,7 +2,7 @@ describe DataKitten::License do - describe 'with known licenses' do + describe 'with known license URIs' do known_licenses = { "http://www.opendefinition.org/licenses/cc-by" => "cc-by", @@ -22,10 +22,16 @@ end end - describe 'with an unknown license' do + describe 'with an unknown license URI' do it 'should not provide an abbreviation' do expect(described_class.new(:uri => "http://made-up-cc-by-sa.com/cc-by").abbr).to be_nil end end + + describe 'with no license URI' do + it 'should not provide an abbreviation' do + expect(described_class.new({}).abbr).to be_nil + end + end end
Add new test for license abbreviations
diff --git a/spec/proteus_spec.rb b/spec/proteus_spec.rb index abc1234..def5678 100644 --- a/spec/proteus_spec.rb +++ b/spec/proteus_spec.rb @@ -11,6 +11,6 @@ end it "returns a friendly message if the repo doesn't exist" do - expect(@proteus.new('invalid')).to eq("A thoughtbot repo doesn't exist with that name") + expect { @proteus.new('invalid') }.to output("A thoughtbot repo doesn't exist with that name\n").to_stdout end end
Use RSpec output matcher to test kit's output
diff --git a/spec/models/spree/page_spec.rb b/spec/models/spree/page_spec.rb index abc1234..def5678 100644 --- a/spec/models/spree/page_spec.rb +++ b/spec/models/spree/page_spec.rb @@ -3,5 +3,9 @@ describe Spree::Page do let(:page) { build :page } subject { page } + it { should be_valid } + it "should be decorated by dummy application" do + should respond_to :my_method + end end
Add test for decorating functionality
diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index abc1234..def5678 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -25,6 +25,7 @@ puppet_module_install(:source => proj_root, :module_name => 'tdd_puppet_module') hosts.each do |host| on host, puppet('module', 'install', 'puppetlabs-stdlib'), { :acceptable_exit_codes => [0,1] } + on host, puppet('module', 'install', 'puppetlabs-apt'), { :acceptable_exit_codes => [0,1] } on host, %q{sed -i '/templatedir/d' /etc/puppet/puppet.conf} end end
Install dependency for acceptance test
diff --git a/tests/vcr_test.rb b/tests/vcr_test.rb index abc1234..def5678 100644 --- a/tests/vcr_test.rb +++ b/tests/vcr_test.rb @@ -2,41 +2,49 @@ require 'test/unit' require 'vcr' require 'xmlsimple' +require 'uri' require './libraries_west' VCR.configure do |config| + # where do we store fixtures? config.cassette_library_dir = 'fixtures/library_cassettes' + + # what are we using to mock our HTTP connection? config.hook_into :webmock # or :fakeweb + + # what should we name our cassettes in each test? + config.around_http_request(-> (req) { req.uri =~ /m.solus.co.uk/ }) do |request| + path = URI(request.uri).path + cassette_name = path.slice(path.rindex('/')+1, path.length) + VCR.use_cassette(cassette_name, &request) + end end +# This class tests basic functions against the fixture data class VCRTest < Test::Unit::TestCase def test_authentication - VCR.use_cassette('authentication') do - library = LibrariesWest.new - response = library.send_authentication - assert_match(/Code39A/, response) - end + library = LibrariesWest.new + response = library.send_authentication + assert_match(/Code39A/, response) end - def test_fetch_loans - VCR.use_cassette('loans') do - library = LibrariesWest.new - library.send_authentication - response = library.fetch_loans - assert_match(/<loans>/, response) - end + def test_fetch_loans + library = LibrariesWest.new + library.send_authentication + response = library.fetch_loans + assert_match(/<loans>/, response) end def test_renew_loan - VCR.use_cassette('renew_loan') do - library = LibrariesWest.new - library.send_authentication - response = library.renew_loan(ENV['LOAN_ID']) - xml = XmlSimple.xml_in(response) - assert_match("1", xml['status'].to_s) - end + library = LibrariesWest.new + library.send_authentication + response = library.renew_loan(ENV['LOAN_ID']) + xml = XmlSimple.xml_in(response) + assert_match('1', xml['status'].to_s) end + # def test_logout + + # end + end - -
Refactor cassette name creation into config method
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index abc1234..def5678 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -1,5 +1,5 @@ require 'rails_helper' -RSpec.describe User, :type => :model do +describe User do pending "add some examples to (or delete) #{__FILE__}" end
Change rspec model syntax for User model spec.
diff --git a/spec/suite_frame_spec.rb b/spec/suite_frame_spec.rb index abc1234..def5678 100644 --- a/spec/suite_frame_spec.rb +++ b/spec/suite_frame_spec.rb @@ -13,7 +13,6 @@ end specify "#{t.property('@id')}: #{t.name} ordered#{' (negative test)' unless t.positiveTest?}" do - pending "Ordered version of in03" if %w(#tin03).include?(t.property('@id')) t.options[:ordered] = true expect {t.run self}.not_to write.to(:error) end
Mark frame/in03 not pending (ordered)
diff --git a/spec/unit/helper_spec.rb b/spec/unit/helper_spec.rb index abc1234..def5678 100644 --- a/spec/unit/helper_spec.rb +++ b/spec/unit/helper_spec.rb @@ -1,6 +1,10 @@ require 'spec_helper' describe Que, 'helpers' do + it "should be able to run arbitrary SQL" do + Que.execute("SELECT 1 AS one").to_a.should == [{'one' => '1'}] + end + it "should be able to drop and create the jobs table" do DB.table_exists?(:que_jobs).should be true Que.drop!
Add a spec to ensure that Que.execute remains publically available.
diff --git a/integration-tests/apps/alacarte/runtime_jobs/app/jobs/some_module/another_simple_job.rb b/integration-tests/apps/alacarte/runtime_jobs/app/jobs/some_module/another_simple_job.rb index abc1234..def5678 100644 --- a/integration-tests/apps/alacarte/runtime_jobs/app/jobs/some_module/another_simple_job.rb +++ b/integration-tests/apps/alacarte/runtime_jobs/app/jobs/some_module/another_simple_job.rb @@ -1,8 +1,10 @@ module SomeModule class AnotherSimpleJob + include TorqueBox::Injectors + def initialize(opts = {}) @options = opts - @response_queue = TorqueBox.fetch(@options["queue"]) + @response_queue = fetch(@options["queue"]) end def run
Revert "Proper injection usage in AnotherSimpleJob class" This reverts commit ef91514c3f0e2bab94c8f05fbf6fb7a235e5df67.
diff --git a/config/environments/development.rb b/config/environments/development.rb index abc1234..def5678 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -23,7 +23,6 @@ #config.assets.digest = true config.assets.debug = true - # comment line below in if you want to use browserstack (or some other tunnel) - # config.slimmer.asset_host = "http://www.dev.gov.uk" + config.slimmer.asset_host = ENV["STATIC_DEV"] || Plek.new("preview").find("assets") end
Allow slimmer asset host to be overriden.
diff --git a/config/environments/development.rb b/config/environments/development.rb index abc1234..def5678 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -5,6 +5,9 @@ # every request. This slows down response time but is perfect for development # since you don't have to restart the webserver when you make code changes. config.cache_classes = false + config.autoload_paths += [File.join(Rails.root, "app")] + config.autoload_paths += [File.join(Rails.root, 'lib')] + # Log error messages when you accidentally call methods on nil. config.whiny_nils = true
Make the lib/ directory autoreload
diff --git a/config/initializers/rails_admin.rb b/config/initializers/rails_admin.rb index abc1234..def5678 100644 --- a/config/initializers/rails_admin.rb +++ b/config/initializers/rails_admin.rb @@ -27,7 +27,9 @@ config.actions do dashboard # mandatory index # mandatory - new + new do + except ['UnapprovedProject'] + end export bulk_delete show
Hide new action in admin for unapproved projects
diff --git a/usaidwat.gemspec b/usaidwat.gemspec index abc1234..def5678 100644 --- a/usaidwat.gemspec +++ b/usaidwat.gemspec @@ -8,7 +8,7 @@ s.authors = ["Michael Dippery"] s.email = ["michael@monkey-robot.com"] s.homepage = "" - s.summary = %q{View a user's last 100 Reddit comments} + s.summary = %q{Answers the age-old question, "Where does a Redditor comment the most?"} s.description = %q{View a user's last 100 Reddit comments, organized by subreddit.} s.rubyforge_project = "usaidwat"
Update gemspec with better summary
diff --git a/config/initializers/scrivito.rb b/config/initializers/scrivito.rb index abc1234..def5678 100644 --- a/config/initializers/scrivito.rb +++ b/config/initializers/scrivito.rb @@ -10,4 +10,14 @@ # Disable the default routes to allow route configuration config.inject_preset_routes = false + + # Basic Authentification with Session + # See https://scrivito.com/permissions for details. + config.editing_auth do |env| + user_id = env['rack.session']['user_id'] + + if user_id + Scrivito::User.system_user + end + end end
Add simple auth with session
diff --git a/app/models/info.rb b/app/models/info.rb index abc1234..def5678 100644 --- a/app/models/info.rb +++ b/app/models/info.rb @@ -4,9 +4,15 @@ validates :user_id, presence: true - default_scope -> { order(created_at: :desc) } - scope :not_archived, -> { where(archived: false).order(created_at: :desc) } - scope :archived, -> { where(archived: true).order(created_at: :desc) } + default_scope -> { includes(:user).order(created_at: :desc) } + scope :not_archived, -> { includes(:user, :comments) + .where(archived: false) + .order(created_at: :desc) + } + scope :archived, -> { includes(:user, :comments) + .where(archived: true) + .order(created_at: :desc) + } validates :title, presence: true validates :content, presence: true
Improve DB calls in scopes
diff --git a/app/models/tone.rb b/app/models/tone.rb index abc1234..def5678 100644 --- a/app/models/tone.rb +++ b/app/models/tone.rb @@ -11,6 +11,14 @@ def play @sound.play + end + + def is_playing? + @sound.isPlaying + end + + def stop + @sound.stop end def type
Add methods to check if playing and stop
diff --git a/mongoid-active_merchant.gemspec b/mongoid-active_merchant.gemspec index abc1234..def5678 100644 --- a/mongoid-active_merchant.gemspec +++ b/mongoid-active_merchant.gemspec @@ -22,7 +22,7 @@ spec.add_dependency 'activemerchant', '>= 1.52' spec.add_development_dependency "bundler", ">= 1.10" - spec.add_development_dependency "rake", "~> 10.0" + spec.add_development_dependency "rake", ">= 12.3.3" spec.add_development_dependency "minitest" spec.add_development_dependency "minitest-reporters" end
Update rake to fix security vulnerability
diff --git a/app/controllers/user/confirmations_controller.rb b/app/controllers/user/confirmations_controller.rb index abc1234..def5678 100644 --- a/app/controllers/user/confirmations_controller.rb +++ b/app/controllers/user/confirmations_controller.rb @@ -52,6 +52,6 @@ end def get_user_years_of_birth - (18.years.ago.year..Date.current.year) + (100.years.ago.year..10.years.ago.year).to_a.reverse end end
Adjust year of birth range
diff --git a/singleton/everyday_singleton.rb b/singleton/everyday_singleton.rb index abc1234..def5678 100644 --- a/singleton/everyday_singleton.rb +++ b/singleton/everyday_singleton.rb @@ -9,6 +9,18 @@ class << self def two () 2 end + + <<-DOC + Inside the Foo's body self is Foo. So the above is the same as: + + class Foo; end + class << Foo + def two () 2 end + end + + Or technically you could also just replace self with Foo inside the body, + but this is not used usually. + DOC end def three () 3 end
[singleton] Add another way to extend singleton classes
diff --git a/lib/green-button-data.rb b/lib/green-button-data.rb index abc1234..def5678 100644 --- a/lib/green-button-data.rb +++ b/lib/green-button-data.rb @@ -11,7 +11,8 @@ require 'green-button-data/parser/authorization' require 'green-button-data/parser/application_information' require 'green-button-data/parser/service_category' -require 'green-button-data/parser/local_time_parameter' +require 'green-button-data/parser/local_time_parameters' +require 'green-button-data/parser/reading_type' module GreenButtonData end
Add ReadingType class to requires
diff --git a/cassandra/recipes/ec2snitch.rb b/cassandra/recipes/ec2snitch.rb index abc1234..def5678 100644 --- a/cassandra/recipes/ec2snitch.rb +++ b/cassandra/recipes/ec2snitch.rb @@ -1,13 +1,13 @@ @topo_map = search(:node, "cassandra_cluster_name:#{node[:cassandra][:cluster_name]} AND ec2:placement_availability_zone").map do |n| az_parts = n[:ec2][:placement_availability_zone].split('-') @topo_map[n['ipaddress']] = {:port => n[:cassandra][:storage_port], - :rack => az_parts.last, - :dc => az_parts[0..1].join('-')} + :rack => az_parts.last[1], + :dc => az_parts[0..1].join('-') + "-#{az_parts.last[0]}"} end node.set_unless[:cassandra][:ec2_snitch_default_az] = "us-east-1a" default_az_parts = node[:cassandra][:ec2_snitch_default_az].split('-') -@default_az = {:rack => default_az_parts.last, :dc => default_az_parts[0..1].join('-')} +@default_az = {:rack => default_az_parts.last[1], :dc => default_az_parts[0..1].join('-') + "-#{default_az_parts.last[0]}"} template "/etc/cassandra/rack.properties" do variables(:topo_map => @topo_map, :default_az => @default_az)
Split datacenter and area field for EC2 snitch
diff --git a/core/io/pid_spec.rb b/core/io/pid_spec.rb index abc1234..def5678 100644 --- a/core/io/pid_spec.rb +++ b/core/io/pid_spec.rb @@ -17,13 +17,13 @@ end it "returns the ID of a process associated with stream" do - IO.popen(RUBY_NAME, "r+") { |io| + IO.popen(RUBY_EXE, "r+") { |io| io.pid.should_not == nil } end it "raises IOError on closed stream" do - process_io = IO.popen(RUBY_NAME, "r+") { |io| io } + process_io = IO.popen(RUBY_EXE, "r+") { |io| io } lambda { process_io.pid }.should raise_error(IOError) end end
Use RUBY_EXE not RUBY_NAME if ruby_exe helper is not suitable.
diff --git a/gds_zendesk.gemspec b/gds_zendesk.gemspec index abc1234..def5678 100644 --- a/gds_zendesk.gemspec +++ b/gds_zendesk.gemspec @@ -21,6 +21,6 @@ gem.add_development_dependency "rake" gem.add_development_dependency "rspec", "~> 3" - gem.add_development_dependency "rubocop-govuk", "~> 3" + gem.add_development_dependency "rubocop-govuk", "4.7.0" gem.add_development_dependency "webmock", ">= 2" end
Set a specific version for rubocop-govuk It's not helpful to have this gem as a relative version as you don't want different environments to be using different versions and thus reporting different linting violations.
diff --git a/lib/rack/handler/puma.rb b/lib/rack/handler/puma.rb index abc1234..def5678 100644 --- a/lib/rack/handler/puma.rb +++ b/lib/rack/handler/puma.rb @@ -30,7 +30,14 @@ server.max_threads = Integer(max) yield server if block_given? - server.run.join + begin + server.run.join + rescue Interrupt + puts "* Gracefully stopping, waiting for requests to finish" + server.stop(true) + puts "* Goodbye!" + end + end def self.valid_options
Add interruption support to Rack Handler
diff --git a/lib/sparkpost_rails/delivery_method.rb b/lib/sparkpost_rails/delivery_method.rb index abc1234..def5678 100644 --- a/lib/sparkpost_rails/delivery_method.rb +++ b/lib/sparkpost_rails/delivery_method.rb @@ -19,15 +19,15 @@ :recipients => [ { :address => { - :name => mail.to_addrs.first.display_name, - :email => mail.to_addrs.first.address + # :name => "", + :email => mail.to.first } } ], :content => { :from => { - :name => mail.from_addrs.first.display_name, - :email => mail.from_addrs.first.address + # :name => "", + :email => mail.from.first }, :subject => mail.subject, :reply_to => mail.reply_to.first,
Remove display name for now
diff --git a/lib/retina_tag/engine.rb b/lib/retina_tag/engine.rb index abc1234..def5678 100644 --- a/lib/retina_tag/engine.rb +++ b/lib/retina_tag/engine.rb @@ -27,13 +27,12 @@ end options_default.merge!(options) - image_tag_without_retina(source,options_default) if options_default[:"data-lazy-load"] options_default["data-lowdpi-src"] = options_default.delete(:src) end - tag("img", options_default) + image_tag_without_retina(source, options_default) end
Return chained image_tag to fix "size" attribute handling. A call was originally being made to image_tag_without_retina, but the value was discarded and then it returned tag("img") which does not have the same effect. This changes the return to be the actual call to image_tag_without_retina.
diff --git a/girl_friday.gemspec b/girl_friday.gemspec index abc1234..def5678 100644 --- a/girl_friday.gemspec +++ b/girl_friday.gemspec @@ -17,4 +17,5 @@ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } s.require_paths = ["lib"] s.add_development_dependency 'sinatra', '~> 1.0' + s.add_development_dependency 'rake' end
Add rake dep, fixes GH-10
diff --git a/csv2strings.gemspec b/csv2strings.gemspec index abc1234..def5678 100644 --- a/csv2strings.gemspec +++ b/csv2strings.gemspec @@ -1,3 +1,4 @@+puts RUBY_VERSION Gem::Specification.new do |s| s.name = 'csv2strings' s.version = '0.2.1' @@ -12,7 +13,7 @@ s.add_dependency "thor" - if RUBY_VERSION == '1.8.7' + if RUBY_VERSION < '1.9' s.add_dependency "fastercsv" s.add_dependency "nokogiri", "= 1.5.10" end
Update gemspec for 1.8 failing dependencies
diff --git a/spec/classes/toolkit_spec.rb b/spec/classes/toolkit_spec.rb index abc1234..def5678 100644 --- a/spec/classes/toolkit_spec.rb +++ b/spec/classes/toolkit_spec.rb @@ -0,0 +1,19 @@+require 'spec_helper' +describe 'percona::toolkit' do + + context 'with default values for all parameters' do + it { should compile } + it { should compile.with_all_deps } + it { should contain_class('percona::toolkit') } + + it { should contain_package('percona-toolkit').with_ensure('installed') } + end + + context 'with absent' do + let(:params) do + { :ensure => 'absent' } + end + + it { should contain_package('percona-toolkit').with_ensure('absent') } + end +end
Add unit tests for toolkit
diff --git a/lib/time_entry_mailer.rb b/lib/time_entry_mailer.rb index abc1234..def5678 100644 --- a/lib/time_entry_mailer.rb +++ b/lib/time_entry_mailer.rb @@ -21,9 +21,8 @@ @project = time_entry.project @hours = time_entry.hours - to = @issue.notified_users.map(&:mail) - [ @actor.mail ] - cc = @issue.notified_watchers.map(&:mail) - to + to = @issue.project.members.map(&:mail) - [ @actor.mail ] - mail from: Setting.mail_from, to: to, cc: cc, subject: "#@hours hours logged by #@actor on #@project" + mail from: Setting.mail_from, to: to, subject: "#@hours hours logged by #@actor on #@project" end end
Send timelog notice to all project members @fpietrosanti
diff --git a/spec/shoes/edit_line_spec.rb b/spec/shoes/edit_line_spec.rb index abc1234..def5678 100644 --- a/spec/shoes/edit_line_spec.rb +++ b/spec/shoes/edit_line_spec.rb @@ -4,7 +4,8 @@ let(:input_block) { Proc.new {} } let(:input_opts) { {} } - let(:parent) { double("parent").as_null_object } + let(:app) { Shoes::App.new } + let(:parent) { Shoes::Flow.new app} subject { Shoes::EditLine.new(parent, input_opts, input_block) } it_behaves_like "movable object"
Update EditLine specs to work with Swt backend
diff --git a/spec/tennis/launcher_spec.rb b/spec/tennis/launcher_spec.rb index abc1234..def5678 100644 --- a/spec/tennis/launcher_spec.rb +++ b/spec/tennis/launcher_spec.rb @@ -0,0 +1,75 @@+require "tennis/launcher" + +require "support/my_job" + +RSpec.describe Tennis::Launcher do + before do + allow(Tennis::Fetcher).to receive(:new_link).and_return(fetcher) + allow(Tennis::WorkerPool).to receive(:new_link).and_return(pool) + allow(Celluloid::Condition).to receive(:new).and_return(cond) + end + + describe "the initialization flow" do + it "links a worker pool to itself" do + expect(Tennis::WorkerPool). + to receive(:new_link). + with(cond, options) + instance + end + + it "links a fetcher to itself" do + expect(Tennis::Fetcher). + to receive(:new_link). + with(pool, options) + instance + end + end + + describe "the starting flow" do + subject(:start) { instance.start } + + before do + allow(fetcher).to receive(:async).and_return(fetcher) + end + + it "starts the fetcher" do + expect(fetcher).to receive(:start) + start + end + end + + describe "the stopping flow" do + subject(:stop) { instance.stop } + + before do + allow(pool).to receive(:async).and_return(pool) + end + + it "marks the fetcher as done" do + expect(fetcher).to receive(:done!) + stop + end + + it "commands to the pool to stop" do + expect(pool).to receive(:stop) + stop + end + + it "waits for the pool to finish" do + expect(cond).to receive(:wait) + stop + end + + it "terminates both the pool and the fetcher" do + expect(pool).to receive(:terminate) + expect(fetcher).to receive(:terminate) + stop + end + end + + let(:instance) { described_class.new(options) } + let(:options) { { job_classes: [MyJob], concurrency: 2 } } + let(:fetcher) { double("Tennis::Fetcher", terminate: true, alive?: true, done!: true) } + let(:pool) { double("Tennis::WorkerPool", terminate: true, alive?: true, stop: true) } + let(:cond) { double("Celluloid::Condition", wait: true) } +end
Add a laucher spec, as always very implementation-based
diff --git a/x/docs/launch.rb b/x/docs/launch.rb index abc1234..def5678 100644 --- a/x/docs/launch.rb +++ b/x/docs/launch.rb @@ -15,7 +15,7 @@ attr_reader :repository, :checklist_issue def read - File.read("./x/docs/md/track/LAUNCH.md").gsub('REPO', repository).gsub('CHECKLIST_ISSUE', checklist_issue) + File.read("./x/docs/md/track/LAUNCH.md").gsub('REPO', repository).gsub('CHECKLIST_ISSUE', checklist_issue.to_s) end end end
Handle checklist number as integer in track documentation
diff --git a/class_annotation.rb b/class_annotation.rb index abc1234..def5678 100644 --- a/class_annotation.rb +++ b/class_annotation.rb @@ -0,0 +1,51 @@+# +# Let's assume we have a BookSearch class. The initialize method takes a Hash of +# parameters. +class BookSearch + def initialize(hash) + @author_name = hash[:author_name] + @isbn = hash[:isbn] + end +end + +# +# Now, let's assume we want the initialize method to dynamically handle any list +# of key-values. +class BookSearch + def self.hash_initializer(*attribute_names) + define_method(:initialize) do |*args| + data = args.first || {} + attribute_names.each do |attribute_name| + instance_variable_set "@#{attribute_name}", data[attribute_name] + end + end + end + hash_initializer :author_name, :isbn +end + +# +# If we need the hash_initializer for many classes we can extract it to a +# module. +module Initializers + def hash_initializer(*attribute_names) + define_method(:initialize) do |*args| + data = args.first || {} + attribute_names.each do |attribute_name| + instance_variable_set "@#{attribute_name}", data[attribute_name] + end + end + end +end + +# +# We can now make the method available to the class Class. +Class.send :include, Initializers + +# +# And use it in clear and clean way. +class BookSearch + hash_initializer :author_name, :isbn +end + +BookSearch.new(author_name: 'john.doe', isbn: 123) +# <BookSearch:0x005626957ce6f8 @author_name="john.doe", @isbn=12345>
Initialize objects with a hash_initializer