diff
stringlengths
65
26.7k
message
stringlengths
7
9.92k
diff --git a/app/controllers/identifiers_controller.rb b/app/controllers/identifiers_controller.rb index abc1234..def5678 100644 --- a/app/controllers/identifiers_controller.rb +++ b/app/controllers/identifiers_controller.rb @@ -16,8 +16,9 @@ end def arxiv - @arxiv = "arXiv: " + params[:identifiers].downcase - @paper = Paper.where('lower(identifier) = ?', @arxiv).first + @arxiv = "arxiv: " + params[:identifiers].downcase + @arxiv_condensed = "arxiv: " + params[:identifiers].downcase + @paper = Paper.where('lower(identifier) = ? OR lower(identifier) = ?', @arxiv, @arxiv_condensed).first unless @paper metadata = PaperMetadata.metadata_for(@arxiv) unless metadata.blank?
Fix for arXiv identifiers lookup
diff --git a/app/controllers/invitations_controller.rb b/app/controllers/invitations_controller.rb index abc1234..def5678 100644 --- a/app/controllers/invitations_controller.rb +++ b/app/controllers/invitations_controller.rb @@ -21,6 +21,7 @@ if @member.save @member.clear_invitation_code! self.current_user = @member + current_user.update_attribute(:last_logged_in_at, Time.now.utc) flash[:notice] = "Your new password has been saved." redirect_to(root_path) else
Update last_logged_in_at when somebody is invited and picks a password.
diff --git a/versioned-rails-guides.rb b/versioned-rails-guides.rb index abc1234..def5678 100644 --- a/versioned-rails-guides.rb +++ b/versioned-rails-guides.rb @@ -0,0 +1,21 @@+#!/usr/bin/env ruby + +# For each tag of a released version after 2.3.x +# and 'edge' too? edge needs a commit hash +all_tags = `git tag`.split("\n") +released_version_tags = tags.select { |t| + t.match(/^v(2\.3\.\d+|[34]\.\d+\.\d+)$/) + } + +# Generate the guides: +# bundle +# cd railties +# bundle exec rake generate_guides ALL=1 +# into a location named for the tag + +# after some version?? +# bundle +# cd guides +# bundle exec rake guides:generate ALL=1 + +# @version = ENV['RAILS_VERSION'] || 'local'
Tag filtering and pseudocode of rails guide version generating
diff --git a/app/controllers/validations_controller.rb b/app/controllers/validations_controller.rb index abc1234..def5678 100644 --- a/app/controllers/validations_controller.rb +++ b/app/controllers/validations_controller.rb @@ -7,10 +7,10 @@ @article.add_validation(@article.id, current_user) if @article.save - render :"/articles/show", {notice: 'You have validated this article!'} + render :"/articles/show", {notice: 'You have successfully validated this article!'} else - flash[:notice]= current_user.article.errors.full_messages + flash[:error]= current_user.article.errors.full_messages redirect_to articles_path #, {notice: 'You have already validated this article!'} # flash[:errors].full_messages end
Patch getting error when updating form:
diff --git a/app/helpers/pageflow/embed_code_helper.rb b/app/helpers/pageflow/embed_code_helper.rb index abc1234..def5678 100644 --- a/app/helpers/pageflow/embed_code_helper.rb +++ b/app/helpers/pageflow/embed_code_helper.rb @@ -11,7 +11,7 @@ end def call - %'<iframe src="#{url(entry)}" scrolling="no" allowfullscreen></iframe>' + %'<iframe src="#{url(entry)}" allowfullscreen></iframe>' end private
Remove scrolling attribute from embed iframe snippet `scrolling` attribute is deprecated. Paged entries do not need it since they hide scroll bars via `overflow: hidden`. For Scrolled entries it needs to be removed to enable native scrolling. REDMINE-19063
diff --git a/cookbooks/omnitruck/metadata.rb b/cookbooks/omnitruck/metadata.rb index abc1234..def5678 100644 --- a/cookbooks/omnitruck/metadata.rb +++ b/cookbooks/omnitruck/metadata.rb @@ -4,7 +4,7 @@ license 'Apache2' description 'Installs/Configures omnitruck' long_description 'Installs/Configures omnitruck' -version '0.3.13' +version '0.3.14' depends 'delivery-sugar' depends 'cia_infra'
Increment version to trigger another change We failed in union during functional, and can't "rerun" the pipeline in Automate. Let's try this again. Signed-off-by: Joshua Timberman <d6955d9721560531274cb8f50ff595a9bd39d66f@chef.io>
diff --git a/activesupport/lib/active_support/option_merger.rb b/activesupport/lib/active_support/option_merger.rb index abc1234..def5678 100644 --- a/activesupport/lib/active_support/option_merger.rb +++ b/activesupport/lib/active_support/option_merger.rb @@ -5,7 +5,7 @@ module ActiveSupport class OptionMerger #:nodoc: instance_methods.each do |method| - undef_method(method) unless method.start_with?("__", "instance_eval", "class", "object_id") + undef_method(method) unless method.to_s.start_with?("__", "instance_eval", "class", "object_id") end def initialize(context, options)
Fix undefined method `start_with?' for :to_json
diff --git a/app/controllers/admin/base_controller.rb b/app/controllers/admin/base_controller.rb index abc1234..def5678 100644 --- a/app/controllers/admin/base_controller.rb +++ b/app/controllers/admin/base_controller.rb @@ -12,6 +12,7 @@ def set_pack use_pack 'admin' + use_pack 'public' end end end
Add “public” pack to admin controller, as it is included in upstream admin layout Fixes CW unfolding in moderation
diff --git a/app/controllers/checklists_controller.rb b/app/controllers/checklists_controller.rb index abc1234..def5678 100644 --- a/app/controllers/checklists_controller.rb +++ b/app/controllers/checklists_controller.rb @@ -15,11 +15,15 @@ def find_items result = Array.new @obj.pre_checklist_references.each do |x| - result.concat(x.checklist.all_checklist_items) + if !x.checklist.nil? + result.concat(x.checklist.all_checklist_items) + end end result.concat(@obj.all_checklist_items) @obj.post_checklist_references.each do |x| - result.concat(x.checklist.all_checklist_items) + if !x.checklist.nil? + result.concat(x.checklist.all_checklist_items) + end end result end
Fix weird scenario where checklist reference is nil
diff --git a/spec/unit/tmuxinator/bosh/template_spec.rb b/spec/unit/tmuxinator/bosh/template_spec.rb index abc1234..def5678 100644 --- a/spec/unit/tmuxinator/bosh/template_spec.rb +++ b/spec/unit/tmuxinator/bosh/template_spec.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require 'spec_helper' require 'tmuxinator/bosh/console/template' +require 'yaml' RSpec.describe Tmuxinator::BOSH::Console::Template do subject(:template) { Tmuxinator::BOSH::Console::Template.new(template_source) } @@ -21,4 +22,27 @@ allow(template_source).to receive(:read).and_return 'foo <%= bar %>' expect(template.render(binding)).to eq('foo baz') end + + context 'using the default template' do + let(:project_name) { 'test' } + let(:instances) { [] } + let(:template_source) { + (Pathname(__dir__).parent.parent.parent.parent / 'templates/bosh-console.yml') + } + + context 'no instances' do + let(:result) { template.render(binding) } + it 'produces valid YAML' do + expect { YAML.load(result) }.to_not raise_error + end + + it 'renders the project name' do + expect(YAML.load(result)['name']).to eq('test') + end + + it 'renders no windows' do + expect(YAML.load(result)['windows']).to be_nil + end + end + end end
Add tests for default template
diff --git a/app/controllers/api/v2/anime_controller.rb b/app/controllers/api/v2/anime_controller.rb index abc1234..def5678 100644 --- a/app/controllers/api/v2/anime_controller.rb +++ b/app/controllers/api/v2/anime_controller.rb @@ -4,7 +4,8 @@ def show if params[:id].start_with? "myanimelist:" - anime = Anime.find_by(mal_id: params[:id].split(':')[1]) + anime = Anime.find_by(mal_id: params[:id].split(':')[1]) || + raise(ActiveRecord::RecordNotFound) else anime = Anime.find(params[:id]) end
Fix 500 when MAL lookup fails.
diff --git a/app/serializers/gobierto_plans/node_serializer.rb b/app/serializers/gobierto_plans/node_serializer.rb index abc1234..def5678 100644 --- a/app/serializers/gobierto_plans/node_serializer.rb +++ b/app/serializers/gobierto_plans/node_serializer.rb @@ -6,7 +6,7 @@ cache key: "node" - attributes :id, :name_translations, :category_id, :progress, :starts_at, :ends_at, :status_id, :published_version, :position, :external_id + attributes :id, :name, :category_id, :progress, :starts_at, :ends_at, :status_id, :published_version, :position, :external_id def category_id object.categories.find_by(gplan_categories_nodes: { category_id: instance_options[:plan].categories })&.id
Return translated name in projects
diff --git a/app/controllers/installation_controller.rb b/app/controllers/installation_controller.rb index abc1234..def5678 100644 --- a/app/controllers/installation_controller.rb +++ b/app/controllers/installation_controller.rb @@ -12,7 +12,7 @@ def consul_installation_details { - release: "v0.19" + release: "1.0.0-beta" }.merge(features: settings_feature_flags) end
Update release version number to 1.0.0-beta
diff --git a/Formula/bash-completion.rb b/Formula/bash-completion.rb index abc1234..def5678 100644 --- a/Formula/bash-completion.rb +++ b/Formula/bash-completion.rb @@ -9,7 +9,7 @@ def install inreplace "bash_completion" do |s| s.gsub! '/etc/bash_completion', "#{etc}/bash_completion" - s.gsub! "bash_completion", 'readlink -f', "readlink" + s.gsub! 'readlink -f', "readlink" end system "./configure", "--prefix=#{prefix}"
Remove extraneous argument in line 12 Signed-off-by: Adam Vandenberg <34c2b6407fd5a10249a15d699d40f9ed1782e98c@gmail.com>
diff --git a/app/controllers/admin/papers_controller.rb b/app/controllers/admin/papers_controller.rb index abc1234..def5678 100644 --- a/app/controllers/admin/papers_controller.rb +++ b/app/controllers/admin/papers_controller.rb @@ -3,7 +3,7 @@ before_action :set_activity before_action :set_paper, only: [:show, :update] def index - @papers = Paper.joins(:user).where(activity: @activity).order(sort_column + " "+ sort_direction) + @papers = Paper.joins(:user).where(activity: @activity).order(sort_sql) @notification = Notification.new end @@ -17,6 +17,12 @@ redirect_to admin_activity_paper_path(@activity, @paper) end private + + def sort_sql + "#{sort_column} #{sort_direction}" + end + + def set_activity @activity = Activity.find(params[:activity_id]) end
Use sort_sql to merge order and column
diff --git a/app/helpers/spree/base_helper_decorator.rb b/app/helpers/spree/base_helper_decorator.rb index abc1234..def5678 100644 --- a/app/helpers/spree/base_helper_decorator.rb +++ b/app/helpers/spree/base_helper_decorator.rb @@ -2,7 +2,7 @@ module BaseHelper def taxons_tree(root_taxon, current_taxon, max_level = 1) - return '' if max_leve < 1 || root_taxon.children.empty? + return '' if max_level < 1 || root_taxon.children.empty? content_tag :ul, class: 'taxons_list' do root_taxon.children.map do |taxon| css_class = (current_taxon && current_taxon.self_and_ancestors.include?(taxon)) ? 'current' : nil
Add css class to taxon links.
diff --git a/app/workers/background_migration_worker.rb b/app/workers/background_migration_worker.rb index abc1234..def5678 100644 --- a/app/workers/background_migration_worker.rb +++ b/app/workers/background_migration_worker.rb @@ -20,7 +20,7 @@ now = Time.now.to_i schedule = now + delay.to_i - raise ArgumentError if schedule <= now + raise ArgumentError, 'Delay time invalid!' if schedule <= now Sidekiq::Client.push_bulk('class' => self, 'queue' => sidekiq_options['queue'],
Add description to exception in bg migrations worker
diff --git a/app/services/boards/issues/move_service.rb b/app/services/boards/issues/move_service.rb index abc1234..def5678 100644 --- a/app/services/boards/issues/move_service.rb +++ b/app/services/boards/issues/move_service.rb @@ -6,36 +6,24 @@ return false unless valid_move? update_service.execute(issue) - reopen_service.execute(issue) if moving_from.done? - close_service.execute(issue) if moving_to.done? - - true end private def valid_move? - moving_from.present? && moving_to.present? + moving_from_list.present? && moving_to_list.present? end def issue @issue ||= project.issues.visible_to_user(user).find_by!(iid: params[:id]) end - def moving_from - @moving_from ||= board.lists.find_by(id: params[:from_list_id]) + def moving_from_list + @moving_from_list ||= board.lists.find_by(id: params[:from_list_id]) end - def moving_to - @moving_to ||= board.lists.find_by(id: params[:to_list_id]) - end - - def close_service - ::Issues::CloseService.new(project, user) - end - - def reopen_service - ::Issues::ReopenService.new(project, user) + def moving_to_list + @moving_to_list ||= board.lists.find_by(id: params[:to_list_id]) end def update_service @@ -45,18 +33,24 @@ def issue_params { add_label_ids: add_label_ids, - remove_label_ids: remove_label_ids + remove_label_ids: remove_label_ids, + state_event: issue_state } end + def issue_state + return 'reopen' if moving_from_list.done? + return 'close' if moving_to_list.done? + end + def add_label_ids - [moving_to.label_id].compact + [moving_to_list.label_id].compact end def remove_label_ids label_ids = - if moving_to.label? - moving_from.label_id + if moving_to_list.label? + moving_from_list.label_id else board.lists.label.pluck(:label_id) end
Use `Issues::UpdateService` to close/reopen an issue
diff --git a/app/updaters/cocoa_pod_category_updater.rb b/app/updaters/cocoa_pod_category_updater.rb index abc1234..def5678 100644 --- a/app/updaters/cocoa_pod_category_updater.rb +++ b/app/updaters/cocoa_pod_category_updater.rb @@ -9,12 +9,24 @@ category_name = categories_import[cocoa_pod.name] if category_name.present? category = cocoa_pod.cocoa_pod_category - if !category || category.name != category_name - Rails.logger.info "Assigning category #{category_name} to #{cocoa_pod.name}" - new_category = CocoaPodCategory.find_or_create_by_name(category_name) - cocoa_pod.cocoa_pod_category = new_category - cocoa_pod.save + if category + if category.name == category_name + Rails.logger.info "Keeping #{cocoa_pod.name} in #{category_name}" + else + Rails.logger.info "Moving #{cocoa_pod.name} to #{category_name} "\ + "(from #{category.name})" + move cocoa_pod, category_name + end + else + Rails.logger.info "Moving #{cocoa_pod.name} to #{category_name}" + move cocoa_pod, category_name end end end + + def move cocoa_pod, category_name + new_category = CocoaPodCategory.find_or_create_by_name(category_name) + cocoa_pod.cocoa_pod_category = new_category + cocoa_pod.save + end end
Improve logging of cocoa pod category updater.
diff --git a/spec/models/metrics/accessibility_spec.rb b/spec/models/metrics/accessibility_spec.rb index abc1234..def5678 100644 --- a/spec/models/metrics/accessibility_spec.rb +++ b/spec/models/metrics/accessibility_spec.rb @@ -3,12 +3,20 @@ describe Metrics::Accessibility do it "should split a given text into its words" do + text = "Estimates of average farm rent prices by farm type." expectations = ['Estimates', 'of', 'average', 'farm', 'rent', 'prices', 'by', 'farm', 'type'] words = Metrics::Accessibility.split_to_words(text) words.should match_array expectations + + words = Metrics::Accessibility.split_to_words("") + words.should match_array [] + + words = Metrics::Accessibility.split_to_words("Estimates") + words.should match_array ['Estimates'] + end end
Add more tests for the word splitter Obiously one test is ridicilous too few, so I just added two more. Signed-off-by: Konrad Reiche <4ff0213f56e2082fcd8c882d04c546881c579ce4@gmail.com>
diff --git a/spec/controllers/home_controller_spec.rb b/spec/controllers/home_controller_spec.rb index abc1234..def5678 100644 --- a/spec/controllers/home_controller_spec.rb +++ b/spec/controllers/home_controller_spec.rb @@ -1,6 +1,17 @@ require 'spec_helper' describe HomeController do + context 'issues' do + it 'loads only published issues' do + shown = Issue.make! status: 'published' + not_shown = Issue.make! status: 'shelved' + + get :index + + assigns(:issues).should == [shown] + end + end + context 'with rendered views' do render_views
Add spec to make sure only published issues are shown on the front page.
diff --git a/api/config/initializers/doorkeeper.rb b/api/config/initializers/doorkeeper.rb index abc1234..def5678 100644 --- a/api/config/initializers/doorkeeper.rb +++ b/api/config/initializers/doorkeeper.rb @@ -14,8 +14,6 @@ current_spree_user&.has_spree_role?('admin') || redirect_to(routes.root_url) end - use_refresh_token - grant_flows %w(password) access_token_methods :from_bearer_authorization, :from_access_token_param
Remove duplicate `use_refresh_token` in Doorkeeper initializer
diff --git a/app/config/capistrano/tasks/configure.rake b/app/config/capistrano/tasks/configure.rake index abc1234..def5678 100644 --- a/app/config/capistrano/tasks/configure.rake +++ b/app/config/capistrano/tasks/configure.rake @@ -6,7 +6,7 @@ DESC task :cachetool do # Set the correct bin - SSHKit.config.command_map[:cachetool] = "#{fetch :php_bin_path} #{fetch :deploy_to}/shared/cachetool.phar" + SSHKit.config.command_map[:cachetool] = "#{fetch :php_bin} #{fetch :deploy_to}/shared/cachetool.phar" end end end
Prepend the PHP binary to our cachetool command
diff --git a/app/controllers/job_messages_controller.rb b/app/controllers/job_messages_controller.rb index abc1234..def5678 100644 --- a/app/controllers/job_messages_controller.rb +++ b/app/controllers/job_messages_controller.rb @@ -14,7 +14,7 @@ flash_now(:success, "#{status[:progress]} out of #{status[:total]}") else flash_now(:success, "#{status.status}") - if status.completed? + if status.completed? or status.failed? session[:job_id] = nil end end
Remove job_id when the job failed
diff --git a/app/reports/state_of_good_repair_report.rb b/app/reports/state_of_good_repair_report.rb index abc1234..def5678 100644 --- a/app/reports/state_of_good_repair_report.rb +++ b/app/reports/state_of_good_repair_report.rb @@ -17,13 +17,13 @@ # Override standard method (via service), get all undisposed assets def get_assets(organization_id_list, fiscal_year, asset_type_id=nil, asset_subtype_id=nil ) - Asset.active.where(organization_id: organization_id_list) + Asset.operational.where(organization_id: organization_id_list) end def set_defaults if @fy_year @fy_year = @fy_year.to_i - else + else @fy_year = current_fiscal_year_year end end
Remove use of deprecated scope
diff --git a/app/services/pxe_iso_visibility_service.rb b/app/services/pxe_iso_visibility_service.rb index abc1234..def5678 100644 --- a/app/services/pxe_iso_visibility_service.rb +++ b/app/services/pxe_iso_visibility_service.rb @@ -4,9 +4,9 @@ field_names_to_hide = [] if supports_pxe - field_names_to_edit += [:pxe_image_id, :pxe_server_id] + field_names_to_edit += %i(pxe_image_id pxe_server_id) else - field_names_to_hide += [:pxe_image_id, :pxe_server_id] + field_names_to_hide += %i(pxe_image_id pxe_server_id) end if supports_iso
Fix rubocop warnings in PxeIsoVisibilityService
diff --git a/lib/dynflow/actors/execution_plan_cleaner.rb b/lib/dynflow/actors/execution_plan_cleaner.rb index abc1234..def5678 100644 --- a/lib/dynflow/actors/execution_plan_cleaner.rb +++ b/lib/dynflow/actors/execution_plan_cleaner.rb @@ -40,7 +40,12 @@ def clean! plans = @world.persistence.find_old_execution_plans(Time.now.utc - @max_age) + report(plans) @world.persistence.delete_execution_plans(uuid: plans.map(&:id)) + end + + def report(plans) + @world.logger.info("Execution plan cleaner removing #{plans.count} execution plans.") end def set_clock
Make execution plan cleaner log
diff --git a/lib/kafka/round_robin_assignment_strategy.rb b/lib/kafka/round_robin_assignment_strategy.rb index abc1234..def5678 100644 --- a/lib/kafka/round_robin_assignment_strategy.rb +++ b/lib/kafka/round_robin_assignment_strategy.rb @@ -23,7 +23,11 @@ end topics.each do |topic| - partitions = @cluster.partitions_for(topic).map(&:partition_id) + begin + partitions = @cluster.partitions_for(topic).map(&:partition_id) + rescue UnknownTopicOrPartition + raise UnknownTopicOrPartition, "unknown topic #{topic}" + end partitions_per_member = partitions.group_by {|partition_id| partition_id % members.count
Improve error message for UnknownTopicOrPartition It's not really useful unless you know which topic is missing.
diff --git a/app/lib/mi_bridges/driver/absent_parent_information_page.rb b/app/lib/mi_bridges/driver/absent_parent_information_page.rb index abc1234..def5678 100644 --- a/app/lib/mi_bridges/driver/absent_parent_information_page.rb +++ b/app/lib/mi_bridges/driver/absent_parent_information_page.rb @@ -1,8 +1,22 @@ module MiBridges class Driver - class AbsentParentInformationPage < ClickNextPage + class AbsentParentInformationPage < FillInAndClickNextPage def self.title "Absent Parent Information" + end + + def skip_infinite_loop_check; end + + def fill_in_required_fields + if page.has_css?("#starCommonAbsentParent") + check_no_one_for_common_absent_parent + end + end + + private + + def check_no_one_for_common_absent_parent + click_id("NoOne_ABSENT") end end end
Check "no one" for common absent parent question * If both parents are not in the household, MIBridges asks which children have a common absent parent * We are selecting "No one" in all cases. This info can be corrected during an interview. * Also had to override `skip_infinite_loop_check` since this page shows up TWICE for each child, which would trigger an infinite loop check if there are more than 2 children in a household with an absent parent. * This was confirmed by driving the SNAP app with id mentioned in the tracker ticket. * [Finishes #153388256] https://www.pivotaltracker.com/story/show/153388256
diff --git a/lib/crawler/module_base.rb b/lib/crawler/module_base.rb index abc1234..def5678 100644 --- a/lib/crawler/module_base.rb +++ b/lib/crawler/module_base.rb @@ -15,7 +15,6 @@ def init_agent @agent = Mechanize.new - # @agent.set_proxy('w3c.widzew.net', 8080) # disabling keep alive will make sure we can easier switch circuit in tor @agent.keep_alive = false
Remove commented out code with proxy details
diff --git a/app/controllers/application.rb b/app/controllers/application.rb index abc1234..def5678 100644 --- a/app/controllers/application.rb +++ b/app/controllers/application.rb @@ -10,6 +10,7 @@ before_filter :can_create?, :only => [:new, :create] before_filter :can_edit?, :only => [:edit, :update, :destroy] + before_filter :current_network map_resource :profile, :singleton => true, :class => "User", :find => :current_user
Load current_network in an ApplicationController before_filter
diff --git a/app/controllers/api/maps_controller.rb b/app/controllers/api/maps_controller.rb index abc1234..def5678 100644 --- a/app/controllers/api/maps_controller.rb +++ b/app/controllers/api/maps_controller.rb @@ -2,6 +2,8 @@ module Api class MapsController < Api::ApplicationController + skip_before_action :verify_api_key + def index @maps = MapUpload.available_maps @cloud_maps = MapUpload.available_cloud_maps
Make maps listing public in API
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 @@ -1,6 +1,6 @@ class ProductsController < ApplicationController before_filter :find_product, :only => [:show, :edit, :update] - before_filter :admin_required, :except => [:show] + before_filter :admin_or_manager_required, :except => [:show] def index @products = Product.all(:conditions => {:website_id => @w.id}, :order => :name) @@ -40,7 +40,8 @@ protected def find_product - @product = Product.find(params[:id]) + @product = Product.find_by_id_and_website_id(params[:id], @w.id) + render :file => "#{RAILS_ROOT}/public/404.html", :status => "404 Not Found" if @product.nil? end end
Allow managers to show, edit and update products; restrict products to current website or show 404 page if not found
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 @@ -2,19 +2,13 @@ before_action :check_accounts_enabled def create - if logged_in? - redirect_to default_redirect_path - return - end + redirect_to Plek.find("account-manager") and return if logged_in? redirect_if_not_test Services.oidc.auth_uri(redirect_path: params["redirect_path"])[:uri] end def callback - unless params[:code] - redirect_to default_redirect_path - return - end + redirect_to Plek.new.website_root and return unless params[:code] state = params.require(:state) @@ -35,12 +29,19 @@ cookies[:cookies_policy] = cookies_policy.merge(usage: true).to_json end - redirect_if_not_test(callback[:redirect_path] || default_redirect_path) + redirect_if_not_test(callback[:redirect_path] || Plek.find("account-manager")) end def delete - logout! - redirect_if_not_test Plek.new.website_root + if params[:continue] + logout! + redirect_if_not_test URI.join(Plek.find("account-manager"), "logout", "?done=1") + elsif params[:done] + logout! + redirect_if_not_test Plek.new.website_root + else + redirect_if_not_test URI.join(Plek.find("account-manager"), "logout", "?continue=1") + end end protected @@ -52,8 +53,4 @@ redirect_to url end end - - def default_redirect_path - Plek.find("account-manager") - end end
Implement finder-frontend side of single-sign-out We want signing out of finder-frontend to sign out of the account manager, and vice versa, for this initial experiment. This is a bit unusual for a federated accounts system like this, but for now we are presenting the GOV.UK account as more of a Transition Checker account. We will work on the larger design problem of making users understand that the account is a distinct thing later. Here's how it'll work. It works the same on both sides, so I'll just call the two endpoints "logoutA" and "logoutB". 1. User visits logoutA 2. User is 302-redirected to logoutB?continue=1 3. User's B session cookie is deleted 4. User is redirected to logoutA?done=1 5. User's A session cookie is deleted 6. The post-logout screen or redirect is shown Redirecting through every signed-in service won't scale beyond 1 service, but for this first experiment, we do only have 1.
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,7 +3,7 @@ end def create - if user = UserAuthenticator.authenticate(params[:session]) + if (user = UserAuthenticator.authenticate(params[:session])) log_in user redirect_to user else
Put variable assignment in brackets
diff --git a/app/controllers/concerns/errorable.rb b/app/controllers/concerns/errorable.rb index abc1234..def5678 100644 --- a/app/controllers/concerns/errorable.rb +++ b/app/controllers/concerns/errorable.rb @@ -2,11 +2,25 @@ extend ActiveSupport::Concern included do - rescue_from Errors::FormatError, ActionController::UnknownFormat, with: :handle_format_error - rescue_from Errors::AuthenticationError, with: :handle_authentication_error - rescue_from Errors::RequestError, with: :handle_request_error - rescue_from Errors::Connectors::ConnectorError, with: :handle_connector_error - rescue_from Errors::Connectors::ServiceError, with: :handle_service_error + rescue_from Errors::FormatError, ActionController::UnknownFormat do + render nothing: true, status: :not_acceptable + end + + rescue_from Errors::AuthenticationError do + render_error :unauthorized, 'Not Authorized' + end + + rescue_from Errors::RequestError do |ex| + render_error :bad_request, ex.message + end + + rescue_from Errors::Connectors::ConnectorError do |ex| + render_error :internal_server_error, ex.message + end + + rescue_from Errors::Connectors::ServiceError do |ex| + render_error :service_unavailable, ex.message + end end # Converts a sybolized code and message into a valid Rails reponse. @@ -17,27 +31,4 @@ def render_error(code, message) respond_with Utils::RenderableError.new(code, message), status: code end - - # Handles authorization errors and responds with appropriate HTTP code and headers. - # - # @param exception [Exception] exception to convert into a response - def handle_authentication_error - render_error :unauthorized, 'Not Authorized' - end - - def handle_connector_error(ex) - render_error :internal_server_error, ex.message - end - - def handle_service_error(ex) - render_error :service_unavailable, ex.message - end - - def handle_format_error - render nothing: true, status: :not_acceptable - end - - def handle_request_error(ex) - render_error :bad_request, ex.message - end end
Move error handling from methods to blocks
diff --git a/app/controllers/reviews_controller.rb b/app/controllers/reviews_controller.rb index abc1234..def5678 100644 --- a/app/controllers/reviews_controller.rb +++ b/app/controllers/reviews_controller.rb @@ -1,4 +1,5 @@ class ReviewsController < ApplicationController + before_action :authenticate_user!, only: [:create, :update, :destroy] def show @review = Review.find_by(id: params[:id])
Fix if ng show conditional
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index abc1234..def5678 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -2,4 +2,5 @@ # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. protect_from_forgery with: :exception + include CanCan::ControllerAdditions end
Include cancan controllers in application controller
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index abc1234..def5678 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -2,4 +2,8 @@ # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. protect_from_forgery with: :exception + + def after_sign_in_path_for(resource) + stored_location_for(resource) || dashboards_path + end end
Add sign in redirect to dashboard.
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index abc1234..def5678 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -27,6 +27,6 @@ caller[0] =~ /`([^']*)'/ and where = $1 logger.error "[#{where}] #{error.class}: #{error.to_s}" logger.info error.backtrace.join("\n") - ExceptionNotifier::Notifier.exception_notification(request.env, error).deliver + #ExceptionNotifier::Notifier.exception_notification(request.env, error).deliver end end
Remove exception notification tool again for debugging
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index abc1234..def5678 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -16,6 +16,8 @@ end def authenticate_admin_user! - redirect_to :back, notice: "Not allowed" unless current_user.admin? + if current_user && !current_user.admin? + redirect_to :back, notice: "Not allowed" + end end end
Fix bug in admin user auth.
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index abc1234..def5678 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,7 +1,6 @@-require 'gds_api/helpers' +require 'gds_api/content_api' class ApplicationController < ActionController::Base - include GdsApi::Helpers include Slimmer::Headers protect_from_forgery with: :exception @@ -35,4 +34,11 @@ rescue StandardError # Triggered by trying to parameterize malformed UTF-8 cacheable_404 end + + def content_api + @content_api ||= GdsApi::ContentApi.new( + Plek.current.find('contentapi'), + { web_urls_relative_to: Plek.current.website_root } + ) + end end
Set Content API web URLs relative to the website root Define a custom instance of the Content API adapter, configured to use the value returned from 'Plek.current.website_root' as the hostname for the tag URLs. This fixes tag URLs in development pointing to the 'www' host.
diff --git a/resources/rsync_mirror.rb b/resources/rsync_mirror.rb index abc1234..def5678 100644 --- a/resources/rsync_mirror.rb +++ b/resources/rsync_mirror.rb @@ -0,0 +1,43 @@+property :name, [String, Symbol], required: true, name_property: true +property :local_path, String, required: false +property :repo_name, String, required: true +property :repo_description, String, required: true +property :repo_url, String, required: true +property :rsync_options, String, required: false, + default: '-aHS --numeric-ids --delete --delete-delay --delay-updates' + +def real_local_path + if local_path == NilClass + "#{local_path}/#{name}/" + else + "/var/lib/yum-repo/#{name}/" + end +end + +def real_rsync_options + if rsync_options == NilClass + '-aHS --numeric-ids --delete --delete-delay --delay-updates' + else + rsync_options + end +end + +action :create do + directory real_local_path do + owner 'root' + group 'root' + mode '0755' + action :create + end + ruby_block 'reposync' do + block do + system "rsync #{real_rsync_options} #{repo_url} #{real_local_path}" + end + end +end + +action :delete do + directory real_local_path do + action :delete + end +end
Add new resource type and clean up code in mirror resource
diff --git a/app/metal/recently_viewed_products.rb b/app/metal/recently_viewed_products.rb index abc1234..def5678 100644 --- a/app/metal/recently_viewed_products.rb +++ b/app/metal/recently_viewed_products.rb @@ -1,5 +1,5 @@ # Allow the metal piece to run in isolation -require(File.dirname(__FILE__) + "/../../config/environment") unless defined?(Rails) +require(SPREE_ROOT + "/config/environment") unless defined?(Rails) class RecentlyViewedProducts def self.call(env)
Allow RecentlyViewedProducts Metal to run from extension app/metal subdir, without copying to SPREE_ROOT app/metal subdir.
diff --git a/app/models/spree/product_decorator.rb b/app/models/spree/product_decorator.rb index abc1234..def5678 100644 --- a/app/models/spree/product_decorator.rb +++ b/app/models/spree/product_decorator.rb @@ -1,7 +1,7 @@ Spree::Product.class_eval do def option_values - @_option_values ||= Spree::OptionValue.find_by_sql(["SELECT ov.* FROM spree_option_values ov INNER JOIN spree_option_values_variants ovv ON ovv.option_value_id = ov.id INNER JOIN spree_variants v on ovv.variant_id = v.id WHERE v.product_id = ? ORDER BY v.position", self.id]) + @_option_values ||= Spree::OptionValue.for_product(self).order(:position).sort_by {|ov| ov.option_type.position } end def grouped_option_values
Revert "Order options by variant position" Revert since OptionValue#for_product scope is fixed. Will use a ruby sort instead to sort values by variant position This reverts commit 7a05f0a7a10f62944885da1ba1710d7f4d43c588. Conflicts: app/models/spree/product_decorator.rb
diff --git a/lib/mutant/node_helpers.rb b/lib/mutant/node_helpers.rb index abc1234..def5678 100644 --- a/lib/mutant/node_helpers.rb +++ b/lib/mutant/node_helpers.rb @@ -23,9 +23,9 @@ RAISE = s(:send, nil, :raise) - N_NIL = s(:nil) N_TRUE = s(:true) N_FALSE = s(:false) + N_NIL = s(:nil) N_EMPTY = s(:empty) end # NodeHelpers
Move true and false nodes above nil
diff --git a/app/helpers/pano/application_helper.rb b/app/helpers/pano/application_helper.rb index abc1234..def5678 100644 --- a/app/helpers/pano/application_helper.rb +++ b/app/helpers/pano/application_helper.rb @@ -1,6 +1,17 @@ module Pano module ApplicationHelper + def absolute_root_url + root_url(host: host_without_demo) + end + + def host_without_demo + request.host.gsub(/^demo./, '') + end + + def host_with_demo + 'demo.' + host_without_demo + end end end
Put back demo account helpers
diff --git a/app/controllers/spree/admin/return_authorizations_controller.rb b/app/controllers/spree/admin/return_authorizations_controller.rb index abc1234..def5678 100644 --- a/app/controllers/spree/admin/return_authorizations_controller.rb +++ b/app/controllers/spree/admin/return_authorizations_controller.rb @@ -0,0 +1,24 @@+module Spree + module Admin + class ReturnAuthorizationsController < ResourceController + belongs_to 'spree/order', find_by: :number + + update.after :associate_inventory_units + create.after :associate_inventory_units + + def fire + @return_authorization.public_send("#{params[:e]}!") + flash[:success] = Spree.t(:return_authorization_updated) + redirect_to :back + end + + protected + + def associate_inventory_units + (params[:return_quantity] || []).each do |variant_id, qty| + @return_authorization.add_variant(variant_id.to_i, qty.to_i) + end + end + end + end +end
Bring return authorizations controller from spree_backend
diff --git a/importu.gemspec b/importu.gemspec index abc1234..def5678 100644 --- a/importu.gemspec +++ b/importu.gemspec @@ -8,8 +8,11 @@ s.authors = ["Daniel Hedlund"] s.email = ["daniel@digitree.org"] s.homepage = "https://github.com/dhedlund/importu" - s.summary = "A framework for importing data" - s.description = "Importu is a framework for importing data" + s.summary = "Because an import should be defined by a contract, not " + + "a sequence of commands" + s.description = "Importu simplifies the process of defining and sharing " + + "contracts that structured data must conform to in order " + + "to be importable into your application." s.files = `git ls-files`.split("\n") s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
Update gemspec with better descriptions of the gem
diff --git a/app/models/renalware/clinics/clinic.rb b/app/models/renalware/clinics/clinic.rb index abc1234..def5678 100644 --- a/app/models/renalware/clinics/clinic.rb +++ b/app/models/renalware/clinics/clinic.rb @@ -8,8 +8,12 @@ include Accountable acts_as_paranoid - has_many :clinic_visits, dependent: :restrict_with_exception - has_many :appointments, dependent: :restrict_with_exception + # The dependent option is not really compatible with acts_as_paranoid + # rubocop:disable Rails/HasManyOrHasOneDependent + has_many :clinic_visits + has_many :appointments + # rubocop:enable Rails/HasManyOrHasOneDependent + belongs_to :default_modality_description, class_name: "Modalities::Description" validates :name, presence: true, uniqueness: true
Remove :dependent option from has_many on Clinic Removed `dependent: :restrict_with_exception` as this is incompatible with acts_as_paranoid and causes a ActiveRecord::DeleteRestrictionError error to be raised.
diff --git a/cookbooks/geoipupdate/attributes/default.rb b/cookbooks/geoipupdate/attributes/default.rb index abc1234..def5678 100644 --- a/cookbooks/geoipupdate/attributes/default.rb +++ b/cookbooks/geoipupdate/attributes/default.rb @@ -1,9 +1,5 @@ default[:geoipupdate][:account] = "149244" default[:geoipupdate][:editions] = %w[GeoLite2-ASN GeoLite2-City GeoLite2-Country] -default[:geoipupdate][:directory] = if node[:lsb][:release].to_f < 22.04 - "/usr/share/GeoIP" - else - "/var/lib/GeoIP" - end +default[:geoipupdate][:directory] = "/usr/share/GeoIP" default[:apt][:sources] |= ["maxmind"]
Correct path to geoip directory on 22.04
diff --git a/puppet-lint-absolute_template_path.gemspec b/puppet-lint-absolute_template_path.gemspec index abc1234..def5678 100644 --- a/puppet-lint-absolute_template_path.gemspec +++ b/puppet-lint-absolute_template_path.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |spec| spec.name = 'puppet-lint-absolute_template_path' - spec.version = '1.0.0' + spec.version = '1.0.1' spec.homepage = 'https://github.com/deanwilson/puppet-lint-absolute_template_path' spec.license = 'MIT' spec.author = 'Dean Wilson' @@ -15,11 +15,11 @@ spec.summary = 'puppet-lint absolute template path check' spec.description = <<-EOF A new check for puppet-lint that checks all template paths are in the - template('example/template.erb') form rather than + template('example/template.erb') form rather than template('/etc/puppet/modules/example/templates/template.erb') EOF - spec.add_dependency 'puppet-lint', '~> 1.1' + spec.add_dependency 'puppet-lint', '>= 1.1', '< 3.0' spec.add_development_dependency 'rspec', '~> 3.0' spec.add_development_dependency 'rspec-its', '~> 1.0' spec.add_development_dependency 'rspec-collection_matchers', '~> 1.0'
Allow puppet-lint 2.0 as a dependency and bump check version
diff --git a/app/helpers/galleries_helper.rb b/app/helpers/galleries_helper.rb index abc1234..def5678 100644 --- a/app/helpers/galleries_helper.rb +++ b/app/helpers/galleries_helper.rb @@ -1,5 +1,5 @@ module GalleriesHelper def writable? - !(@gallery.read_only && !@boss_token) + @gallery && !(@gallery.read_only && !@boss_token) end end
Enable use of "writable?" helper without gallery set.
diff --git a/app/services/order_checkout_restart.rb b/app/services/order_checkout_restart.rb index abc1234..def5678 100644 --- a/app/services/order_checkout_restart.rb +++ b/app/services/order_checkout_restart.rb @@ -13,7 +13,7 @@ clear_shipments clear_payments - order.reload + order.reload.update! end private
Update order totals after deleting shipments and payments
diff --git a/Casks/intellij-idea-eap.rb b/Casks/intellij-idea-eap.rb index abc1234..def5678 100644 --- a/Casks/intellij-idea-eap.rb +++ b/Casks/intellij-idea-eap.rb @@ -1,19 +1,19 @@ cask :v1 => 'intellij-idea-eap' do - version '141.1531.2' - sha256 '66fe6dcc84508cac655cac251975e69075ed1b0a80e9bf2baaa02b2a0b33c98d' + version '142.2491.4' + sha256 'a7ce7ec03940b775963cfaf69b2e39bae23a98746691ef9e84b59c8c00d494ff' - url "http://download-cf.jetbrains.com/idea/ideaIU-#{version}.dmg" - homepage 'https://confluence.jetbrains.com/display/IDEADEV/IDEA+14.1+EAP' + url "https://download.jetbrains.com/idea/ideaIU-#{version}-custom-jdk-bundled.dmg" + name 'IntelliJ IDEA EAP' + homepage 'https://confluence.jetbrains.com/display/IDEADEV/IDEA+15+EAP' license :commercial - app 'IntelliJ IDEA 14 EAP.app' - - postflight do - plist_set(':JVMOptions:JVMVersion', '1.6+') - end + app 'IntelliJ IDEA 15 EAP.app' zap :delete => [ - '~/Library/Application Support/IntelliJIdea14', - '~/Library/Preferences/IntelliJIdea14', + '~/Library/Preferences/com.jetbrains.intellij.plist', + '~/Library/Application Support/IntelliJIdea15', + '~/Library/Preferences/IntelliJIdea15', + '~/Library/Caches/IntelliJIdea15', + '~/Library/Logs/IntelliJIdea15', ] end
Update IntelliJ EAP to 15; version 142.2491.4.
diff --git a/spec/lib/champaign_queue/clients/sqs_spec.rb b/spec/lib/champaign_queue/clients/sqs_spec.rb index abc1234..def5678 100644 --- a/spec/lib/champaign_queue/clients/sqs_spec.rb +++ b/spec/lib/champaign_queue/clients/sqs_spec.rb @@ -2,10 +2,10 @@ describe ChampaignQueue::Clients::Sqs do context "with SQS_QUEUE_URL" do - xit "delivers payload to AWS SQS Queue" do + it "delivers payload to AWS SQS Queue" do expected_arguments = { - queue_url: "http://example.com", + queue_url: ENV['SQS_QUEUE_URL'], message_body: {foo: :bar}.to_json }
Fix broken spec - push to test CircleCI autodeploy
diff --git a/db/migrate/20170403073501_add_variant_to_journal_entry_items.rb b/db/migrate/20170403073501_add_variant_to_journal_entry_items.rb index abc1234..def5678 100644 --- a/db/migrate/20170403073501_add_variant_to_journal_entry_items.rb +++ b/db/migrate/20170403073501_add_variant_to_journal_entry_items.rb @@ -1,5 +1,42 @@ class AddVariantToJournalEntryItems < ActiveRecord::Migration - def change + def up add_column :journal_entry_items, :variant_id, :integer + + #  historic resumption + execute 'UPDATE journal_entry_items AS jei' \ + ' SET variant_id = pi.variant_id' \ + ' FROM' \ + ' journal_entries AS je' \ + ' JOIN purchases AS p ON p.journal_entry_id = je.id' \ + ' JOIN purchase_items AS pi ON pi.purchase_id = p.id' \ + ' WHERE je.id = jei.entry_id' \ + + + execute 'UPDATE journal_entry_items AS jei' \ + ' SET variant_id = si.variant_id' \ + ' FROM' \ + ' journal_entries AS je' \ + ' JOIN sales AS s ON s.journal_entry_id = je.id' \ + ' JOIN sale_items AS si ON si.sale_id = s.id' \ + ' WHERE je.id = jei.entry_id' \ + + + # execute 'UPDATE journal_entry_items AS jei' \ + # " SET variant_id = ii.variant_id" \ + # ' FROM' \ + # ' journal_entries AS je' \ + # ' JOIN inventories AS i ON i.journal_entry_id = je.id' \ + # ' JOIN inventory_items AS ii ON ii.inventory_id = i.id' \ + # ' WHERE je.id = jei.entry_id' \ + + execute 'UPDATE journal_entry_items AS jei' \ + ' SET variant_id = pi.variant_id' \ + ' FROM' \ + ' journal_entries AS je' \ + ' JOIN parcels AS p ON p.journal_entry_id = je.id' \ + ' JOIN parcel_items AS pi ON pi.parcel_id = p.id' \ + ' WHERE je.id = jei.entry_id' \ end + + def down; end end
Add historic resumption for jei variant
diff --git a/spec/lib/nabokov/helpers/cork_helper_spec.rb b/spec/lib/nabokov/helpers/cork_helper_spec.rb index abc1234..def5678 100644 --- a/spec/lib/nabokov/helpers/cork_helper_spec.rb +++ b/spec/lib/nabokov/helpers/cork_helper_spec.rb @@ -0,0 +1,33 @@+require 'nabokov/helpers/cork_helper' + +describe Nabokov::CorkHelper do + let(:ui) { object_double(Cork::Board.new(silent: true, verbose: true)) } + + describe "show_prompt" do + it "prints bold greed symbol" do + expect(ui).to receive(:print).with("> ".bold.green) + Nabokov::CorkHelper.new(ui).show_prompt + end + end + + describe "say" do + it "prints plain message" do + expect(ui).to receive(:puts).with("Hey!") + Nabokov::CorkHelper.new(ui).say("Hey!") + end + end + + describe "inform" do + it "prints green message" do + expect(ui).to receive(:puts).with("Nabokov is working".green) + Nabokov::CorkHelper.new(ui).inform("Nabokov is working") + end + end + + describe "error" do + it "prints red message" do + expect(ui).to receive(:puts).with("Something went wrong".red) + Nabokov::CorkHelper.new(ui).error("Something went wrong") + end + end +end
Add simple tests for CorkHelper;
diff --git a/lib/scanny/checks/check.rb b/lib/scanny/checks/check.rb index abc1234..def5678 100644 --- a/lib/scanny/checks/check.rb +++ b/lib/scanny/checks/check.rb @@ -20,6 +20,10 @@ def issue(impact, message, options = {}) @issues << Issue.new(@file, @line, impact, message, options[:cwe]) end + + def strict? + false + end end end end
Check should not be strict by default
diff --git a/app/models/enhancements/user.rb b/app/models/enhancements/user.rb index abc1234..def5678 100644 --- a/app/models/enhancements/user.rb +++ b/app/models/enhancements/user.rb @@ -6,13 +6,17 @@ def record_action(edition, type, options = {}) action = record_action_without_noise(edition, type, options) - NoisyWorkflow.make_noise(action).deliver - NoisyWorkflow.request_fact_check(action).deliver if type.to_s == "send_fact_check" + make_record_action_noises(action, type) end def record_action_without_validation(edition, type, options={}) action = record_action_without_validation_without_noise(edition, type, options) - NoisyWorkflow.make_noise(action).deliver - NoisyWorkflow.request_fact_check(action).deliver if type.to_s == "send_fact_check" + make_record_action_noises(action, type) end + + private + def make_record_action_noises(action, type) + NoisyWorkflow.make_noise(action).deliver + NoisyWorkflow.request_fact_check(action).deliver if type.to_s == "send_fact_check" + end end
Remove duplication of NoisyWorkflow invocations We want these two methods to be as similar as possible, so sharing more code without duplication is a good thing.
diff --git a/config/initializers/new_rails_defaults.rb b/config/initializers/new_rails_defaults.rb index abc1234..def5678 100644 --- a/config/initializers/new_rails_defaults.rb +++ b/config/initializers/new_rails_defaults.rb @@ -2,10 +2,10 @@ # for Rails 3. You can remove this initializer when Rails 3 is released. # Include Active Record class name as root for JSON serialized output. -ActiveRecord::Base.include_root_in_json = true +# ActiveRecord::Base.include_root_in_json = true # Store the full class name (including module namespace) in STI type column. -ActiveRecord::Base.store_full_sti_class = true +# ActiveRecord::Base.store_full_sti_class = true # Use ISO 8601 format for JSON serialized times and dates. ActiveSupport.use_standard_json_time_format = true
Comment out new AR defaults for Rails 3 Signed-off-by: Alex Coles <60c6d277a8bd81de7fdde19201bf9c58a3df08f4@alexcolesportfolio.com>
diff --git a/actiontext/lib/action_text/engine.rb b/actiontext/lib/action_text/engine.rb index abc1234..def5678 100644 --- a/actiontext/lib/action_text/engine.rb +++ b/actiontext/lib/action_text/engine.rb @@ -34,13 +34,16 @@ end end - initializer "action_text.renderer" do + initializer "action_text.renderer" do |app| + app.executor.to_run { ActionText::Content.renderer = ApplicationController.renderer } + app.executor.to_complete { ActionText::Content.renderer = ApplicationController.renderer } + ActiveSupport.on_load(:action_text_content) do - self.renderer ||= ApplicationController.renderer + self.renderer = ApplicationController.renderer end ActiveSupport.on_load(:action_controller_base) do - before_action { ActionText::Content.renderer = ActionText::Content.renderer.new(request.env) } + before_action { ActionText::Content.renderer = ApplicationController.renderer.new(request.env) } end end end
Reset ActionText::Content.renderer before and after each request
diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index abc1234..def5678 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -27,9 +27,7 @@ @group = Group.new(group_params) respond_to do |format| if @group.save - user_group = UserGroup.new(user: current_user, group: @group) - user_group.update(is_leader: true) - user_group.save + user_group = UserGroup.create(user: current_user, group: @group, is_leader: true) format.html { redirect_to @group, notice: "Group was successfully created." } else format.html { render :new }
Change new to create for user_group in create method
diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index abc1234..def5678 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -1,7 +1,7 @@ class SearchController < ApplicationController def search # TODO: get "undefined method `sphinx_index_options'" when Person and any other class is given??? - @people = ThinkingSphinx.search(params[:query], :classes => [Person]) - @invoices = ThinkingSphinx.search(params[:query], :classes => [Invoice]) + @people = ThinkingSphinx.search(params[:query], :classes => [Person], :star => true) + @invoices = ThinkingSphinx.search(params[:query], :classes => [Invoice], :star => true) end end
Allow partial matches in global search.
diff --git a/core/app/interactors/commands/users/anonymize_user_model.rb b/core/app/interactors/commands/users/anonymize_user_model.rb index abc1234..def5678 100644 --- a/core/app/interactors/commands/users/anonymize_user_model.rb +++ b/core/app/interactors/commands/users/anonymize_user_model.rb @@ -12,8 +12,8 @@ user[field] = User.fields[field].default_val end - user.first_name = 'anonymous' - user.last_name = 'anonymous' + user.first_name = 'Deleted' + user.last_name = 'user' user.password = 'some_password_henk_gerard_gerrit' user.password_confirmation = 'some_password_henk_gerard_gerrit'
Call deleted users "Deleted user"
diff --git a/examples/eventmachine_adapter/error_handling/handling_a_channel_level_exception.rb b/examples/eventmachine_adapter/error_handling/handling_a_channel_level_exception.rb index abc1234..def5678 100644 --- a/examples/eventmachine_adapter/error_handling/handling_a_channel_level_exception.rb +++ b/examples/eventmachine_adapter/error_handling/handling_a_channel_level_exception.rb @@ -0,0 +1,41 @@+#!/usr/bin/env ruby +# encoding: utf-8 + +__dir = File.dirname(File.expand_path(__FILE__)) +require File.join(__dir, "..", "example_helper") + +amq_client_example "Declare a new fanout exchange" do |connection| + channel = AMQ::Client::Channel.new(connection, 1) + channel.open do + puts "Channel #{channel.id} is now open!" + + channel.on_error do |ch, close| + puts "Handling a channel-level exception: #{close.reply_text}" + end + + EventMachine.add_timer(0.4) do + # these two definitions result in a race condition. For sake of this example, + # however, it does not matter. Whatever definition succeeds first, 2nd one will + # cause a channel-level exception (because attributes are not identical) + AMQ::Client::Queue.new(connection, channel, "amqpgem.examples.channel_exception").declare(false, false, false, true) do |queue| + puts "#{queue.name} is ready to go" + end + + AMQ::Client::Queue.new(connection, channel, "amqpgem.examples.channel_exception").declare(false, true, false, false) do |queue| + puts "#{queue.name} is ready to go" + end + end + end + + + show_stopper = Proc.new do + $stdout.puts "Stopping..." + + connection.close { + EM.stop { exit } + } + end + + Signal.trap "INT", show_stopper + EM.add_timer(2, show_stopper) +end
Add a channel-level exception handling example
diff --git a/RMActionController.podspec b/RMActionController.podspec index abc1234..def5678 100644 --- a/RMActionController.podspec +++ b/RMActionController.podspec @@ -6,7 +6,7 @@ s.screenshots = "http://cooperrs.github.io/RMActionViewController/Images/Blur-Screen-Portrait.png", "http://cooperrs.github.io/RMActionViewController/Images/Blur-Screen-Landscape.png", "http://cooperrs.github.io/RMActionViewController/Images/Blur-Screen-Portrait-Black.png" s.license = { :type => 'MIT', :file => 'LICENSE' } s.author = { "Roland Moers" => "rm@cooperrs.de" } - s.source = { :git => "https://github.com/CooperRS/RMActionViewController.git", :tag => "1.0.0" } + s.source = { :git => "https://github.com/CooperRS/RMActionViewController.git", :head } s.source_files = 'RMActionViewController/*' s.platform = :ios, '8.0' s.requires_arc = true
Use git head for now in podspec file
diff --git a/db/migrate/20151010182141_add_archive_reason_to_projects.rb b/db/migrate/20151010182141_add_archive_reason_to_projects.rb index abc1234..def5678 100644 --- a/db/migrate/20151010182141_add_archive_reason_to_projects.rb +++ b/db/migrate/20151010182141_add_archive_reason_to_projects.rb @@ -0,0 +1,6 @@+class AddArchiveReasonToProjects < ActiveRecord::Migration + def change + add_column :projects, :archived_reason, :string + add_column :projects, :archived_by_user_id, :integer + end +end
Add archive columns to project
diff --git a/lib/tasks/canvas_pact.rake b/lib/tasks/canvas_pact.rake index abc1234..def5678 100644 --- a/lib/tasks/canvas_pact.rake +++ b/lib/tasks/canvas_pact.rake @@ -15,16 +15,14 @@ PactBroker::Client::PublicationTask.new(:jenkins_post_merge) do |task| format_rake_task( task, - ENV.fetch('PACT_BROKER_BASE_URL'), - ENV.fetch('PACT_BROKER_BASIC_AUTH_USERNAME'), - ENV.fetch('PACT_BROKER_BASIC_AUTH_PASSWORD'), + ENV.fetch('PACT_BROKER_HOST'), + ENV.fetch('PACT_BROKER_USERNAME'), + ENV.fetch('PACT_BROKER_PASSWORD'), 'master' ) end def format_rake_task(task, url, username, password, task_tag) - require 'quiz_api_client' - task.consumer_version = CanvasApiClient::VERSION task.pattern = 'pacts/*.json'
spec: Modify cnvas_rake file for pact Test Plan: -- Passes Jenkins Change-Id: I55c8cc6d0a742afd330e54c6c1c74d08cd6332ef Reviewed-on: https://gerrit.instructure.com/153898 Reviewed-by: Anju Reddy <851202533fb1f0b615e4547ba226c76996d060dd@instructure.com> Tested-by: Jenkins Product-Review: Deepeeca Soundarrajan <5bcd4b623f00b7fc2942cd1c65c245b30a48a61f@instructure.com> QA-Review: Deepeeca Soundarrajan <5bcd4b623f00b7fc2942cd1c65c245b30a48a61f@instructure.com>
diff --git a/lib/active_admin_import/import_result.rb b/lib/active_admin_import/import_result.rb index abc1234..def5678 100644 --- a/lib/active_admin_import/import_result.rb +++ b/lib/active_admin_import/import_result.rb @@ -28,8 +28,8 @@ total == 0 end - def failed_message(limit: nil) - limit ||= failed.count + def failed_message(options = {}) + limit = options.fetch(:limit, failed.count) failed.first(limit).map{|record| errors = record.errors (errors.full_messages.zip errors.keys.map{|k| record.send k}).map{|ms| ms.join(' - ')}.join(', ')
Remove keyword argument to make Ruby 1.9 compatible
diff --git a/lib/app/helpers/google_closure_helper.rb b/lib/app/helpers/google_closure_helper.rb index abc1234..def5678 100644 --- a/lib/app/helpers/google_closure_helper.rb +++ b/lib/app/helpers/google_closure_helper.rb @@ -5,6 +5,7 @@ unless ActionController::Base.perform_caching closure_base_path = File.join(GoogleClosureCompiler.closure_library_path, 'goog') out << "<script src='#{File.join('/javascripts', closure_base_path, 'base.js')}' type='text/javascript'></script>" + out << "<script type='text/javascript'>goog.require('goog.events');</script>" end out << javascript_include_tag(file_path, :cache => "cache/closure/#{file_path.delete('.js')}") out
Include google events scripts in dev environment
diff --git a/lib/fucking_scripts_digital_ocean/scp.rb b/lib/fucking_scripts_digital_ocean/scp.rb index abc1234..def5678 100644 --- a/lib/fucking_scripts_digital_ocean/scp.rb +++ b/lib/fucking_scripts_digital_ocean/scp.rb @@ -16,7 +16,14 @@ private def create_local_archive - includes = @opts.fetch(:files) + @opts.fetch(:scripts) + files = @opts[:files] || [] + scripts = @opts[:scripts] || [] + includes = files + scripts + + if includes.empty? + raise "Both files and scripts are empty. You should provide some" + end + `tar -czf #{FILENAME} #{includes.join(" ")}` end
Allow user to optionally skip either files or scripts
diff --git a/build/clojars/bin/push-to-clojars.rb b/build/clojars/bin/push-to-clojars.rb index abc1234..def5678 100644 --- a/build/clojars/bin/push-to-clojars.rb +++ b/build/clojars/bin/push-to-clojars.rb @@ -0,0 +1,21 @@+#!/usr/bin/env ruby + +Dir["target/*"].each do |dir| + if File.directory?(dir) + puts "Processing #{dir}..." + Dir.chdir(dir) do + if File.exists?("project.clj") + puts "-> generating pom..." + %x{lein pom} + cmd = "scp pom.xml *.jar clojars@clojars.org:" + puts "-> #{cmd}" + %x{#{cmd}} + else + puts "-> No project.clj found in #{dir} - skipping" + end + end + end +end + + +
Add script to facilitate pushing to clojars going forward.
diff --git a/Library/Formula/tarsnap.rb b/Library/Formula/tarsnap.rb index abc1234..def5678 100644 --- a/Library/Formula/tarsnap.rb +++ b/Library/Formula/tarsnap.rb @@ -8,9 +8,8 @@ depends_on 'lzma' => :optional def install - system "./configure", "--disable-debug", "--disable-dependency-tracking", - "--prefix=#{prefix}", - "--enable-sse2" + system "./configure", "--disable-dependency-tracking", + "--prefix=#{prefix}" system "make install" end end
Tarsnap: Remove --enable-sse2 and --disable-debug flags * The --enable-sse2 flag causes the compile to hang when the llvm-gcc compiler that comes with Xcode 4 is used. * The configure script doesn't recognize the --disable-debug option Signed-off-by: Adam Vandenberg <34c2b6407fd5a10249a15d699d40f9ed1782e98c@gmail.com>
diff --git a/lib/van_helsing/bundler.rb b/lib/van_helsing/bundler.rb index abc1234..def5678 100644 --- a/lib/van_helsing/bundler.rb +++ b/lib/van_helsing/bundler.rb @@ -9,7 +9,7 @@ queue %{ echo "-----> Installing gem dependencies using Bundler" mkdir -p "#{shared_path}/bundle" - mkdir -p "#{release_path}/vendor" + mkdir -p "./vendor" ln -s "#{shared_path}/bundle" "#{bundle_path}" bundle install #{bundle_options} }
Make bundle:install not dependent on release_path.
diff --git a/config/unicorn.example.rb b/config/unicorn.example.rb index abc1234..def5678 100644 --- a/config/unicorn.example.rb +++ b/config/unicorn.example.rb @@ -12,8 +12,8 @@ listen "127.0.0.1:3402" pid "#{shared_path}/pids/unicorn.pid" -stderr_path "#{shared_path}/logs/unicorn.stderr.log" -stdout_path "#{shared_path}/logs/unicorn.stdout.log" +stderr_path "#{shared_path}/log/unicorn.stderr.log" +stdout_path "#{shared_path}/log/unicorn.stdout.log" before_fork do |server, worker| Signal.trap 'TERM' do
Fix log dir in unicorn config
diff --git a/lib/vocker/cap/linux/docker_installed.rb b/lib/vocker/cap/linux/docker_installed.rb index abc1234..def5678 100644 --- a/lib/vocker/cap/linux/docker_installed.rb +++ b/lib/vocker/cap/linux/docker_installed.rb @@ -4,7 +4,7 @@ module Linux module DockerInstalled def self.docker_installed(machine) - machine.communicate.test("test -d /var/lib/docker", sudo: true) + machine.communicate.test("test -f /usr/bin/docker", sudo: true) end end end
Improve checking for whether docker is installed
diff --git a/_plugins/tag_pagination.rb b/_plugins/tag_pagination.rb index abc1234..def5678 100644 --- a/_plugins/tag_pagination.rb +++ b/_plugins/tag_pagination.rb @@ -4,7 +4,7 @@ def generate(site) site.tags.dup.each do |tag, posts| - paginate(site, tag, posts.reverse) + paginate(site, tag, posts.sort { |a, b| b.date <=> a.date }) end end
Sort posts in descending order
diff --git a/core/objectspace/weakmap/shared/include.rb b/core/objectspace/weakmap/shared/include.rb index abc1234..def5678 100644 --- a/core/objectspace/weakmap/shared/include.rb +++ b/core/objectspace/weakmap/shared/include.rb @@ -20,13 +20,15 @@ map.send(@method, key2).should == false end - ruby_bug "#16826", "2.7.0"..."2.8.1" do - it "reports true if the pair exists and the value is nil" do - map = ObjectSpace::WeakMap.new - key = Object.new - map[key] = nil - map.size.should == 1 - map.send(@method, key).should == true + ruby_version_is "2.7" do + ruby_bug "#16826", "2.7.0"..."2.8.1" do + it "reports true if the pair exists and the value is nil" do + map = ObjectSpace::WeakMap.new + key = Object.new + map[key] = nil + map.size.should == 1 + map.send(@method, key).should == true + end end end end
Add missing version guard, frozen values are not accepted before 2.7
diff --git a/cookbooks/hardware/attributes/default.rb b/cookbooks/hardware/attributes/default.rb index abc1234..def5678 100644 --- a/cookbooks/hardware/attributes/default.rb +++ b/cookbooks/hardware/attributes/default.rb @@ -7,7 +7,7 @@ case dmi.system.product_name when "ProLiant DL360 G6", "ProLiant DL360 G7" - default[:hardware][:sensors][:power][:power1] = { :ignore => true } + default[:hardware][:sensors]["power_meter-*"][:power]["power1"] = { :ignore => true } end end end
Fix disabling of power meter on G6 machines
diff --git a/silverpop.gemspec b/silverpop.gemspec index abc1234..def5678 100644 --- a/silverpop.gemspec +++ b/silverpop.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |s| s.name = "silverpop" - s.version = "1.0.0" + s.version = "1.1.1" s.date = "2010-01-14" s.summary = "Silverpop Engage and Transact API -- Extracted from ShoeDazzle.com" s.email = "george@georgetruong.com"
Set the correct gem version to 1.1.1
diff --git a/app/models/content_base.rb b/app/models/content_base.rb index abc1234..def5678 100644 --- a/app/models/content_base.rb +++ b/app/models/content_base.rb @@ -12,6 +12,6 @@ validates :body, presence: true - attr_accessible :body + attr_accessible :body, :link_id end end
Make link_id mass-assignable on contents
diff --git a/app/helpers/carto/bolt.rb b/app/helpers/carto/bolt.rb index abc1234..def5678 100644 --- a/app/helpers/carto/bolt.rb +++ b/app/helpers/carto/bolt.rb @@ -0,0 +1,49 @@+# encoding utf-8 + +module Carto + class Bolt + DEFAULT_REDIS_OBJECT = $users_metadata + DEFAULT_TTL_MS = 10000 + + def initialize(bolt_key, redis_object: DEFAULT_REDIS_OBJECT, ttl_ms: DEFAULT_TTL_MS) + @bolt_key = add_namespace_to_key(bolt_key) + @redis_object = redis_object + @ttl_ms = ttl_ms + end + + def lock + is_locked = @redis_object.set(@bolt_key, true, px: @ttl_ms, nx: true) + + if block_given? + begin + yield is_locked + !!is_locked + ensure + unlock if is_locked + end + else + is_locked + end + end + + def unlock + removed_keys = @redis_object.del(@bolt_key) + + if removed_keys > 1 + CartoDB.notify_error('Removed bolt key was duplicated', bolt_key: @bolt_key, amount: removed_keys) + end + + removed_keys > 0 ? true : false + end + + def info + { ttl_ms: @ttl_ms, bolt_key: @bolt_key } + end + + protected + + def add_namespace_to_key(key) + "rails:bolt:#{key}" + end + end +end
Add own redis lock implementation
diff --git a/app/models/my_gene_info.rb b/app/models/my_gene_info.rb index abc1234..def5678 100644 --- a/app/models/my_gene_info.rb +++ b/app/models/my_gene_info.rb @@ -16,7 +16,7 @@ end def self.my_gene_info_url(entrez_id) - "http://mygene.info/v2/gene/#{entrez_id}?fields=name,symbol,alias,interpro,pathway,summary,genomic_pos_hg19" + "http://mygene.info/v2/gene/#{entrez_id}?fields=name,symbol,alias,interpro,pathway,summary,genomic_pos_hg19,uniprot" end def self.cache_key(gene_id)
Add uniprot identifiers to mygene.info endpoint query
diff --git a/app/models/news_article.rb b/app/models/news_article.rb index abc1234..def5678 100644 --- a/app/models/news_article.rb +++ b/app/models/news_article.rb @@ -21,7 +21,7 @@ def image_must_have_a_description if image.present? && image_alt_text.blank? - errors.add :image_alt_text, 'All images must have a description' + errors.add :image_alt_text, 'must be provided' end end
Clean up validation failure message when alt-text is missing
diff --git a/app/models/shell_runner.rb b/app/models/shell_runner.rb index abc1234..def5678 100644 --- a/app/models/shell_runner.rb +++ b/app/models/shell_runner.rb @@ -19,6 +19,7 @@ # Within the production environment, it could be the case the environment variables pollute # the process and cause vagrant commands to fail # Other variables are: `GEM_HOME='' BUNDLE_GEMFILE='' RUBYLIB='' BUNDLER_VERSION='' BUNDLE_BIN_PATH=''` + # See https://github.com/mitchellh/vagrant/issues/6158 def reset_env "RUBYLIB='' " end
Add Github issue reference for `RUBYLIB` variable
diff --git a/action_mailer_stop.gemspec b/action_mailer_stop.gemspec index abc1234..def5678 100644 --- a/action_mailer_stop.gemspec +++ b/action_mailer_stop.gemspec @@ -10,7 +10,7 @@ spec.email = ["adrien.siami@dimelo.com"] spec.description = "Call 'stop!' from an ActionMailer class to abort the delivery of your email" spec.summary = "Call 'stop!' from an ActionMailer class to abort the delivery of your email" - spec.homepage = "" + spec.homepage = "https://github.com/dimelo/action_mailer_stop" spec.license = "MIT" spec.files = `git ls-files`.split($/)
Add link to github repo
diff --git a/benchmarks.rb b/benchmarks.rb index abc1234..def5678 100644 --- a/benchmarks.rb +++ b/benchmarks.rb @@ -1,33 +1,13 @@-$:.unshift(File.dirname(__FILE__) + '/lib') -require 'rubygems' +require 'spec/spec_helper' require 'logger' -require 'delayed_job' require 'benchmark' -RAILS_ENV = 'test' - -Delayed::Worker.logger = Logger.new('/dev/null') - -BACKENDS = [] -Dir.glob("#{File.dirname(__FILE__)}/spec/setup/*.rb") do |backend| - begin - backend = File.basename(backend, '.rb') - require "spec/setup/#{backend}" - BACKENDS << backend.to_sym - rescue LoadError - puts "Unable to load #{backend} backend! #{$!}" - end -end - +# Delayed::Worker.logger = Logger.new('/dev/null') Benchmark.bm(10) do |x| - BACKENDS.each do |backend| - require "spec/setup/#{backend}" - Delayed::Worker.backend = backend - - n = 10000 - n.times { "foo".delay.length } + Delayed::Job.delete_all + n = 10000 + n.times { "foo".delay.length } - x.report(backend.to_s) { Delayed::Worker.new(:quiet => true).work_off(n) } - end + x.report { Delayed::Worker.new(:quiet => true).work_off(n) } end
Update benchmark to just run AR backend
diff --git a/app/models/rez/section.rb b/app/models/rez/section.rb index abc1234..def5678 100644 --- a/app/models/rez/section.rb +++ b/app/models/rez/section.rb @@ -1,5 +1,6 @@ module Rez class Section < ActiveRecord::Base + validates :name, presence: true def items Item.where(id: item_ids)
Add name presence validation to Section.
diff --git a/app/models/transaction.rb b/app/models/transaction.rb index abc1234..def5678 100644 --- a/app/models/transaction.rb +++ b/app/models/transaction.rb @@ -1,4 +1,8 @@ class Transaction < ActiveRecord::Base + include ActionView::Helpers::DateHelper + + after_create :trigger_message + belongs_to :request validates :transaction_type, inclusion: { in: ['request', 'response', 'fulfillment'] } @@ -18,4 +22,47 @@ def pretty_date time_ago_in_words(created_at) end -end+ + def trigger_message + request_obj = self.request + + case self.transaction_type + when "request" + trigger_request_message(request_obj) + when "response" + trigger_response_message(request_obj) + when "fulfillment" + trigger_fulfillment_message(request_obj) + end + end + + def trigger_request_message(request) + Pusher["presence-#{request.group.id}"].trigger('new_transaction', { + class: 'profpic', + height: '100', + width: '100', + align: 'left', + src: request.requester.picture, + request_text: request_text, + requester_link: "/users/#{request.requester.id}", + requester_first_name: request.requester.first_name, + time: pretty_date + }) + end + + def trigger_response_message(request) + end + + def trigger_fulfillment_message(request) + end + + def request_text + ['cried out for help', + 'sent an SOS', + 'made a request', + 'shouted for aid', + 'sent out a smoke signal', + 'pinged neighbors', + 'lit the beacons'].sample + end +end
Add ability to trigger a message to other users.
diff --git a/spec/view_spec.rb b/spec/view_spec.rb index abc1234..def5678 100644 --- a/spec/view_spec.rb +++ b/spec/view_spec.rb @@ -2,8 +2,12 @@ describe Hyperloop::View do before :each do - @html_view = Hyperloop::View.new('spec/fixtures/simple/app/views/about.html') - @erb_view = Hyperloop::View.new('spec/fixtures/erb/app/views/about.html.erb') + @html_view = Hyperloop::View.new('spec/fixtures/simple/app/views/about.html') + @erb_view = Hyperloop::View.new('spec/fixtures/erb/app/views/about.html.erb') + @layout_view = Hyperloop::View.new( + 'spec/fixtures/layouts/app/views/index.html.erb', + 'spec/fixtures/layouts/app/views/layouts/application.html.erb' + ) end describe '#format' do @@ -32,7 +36,14 @@ end it 'renders ERB files' do - expect(text_in(@erb_view.render, 'h1')).to match('I was born on December 21') + expect(text_in(@erb_view.render, 'h1')).to eql('I was born on December 21') + end + + it 'renders ERB files in layouts' do + html = @layout_view.render + + expect(text_in(html, 'h1')).to eql('Layout Header') + expect(text_in(html, 'h2')).to eql('This is the root page!') end end end
Add view spec for layouts
diff --git a/app/requests/rubycasts.rb b/app/requests/rubycasts.rb index abc1234..def5678 100644 --- a/app/requests/rubycasts.rb +++ b/app/requests/rubycasts.rb @@ -7,10 +7,12 @@ use Rack::CommonLogger, logger_file! use OmniAuth::Strategies::GitHub, Configuration.omni_auth[:client_id], Configuration.omni_auth[:secret] - set :root, File.expand_path(File.join(File.dirname(__FILE__), '..', '..')) - set :views, Proc.new { File.join(root, 'app', "views") } - set :public, Proc.new { File.join(root, "public") } - set :logging, false + configure do + set :root, File.expand_path(File.join(File.dirname(__FILE__), '..', '..')) + set :views, Proc.new { File.join(root, 'app', "views") } + set :public, Proc.new { File.join(root, "public") } + set :logging, false + end enable :sessions
Put all methods in a configure block
diff --git a/db/migrate/2_add_missing_unique_indices.rb b/db/migrate/2_add_missing_unique_indices.rb index abc1234..def5678 100644 --- a/db/migrate/2_add_missing_unique_indices.rb +++ b/db/migrate/2_add_missing_unique_indices.rb @@ -5,7 +5,9 @@ remove_index :taggings, :tag_id remove_index :taggings, [:taggable_id, :taggable_type, :context] - add_index :taggings, [:tag_id, :taggable_id, :taggable_type, :context, :tagger_id, :tagger_type], unique: true, name: 'tagging_idx' + add_index :taggings, + [:tag_id, :taggable_id, :taggable_type, :context, :tagger_id, :tagger_type], + unique: true, name: 'taggings_idx' end def self.down
Format new migration so easier to read
diff --git a/app/controllers/api_controller.rb b/app/controllers/api_controller.rb index abc1234..def5678 100644 --- a/app/controllers/api_controller.rb +++ b/app/controllers/api_controller.rb @@ -1,11 +1,15 @@ class ApiController < ApplicationController - before_action :change_query_order, :add_querying, only: :index + before_action :add_querying, :change_query_order, only: :index @@order = :id @@query = "" def add_querying @@query = (params[:q] == nil) ? "" : "%#{params[:q].downcase}%" + end + + def change_per_page + (params[:per_page].to_i > 100) ? 100 : params[:per_page].to_i end def change_query_order
Add Per Page Method To API Controller Add the per page method to API Controller in order to control how much data is display at one time, the default is 25 per page with a max of 100. The page method is automatically done by API Pagination gem.
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index abc1234..def5678 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -7,9 +7,9 @@ def button_link_to(name = nil, options = {}, html_options = {}, &block) if block_given? + html_options = options + options = name name = capture(&block) - options = name - html_options = options end html_options[:class] ||= "" html_options[:class] += " btn btn-default"
Fix assignment order in button_link_to
diff --git a/lib/admin.rb b/lib/admin.rb index abc1234..def5678 100644 --- a/lib/admin.rb +++ b/lib/admin.rb @@ -0,0 +1,52 @@+#### +## bnc.im administration bot +## +## Copyright (c) 2013, 2014 Andrew Northall +## +## MIT License +## See LICENSE file for details. +#### + + +require 'socket' +require 'openssl' +require 'timeout' + +class Numeric + def duration + secs = self.to_int + mins = secs / 60 + hours = mins / 60 + days = hours / 24 + + if days > 0 + "#{days} day#{'s' unless days == 1} and #{hours % 24} hour#{'s' unless (hours % 24) == 1}" + elsif hours > 0 + "#{hours} hour#{'s' unless (hours % 24) == 1} and #{mins % 60} minute#{'s' unless (mins % 60) == 1}" + elsif mins > 0 + "#{mins} minute#{'s' unless (mins % 60) == 1} and #{secs % 60} second#{'s' unless (secs % 60) == 1}" + elsif secs >= 0 + "#{secs} second#{'s' unless (secs % 60) == 1}" + end + end +end + +class AdminPlugin + include Cinch::Plugin + match "help", method: :help + match /kill (\S+) (.+)$/, method: :kill + listen_to :"376", method: :do_connect + + def do_connect(m) + bot.oper("Cp49tBE2Yex1", user="Electro") + end + def help(m) + m.reply "#{Format(:bold, "[COMMANDS]")} !help !kill" + + end + def kill(m, user, reason) + puts $bots + puts $bots["electrocode"] + bot.irc.send("KILL #{user} #{reason}") + end +end
Revert "Change Admin over to Oper" This reverts commit 31f0bc53577e7c24b74cb3cc011a15c2bdb2d232.
diff --git a/features/step_definitions/flavor_steps.rb b/features/step_definitions/flavor_steps.rb index abc1234..def5678 100644 --- a/features/step_definitions/flavor_steps.rb +++ b/features/step_definitions/flavor_steps.rb @@ -16,6 +16,22 @@ end Given /^a repository '(.+)' with versions '(.+)'$/ do |basename, versions| + repository_path = expand("$tmp/repos/#{basename}") + system <<-"END" + { + mkdir -p '#{repository_path}' && + cd '#{repository_path}' && + git init && + mkdir doc && + for v in #{versions} + do + echo "*#{basename}* $v" >'doc/#{basename}.txt' + git add doc + git commit -m "Version $v" + git tag -m "Version $v" "$v" + done + } >/dev/null + END end Given 'flavorfile' do |content|
Define a step to set up a repository
diff --git a/spec/controllers/pages_controller_spec.rb b/spec/controllers/pages_controller_spec.rb index abc1234..def5678 100644 --- a/spec/controllers/pages_controller_spec.rb +++ b/spec/controllers/pages_controller_spec.rb @@ -1 +1,126 @@-RSpec.describe PagesController, type: :controller do; end +RSpec.describe PagesController, type: :controller do + describe 'GET #home' do + it 'respond to request' do + get :home + + expect(response).to be_success + end + + it 'before_filter' do + blurbs_file = File.read('doc/contributors/blurbs.json') + + expect(JSON).to receive(:parse).with(blurbs_file) + + get :home + end + + context 'logged in' do + let(:user) { create(:user) } + + include_context :logged_in_user + + it 'if has no stories' do + list = double + + expect(Kaminari).to receive(:paginate_array).and_return(list) + expect(list).to receive(:page) + + get :home + end + + it 'if have stories' do + create(:strategy, userid: user.id) + categories = create_list(:category, 2, userid: user.id) + moods = create_list(:mood, 2, userid: user.id) + + get :home + + expect(assigns(:moment)).to be_a_new(Moment) + expect(assigns(:categories)).to eq(categories.reverse) + expect(assigns(:moods)).to eq(moods.reverse) + end + end + + context 'not logged in' do + end + end + + describe 'GET #blog' do + it 'respond to request' do + get :blog + + expect(response).to be_success + end + + it 'read external JSON file' do + data = double([]) + + expect(JSON).to receive(:parse).with(File.read('doc/contributors/posts.json')).and_return(data) + expect(data).to receive(:reverse!) + + get :blog + end + end + + describe 'GET #contributors' do + it 'respond to request' do + get :contributors + + expect(response).to be_success + end + + it 'read external JSON file' do + data = [] + blurbs_file = File.read('doc/contributors/blurbs.json') + contributors_file = File.read('doc/contributors/contributors.json') + + expect(JSON).to receive(:parse).with(blurbs_file) + expect(JSON).to receive(:parse).with(contributors_file).and_return(data) + expect(data).to receive(:sort_by!) + + get :contributors + end + end + + describe 'GET #partners' do + it 'respond to request' do + get :partners + + expect(response).to be_success + end + + it 'read external JSON file' do + data = [] + file = File.read('doc/contributors/partners.json') + + expect(JSON).to receive(:parse).with(file).and_return(data) + expect(data).to receive(:sort_by!) + + get :partners + end + end + + describe 'GET #about' do + it 'respond to request' do + get :about + + expect(response).to be_success + end + end + + describe 'GET #faq' do + it 'respond to request' do + get :faq + + expect(response).to be_success + end + end + + describe 'GET #privacy' do + it 'respond to request' do + get :privacy + + expect(response).to be_success + end + end +end
Add 100% coverage to pages controller
diff --git a/spec/support/action_controller_helpers.rb b/spec/support/action_controller_helpers.rb index abc1234..def5678 100644 --- a/spec/support/action_controller_helpers.rb +++ b/spec/support/action_controller_helpers.rb @@ -1,4 +1,4 @@-require 'actionpack' +require 'action_pack' module ActionControllerHelpers
Fix deprecation warning when requiring action_pack
diff --git a/test/controllers/location_controller_test.rb b/test/controllers/location_controller_test.rb index abc1234..def5678 100644 --- a/test/controllers/location_controller_test.rb +++ b/test/controllers/location_controller_test.rb @@ -6,10 +6,7 @@ include WebMocking include Devise::Test::ControllerHelpers - before do - @user = create(:user) - @request.headers['REMOTE_ADDR'] = '87.223.138.147' - end + before { @user = create(:user) } def test_asks_location get :ask
Remove unnecessarily setting header in a test