diff
stringlengths
65
26.7k
message
stringlengths
7
9.92k
diff --git a/polished-knockout.gemspec b/polished-knockout.gemspec index abc1234..def5678 100644 --- a/polished-knockout.gemspec +++ b/polished-knockout.gemspec @@ -10,7 +10,7 @@ spec.email = ["jared@jaredwhite.com"] spec.description = %q{An Opal wrapper for creating view models that use Knockout.js for dynamic HTML updates and event handling} spec.summary = spec.description - spec.homepage = "https://github.com/polished-rb/knockout" + spec.homepage = "https://github.com/polished-rb/knockout-rb" spec.license = "MIT" spec.files = `git ls-files -z`.split("\x0")
Use knockout-rb, not knockout, so as to avoid repo naming collision with main knockout project
diff --git a/rom-sql.gemspec b/rom-sql.gemspec index abc1234..def5678 100644 --- a/rom-sql.gemspec +++ b/rom-sql.gemspec @@ -15,7 +15,7 @@ spec.files = Dir['CHANGELOG.md', 'LICENSE', 'README.md', 'lib/**/*'] spec.require_paths = ['lib'] - spec.required_ruby_version = ">= 2.3.0" + spec.required_ruby_version = ">= 2.4.0" spec.add_runtime_dependency 'sequel', '>= 4.49' spec.add_runtime_dependency 'dry-equalizer', '~> 0.2'
Drop support for Ruby < 2.4
diff --git a/test/integration/default/serverspec/postgresql_spec.rb b/test/integration/default/serverspec/postgresql_spec.rb index abc1234..def5678 100644 --- a/test/integration/default/serverspec/postgresql_spec.rb +++ b/test/integration/default/serverspec/postgresql_spec.rb @@ -0,0 +1,25 @@+require "spec_helper" + +describe "practicingruby::_postgresql" do + let(:postgresql_version) { "9.1" } + + it "installs PostgreSQL server" do + expect(package "postgresql-#{postgresql_version}").to be_installed + end + + it "installs PostgreSQL client" do + expect(package "postgresql-client-#{postgresql_version}").to be_installed + end + + it "starts PostgreSQL server" do + output = /^Running clusters: #{postgresql_version}\/main/ + expect(command "service postgresql status").to return_stdout output + + expect(port 5432).to be_listening + end + + it "creates database for Rails app" do + db_name = "practicing-ruby-production" + expect(command "sudo -u postgres psql -l").to return_stdout /#{db_name}/ + end +end
Add integration test for PostgreSQL
diff --git a/spec/command/linux/bridge_spec.rb b/spec/command/linux/bridge_spec.rb index abc1234..def5678 100644 --- a/spec/command/linux/bridge_spec.rb +++ b/spec/command/linux/bridge_spec.rb @@ -0,0 +1,12 @@+require 'spec_helper' + +property[:os] = nil +set :os, :family => 'linux' + +describe get_command(:check_bridge_exists, 'br0') do + it { should eq "ip link show br0" } +end + +describe get_command(:check_bridge_has_interface, 'br0', 'eth0') do + it { should eq "brctl show br0 | grep -o eth0" } +end
Add tests for Bridge resource on Linux
diff --git a/spec/helpers/plots_helper_spec.rb b/spec/helpers/plots_helper_spec.rb index abc1234..def5678 100644 --- a/spec/helpers/plots_helper_spec.rb +++ b/spec/helpers/plots_helper_spec.rb @@ -9,7 +9,7 @@ before { plot.featured_plant = nil } before { allow(helper).to receive(:current_user).and_return(current_user) } it "returns 'Unassigned' with a link to edit the plot" do - expect(helper.link_to_featured_plant(plot)).to match "Unassigned. <a title=\"Edit Plot #1\" href=\"/plots/1/edit\">Add one?</a>" + expect(helper.link_to_featured_plant(plot)).to match "Unassigned. <a title=\"Edit Plot #1\" class=\"plant\" href=\"/plots/1/edit\">Add one?</a>" end end
Update link in spec to fix broken test
diff --git a/ruby/to_file.rb b/ruby/to_file.rb index abc1234..def5678 100644 --- a/ruby/to_file.rb +++ b/ruby/to_file.rb @@ -0,0 +1,31 @@+#!/bin/env ruby + +# A ruby module is a collection of functions and constants. +# By including a module as part of a class, those behaviors and constants become +# part of the class. +module ToFile + def filename + "object_#{self.object_id}.txt" + end + + def to_f + # The `to_s' method is define in a class but used in the module + File.open(filename, 'w') {|f| f.write(to_s)} + end +end + +class Person + include ToFile + attr_accessor :name + + def initialize(name) + @name = name + end + + def to_s + name + end +end + +Person.new('matz').to_f +# => create the file 'object_12573620.txt' containing 'matz'
Add an example of mixin By including a module in a class we can add behaviors without using an inheritance relation. We can add features regardless of his others properties.
diff --git a/app/controllers/widgets_controller.rb b/app/controllers/widgets_controller.rb index abc1234..def5678 100644 --- a/app/controllers/widgets_controller.rb +++ b/app/controllers/widgets_controller.rb @@ -1,5 +1,5 @@ class WidgetsController < ApplicationController - #before_filter :authenticate + before_filter :authenticate before_filter :find_widget, only: [:show] def new
Add back before_filter on widgets so you must be logged in
diff --git a/tekido.gemspec b/tekido.gemspec index abc1234..def5678 100644 --- a/tekido.gemspec +++ b/tekido.gemspec @@ -10,7 +10,7 @@ spec.email = ["pinzolo@gmail.com"] spec.description = %q{`Tekido` generates various random value.} spec.summary = %q{A handy little random value generator.} - spec.homepage = "" + spec.homepage = "https://github.com/pinzolo/tekido" spec.license = "MIT" spec.files = `git ls-files`.split($/)
Add homepage URL to gemspec
diff --git a/puppet-lint-duplicate_class_parameters-check.gemspec b/puppet-lint-duplicate_class_parameters-check.gemspec index abc1234..def5678 100644 --- a/puppet-lint-duplicate_class_parameters-check.gemspec +++ b/puppet-lint-duplicate_class_parameters-check.gemspec @@ -22,7 +22,7 @@ spec.add_development_dependency 'rspec', '~> 3.9.0' spec.add_development_dependency 'rspec-its', '~> 1.0' spec.add_development_dependency 'rspec-collection_matchers', '~> 1.0' - spec.add_development_dependency 'rubocop', '~> 0.76.0' + spec.add_development_dependency 'rubocop', '~> 0.77.0' spec.add_development_dependency 'rake', '~> 13.0.0' spec.add_development_dependency 'rspec-json_expectations', '~> 2.2' spec.add_development_dependency 'simplecov', '~> 0.17.1'
Update rubocop requirement from ~> 0.76.0 to ~> 0.77.0 Updates the requirements on [rubocop](https://github.com/rubocop-hq/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop-hq/rubocop/releases) - [Changelog](https://github.com/rubocop-hq/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop-hq/rubocop/compare/v0.76.0...v0.77.0) Signed-off-by: dependabot-preview[bot] <5bdcd3c0d4d24ae3e71b3b452a024c6324c7e4bb@dependabot.com>
diff --git a/app/jobs/user_import_operation_job.rb b/app/jobs/user_import_operation_job.rb index abc1234..def5678 100644 --- a/app/jobs/user_import_operation_job.rb +++ b/app/jobs/user_import_operation_job.rb @@ -9,6 +9,8 @@ unless succeeded operation_failed(format_error_report(batch.errors)) end + ensure + File.delete(path) rescue nil end private
2343: Delete file upload after job processing
diff --git a/dash/app/controllers/spree/admin/overview_controller.rb b/dash/app/controllers/spree/admin/overview_controller.rb index abc1234..def5678 100644 --- a/dash/app/controllers/spree/admin/overview_controller.rb +++ b/dash/app/controllers/spree/admin/overview_controller.rb @@ -18,7 +18,7 @@ private def check_last_jirafe_sync_time - if Spree::Dash.configured? + if Spree::Dash::Config.configured? if session[:last_jirafe_sync] hours_since_last_sync = ((DateTime.now - session[:last_jirafe_sync]) * 24).to_i redirect_to admin_analytics_sync_path if hours_since_last_sync > 24
Correct call to Spree::Dash::Config.configured? within Admin::OverviewController
diff --git a/test/helper.rb b/test/helper.rb index abc1234..def5678 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -1,7 +1,7 @@ require 'rubygems' require 'bundler' begin - Bundler.setup(:default, :development) + Bundler.setup(:default, :development, :test) rescue Bundler::BundlerError => e $stderr.puts e.message $stderr.puts "Run `bundle install` to install missing gems"
Add test enviroment to bundler setup on tests This made possible to run individual tests with something like: ruby -Itest/ test/test_spinning_cursor.rb -v -n "/allow you to change the banner/" Necessary to faster repeating individual tests.
diff --git a/renderer.rb b/renderer.rb index abc1234..def5678 100644 --- a/renderer.rb +++ b/renderer.rb @@ -6,7 +6,9 @@ COLON = 10 def initialize(game) - @game = game + @game = game + @bomb_led = LED.new(game, 495, 9) + @elapsed_led = LED.new(game, 210, 9) end def draw(overlay) @@ -27,7 +29,7 @@ bombs = @game.grid.bombs_left digits = [bombs / 10, bombs % 10] - display_led(digits, 495, 9) + @bomb_led.draw(digits) end def draw_elapsed @@ -35,18 +37,7 @@ secs = elapsed % 60 digits = [elapsed / 60, COLON, secs / 10, secs % 10] - display_led(digits, 210, 9) - end - - # This reeks of :reek:UncommunicativeParameterName - # This reeks of :reek:UncommunicativeVariableName - def display_led(digits, x, y) - dimage = @game.image[:digits] - - digits.each do |digit| - dimage[digit].draw(x, y, 1) - x += dimage[0].width - end + @elapsed_led.draw(digits) end def draw_grid @@ -54,3 +45,21 @@ end end end + +# Draw a set of digits to look like a 7-segment LED display +class LED + def initialize(game, left, top) + @images = game.image[:digits] + @left = left + @top = top + end + + def draw(digits) + col = @left + + digits.each do |digit| + @images[digit].draw(col, @top, 1) + col += @images[0].width + end + end +end
Add a LED class for bombs and elapsed time display
diff --git a/app/decorators/controllers/refinery/pages_controller_decorator.rb b/app/decorators/controllers/refinery/pages_controller_decorator.rb index abc1234..def5678 100644 --- a/app/decorators/controllers/refinery/pages_controller_decorator.rb +++ b/app/decorators/controllers/refinery/pages_controller_decorator.rb @@ -1,3 +1,5 @@+require 'date' + module RefineryPagesControllerDecorator include ActionView::Helpers::NumberHelper include ActionView::Helpers::DateHelper @@ -10,7 +12,7 @@ gem_downloads: number_with_delimiter(rubygems_downloads), gem_version: latest_version, github_watchers: number_with_delimiter(github_watchers), - latest_commit_date: distance_of_time_in_words(Time.now.utc - Time.parse(latest_update.first).utc), + latest_commit_date: Date.parse(latest_update.first), latest_commit_author: latest_update.last }
Use an ISO 8601 date instead of distance. Fixes #7
diff --git a/definitions/disk-monitor.rb b/definitions/disk-monitor.rb index abc1234..def5678 100644 --- a/definitions/disk-monitor.rb +++ b/definitions/disk-monitor.rb @@ -20,7 +20,7 @@ template application[:bin] do source application[:template] cookbook application[:cookbook] - user application[:user] + owner application[:user] group application[:group] mode 0755 variables application
Switch template dsl to use the correct method for user permissions (owner)
diff --git a/spec/helpers/physical_server_helper/textual_summary_spec.rb b/spec/helpers/physical_server_helper/textual_summary_spec.rb index abc1234..def5678 100644 --- a/spec/helpers/physical_server_helper/textual_summary_spec.rb +++ b/spec/helpers/physical_server_helper/textual_summary_spec.rb @@ -0,0 +1,28 @@+describe PhysicalServerHelper::TextualSummary do + it "#textual_ipv4" do + network = FactoryGirl.build(:network, :ipaddress => "192.168.1.1") + guest_device = FactoryGirl.build(:guest_device, :network => network) + hardware = FactoryGirl.build(:hardware, :guest_devices => [guest_device]) + computer_system = FactoryGirl.build(:computer_system, :hardware => hardware) + @record = FactoryGirl.build(:physical_server, :computer_system => computer_system) + + result = helper.textual_ipv4 + expect(result[:label]).to eq("IPv4 Address") + expect(result[:value]).to eq("<a target=\"_blank\" href=\"https://192.168.1.1\">192.168.1.1</a>") + + network.ipaddress = "192.168.1.1,192.168.1.2" + result = helper.textual_ipv4 + expect(result[:label]).to eq("IPv4 Address") + expect(result[:value]).to eq("<a target=\"_blank\" href=\"https://192.168.1.1\">192.168.1.1</a>, <a target=\"_blank\" href=\"https://192.168.1.2\">192.168.1.2</a>") + + network.ipaddress = "192.168.1.1, 192.168.1.2" + result = helper.textual_ipv4 + expect(result[:label]).to eq("IPv4 Address") + expect(result[:value]).to eq("<a target=\"_blank\" href=\"https://192.168.1.1\">192.168.1.1</a>, <a target=\"_blank\" href=\"https://192.168.1.2\">192.168.1.2</a>") + + network.ipaddress = "" + result = helper.textual_ipv4 + expect(result[:label]).to eq("IPv4 Address") + expect(result[:value]).to eq("") + end +end
Add spec test for textual_ipv4
diff --git a/init.rb b/init.rb index abc1234..def5678 100644 --- a/init.rb +++ b/init.rb @@ -2,7 +2,9 @@ require File.join(File.dirname(__FILE__), '/lib/rites_portal.rb') require File.join(File.dirname(__FILE__), '/lib/sds_connect.rb') +# Access this class so that the has_many_polymorphs code will get called and set up the associations in Teacher and Student RitesPortal::School + RitesPortal::SdsConnect::Connect.setup # Using a separate DB isn't going to work because of the various join tables we'll have to make to the existing app's db
Comment explaining why we're accessing School.
diff --git a/Casks/opera-developer.rb b/Casks/opera-developer.rb index abc1234..def5678 100644 --- a/Casks/opera-developer.rb +++ b/Casks/opera-developer.rb @@ -1,6 +1,6 @@ cask :v1 => 'opera-developer' do - version '29.0.1795.14' - sha256 'ce0e8ecdac8c1fda65369acc5d9539faad529e0970c4a6de0c5ed832e29d34e0' + version '30.0.1812.0' + sha256 'ec032b5545358e5358f96cdf16f5eb813f726727d9fcb878520f2669473f2bc7' url "http://get.geo.opera.com/pub/opera-developer/#{version}/mac/Opera_Developer_#{version}_Setup.dmg" homepage 'http://www.opera.com/developer'
Upgrade Opera Developer.app to v30.0.1812.0
diff --git a/spec/integration/example_spec.rb b/spec/integration/example_spec.rb index abc1234..def5678 100644 --- a/spec/integration/example_spec.rb +++ b/spec/integration/example_spec.rb @@ -9,7 +9,7 @@ let(:default_title) { "Example Presentation" } let(:description) { "Several parade examples to assist with showing others how to get started with Parade" } - let(:slide_count) { 74 } + let(:slide_count) { 73 } let(:section_count) { 4 } its(:title) { should eq default_title } @@ -37,7 +37,7 @@ let(:section) { subject.sections[1] } let(:title) { "Advanced Features" } - let(:slide_count) { 55 } + let(:slide_count) { 54 } it_should_behave_like "a properly parsed section" end
FIX for integration specs based on example preso change
diff --git a/spec/integration/haproxy_spec.rb b/spec/integration/haproxy_spec.rb index abc1234..def5678 100644 --- a/spec/integration/haproxy_spec.rb +++ b/spec/integration/haproxy_spec.rb @@ -0,0 +1,24 @@+require 'spec_helper' + +require 'httparty' + +RSpec.describe "haproxy" do + [0, 1].each do |job_index| + context "when the job rmq/#{job_index} is down" do + before(:all) do + bosh.stop("rmq/#{job_index}") + end + + after(:all) do + bosh.start("rmq/#{job_index}") + end + + it 'I can still access the managment UI' do + res = HTTParty.get(rabbitmq_api_url) + + expect(res.code).to eql(200) + expect(res.body).to include('RabbitMQ Management') + end + end + end +end
Revert "Remove haproxy system test" This reverts commit 25e6748fcabfd35ea2f98702a94f460a284afe74.
diff --git a/human_player.rb b/human_player.rb index abc1234..def5678 100644 --- a/human_player.rb +++ b/human_player.rb @@ -44,4 +44,11 @@ end end + + def call_shot + guess = nil + + + end + end
Add computer guessing for calling shots.
diff --git a/tasks/rspec.rake b/tasks/rspec.rake index abc1234..def5678 100644 --- a/tasks/rspec.rake +++ b/tasks/rspec.rake @@ -1,3 +1,10 @@ require 'rspec/core/rake_task' -RSpec::Core::RakeTask.new('spec') +RSpec::Core::RakeTask.new(:spec) + +namespace :spec do + desc "Open coverage report in browser" + task :open_coverage => :browser do + sh "#{ENV["DEVELOPMENT_WEBBROWSER"]} coverage/index.html" + end +end
Add a task to open the coverage report
diff --git a/spec/db_spec.rb b/spec/db_spec.rb index abc1234..def5678 100644 --- a/spec/db_spec.rb +++ b/spec/db_spec.rb @@ -25,7 +25,19 @@ expect(Db.table_exists?(test_table)).to be_false end + it "creates a table when called to" do + Db.create_table test_table, nil, '(var1 text)' + expect(Db.table_exists?(test_table)).to be_true + end + + it "drops a table when called to" do + Db.create_table test_table, nil, '(var1 text)' + Db.drop_table test_table + expect(Db.table_exists?(test_table)).to be_false + end + it "says it is tracking tables after tracking is set up" do + Db.tear_down_tracking Db.set_up_tracking expect(Db.tracking_tables?).to be_true end
Add tests for table creation, table drops
diff --git a/test/features/support/pages/catalinker/catalinker_client.rb b/test/features/support/pages/catalinker/catalinker_client.rb index abc1234..def5678 100644 --- a/test/features/support/pages/catalinker/catalinker_client.rb +++ b/test/features/support/pages/catalinker/catalinker_client.rb @@ -13,7 +13,8 @@ end def add(title, author, date, biblio) - @browser.button(:data_automation_id => /new_work_button/).click + btn = @browser.button(:data_automation_id => /new_work_button/).wait_until_present + btn.click addTriple("name", title) addTriple("year", date)
Make sure new work button is present
diff --git a/lib/flickrie/collection.rb b/lib/flickrie/collection.rb index abc1234..def5678 100644 --- a/lib/flickrie/collection.rb +++ b/lib/flickrie/collection.rb @@ -7,7 +7,7 @@ # (you can evem use it with [will_paginate](https://github.com/mislav/will_paginate), # see {Flickrie.pagination}). It also has the method {#find} which finds by ID # (just like ActiveRecord). - class Collection < (defined?(WillPaginate) ? WillPaginate::Collection : Array) + class Collection < (Flickrie.pagination == :will_paginate ? WillPaginate::Collection : Array) attr_reader :current_page, :per_page, :total_entries, :total_pages def initialize(params)
Fix Flickrie::Collection still using will_paginate, even though it isn't explicitly set
diff --git a/spec/classes/params_spec.rb b/spec/classes/params_spec.rb index abc1234..def5678 100644 --- a/spec/classes/params_spec.rb +++ b/spec/classes/params_spec.rb @@ -11,4 +11,17 @@ it "Should not contain any resources" do subject.resources.size.should == 4 end + + describe "With unknown lsbdistid" do + + let(:facts) { { :lsbdistid => 'CentOS' } } + let (:title) { 'my_package' } + + it do + expect { + should compile + }.to raise_error(Puppet::Error, /Unsupported lsbdistid/) + end + + end end
Add spec test to test for failure
diff --git a/spec/classes/params_spec.rb b/spec/classes/params_spec.rb index abc1234..def5678 100644 --- a/spec/classes/params_spec.rb +++ b/spec/classes/params_spec.rb @@ -0,0 +1,10 @@+require 'spec_helper' + +describe 'nexus::params', :type => :class do + + context 'with default params' do + it { should contain_class('nexus::params') } + end +end + +# vim: sw=2 ts=2 sts=2 et :
Add basic tests for nexus::params Signed-off-by: Andrew Grimberg <1f872228929e751eea07667e68fbb1655199bd12@linuxfoundation.org>
diff --git a/react-native-track-player.podspec b/react-native-track-player.podspec index abc1234..def5678 100644 --- a/react-native-track-player.podspec +++ b/react-native-track-player.podspec @@ -3,19 +3,21 @@ package = JSON.parse(File.read(File.join(__dir__, "package.json"))) Pod::Spec.new do |s| - s.name = package["name"] - s.version = package["version"] - s.summary = package['description'] - s.license = package['license'] - - s.author = "David Chavez" - s.homepage = package['repository']['url'] - s.platform = :ios, "10.0" + s.name = package["name"] + s.version = package["version"] + s.summary = package["description"] + s.license = package["license"] - s.source = { :git => package['repository']['url'], :tag => "v#{s.version}" } - s.source_files = "ios/**/*.{h,m,swift}" - s.swift_version = "4.2" + s.author = "David Chavez" + s.homepage = package["repository"]["url"] + s.platform = :ios, "10.0" + + s.source = { :git => package["repository"]["url"], :tag => "v#{s.version}" } + s.source_files = "ios/**/*.{h,m,swift}" + + s.exclude_files = ["ios/RNTrackPlayer/Vendor/AudioPlayer/Example"] + + s.swift_version = "5.0" s.dependency "React" - s.exclude_files = ["ios/RNTrackPlayer/Vendor/AudioPlayer/Example"] end
[iOS] Update podspec swift version to match SwiftAudio submodule. Cleanup quotes and other formatting.
diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb index abc1234..def5678 100644 --- a/spec/models/comment_spec.rb +++ b/spec/models/comment_spec.rb @@ -1,11 +1,6 @@ require 'rails_helper' RSpec.describe Comment, type: :model do - let(:question) { create(:question) } - let(:user) {create(:user, username: 'Tyaasdfasdf', email: 'ty@example.com')} - before do - allow_any_instance_of(ApplicationController).to receive(:current_user).and_return(user) - end it { should belong_to(:user) }
Remove unnecessary lets from comment model test
diff --git a/spec/dummy/app/controllers/application_controller.rb b/spec/dummy/app/controllers/application_controller.rb index abc1234..def5678 100644 --- a/spec/dummy/app/controllers/application_controller.rb +++ b/spec/dummy/app/controllers/application_controller.rb @@ -1,3 +1,7 @@ class ApplicationController < ActionController::Base protect_from_forgery + + def sign_in_path + '/sign_in' + end end
Define sign_in_path in ApplicationController for dummy application
diff --git a/tltool.gemspec b/tltool.gemspec index abc1234..def5678 100644 --- a/tltool.gemspec +++ b/tltool.gemspec @@ -8,8 +8,8 @@ spec.version = Tltool::VERSION spec.authors = ["Pinnapong Silpsakulsuk"] spec.email = ["pinnapong@gmail.com"] - spec.summary = %q{TODO: Write a short summary. Required.} - spec.description = %q{TODO: Write a longer description. Optional.} + spec.summary = %q{Timelapse CLI Toolkit.} + spec.description = %q{A CLI tool for timelapse photography workflow.} spec.homepage = "" spec.license = "MIT"
Add gem summary and description
diff --git a/app/controllers/auth.rb b/app/controllers/auth.rb index abc1234..def5678 100644 --- a/app/controllers/auth.rb +++ b/app/controllers/auth.rb @@ -8,8 +8,8 @@ end post '/signup' do - puts 'create new user' - redirect '/signin' + + redirect '/' end get '/signout' do
Update signup POST route to redirect to homepage
diff --git a/lib/moonshine/memcached.rb b/lib/moonshine/memcached.rb index abc1234..def5678 100644 --- a/lib/moonshine/memcached.rb +++ b/lib/moonshine/memcached.rb @@ -1,14 +1,15 @@ module Moonshine module Memcached - # Define options for this plugin via the <tt>configure</tt> method # in your application manifest: - # + # # configure(:memcached => {:foo => true}) - # + # # Then include the plugin and call the recipe(s) you need: - # - # recipe :memcached def memcached(options = {}) + # + # recipe :memcached + + def memcached(options = {}) options = { :enable_on_boot => true }.merge(options) exec 'apt-get install -q -y --force-yes memcached', @@ -17,19 +18,17 @@ :unless => 'dpkg -l | grep memcached' service 'memcached', :ensure => :running, :enable => options[:enable_on_boot], :require => exec('memcached package') - - file '/etc/memcached.conf', + + file '/etc/memcached.conf', :content => template(File.join(File.dirname(__FILE__), '..', '..', 'templates', 'memcached.conf.erb'), binding), :mode => '644', :require => exec('memcached package'), :notify => service('memcached') - + # install client gem if specified. otherwise, use version bundled with rails. if options[:client] gem 'memcache-client', :require => exec('memcached package'), :version => options[:client] - end - - end - - end -end+ end + end + end +end
Fix previous commit. GitHub web interface is not nice for editing.
diff --git a/app/models/notify_user/apn_connection.rb b/app/models/notify_user/apn_connection.rb index abc1234..def5678 100644 --- a/app/models/notify_user/apn_connection.rb +++ b/app/models/notify_user/apn_connection.rb @@ -5,7 +5,7 @@ end def setup - @uri, @certificate = if Rails.env.production? + @uri, @certificate = if Rails.env.production? || Rails.env.staging? [ Houston::APPLE_PRODUCTION_GATEWAY_URI, File.read("#{Rails.root}/config/keys/production_push.pem")
Make both the staging and production environments use the production gateway and cert. Temp solution for TN, something gets set in the actual project using `notify_user` dictate which gateway it wants to use per environment.
diff --git a/app/models/sql_probe/event_set_writer.rb b/app/models/sql_probe/event_set_writer.rb index abc1234..def5678 100644 --- a/app/models/sql_probe/event_set_writer.rb +++ b/app/models/sql_probe/event_set_writer.rb @@ -17,17 +17,19 @@ full_path = File.join(output_dir, "#{file_id}.yml") # write contents - result = File.open(full_path, 'w') do |file| - file << { - 'name' => name, - 'start_time' => start_time, - 'duration' => duration, - 'params' => params, - 'events' => events - }.to_yaml(line_width: -1) - end - ActiveSupport::Notifications.instrument 'sql_probe.file', path: full_path - result + event_group = { + 'id' => Digest::MD5.hexdigest(full_path), + 'name' => name, + 'start_time' => start_time, + 'duration' => duration, + 'params' => params, + 'events' => events + }.to_yaml(line_width: -1) + return false unless event_group + + File + .open(full_path, 'w') { |file| file << event_group } + .tap { ActiveSupport::Notifications.instrument 'sql_probe.file', path: full_path } end def flatten_event_payload(event)
Add MD5 id to Event Set
diff --git a/app/mutations/working_group/base_form.rb b/app/mutations/working_group/base_form.rb index abc1234..def5678 100644 --- a/app/mutations/working_group/base_form.rb +++ b/app/mutations/working_group/base_form.rb @@ -3,9 +3,7 @@ attribute :name, :string attribute :description, :string, required: false - attribute :admin_ids, :array, class: String, default: proc{ working_group.admins.active.map(&:id) } attribute :type, :symbol, default: proc{ working_group.type }, in: %i(public private) - def new_url circle_working_groups_path(working_group.circle) @@ -13,12 +11,6 @@ def update_url circle_working_group_path(working_group.circle, working_group) - end - - def admin_options - working_group.circle.users.active.map { |u| - [u.name, u.id] - } end def type_options @@ -36,9 +28,5 @@ working_group.save end - - def clean_admin_ids - admin_ids.keep_if(&:present?).map(&:to_i) - end end -end+end
Remove legacy admin edit code from working group edit page
diff --git a/lib/npr_todays_news/cli.rb b/lib/npr_todays_news/cli.rb index abc1234..def5678 100644 --- a/lib/npr_todays_news/cli.rb +++ b/lib/npr_todays_news/cli.rb @@ -30,7 +30,9 @@ def list_stories @news_list.stories.each.with_index(1) do |story, index| - puts "#{index}. #{story.title}" #-- #{story.teaser} + puts "#{index}. #{story.title}:" + puts "#{story.teaser}" + puts "" end options_output end @@ -39,5 +41,5 @@ puts "" puts "To read a story in your browser, type (#1-3) or 'exit' to quit." end - + end
Add story teaser to output when listing the featured stories.
diff --git a/lib/restforce/file_part.rb b/lib/restforce/file_part.rb index abc1234..def5678 100644 --- a/lib/restforce/file_part.rb +++ b/lib/restforce/file_part.rb @@ -1,6 +1,11 @@ # frozen_string_literal: true +# rubocop:disable Lint/DuplicateBranch case Faraday::VERSION +when /\A0\.16\./ + # Faraday 0.16.x behaves like v1.x - see + # https://github.com/lostisland/faraday/releases/tag/v0.17.0 + require 'faraday/file_part' when /\A0\./ require 'faraday/upload_io' when /\A1\.[0-8]\./ @@ -16,6 +21,7 @@ raise "Unexpected Faraday version #{Faraday::VERSION} - not sure how to set up " \ "multipart support" end +# rubocop:enable Lint/DuplicateBranch module Restforce if defined?(::Faraday::FilePart)
Fix compatability with Faraday 0.16.x by setting up multipart support like v1.x
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 @@ -23,7 +23,15 @@ end puts "Loaded #{Electorate.count} electorates" - # TODO: Load people.xml + # people.xml + people_xml = Nokogiri.parse(File.read("#{XML_DATA_DIRECTORY}/people.xml")) + member_to_person = {} + people_xml.search(:person).each do |person| + person.search(:office).each do |office| + member_to_person[office[:id]] = person[:id] + end + end + # TODO: Load ministers.xml # TODO: Load representatives.xml # TODO: Load senators.xml
Load people.xml part of memxml2db.pl
diff --git a/lib/zebra/zpl/printable.rb b/lib/zebra/zpl/printable.rb index abc1234..def5678 100644 --- a/lib/zebra/zpl/printable.rb +++ b/lib/zebra/zpl/printable.rb @@ -16,6 +16,9 @@ def position=(coords) @position, @x, @y = coords, coords[0], coords[1] + if @justification + @x = 0 + end end def justification=(just)
Set x position to zero if justification is given
diff --git a/Casks/logic.rb b/Casks/logic.rb index abc1234..def5678 100644 --- a/Casks/logic.rb +++ b/Casks/logic.rb @@ -4,7 +4,7 @@ url "http://downloads.saleae.com/betas/#{version}/Logic-#{version}-Darwin.dmg" name 'Logic' - homepage 'http://www.saleae.com/' + homepage 'https://www.saleae.com/' license :commercial app 'Logic.app'
Fix homepage to use SSL in Logic Cask The HTTP URL is already getting redirected to HTTPS. Using the HTTPS URL directly makes it more secure and saves a HTTP round-trip.
diff --git a/Cosmos.podspec b/Cosmos.podspec index abc1234..def5678 100644 --- a/Cosmos.podspec +++ b/Cosmos.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "Cosmos" - s.version = "8.0.0" + s.version = "8.0.1" s.license = { :type => "MIT" } s.homepage = "https://github.com/marketplacer/Cosmos" s.summary = "5-star rating control written in Swift"
Add RightToLeft to tvOS target
diff --git a/Formula/p0f.rb b/Formula/p0f.rb index abc1234..def5678 100644 --- a/Formula/p0f.rb +++ b/Formula/p0f.rb @@ -1,24 +1,24 @@-require 'formula' +require "formula" class P0f < Formula - homepage 'http://lcamtuf.coredump.cx/p0f3/' - url 'http://lcamtuf.coredump.cx/p0f3/releases/p0f-3.07b.tgz' - sha1 'ae2c4fbcddf2a5ced33abd81992405b93207e7c8' + homepage "http://lcamtuf.coredump.cx/p0f3/" + url "http://lcamtuf.coredump.cx/p0f3/releases/p0f-3.07b.tgz" + sha1 "ae2c4fbcddf2a5ced33abd81992405b93207e7c8" def install inreplace "config.h", "p0f.fp", "#{etc}/p0f/p0f.fp" - system './build.sh' - sbin.install 'p0f' - (etc + 'p0f').install 'p0f.fp' + system "./build.sh" + sbin.install "p0f" + (etc + "p0f").install "p0f.fp" end test do - require 'base64' + require "base64" - pcap = '1MOyoQIABAAAAAAAAAAAAP//AAAAAAAA92EsVI67DgBEAAAA' \ - 'RAAAAAIAAABFAABAbvpAAEAGAAB/AAABfwAAAcv8Iyjt2/Pg' \ - 'AAAAALAC///+NAAAAgQ/2AEDAwQBAQgKCyrc9wAAAAAEAgAA' - (testpath / 'test.pcap').write(Base64.decode64(pcap)) + pcap = "1MOyoQIABAAAAAAAAAAAAP//AAAAAAAA92EsVI67DgBEAAAA" \ + "RAAAAAIAAABFAABAbvpAAEAGAAB/AAABfwAAAcv8Iyjt2/Pg" \ + "AAAAALAC///+NAAAAgQ/2AEDAwQBAQgKCyrc9wAAAAAEAgAA" + (testpath / "test.pcap").write(Base64.decode64(pcap)) system "#{sbin}/p0f", "-r", "test.pcap" end end
Use double-quotes on all lines
diff --git a/spec/classes/charles_spec.rb b/spec/classes/charles_spec.rb index abc1234..def5678 100644 --- a/spec/classes/charles_spec.rb +++ b/spec/classes/charles_spec.rb @@ -4,6 +4,6 @@ it { should contain_class('charles') } it { should contain_package('Charles').with_provider('appdmg_eula_charles') } - it { should contain_package('Charles').with_source('http://cdn2.charlesproxy.com/release/3.8.3/charles-proxy-3.8.3a-applejava.dmg') } + it { should contain_package('Charles').with_source('http://www.charlesproxy.com/assets/release/3.8.3/charles-proxy-3.8.3a-applejava.dmg') } end
Update spec for new resource url
diff --git a/scripts/merge-candidates.rb b/scripts/merge-candidates.rb index abc1234..def5678 100644 --- a/scripts/merge-candidates.rb +++ b/scripts/merge-candidates.rb @@ -41,6 +41,7 @@ ") # Delete the loser candidate +DeletedCandidate.create(:old_candidate_id => loser, :candidate_id => winner) Candidate.get(loser).destroy puts "Merge completed. Here is the merged candidate:"
Create a DeletedCandidate for the merged candidate
diff --git a/lib/qbwc_requests/bill_payment_credit_card/v07/query.rb b/lib/qbwc_requests/bill_payment_credit_card/v07/query.rb index abc1234..def5678 100644 --- a/lib/qbwc_requests/bill_payment_credit_card/v07/query.rb +++ b/lib/qbwc_requests/bill_payment_credit_card/v07/query.rb @@ -2,6 +2,7 @@ module BillPaymentCreditCard module V07 class Query < QbwcRequests::Base + field :txn_id field :max_returned field :modified_date_range_filter field :include_line_items
Add transaction id to bill payment credit card
diff --git a/app/models/api_error.rb b/app/models/api_error.rb index abc1234..def5678 100644 --- a/app/models/api_error.rb +++ b/app/models/api_error.rb @@ -10,9 +10,9 @@ [ { :code => INVALID_ARGUMENT, :description => "Invalid argument", :status_code => 403 }, { :code => INVALID_RANGE, :description => "Invalid range argument - missing beg or end", :status_code => 403 }, - { :code => INVALID_API_TOKEN, :description => "Invalid API token", :status_code => 403 }, - { :code => INVALID_USERNAME_OR_PASSWORD, :description => "Invalid username or password", :status_code => 403 }, - { :code => INVALID_PERSON_ID, :description => "Invalid person id", :status_code => 403 }, + { :code => INVALID_API_TOKEN, :description => "Invalid API token", :status_code => 401 }, + { :code => INVALID_USERNAME_OR_PASSWORD, :description => "Invalid username or password", :status_code => 401 }, + { :code => INVALID_PERSON_ID, :description => "Invalid person id", :status_code => 401 }, { :code => UNAUTHORIZED, :description => "Unauthorized for this action", :status_code => 403 }, ]
Use 401 for bad authentication, use 403 for lack of permission
diff --git a/Loggie.podspec b/Loggie.podspec index abc1234..def5678 100644 --- a/Loggie.podspec +++ b/Loggie.podspec @@ -7,7 +7,7 @@ s.author = { 'Filip Beć' => 'filip.bec@gmail.com' } s.source = { :git => 'https://github.com/infinum/iOS-Loggie.git', :tag => s.version.to_s } s.social_media_url = 'https://twitter.com/FilipBec' - + s.swift_version = '4.2' s.ios.deployment_target = '8.0' s.source_files = 'Loggie/Classes/**/*.{swift}'
Update Podspec to Swift 4.2
diff --git a/config/software/fluentd.rb b/config/software/fluentd.rb index abc1234..def5678 100644 --- a/config/software/fluentd.rb +++ b/config/software/fluentd.rb @@ -1,5 +1,5 @@ name "fluentd" -default_version 'a3068ff3f73525c72694465a5f42bcae6bf90104' +default_version 'a8ec325bbdf13c2c8cd9839abb566811dab4418c' dependency "ruby" #dependency "bundler"
Update Fluentd to v0.10.49 with latest change
diff --git a/traducto.gemspec b/traducto.gemspec index abc1234..def5678 100644 --- a/traducto.gemspec +++ b/traducto.gemspec @@ -3,7 +3,7 @@ gem.description = "Rails helpers collection to simplify the localization code." gem.summary = "Rails helpers collection to simplify the localization code." gem.homepage = "https://github.com/alchimikweb/traducto" - gem.version = "1.0.2" + gem.version = "1.0.3" gem.licenses = ["MIT"] gem.authors = ["Sebastien Rosa"] @@ -14,7 +14,7 @@ gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) gem.require_paths = ["lib"] - gem.add_dependency "rails", ['>= 3.0.0'] + gem.add_dependency "rails", ['>= 4.0.0'] gem.add_development_dependency "sqlite3" gem.add_development_dependency "rspec-rails" gem.add_development_dependency "simplecov"
Fix a bundle install dependencies
diff --git a/lib/generators/jsonapi/serializable/serializable_generator.rb b/lib/generators/jsonapi/serializable/serializable_generator.rb index abc1234..def5678 100644 --- a/lib/generators/jsonapi/serializable/serializable_generator.rb +++ b/lib/generators/jsonapi/serializable/serializable_generator.rb @@ -27,7 +27,7 @@ end def type - model_klass.name.underscore.pluralize + model_klass.model_name.plural end def attr_names
Fix serializable type for namespaced models
diff --git a/lib/vagrant-ca-certificates/cap/debian/update_certificates.rb b/lib/vagrant-ca-certificates/cap/debian/update_certificates.rb index abc1234..def5678 100644 --- a/lib/vagrant-ca-certificates/cap/debian/update_certificates.rb +++ b/lib/vagrant-ca-certificates/cap/debian/update_certificates.rb @@ -7,10 +7,18 @@ def self.update_certificates(machine) ca_certs = File.join(machine.config.ca_certificates.certs_path, 'vagrant') ca_config = '/etc/ca-certificates.conf' - machine.communicate.tap do |comm| + # Remove any existing references to vagrant certificates. + comm.sudo("sed -i '/^vagrant/ d' '#{ca_config}'") + # Add references to uploaded certificates. comm.sudo("find #{ca_certs} -maxdepth 1 -type f -exec basename {} \\; | sed -e 's#^#vagrant\/#' >> #{ca_config} ") - comm.sudo('update-ca-certificates') + # Update. + comm.sudo("update-ca-certificates") do |type, data| + if [:stderr, :stdout].include?(type) + next if data =~ /stdin: is not a tty/ + machine.env.ui.info data + end + end end end end
Make debian update certificate action idempotent.
diff --git a/tasks/util.rb b/tasks/util.rb index abc1234..def5678 100644 --- a/tasks/util.rb +++ b/tasks/util.rb @@ -5,7 +5,7 @@ # Project -> [Branch1, Branch2, ...] DOWNSTREAM_EXAMPLES = { - 'react4j-todomvc' => %w(raw raw_maven arez arez_maven spritz dagger dagger_maven raw_maven_j2cl arez_maven_j2cl dagger_maven_j2cl), + 'react4j-todomvc' => %w(raw arez spritz dagger dagger_maven raw_maven_j2cl arez_maven_j2cl dagger_maven_j2cl), 'react4j-drumloop' => %w(master), 'react4j-flux-challenge' => %w(master), }
Remove some maven examples that we no longer care about
diff --git a/app/helpers/application_helper/toolbar/ansible_credential_center.rb b/app/helpers/application_helper/toolbar/ansible_credential_center.rb index abc1234..def5678 100644 --- a/app/helpers/application_helper/toolbar/ansible_credential_center.rb +++ b/app/helpers/application_helper/toolbar/ansible_credential_center.rb @@ -34,7 +34,7 @@ button( :ansible_credential_tag, 'pficon pficon-edit fa-lg', - N_('Edit Tags for the selected Ansible Credentials'), + N_('Edit Tags for this Ansible Credential'), N_('Edit Tags'), ), ]
Fix tool tip when tagging Ansible Credential from its summary page
diff --git a/rulers.gemspec b/rulers.gemspec index abc1234..def5678 100644 --- a/rulers.gemspec +++ b/rulers.gemspec @@ -20,10 +20,10 @@ spec.require_paths = ["lib"] spec.add_development_dependency "bundler", "~> 1.5" - spec.add_development_dependency "rake", '~> 0' + spec.add_development_dependency "rake", '~> 10.3' spec.add_runtime_dependency "rack", '~> 1.5' - spec.add_development_dependency "rack-test", '~> 0' - spec.add_development_dependency "test-unit", '~> 0' + spec.add_development_dependency "rack-test", '~> 0.6' + spec.add_development_dependency "test-unit", '~> 3.0' end
Update gemspec to add specific gem version
diff --git a/spec/features/admin_spec.rb b/spec/features/admin_spec.rb index abc1234..def5678 100644 --- a/spec/features/admin_spec.rb +++ b/spec/features/admin_spec.rb @@ -7,7 +7,7 @@ end let(:user) do - FactoryGirl.create(:user, email: 'user@example.com') + FactoryGirl.create(:activated_user, email: 'user@example.com') end let(:admin_user) do @@ -27,4 +27,17 @@ click_link 'Report' expect(current_path).to eq '/login' end + + it 'displays delete links for admin users only' do + login_as('admin@example.com') + visit '/' + expect(page).to have_link 'X' + visit '/topics/1' + expect(page).to have_link 'X' + log_out + login_as('user@example.com') + expect(page).to_not have_link 'X' + visit '/' + expect(page).to_not have_link 'X' + end end
Add capybara spec for delete links
diff --git a/spec/helper/backend_spec.rb b/spec/helper/backend_spec.rb index abc1234..def5678 100644 --- a/spec/helper/backend_spec.rb +++ b/spec/helper/backend_spec.rb @@ -0,0 +1,11 @@+require 'spec_helper' + +describe 'backend_for(:type) returns correct backend object' do + it 'backend_for(:exec) returns SpecInfra::Backend::Exec' do + expect(backend_for(:exec)).to be_an_instance_of SpecInfra::Backend::Exec + end + + it 'backend_for(:ssh) returns SpecInfra::Backend::Ssh' do + expect(backend_for(:ssh)).to be_an_instance_of SpecInfra::Backend::Ssh + end +end
Add spec for backend helper
diff --git a/spec/lib/cadooz/services.rb b/spec/lib/cadooz/services.rb index abc1234..def5678 100644 --- a/spec/lib/cadooz/services.rb +++ b/spec/lib/cadooz/services.rb @@ -2,4 +2,45 @@ describe Cadooz::BusinessOrderService do + describe "instance methods" do + context "create order" do + + end + + context "get order status" do + + end + + context "get order status by customer reference number" do + + end + + context "get changed orders" do + + end + + context "get order" do + + end + + context "get available catalogs" do + + end + + context "get product informations" do + + end + + context "get available categories" do + + end + + context "get available products" do + + end + + context "get vouchers for order" do + + end + end end
Add contexts for service specs
diff --git a/spec/support/gff3_macros.rb b/spec/support/gff3_macros.rb index abc1234..def5678 100644 --- a/spec/support/gff3_macros.rb +++ b/spec/support/gff3_macros.rb @@ -5,11 +5,12 @@ diffable end - -def attributes_to_hash(gff3) - [:attributes,:end,:feature,:frame,:score,:seqname, - :source,:strand].inject(Hash.new) do |hash,attr| - hash[attr] = gff3.send(attr) - hash +def attributes_to_hash(gff) + fields = [:end,:feature,:frame,:score,:seqname,:source,:strand] + hash = fields.inject(Hash.new) do |h,f| + h[f] = gff.send(f) + h end + hash[:attributes] = gff.attributes.sort + hash end
Order of gff3 attribute fields does not matter.
diff --git a/actionpack/lib/action_controller/record_identifier.rb b/actionpack/lib/action_controller/record_identifier.rb index abc1234..def5678 100644 --- a/actionpack/lib/action_controller/record_identifier.rb +++ b/actionpack/lib/action_controller/record_identifier.rb @@ -4,7 +4,7 @@ module RecordIdentifier MESSAGE = 'method will no longer be included by default in controllers since Rails 4.1. ' + 'If you would like to use it in controllers, please include ' + - 'ActionView::RecodIdentifier module.' + 'ActionView::RecordIdentifier module.' def dom_id(record, prefix = nil) ActiveSupport::Deprecation.warn('dom_id ' + MESSAGE)
Fix typo in deprecation warning
diff --git a/spec/birthday_bot_spec.rb b/spec/birthday_bot_spec.rb index abc1234..def5678 100644 --- a/spec/birthday_bot_spec.rb +++ b/spec/birthday_bot_spec.rb @@ -8,8 +8,9 @@ end it "posts tweet" do - expect(bot).to receive(:post_tweet).with("今日はキュアミラクル(Cv. 高橋李依)の誕生日です! https://github.com/sue445/cure-bots") + allow(bot).to receive(:post_tweet) bot.perform + expect(bot).to have_received(:post_tweet).with("今日はキュアミラクル(Cv. 高橋李依)の誕生日です! https://github.com/sue445/cure-bots") end end @@ -19,8 +20,9 @@ end it "does not post tweet" do - expect(bot).not_to receive(:post_tweet) + allow(bot).to receive(:post_tweet) bot.perform + expect(bot).not_to have_received(:post_tweet) end end end
Use spy instead of mock
diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index abc1234..def5678 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -1,5 +1,9 @@ require 'spec_helper' describe 'goaudit' do + let (:facts) {{ + :osfamily => 'Debian' + }} + context 'with default values for all parameters' do it { should contain_class('goaudit') } end
Set osfamily fact in spec test
diff --git a/SSPPullToRefresh.podspec b/SSPPullToRefresh.podspec index abc1234..def5678 100644 --- a/SSPPullToRefresh.podspec +++ b/SSPPullToRefresh.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'SSPPullToRefresh' - s.version = '0.1.6' + s.version = '0.1.7' s.summary = 'General classes for "Pull-To-Refresh" concept customisation' s.description = <<-DESC
Update pod spec to 0.1.7
diff --git a/app/helpers/forms_helper.rb b/app/helpers/forms_helper.rb index abc1234..def5678 100644 --- a/app/helpers/forms_helper.rb +++ b/app/helpers/forms_helper.rb @@ -3,21 +3,30 @@ def breadcrumbs content_tag(:ol, class: 'breadcrumb') do wizard_steps.collect do |every_step| - class_str = - if every_step == step - "active" - elsif past_step?(every_step) - "past" - else - "future" - end - concat( - content_tag(:li, class: class_str) do - link_to I18n.t(every_step), wizard_path(every_step) + content_tag(:li, class: breadcrumb_class(every_step)) do + breadcrumb(every_step) end ) end end end + + def breadcrumb(every_step) + if step == every_step + I18n.t(every_step) + else + link_to I18n.t(every_step), wizard_path(every_step) + end + end + + def breadcrumb_class(every_step) + if every_step == step + "active" + elsif past_step?(every_step) + "past" + else + "future" + end + end end
Fix breadcrumbs to indicate which one we're on
diff --git a/app/models/order_request.rb b/app/models/order_request.rb index abc1234..def5678 100644 --- a/app/models/order_request.rb +++ b/app/models/order_request.rb @@ -4,7 +4,7 @@ belongs_to :external_system attr_accessible :external_copyright_charge, :external_currency, :external_number, :external_service_charge, :external_url, :shelfmark, - :reason_id, :reason_text + :reason_id, :reason_text, :order_status_id validates :order, :presence => true validates :order_status, :presence => true
Make order status updateable from admin interface.
diff --git a/app/policies/post_policy.rb b/app/policies/post_policy.rb index abc1234..def5678 100644 --- a/app/policies/post_policy.rb +++ b/app/policies/post_policy.rb @@ -1,10 +1,12 @@ PostPolicy = Struct.new(:user, :post) do def update? + return false unless user user.admin? or post.user == user end def destroy? + return false unless user user.admin? end end
Fix bug with nil user.
diff --git a/app/models/user_identity.rb b/app/models/user_identity.rb index abc1234..def5678 100644 --- a/app/models/user_identity.rb +++ b/app/models/user_identity.rb @@ -1,4 +1,5 @@ class UserIdentity < ActiveRecord::Base belongs_to :user validates :provider, uniqueness: { scope: :user_id } + validates :uid, uniqueness: { scope: :provider } end
Add validation for uid uniqness [GIOT-29]
diff --git a/app/models/user_location.rb b/app/models/user_location.rb index abc1234..def5678 100644 --- a/app/models/user_location.rb +++ b/app/models/user_location.rb @@ -13,6 +13,8 @@ class UserLocation < ActiveRecord::Base include Locatable + attr_accessible :category_id, :loc_json + belongs_to :user belongs_to :category, class_name: "LocationCategory"
Allow only category_id and loc_json to be set by mass assignment.
diff --git a/lib/banquo/banquo.rb b/lib/banquo/banquo.rb index abc1234..def5678 100644 --- a/lib/banquo/banquo.rb +++ b/lib/banquo/banquo.rb @@ -1,6 +1,6 @@ module Banquo def self.create_user(options) - cmd = `casperjs #{File.dirname(__FILE__)}/script/create-user.js #{BASE_URL} #{options[:email]} #{options[:password]}` + cmd = `casperjs --web-security=no #{File.dirname(__FILE__)}/script/create-user.js #{BASE_URL} #{options[:email]} #{options[:password]}` cmd =~ /User created/ or false end
Set `--web-security=no` flag when creating a user
diff --git a/core/db/migrate/20101026184808_migrate_checkout_to_orders.rb b/core/db/migrate/20101026184808_migrate_checkout_to_orders.rb index abc1234..def5678 100644 --- a/core/db/migrate/20101026184808_migrate_checkout_to_orders.rb +++ b/core/db/migrate/20101026184808_migrate_checkout_to_orders.rb @@ -1,4 +1,8 @@ class MigrateCheckoutToOrders < ActiveRecord::Migration + + class Checkout < ActiveRecord::Base + end + def self.up Order.find_each do |order| checkout = update_order(order)
Fix checkout_to_order migration to include Checkout model
diff --git a/lib/attribute_normalizer/normalizers/whitespace_normalizer.rb b/lib/attribute_normalizer/normalizers/whitespace_normalizer.rb index abc1234..def5678 100644 --- a/lib/attribute_normalizer/normalizers/whitespace_normalizer.rb +++ b/lib/attribute_normalizer/normalizers/whitespace_normalizer.rb @@ -2,7 +2,7 @@ module Normalizers module WhitespaceNormalizer def self.normalize(value, options = {}) - value.is_a?(String) ? value.gsub(/[^\S\n]+/, ' ').gsub(/\s+\n$/, "\n").strip : value + value.is_a?(String) ? value.gsub(/[^\S\n]+/, ' ').gsub(/\s?\n\s?/, "\n").strip : value end end end
Remove whitespaces adjacent to newline. Actually pass all tests
diff --git a/files/opt/nanobox/hooks/lib/stderr.rb b/files/opt/nanobox/hooks/lib/stderr.rb index abc1234..def5678 100644 --- a/files/opt/nanobox/hooks/lib/stderr.rb +++ b/files/opt/nanobox/hooks/lib/stderr.rb @@ -2,7 +2,8 @@ class Stderr def initialize(opts) - @log_level = level_to_int(opts[:log_level]) + level = opts[:log_level] || 'info' + @log_level = level_to_int(level) end def level_to_int(level)
Set info log level when none is provided
diff --git a/db/migrate/20121113120000_create_honorific_prefixes_table.rb b/db/migrate/20121113120000_create_honorific_prefixes_table.rb index abc1234..def5678 100644 --- a/db/migrate/20121113120000_create_honorific_prefixes_table.rb +++ b/db/migrate/20121113120000_create_honorific_prefixes_table.rb @@ -1,6 +1,6 @@ class CreateHonorificPrefixesTable < ActiveRecord::Migration def up - change_table "honorific_prefixes" do |t| + create_table "honorific_prefixes" do |t| t.integer "sex" t.string "name" t.integer "position"
Create not alter table honorific_prefixes in the so called migration.
diff --git a/ydf.gemspec b/ydf.gemspec index abc1234..def5678 100644 --- a/ydf.gemspec +++ b/ydf.gemspec @@ -19,7 +19,7 @@ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - spec.add_development_dependency "bundler", "~> 1.12" - spec.add_development_dependency "rake", "~> 10.0" - spec.add_development_dependency "rspec", "~> 3.0" + spec.add_development_dependency "bundler" + spec.add_development_dependency "rake" + spec.add_development_dependency "rspec" end
Remove versions of dependent gems in development
diff --git a/lib/ohm/datatypes.rb b/lib/ohm/datatypes.rb index abc1234..def5678 100644 --- a/lib/ohm/datatypes.rb +++ b/lib/ohm/datatypes.rb @@ -7,7 +7,7 @@ module DataTypes module Type Integer = lambda { |x| x.to_i } - Decimal = lambda { |x| x && BigDecimal(x.to_s) } + Decimal = lambda { |x| BigDecimal(x.to_s) } Float = lambda { |x| x.to_f } Boolean = lambda { |x| !!x } Time = lambda { |t| t && (t.kind_of?(::Time) ? t : ::Time.parse(t)) }
Fix behavior of Decimal to return 0 for nil / empty string (via @soveran).
diff --git a/lib/pogoplug/file.rb b/lib/pogoplug/file.rb index abc1234..def5678 100644 --- a/lib/pogoplug/file.rb +++ b/lib/pogoplug/file.rb @@ -46,6 +46,7 @@ parent_id: json['parentid'], size: json['size'].to_i, origin: json['origin'], + properties: json['properties'] || {}, raw: json ) end
Include properties when parsing as well
diff --git a/test/system/fluentd/setting/filter_record_transformer_test.rb b/test/system/fluentd/setting/filter_record_transformer_test.rb index abc1234..def5678 100644 --- a/test/system/fluentd/setting/filter_record_transformer_test.rb +++ b/test/system/fluentd/setting/filter_record_transformer_test.rb @@ -0,0 +1,30 @@+require "application_system_test_case" + +class FilterRecordTransformerTest < ApplicationSystemTestCase + setup do + login_with(FactoryBot.build(:user)) + @daemon = stub_daemon + end + + test "show form" do + visit(daemon_setting_filter_record_transformer_path) + assert do + page.has_css?("textarea[name=\"setting[record]\"]") + end + end + + test "update config" do + value = "key value" + assert do + !@daemon.agent.config.include?(value) + end + visit(daemon_setting_filter_record_transformer_path) + within("form") do + fill_in("Record", with: value) + end + click_button(I18n.t("fluentd.common.finish")) + assert do + @daemon.agent.config.include?(value) + end + end +end
Add system test for filter_record_transformer Signed-off-by: Kenji Okimoto <7a4b90a0a1e6fc688adec907898b6822ce215e6c@clear-code.com>
diff --git a/attributes/server_apache.rb b/attributes/server_apache.rb index abc1234..def5678 100644 --- a/attributes/server_apache.rb +++ b/attributes/server_apache.rb @@ -1,6 +1,6 @@ default['icinga2']['apache_modules'] = value_for_platform( - %w(centos redhat fedora) => { '>= 7' => %w(default mod_wsgi mod_php5 mod_cgi mod_ssl mod_rewrite), + %w(centos redhat fedora) => { '>= 7.0' => %w(default mod_wsgi mod_php5 mod_cgi mod_ssl mod_rewrite), 'default' => %w(default mod_python mod_php5 mod_cgi mod_ssl mod_rewrite) }, 'amazon' => { 'default' => %w(default mod_python mod_php5 mod_cgi mod_ssl mod_rewrite) }, 'ubuntu' => { 'default' => %w(default mod_python mod_php5 mod_cgi mod_ssl mod_rewrite) }
Fix version contraint for centos 7 apache modules
diff --git a/uidable.gemspec b/uidable.gemspec index abc1234..def5678 100644 --- a/uidable.gemspec +++ b/uidable.gemspec @@ -23,6 +23,6 @@ spec.require_paths = ["lib"] spec.required_ruby_version = '>= 2.1.0' - spec.add_development_dependency "bundler", "~> 1.9" - spec.add_development_dependency "rake", "~> 10.0" + spec.add_development_dependency "bundler", "~> 2.1.2" + spec.add_development_dependency "rake", "~> 13.0" end
Update bundler and rake version
diff --git a/Casks/sidekick.rb b/Casks/sidekick.rb index abc1234..def5678 100644 --- a/Casks/sidekick.rb +++ b/Casks/sidekick.rb @@ -2,7 +2,7 @@ version :latest sha256 :no_check - url 'http://oomphalot.com/sidekick/release/Sidekick.zip' + url 'http://releases.oomphalot.com.s3-website-us-east-1.amazonaws.com/Sidekick/Sidekick.zip' appcast 'http://updates.oomphalot.com/?app=Sidekick' homepage 'http://oomphalot.com/sidekick/' license :unknown
Update the URL for fetching Sidekick since they moved to Amazon S3
diff --git a/spec/henson/source/github_spec.rb b/spec/henson/source/github_spec.rb index abc1234..def5678 100644 --- a/spec/henson/source/github_spec.rb +++ b/spec/henson/source/github_spec.rb @@ -34,7 +34,7 @@ it.expects(:version).returns("1.1.2").at_least(3) ui.expects(:debug). - with("Downloading bar/puppet-foo@1.1.2 to /Users/wfarr/src/henson/.henson/cache/github/foo-1.1.2.tar.gz...") + with("Downloading #{it.send(:repo)}@#{it.send(:version)} to #{it.send(:cache_path).to_path}...") it.send(:api).expects(:download_tag_for_repo).with( 'bar/puppet-foo',
Fix yet another hardcoded spec
diff --git a/spec/support/controller_macros.rb b/spec/support/controller_macros.rb index abc1234..def5678 100644 --- a/spec/support/controller_macros.rb +++ b/spec/support/controller_macros.rb @@ -0,0 +1,17 @@+module ControllerMacros + def login_admin + before(:each) do + @request.env["devise.mapping"] = Devise.mappings[:user] + sign_in Factory.create(:administrator) + end + end + + def login_contestant + before(:each) do + @request.env["devise.mapping"] = Devise.mappings[:user] + sign_in Factory.create(:contestant) + # @user.confirm! # or set a confirmed_at inside the factory. Only necessary if you are using the confirmable module + end + end + +end
Add macros for devise spec testing
diff --git a/spec/support/test_classes/book.rb b/spec/support/test_classes/book.rb index abc1234..def5678 100644 --- a/spec/support/test_classes/book.rb +++ b/spec/support/test_classes/book.rb @@ -1,6 +1,6 @@ class Book attr_accessor :title, :authors - def initialize title="Foo Bar", authors=[] + def initialize title="Foo Bar #{Time.now.to_f.to_s}", authors=[] @title = title @authors = authors end
Make default test class data index-friendly
diff --git a/lib/conjure/provision/docker_image.rb b/lib/conjure/provision/docker_image.rb index abc1234..def5678 100644 --- a/lib/conjure/provision/docker_image.rb +++ b/lib/conjure/provision/docker_image.rb @@ -3,14 +3,15 @@ class DockerImage attr_reader :image_name - def initialize(base_image_name) + def initialize(server, base_image_name) + @server = server @image_name = base_image_name end def start(shell_command, options = {}) - container_id = `docker run -d #{options[:run_options].to_s} #{image_name} #{shell_command}`.strip + container_id = @server.run("docker run -d #{options[:run_options].to_s} #{image_name} #{shell_command}").strip sleep 2 - ip_address = `docker inspect -format '{{ .NetworkSettings.IPAddress }}' #{container_id}`.strip + ip_address = @server.run("docker inspect -format '{{ .NetworkSettings.IPAddress }}' #{container_id}").strip raise "Container failed to start" unless ip_address.present? ip_address end
Support remote server operation in Provision::DockerImage
diff --git a/test/helpers/git_helper.rb b/test/helpers/git_helper.rb index abc1234..def5678 100644 --- a/test/helpers/git_helper.rb +++ b/test/helpers/git_helper.rb @@ -2,22 +2,23 @@ module GitHelper module_function - def git_commit_am(message) - index = @repo.index + def git_commit(index, message) options = {} - - index.read_tree(@repo.head.target.tree) unless @repo.empty? - index.add_all - options[:tree] = index.write_tree(@repo) options[:author] = { email: "foo@bar.com", name: 'Author', time: Time.now } options[:committer] = options[:author] options[:message] = message options[:parents] = @repo.empty? ? [] : [@repo.head.target].compact options[:update_ref] = 'HEAD' - Rugged::Commit.create(@repo, options) index.write + end + + def git_commit_am(message) + index = @repo.index + index.read_tree(@repo.head.target.tree) unless @repo.empty? + index.add_all + git_commit(index, message) end def git_checkout_b(branch)
Split `git_commit_am` and create `git_commit`
diff --git a/spec/views/medicaid/contact_social_security/edit.html.erb_spec.rb b/spec/views/medicaid/contact_social_security/edit.html.erb_spec.rb index abc1234..def5678 100644 --- a/spec/views/medicaid/contact_social_security/edit.html.erb_spec.rb +++ b/spec/views/medicaid/contact_social_security/edit.html.erb_spec.rb @@ -0,0 +1,64 @@+require "rails_helper" + +describe "medicaid/contact_social_security/edit.html.erb" do + before do + controller.singleton_class.class_eval do + def current_path + "/steps/medicaid/contact_social_security" + end + + helper_method :current_path + end + end + + context "one member has an invalid SSN" do + it "shows an error for that one member" do + controller.singleton_class.class_eval do + def single_member_household? + true + end + + helper_method :single_member_household? + end + + app = create(:medicaid_application, anyone_new_mom: true) + member = build(:member, ssn: "wrong", benefit_application: app) + member.save(validate: false) + member.valid? + step = Medicaid::ContactSocialSecurity.new(members: [member]) + assign(:step, step) + + render + + expect(rendered).to include("Make sure to provide 9 digits") + end + end + + context "two members have invalid SSN's" do + it "shows errors for each member" do + controller.singleton_class.class_eval do + def single_member_household? + false + end + + helper_method :single_member_household? + end + + app = create(:medicaid_application, anyone_new_mom: true) + + member1 = build(:member, ssn: "wrong", benefit_application: app) + member1.save(validate: false) + member1.valid? + + member2 = build(:member, ssn: "nope", benefit_application: app) + member2.save(validate: false) + member2.valid? + + step = Medicaid::ContactSocialSecurity.new(members: [member1, member2]) + assign(:step, step) + + render + expect(rendered.scan("Make sure to provide 9 digits").size).to eq 2 + end + end +end
Add spec to ensure error messages are showing
diff --git a/db/migrate/20200417183101_add_missing_reference_number_on_entries.rb b/db/migrate/20200417183101_add_missing_reference_number_on_entries.rb index abc1234..def5678 100644 --- a/db/migrate/20200417183101_add_missing_reference_number_on_entries.rb +++ b/db/migrate/20200417183101_add_missing_reference_number_on_entries.rb @@ -0,0 +1,51 @@+class AddMissingReferenceNumberOnEntries < ActiveRecord::Migration + def change + reversible do |dir| + dir.up do + # update null entry reference_number from not null sale reference_number + execute <<-SQL + UPDATE journal_entries + SET reference_number = sales.reference_number + FROM sales + WHERE journal_entries.resource_id = sales.id + AND journal_entries.resource_type = 'Sale' + AND journal_entries.reference_number IS NULL + AND sales.reference_number IS NOT NULL + SQL + + # update null entry reference_number from sale number because 'null sale reference_number' + execute <<-SQL + UPDATE journal_entries + SET reference_number = sales.number + FROM sales + WHERE journal_entries.resource_id = sales.id + AND journal_entries.resource_type = 'Sale' + AND journal_entries.reference_number IS NULL + AND sales.reference_number IS NULL + SQL + + # update null entry reference_number from not null purchase reference_number + execute <<-SQL + UPDATE journal_entries + SET reference_number = purchases.reference_number + FROM purchases + WHERE journal_entries.resource_id = purchases.id + AND journal_entries.resource_type = 'Purchase' + AND journal_entries.reference_number IS NULL + AND purchases.reference_number IS NOT NULL + SQL + + # update null entry reference_number from purchase number because 'null purchase reference_number' + execute <<-SQL + UPDATE journal_entries + SET reference_number = purchases.number + FROM purchases + WHERE journal_entries.resource_id = purchases.id + AND journal_entries.resource_type = 'Purchase' + AND journal_entries.reference_number IS NULL + AND purchases.reference_number IS NULL + SQL + end + end + end +end
Add migration to set sale/purchase reference_number on entry if nil.
diff --git a/libraries/helpers.rb b/libraries/helpers.rb index abc1234..def5678 100644 --- a/libraries/helpers.rb +++ b/libraries/helpers.rb @@ -1,16 +1,39 @@ module VarnishCookbook # Helper methods to be used in multiple Varnish cookbook libraries. module Helpers + def self.installed_major_version # Has issues being stubbed without 'self.' + cmd_str = 'varnishd -V 2>&1' + cmd = Mixlib::ShellOut.new(cmd_str) + cmd.environment['HOME'] = ENV.fetch('HOME', '/root') - def percent_of_total_mem(percent) - "#{(node['memory']['total'][0..-3].to_i * (percent / 100)).to_i}K" + begin + cmd.run_command + cmd_stdout = cmd.stdout.to_s + + raise "Output of #{cmd_str} was nil; can't determine varnish version" unless cmd_stdout + Chef::Log.debug "#{cmd_str} ran and detected varnish version: #{cmd_stdout}" + + matches = cmd_stdout.match(/varnish-([0-9]\.[0-9])/) + version_found = matches && matches[0] && matches[1] + raise "Cannot parse varnish version from #{cmd_stdout}" unless version_found + + return matches[1].to_f + rescue => ex + Chef::Log.warn 'Unable to run varnishd to get version.' + raise ex + end + end - #def systemd_daemon_reload - # execute 'systemctl-daemon-reload' do - # command '/bin/systemctl --system daemon-reload' - # action :nothing - # end - #end - end + def self.percent_of_total_mem(total_mem, percent) + "#{(total_mem[0..-3].to_i * (percent / 100)).to_i}K" + end + + def systemd_daemon_reload + execute 'systemctl-daemon-reload' do + command '/bin/systemctl --system daemon-reload' + action :nothing + end + end + end unless defined?(VarnishCookbook::Helpers) end
Add back shell out version detection
diff --git a/config/initializers/fast_gettext.rb b/config/initializers/fast_gettext.rb index abc1234..def5678 100644 --- a/config/initializers/fast_gettext.rb +++ b/config/initializers/fast_gettext.rb @@ -1,2 +1,2 @@-FastGettext.add_text_domain 'app', :path => 'locale', :type => :po, :ignore_fuzzy => true, :ignore_obsolete => true +FastGettext.add_text_domain 'app', :path => 'locale', :type => :po FastGettext.default_text_domain = 'app'
Put back the gettext fuzzy/obsolete warnings Be careful: turns out that the :ignore_fuzzy flag changes the behaviour of gettext. The warnings dont show up, but the fuzzy strings get used, and theyre most often wrong!
diff --git a/cookbooks/wt_streaminglogreplayer/recipes/undeploy.rb b/cookbooks/wt_streaminglogreplayer/recipes/undeploy.rb index abc1234..def5678 100644 --- a/cookbooks/wt_streaminglogreplayer/recipes/undeploy.rb +++ b/cookbooks/wt_streaminglogreplayer/recipes/undeploy.rb @@ -11,9 +11,9 @@ install_dir = "#{node['wt_common']['install_dir_linux']}/streaminglogreplayer" runit_service "streaminglogreplayer" do - action :disable - run_restart false -end + action :disable + run_restart false +end # try to stop the service, but allow a failure without printing the error service "streaminglogreplayer" do
Fix uninstall script formatting in log replayer
diff --git a/app/controllers/search_results_controller.rb b/app/controllers/search_results_controller.rb index abc1234..def5678 100644 --- a/app/controllers/search_results_controller.rb +++ b/app/controllers/search_results_controller.rb @@ -2,14 +2,14 @@ decorates_assigned :search_results, with: SearchResultCollectionDecorator def index - if params[:query].present? - @search_results = PerformCorrectiveSearch.new(params[:query], params[:page]).call + return if params[:query].blank? - if @search_results.any? - render 'search_results/index_with_results' - else - render 'search_results/index_no_results' - end + @search_results = PerformCorrectiveSearch.new(params[:query], params[:page]).call + + if @search_results.any? + render 'search_results/index_with_results' + else + render 'search_results/index_no_results' end end
Use a guard clause instead of wrapping the code inside a conditional expression
diff --git a/lib/keychain.rb b/lib/keychain.rb index abc1234..def5678 100644 --- a/lib/keychain.rb +++ b/lib/keychain.rb @@ -22,7 +22,7 @@ # @note This method asks only for the metadata to be returned and thus # does not need user authorization to get results. # Returns true if there are any item matching the given attributes. - # @raise [Exception] for unexpected errors + # @raise [KeychainException] for unexpected errors # @return [true,false] def exists? result = Pointer.new :id @@ -44,6 +44,7 @@ end +# A trivial exception class that exists because it has a unique name. class KeychainException < Exception end
Fix a documentation typo and add missing documentation
diff --git a/app/models/renalware/letters/rtf_renderer.rb b/app/models/renalware/letters/rtf_renderer.rb index abc1234..def5678 100644 --- a/app/models/renalware/letters/rtf_renderer.rb +++ b/app/models/renalware/letters/rtf_renderer.rb @@ -35,10 +35,12 @@ temp_html_file.unlink # allows garbage collection and temp file removal end + # Use windows line endings (CRLF) rather than linux (LF). + # This solves a problem at Barts exporting RTFs to send to GPs def rtf_content_converted_from(html_temp_file) rtf_template = File.join(Engine.root, "lib", "pandoc", "templates", "default.rtf") options = { template: rtf_template } - PandocRuby.html([html_temp_file.path], options, :standalone).to_rtf + PandocRuby.html([html_temp_file.path], options, :standalone).to_rtf("--eol=crlf") end def html_with_images_stripped
Use Windows CRLF line endings when rendering RTF letters Previously we were using the native default == Linux == LF in Pandoc which was causing problems at Batrs with the RTFs they send to GPs.
diff --git a/lib/data_mapper/finalizer/dependent_relationship_set.rb b/lib/data_mapper/finalizer/dependent_relationship_set.rb index abc1234..def5678 100644 --- a/lib/data_mapper/finalizer/dependent_relationship_set.rb +++ b/lib/data_mapper/finalizer/dependent_relationship_set.rb @@ -23,6 +23,8 @@ # Iterate over dependent relationships # # @yield [Relationship] + # + # @return [self] # # @api private def each(&block)
Add missing @return yard tag
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 @@ -30,5 +30,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 end end
Add manual exception notification in log_error
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index abc1234..def5678 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -4,6 +4,6 @@ protected def admin? - BasicAuth.admin?(request) + BasicAuth.logged_in?(request) end end
Fix usage of BasicAuth.logged_in? method
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index abc1234..def5678 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -5,7 +5,18 @@ protected - def not_found - render json: { errors: 'Not found' }, status: :not_found + def not_found(exception) + model = build_not_found_model(exception.model) + render_error(model, :not_found) + end + + def build_not_found_model(model_name) + model = model_name.classify.constantize.new + model.errors.add(:id, 'Not found') + model + end + + def render_error(model, status) + render json: model, status: status, adapter: :json_api, serializer: ActiveModel::Serializer::ErrorSerializer end end
Use json-api adapter for error render
diff --git a/app/helpers/channels_helper.rb b/app/helpers/channels_helper.rb index abc1234..def5678 100644 --- a/app/helpers/channels_helper.rb +++ b/app/helpers/channels_helper.rb @@ -1,11 +1,11 @@ module ChannelsHelper def format_body(post) - text = simple_format(post.body) + text = simple_format(post.body, {}, :sanitize => false) if text.length < 64000 - text = auto_link(text) + text = auto_link(text, :sanitize => false) end - text + text.html_safe end def user_link(user)
Disable sanitizing for post bodies
diff --git a/china_region_fu.gemspec b/china_region_fu.gemspec index abc1234..def5678 100644 --- a/china_region_fu.gemspec +++ b/china_region_fu.gemspec @@ -14,4 +14,6 @@ gem.name = "china_region_fu" gem.require_paths = ["lib"] gem.version = ChinaRegionFu::VERSION + + gem.add_dependency 'jquery-rails' end
Add dependency 'jquery-rails' for Jquery
diff --git a/app/helpers/sessions_helper.rb b/app/helpers/sessions_helper.rb index abc1234..def5678 100644 --- a/app/helpers/sessions_helper.rb +++ b/app/helpers/sessions_helper.rb @@ -1,9 +1,11 @@ module SessionsHelper + # Logs in the given user. def log_in(user) session[:user_id] = user.id end + # Returns the current logged-in user (if there is one). def current_user @current_user ||= User.find_by(id: session[:user_id]) end
Add comments within the SessionsHelper to explain the methods there