diff
stringlengths
65
26.7k
message
stringlengths
7
9.92k
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index abc1234..def5678 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -9,5 +9,8 @@ end RSpec.configure do |config| - config.after { clear_cookies } + config.after do + clear_cookies + Mingo.collection.remove + end end
Remove all documents from the Mingo collection (but leave any indexes) after each spec run.
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index abc1234..def5678 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,6 +1,6 @@ require 'codeclimate-test-reporter' +CodeClimate::TestReporter.start + require 'svgeez' -CodeClimate::TestReporter.start - $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
Move svgeez require below testreporter.
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index abc1234..def5678 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -11,6 +11,8 @@ Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} RSpec.configure do |config| + config.include FactoryGirl::Syntax::Methods + # == Mock Framework # # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line: @@ -20,8 +22,10 @@ # config.mock_with :rr config.mock_with :rspec + + # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures - config.fixture_path = "#{::Rails.root}/spec/fixtures" + # config.fixture_path = "#{::Rails.root}/spec/fixtures" # If you're not using ActiveRecord, or you'd prefer not to run each of your # examples within a transaction, remove the following line or assign false
Add FactoryGirl to rspec config
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index abc1234..def5678 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,11 +1,8 @@-require 'rspec' require 'fakefs/spec_helpers' -require 'rspec' require 'pact/support' require 'webmock/rspec' require 'support/factories' require 'support/spec_support' - WebMock.disable_net_connect!(allow_localhost: true)
Remove redundant requires for spec.
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index abc1234..def5678 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,5 @@+$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..')) +$LOAD_PATH.unshift(File.dirname(__FILE__)) require 'rspec' require 'flowdock-irc'
Fix require paths for ruby >1.9.2
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index abc1234..def5678 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,7 +1,7 @@ require 'pathname' require 'rubygems' -gem 'rspec', '~>1.1.12' +gem 'rspec', '>=1.1.12' require 'spec' require Pathname(__FILE__).dirname.parent.expand_path + 'lib/dm-migrations'
Use RSpec >= 1.1.12 so 1.2 can be used as well
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index abc1234..def5678 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -8,22 +8,20 @@ require path end +require 'simplecov' +SimpleCov.coverage_dir(File.join('spec', 'coverage')) + if ENV['TRAVIS'] require 'coveralls' - Coveralls.wear! -else - require 'simplecov' - SimpleCov.coverage_dir(File.join('spec', 'coverage')) + SimpleCov.formatter = Coveralls::SimpleCov::Formatter +elsif ENV['CI'] + require 'simplecov-rcov' + SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter +end - if ENV['CI'] - require 'simplecov-rcov' - SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter - end - - SimpleCov.start do - add_filter '/spec/' - add_filter '/vendor/bundle/' - end +SimpleCov.start do + add_filter '/spec/' + add_filter '/vendor/bundle/' end require 'guard/rubocop'
Use Coveralls as a SimpleCov formatter rather than standalone
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index abc1234..def5678 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -6,24 +6,6 @@ require 'rspec' require 'capybara' -RSpec.configure do |config| - # Workaround for http://code.google.com/p/selenium/issues/detail?id=3147: - # Rerun the example if we hit a transient "docElement is null" error - config.around(:each) do |example| - attempts = 0 - begin - example.run - # example is just a Proc, @example is the current RSpec::Core::Example - e = @example.instance_variable_get('@exception') # usually nil - if (defined?(Selenium::WebDriver::Error::UnknownError) && e.is_a?(Selenium::WebDriver::Error::UnknownError) && - e.message == 'docElement is null' && (attempts += 1) < 5) - @example.instance_variable_set('@exception', nil) - redo - end - end until true - end -end - require 'capybara/spec/spec_helper' module TestSessions
Remove workaround for "docElement is null" error The bug seems to be fixed in Selenium, and it works for me locally, so let's try and see how we do without this.
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index abc1234..def5678 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,10 @@+# frozen_string_literal: true + +# Hack to remove VERSION (which is loaded/required via Gemfile -> *.gemspec) before simplecov +# Without this, simplecov reports the VERSION is not covered by specs. +HubSpot.send(:remove_const, "VERSION") if defined?(HubSpot) +$LOADED_FEATURES.delete_if { |s| s.include?("hub_spot/version") } + require "simplecov" require "bundler/setup" require 'byebug'
Fix to ensure version file is tracked in code coverage
diff --git a/spec/support/vcr.rb b/spec/support/vcr.rb index abc1234..def5678 100644 --- a/spec/support/vcr.rb +++ b/spec/support/vcr.rb @@ -5,5 +5,5 @@ config.hook_into :webmock config.ignore_localhost = true config.configure_rspec_metadata! - # config.default_cassette_options = { match_requests_on: [:method, :host], record: :new_episodes } + config.default_cassette_options = { match_requests_on: [:method, :uri], record: :once, allow_playback_repeats: true } end
Add allow_playback_repeats to default cassette options
diff --git a/0_code_wars/regex_fun_1_few_days_at_gym.rb b/0_code_wars/regex_fun_1_few_days_at_gym.rb index abc1234..def5678 100644 --- a/0_code_wars/regex_fun_1_few_days_at_gym.rb +++ b/0_code_wars/regex_fun_1_few_days_at_gym.rb @@ -0,0 +1,16 @@+# http://www.codewars.com/kata/5720a81309e1f9b232001c5b/ +# --- iteration 1 --- +def gym_slang(phrase) + mappings = { + "probably" => "prolly", + "i am" => "i'm", + "instagram" => "insta", + "do not" => "don't", + "going to" => "gonna", + "combination" => "combo" + } + + phrase.gsub(/(#{mappings.keys.join("|")})/i) do |match| + match[0] + mappings[match.downcase][1..-1] + end +end
Add code wars (7) - few days at the gym
diff --git a/spec/controllers/posts_controller_spec.rb b/spec/controllers/posts_controller_spec.rb index abc1234..def5678 100644 --- a/spec/controllers/posts_controller_spec.rb +++ b/spec/controllers/posts_controller_spec.rb @@ -10,12 +10,12 @@ it 'should get index' do get :index - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'should get new' do get :new - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'should create post' do @@ -32,24 +32,24 @@ it 'should show post' do get :show, params: { id: post1.id } - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'should get edit' do get :edit, params: { id: post1.id } - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end - xit 'should update post' do - patch post_url(@post), params: { post: {} } + it 'should update post' do + patch :update, params: { id: post1.id, post: {} } + expect(response).to redirect_to(post_path(post1)) end - xit 'should destroy post' do - post2 = create(:post) + it 'should destroy post' do + post1.touch before_count = Post.count delete :destroy, params: { id: post1.id } expect(Post.count).to eq(before_count - 1) expect(response).to redirect_to(posts_path) - expect(post2).to be_persisted end end
Add post update and delete tests
diff --git a/spec/controllers/tasks_controller_spec.rb b/spec/controllers/tasks_controller_spec.rb index abc1234..def5678 100644 --- a/spec/controllers/tasks_controller_spec.rb +++ b/spec/controllers/tasks_controller_spec.rb @@ -20,7 +20,7 @@ name: "Write a Todo App", }, } - post :create, params + post :create, params: params expect(response).to redirect_to(:tasks) end.to change { Task.count }.by(1) end
Update spec call to rails 5 style.
diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index abc1234..def5678 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -3,7 +3,8 @@ describe UsersController do describe "GET 'show'" do it "returns http success" do - get :show, username: 'test' + user = create(:user) + get :show, username: user.username response.should be_success end end
Create user before performing show action
diff --git a/spec/features/instrument_versions_spec.rb b/spec/features/instrument_versions_spec.rb index abc1234..def5678 100644 --- a/spec/features/instrument_versions_spec.rb +++ b/spec/features/instrument_versions_spec.rb @@ -3,21 +3,22 @@ feature "Instrument Versions", js: true, versioning: true do before :each do @user = FactoryGirl.create(:user) + @project = FactoryGirl.create(:project) + @user_project = UserProject.create!(user_id: @user.id, project_id: @project.id) visit '/users/sign_in' fill_in 'user_email', :with => @user.email fill_in 'user_password', :with => @user.password click_button 'Sign in' - @instrument = FactoryGirl.create(:instrument) - visit "/instruments/#{@instrument.id}" + @instrument = FactoryGirl.create(:instrument, project: @project) + @old_title = @instrument.title + @instrument.update_attributes!(title: 'New Name') + visit "/projects/#{@instrument.project.id}/instruments/#{@instrument.id}/versions" end scenario "to list past versions" do - old_title = @instrument.title - @instrument.update_attributes!(title: 'New Name') - click_link "Past Versions" within('table.table') do expect(page).to have_text("0") - expect(page).to have_text(old_title) + expect(page).to have_text(@old_title) expect(page).to have_text(@user.email) end end
Fix instrument versions feature spec
diff --git a/spec/lib/training/training_loader_spec.rb b/spec/lib/training/training_loader_spec.rb index abc1234..def5678 100644 --- a/spec/lib/training/training_loader_spec.rb +++ b/spec/lib/training/training_loader_spec.rb @@ -0,0 +1,30 @@+# frozen_string_literal: true +require 'rails_helper' +require "#{Rails.root}/lib/training/training_loader" +require "#{Rails.root}/lib/training_slide" + +describe TrainingLoader do + describe '#load_content' do + let(:content_class) { TrainingSlide } + let(:subject) do + TrainingLoader.new(content_class: content_class, + path_to_yaml: "#{Rails.root}/training_content/none/*.yml", + trim_id_from_filename: false, + wiki_base_page: 'Training modules/dashboard/slides-test') + end + before do + allow(Features).to receive(:wiki_trainings?).and_return(true) + Rails.cache.clear + end + after do + Rails.cache.clear + end + it 'populates the training cache' do + expect(Rails.cache.read('slides')).to be_nil + VCR.use_cassette 'training/load_from_wiki' do + subject.load_content + end + expect(Rails.cache.read('slides')).not_to be_empty + end + end +end
Add start of TrainingLoader spec
diff --git a/spec/services/spree/cart/add_item_spec.rb b/spec/services/spree/cart/add_item_spec.rb index abc1234..def5678 100644 --- a/spec/services/spree/cart/add_item_spec.rb +++ b/spec/services/spree/cart/add_item_spec.rb @@ -0,0 +1,29 @@+require 'spec_helper' + +module Spree + describe Cart::AddItem do + subject { described_class } + + let(:order) { create :order } + let(:variant) { create :variant, price: 20 } + let(:qty) { 1 } + let(:context) { create(:context) } + let(:rate) { create(:rate) } + let(:execute) { subject.call(order: order, + variant: variant, + context: context, + rate: rate, + quantity: qty) } + let(:value) { execute.value } + let(:expected_line_item) { order.reload.line_items.first } + + context 'add travel line item to order' do + it 'change by one and recalculate amount' do + expect { execute }.to change { order.line_items.count }.by(1) + expect(execute).to be_success + expect(value).to eq expected_line_item + expect(order.amount).to eq 20 + end + end + end +end
Why: Add Item to a Card service has been manipulated to accept rate and context, this test is to check that a travel product with rate and context can be added.
diff --git a/lesson14/dont_think_twice_its_all_right.rb b/lesson14/dont_think_twice_its_all_right.rb index abc1234..def5678 100644 --- a/lesson14/dont_think_twice_its_all_right.rb +++ b/lesson14/dont_think_twice_its_all_right.rb @@ -0,0 +1,14 @@+# Lesson 14 - 'Slash' chords and Bass runs +# Don't Think Twice It's Alright - Bob Dylan +require "#{Dir.home}/ruby/pianoforall/lesson14/slash_half_beat_bounce" + +use_synth :piano +BEAT = 0.7 + +slash_half_beat_bounce(:G4, num_bass_octaves: 2, beat: BEAT) +slash_half_beat_bounce(:D4, bass_note: :Fs3, num_bass_octaves: 2, beat: BEAT) +slash_half_beat_bounce(:E4, quality: :minor, num_bass_octaves: 2, beat: BEAT) +slash_half_beat_bounce(:E4, quality: :minor, bass_note: :D3, num_bass_octaves: 2, beat: BEAT) +2.times { slash_half_beat_bounce(:C4, beat: BEAT) } +slash_half_beat_bounce(:G3, beat: BEAT) +slash_half_beat_bounce(:D4, beat: BEAT)
Add Don't Think Twice It's Alright
diff --git a/BBSInspector.podspec b/BBSInspector.podspec index abc1234..def5678 100644 --- a/BBSInspector.podspec +++ b/BBSInspector.podspec @@ -8,14 +8,14 @@ Pod::Spec.new do |s| s.name = "BBSInspector" - s.version = "0.1.0" + s.version = "0.1.1" s.summary = "Extendable device and application information in your iOS application" s.homepage = "https://github.com/bigbossstudio-dev/BBSInspector" # s.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif" s.license = { :type => "MIT" } s.author = { "Cyril Chandelier" => "cyril.chandelier@gmail.com" } s.platform = :ios, '8.0' - s.source = { :git => "https://github.com/bigbossstudio-dev/BBSInspector.git", :tag => "0.1.0" } + s.source = { :git => "https://github.com/bigbossstudio-dev/BBSInspector.git", :tag => "0.1.1" } s.source_files = "Classes", "Library/Classes/*.{h,m,swift}" s.requires_arc = true end
Update pod specification for 0.1.1
diff --git a/files/rubygems-customization/default/operating_system.rb b/files/rubygems-customization/default/operating_system.rb index abc1234..def5678 100644 --- a/files/rubygems-customization/default/operating_system.rb +++ b/files/rubygems-customization/default/operating_system.rb @@ -4,8 +4,8 @@ # system. # Always install and update new gems in "user install mode" -Gem::ConfigFile::OPERATING_SYSTEM_DEFAULTS["install"] = "--user" -Gem::ConfigFile::OPERATING_SYSTEM_DEFAULTS["update"] = "--user" +Gem::ConfigFile::OPERATING_SYSTEM_DEFAULTS["install"] = "--user --no-rdoc --no-ri" +Gem::ConfigFile::OPERATING_SYSTEM_DEFAULTS["update"] = "--user --no-rdoc --no-ri" module Gem
Stop 'chef gem' from installing Gem documentation
diff --git a/app/models/neighborly/balanced/bankaccount/payment_generator.rb b/app/models/neighborly/balanced/bankaccount/payment_generator.rb index abc1234..def5678 100644 --- a/app/models/neighborly/balanced/bankaccount/payment_generator.rb +++ b/app/models/neighborly/balanced/bankaccount/payment_generator.rb @@ -24,7 +24,7 @@ end def payment_class - @payment_class ||= can_debit_resource? ? Payment : DelayedPayment + @payment_class ||= can_debit_resource? ? Neighborly::Balanced::Bankaccount::Payment : Neighborly::Balanced::Bankaccount::DelayedPayment end def can_debit_resource?
Fix error when doing a instand payment
diff --git a/lib/migration_tools/migration_extension.rb b/lib/migration_tools/migration_extension.rb index abc1234..def5678 100644 --- a/lib/migration_tools/migration_extension.rb +++ b/lib/migration_tools/migration_extension.rb @@ -23,7 +23,8 @@ ActiveRecord::Migration.class_eval do extend MigrationTools::MigrationExtension class << self - alias_method_chain :migrate, :forced_groups + alias_method :migrate_without_forced_groups, :migrate + alias_method :migrate, :migrate_with_forced_groups end def migration_group
Replace alias_method_chain with 2 alias_method
diff --git a/lib/mongo_profiler/models/profile_group.rb b/lib/mongo_profiler/models/profile_group.rb index abc1234..def5678 100644 --- a/lib/mongo_profiler/models/profile_group.rb +++ b/lib/mongo_profiler/models/profile_group.rb @@ -5,7 +5,7 @@ field :name, type: String - has_many :profiles + has_many :profiles, dependent: :delete index name: 1 end
Delete related profiles when deleting groups
diff --git a/api/lib/spree/api/testing_support/helpers.rb b/api/lib/spree/api/testing_support/helpers.rb index abc1234..def5678 100644 --- a/api/lib/spree/api/testing_support/helpers.rb +++ b/api/lib/spree/api/testing_support/helpers.rb @@ -32,7 +32,7 @@ end def upload_image(filename) - fixture_file_upload(image(filename).path, 'image/jpg') + fixture_file_upload(image(filename).path) end end end
Revert "Need to pass through a content-type when using upload_image to appease paperclip" This reverts commit b04d57cd7ed194fcf59c4ed67e844c832bdbcc2d.
diff --git a/app/controllers/base_controller_decorator.rb b/app/controllers/base_controller_decorator.rb index abc1234..def5678 100644 --- a/app/controllers/base_controller_decorator.rb +++ b/app/controllers/base_controller_decorator.rb @@ -4,7 +4,7 @@ def save_search keywords = @searcher.try!(:keywords) - if @products.present? and keywords.present? + if @products.try(:any?) and keywords.present? query = Spree::Suggestion.find_or_initialize_by(keywords: keywords) query.items_found = @products.size
Optimize checking for search results. `present?` accidentally runs additional query.
diff --git a/src/bosh-dev/spec/support/ruby_version.rb b/src/bosh-dev/spec/support/ruby_version.rb index abc1234..def5678 100644 --- a/src/bosh-dev/spec/support/ruby_version.rb +++ b/src/bosh-dev/spec/support/ruby_version.rb @@ -3,7 +3,7 @@ module Bosh::Dev class RubyVersion class << self - @@versions = ['2.4.2'] + @@versions = ['2.4.4'] def supported?(version) @@versions.include?(version)
Fix outdated ruby version variable [#156834184](https://www.pivotaltracker.com/story/show/156834184) Co-authored-by: Josh Russett <51387f2e18a282e19bf73e3a4ebd17eb7c8325fd@pivotal.io>
diff --git a/app/models/utils/nav/customization_parser.rb b/app/models/utils/nav/customization_parser.rb index abc1234..def5678 100644 --- a/app/models/utils/nav/customization_parser.rb +++ b/app/models/utils/nav/customization_parser.rb @@ -29,7 +29,7 @@ name: c[0], path: c[1], permitted: true, - icon: "info-circle" + icon: "bookmark" } end result
783: Fix custom menu item icons
diff --git a/motion-addressbook.gemspec b/motion-addressbook.gemspec index abc1234..def5678 100644 --- a/motion-addressbook.gemspec +++ b/motion-addressbook.gemspec @@ -17,8 +17,7 @@ gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) gem.require_paths = ["lib"] - gem.add_dependency 'bubble-wrap', '~> 1.3' - + gem.add_development_dependency 'bubble-wrap', '~> 1.3' gem.add_development_dependency 'rake' gem.add_development_dependency 'rspec' end
Make bubble-wrap a dev dependency for the app example.
diff --git a/weather_hacker.gemspec b/weather_hacker.gemspec index abc1234..def5678 100644 --- a/weather_hacker.gemspec +++ b/weather_hacker.gemspec @@ -17,6 +17,7 @@ gem.add_dependency 'rake', '>= 0.9.2' gem.add_dependency "httparty" + gem.add_dependency "awesome_print" gem.add_development_dependency "rspec" gem.add_development_dependency "simplecov" gem.add_development_dependency "simplecov-vim"
Add dependencies for bin/ script
diff --git a/lib/puppet/functions/extlib/has_module.rb b/lib/puppet/functions/extlib/has_module.rb index abc1234..def5678 100644 --- a/lib/puppet/functions/extlib/has_module.rb +++ b/lib/puppet/functions/extlib/has_module.rb @@ -27,7 +27,6 @@ return false unless File.exist?(metadata_json) metadata = JSON.parse(File.read(metadata_json)) - return true if metadata['name'] == full_module_name - false + metadata['name'] == full_module_name end end
Use a shorter syntax to return
diff --git a/seo_rails_helpers.gemspec b/seo_rails_helpers.gemspec index abc1234..def5678 100644 --- a/seo_rails_helpers.gemspec +++ b/seo_rails_helpers.gemspec @@ -19,7 +19,5 @@ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ['lib'] - spec.add_development_dependency 'bundler', '~> 1.9' - spec.add_development_dependency 'rake', '~> 10.0' spec.add_development_dependency 'rspec-rails', '~> 3.3' end
Remove bundler and rake dependency
diff --git a/modules/assets/spec/classes/assets_spec.rb b/modules/assets/spec/classes/assets_spec.rb index abc1234..def5678 100644 --- a/modules/assets/spec/classes/assets_spec.rb +++ b/modules/assets/spec/classes/assets_spec.rb @@ -0,0 +1,10 @@+require_relative '../../../../spec_helper' + +describe 'assets', :type => :class do + + it { is_expected.to compile } + + it { is_expected.to compile.with_all_deps } + + it { is_expected.to contain_class('assets') } +end
Add stub rspec test to module
diff --git a/app/controllers/html_versions_controller.rb b/app/controllers/html_versions_controller.rb index abc1234..def5678 100644 --- a/app/controllers/html_versions_controller.rb +++ b/app/controllers/html_versions_controller.rb @@ -2,7 +2,7 @@ layout 'detailed-guidance' before_filter :find_publication - before_filter :find_supporting_page + before_filter :find_html_version include CacheControlHelper include PublicDocumentRoutesHelper @@ -24,7 +24,7 @@ end end - def find_supporting_page + def find_html_version unless (@publication.html_version) render text: "Not found", status: :not_found end
Rename mistakenly named method to show intent
diff --git a/spec/controllers/api/api_controller_spec.rb b/spec/controllers/api/api_controller_spec.rb index abc1234..def5678 100644 --- a/spec/controllers/api/api_controller_spec.rb +++ b/spec/controllers/api/api_controller_spec.rb @@ -13,12 +13,31 @@ it 'Response with correct JSON status structure' do hash_body = nil - expect { hash_body = json }.not_to raise_exception - expect(hash_body).to match( - 'message' => I18n.t('api.core.status_ok'), - 'versions' => [{ 'version' => 'v1', - 'baseUrl' => '/api/v1/' }] - ) + expect{hash_body = json}.not_to raise_exception + expect(hash_body).to include(:message => I18n.t('api.core.status_ok')) + expect(hash_body).to include('versions') + + Extends::API_VERSIONS.each_with_index do |ver, index| + expect(hash_body['versions']).to include( + { 'version' => ver, + 'baseUrl' => "/api/#{ver}/" } + ) + end + end + end + + describe 'GET #health' do + before do + get :health + end + + it 'Returns HTTP success' do + expect(response).to be_success + expect(response).to have_http_status(200) + end + + it 'Response with the correct plain text' do + expect(response.body).to match('RUNNING') end end end
Add unit tests for status/health API endpoints Closes [SCI-2746].
diff --git a/spec/service_objects/ak_user_params_spec.rb b/spec/service_objects/ak_user_params_spec.rb index abc1234..def5678 100644 --- a/spec/service_objects/ak_user_params_spec.rb +++ b/spec/service_objects/ak_user_params_spec.rb @@ -1,11 +1,6 @@-require 'browser' +describe AkUserParams do -describe AkUserParams do - before :all do - $browser = Browser.new - end - - let(:petition_signature) {{ + let(:params) {{ signature: { name: Faker::Name.name, email: Faker::Internet.email, @@ -19,27 +14,20 @@ zip: Faker::Address.zip, region: Faker::Config.locale, lang: 'En' - # email - # name - # name gets split to prefix, first name, middle name, last name and suffix automagically by AK ... - # address1 - # address2 - # city - # state - # zip - # postal - # country - # region - # phone - # mailing_id - # id - # plus4 - # lang - # source } }} + let(:browser) { Browser.new } + let(:expected_object) { + (params[:signature].clone).merge({ + user_agent: "", + browser_detected: false, + mobile: false, + tablet: false, + platform: :other + }) + } it 'Builds an object containing data about the user and the action' do - expect(AkUserParams.create(petition_signature)).to eq(true) + expect(AkUserParams.create(params,browser)).to eq(expected_object) end -end+end
Add working spec for ak user params creation
diff --git a/lib/byebug/interfaces/remote_interface.rb b/lib/byebug/interfaces/remote_interface.rb index abc1234..def5678 100644 --- a/lib/byebug/interfaces/remote_interface.rb +++ b/lib/byebug/interfaces/remote_interface.rb @@ -27,7 +27,7 @@ end def puts(message) - @socket.printf(message) + @socket.puts(message) end private
Fix yet another issue recently in remote debugging
diff --git a/spec/coverage_helper.rb b/spec/coverage_helper.rb index abc1234..def5678 100644 --- a/spec/coverage_helper.rb +++ b/spec/coverage_helper.rb @@ -1,8 +1,9 @@ # frozen_string_literal: true require 'simplecov' -require 'simplecov-lcov' if ENV['CI'] + require 'simplecov-lcov' + SimpleCov::Formatter::LcovFormatter.report_with_single_file = true SimpleCov.formatter = SimpleCov::Formatter::LcovFormatter
Modify simplecov-lcov to be required only in CI environment
diff --git a/lib/hdo/utils/representative_vote_feed.rb b/lib/hdo/utils/representative_vote_feed.rb index abc1234..def5678 100644 --- a/lib/hdo/utils/representative_vote_feed.rb +++ b/lib/hdo/utils/representative_vote_feed.rb @@ -14,6 +14,7 @@ propositions.map { |proposition| Entry.new(result, proposition) } end + entries = entries.uniq_by { |e| e.description } entries = entries.first(@limit) if @limit entries
Fix duplicate vote feed items
diff --git a/lib/sinatra-active-model-serializers/json.rb b/lib/sinatra-active-model-serializers/json.rb index abc1234..def5678 100644 --- a/lib/sinatra-active-model-serializers/json.rb +++ b/lib/sinatra-active-model-serializers/json.rb @@ -9,6 +9,17 @@ def json(object, options={}) options = options.merge(settings.active_model_serializers) + + begin + options[:root] = + if options[:root].is_a?(Boolean) && options[:root] == false + false + elsif object.is_a?(Mongoid::Criteria) + options[:each_serializer] = options[:serializer] + object.first.class.name.underscore.pluralize if options[:root] == true + end + rescue LoadError + end serializer = ActiveModel::Serializer.serializer_for(object, options) @@ -29,4 +40,4 @@ Base.set :active_model_serializers, {} Base.set :serializers_path, SERIALIZERS_DEFAULT_PATH -end+end
Add Mongoid::Criteria fetcher for root element
diff --git a/oc-chef-pedant/spec/api/groups_acl_spec.rb b/oc-chef-pedant/spec/api/groups_acl_spec.rb index abc1234..def5678 100644 --- a/oc-chef-pedant/spec/api/groups_acl_spec.rb +++ b/oc-chef-pedant/spec/api/groups_acl_spec.rb @@ -0,0 +1,59 @@+require 'pedant/rspec/common' +require 'pedant/acl' + +describe "Groups ACL", :acl do + include Pedant::ACL + + describe "returns Forbidden when trying to remove the admin group from any grant ACE" do + # For now testing with groups, but potentially also want to test with other objects + %w(admins clients users).each do |test_group| + context "for #{test_group}" do + let(:admin_username) { platform.admin_user.name } + let(:acl_url) { "#{platform.server}/groups/#{test_group}/_acl" } + let(:read_acl_url) { api_url("groups/#{test_group}/_acl") } + let(:write_acl_url) { api_url("groups/#{test_group}/_acl/grant") } + + let(:actors) { ["pivotal"] } + let(:groups) { [] } + + # Both the actors and groups keys must be present when doing a PUT + # or else the server rejects the request + let(:request_body) {{ + "grant" => { + "actors" => actors, + "groups" => groups + } + }} + + # Since we're playing with permissions, let's make sure we restore them + # If these tests pass, this shouldn't be needed, but if they fail we + # might be in a bad state, and then the restore is needed + before :each do + original_state = get(read_acl_url, superuser) + # If we can't get the original state, die, because then we can't restore it + original_state.should look_like({:status => 200}) + # The response is returned as a string that is valid JSON (in this case at least) + # Parsing it turns it into a usable hash + state_hash = JSON.parse original_state + # We're only changing the grant ACE, so pull that out to be able to use it + # for the restore + @original_grant_perms = state_hash['grant'] + end + + after :each do + payload = {"grant" => @original_grant_perms} + # If the original permissions don't restore, die, as we have an issue + put(write_acl_url, superuser, + :payload => payload).should look_like({:status => 200}) + end + + it "returns Fordidden trying to remove grant ace from #{test_group} group", :pending => true do + response = put(write_acl_url, platform.admin_user, + :payload => request_body) + response.should look_like({:status => 403}) + end + + end + end + end +end
Add tests for returning a 403 when removing admin group from any ACE This work isn't done yet, but these are the tests that will show when it is done. For now the tests are marked pending so they can go down into master.
diff --git a/lib/tasks/migrate_old_tinymce_assets.rake b/lib/tasks/migrate_old_tinymce_assets.rake index abc1234..def5678 100644 --- a/lib/tasks/migrate_old_tinymce_assets.rake +++ b/lib/tasks/migrate_old_tinymce_assets.rake @@ -5,19 +5,29 @@ desc 'Migrate old TinyMCE images to new polymorphic format' \ 'IT SHOULD BE RUN ONE TIME ONLY' task migrate_tinymce_assets: :environment do - old_images = TinyMceAsset.where('step_id IS NOT NULL OR result_text_id IS NOT NULL').where(object: nil) - old_images.each do |old_image| - old_format = /\[~tiny_mce_id:#{old_image.id}\]/ - new_format = "<img src='' class='img-responsive' data-mce-token='#{Base62.encode(old_image.id)}'/>" - if old_image.step_id - object = old_image.step - object.description.sub!(old_format, new_format) - else - object = old_image.result_text - object.text.sub!(old_format, new_format) + ActiveRecord::Base.no_touching do + old_images = TinyMceAsset.where('step_id IS NOT NULL OR result_text_id IS NOT NULL') + .where(object: nil) + .preload(:step, :result_text) + old_images.find_each do |old_image| + ActiveRecord::Base.transaction do + old_format = /\[~tiny_mce_id:#{old_image.id}\]/ + new_format = "<img src='' class='img-responsive' data-mce-token='#{Base62.encode(old_image.id)}'/>" + if old_image.step_id + object = old_image.step + object.description.sub!(old_format, new_format) + else + object = old_image.result_text + object.text.sub!(old_format, new_format) + end + object.save! + old_image.update!(object_id: object.id, object_type: object.class.to_s, step_id: nil, result_text_id: nil) + rescue StandardError => ex + Rails.logger.error "Failed to update TinyMceAsset id: #{old_image.id}" + Rails.logger.error ex.message + raise ActiveRecord::Rollback + end end - object.save - old_image.update(object: object, step_id: nil, result_text_id: nil) end end end
Improve speed and error handling of TinyMceAssets migration task [SCI-3459]
diff --git a/test/integration/test_editor.rb b/test/integration/test_editor.rb index abc1234..def5678 100644 --- a/test/integration/test_editor.rb +++ b/test/integration/test_editor.rb @@ -0,0 +1,52 @@+require_relative "../capybara_helper" + +context "editor interface" do + include Capybara::DSL + + setup do + @path = cloned_testpath "examples/lotr.git" + @wiki = Gollum::Wiki.new @path + + Precious::App.set :gollum_path, @path + Precious::App.set :wiki_options, {} + + Capybara.app = Precious::App + end + + teardown do + @path = nil + @wiki = nil + + Capybara.reset_sessions! + Capybara.use_default_driver + end + + test "editor renders help panel" do + visit "/create/new-article" + + in_editor_toolbar do + click_on "Help" + end + + help_widget = find "#gollum-editor-help" + + within help_widget do + click_on "Miscellaneous" + click_on "Emoji" + + assert_includes page.text, + "See the EmojiOne demo for all available emoji. To include one, " \ + "wrap the emoji name in colons and use underscores instead of " \ + "spaces (e.g. :heart: or :point_up:)." + end + + end + + def in_editor_toolbar &block + return unless block_given? + + within "#gollum-editor-function-bar" do + yield + end + end +end
Test the help panel's "Emoji" section This test is passing. I wrote it so I can safely change this panel in a subsequent commit.
diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index abc1234..def5678 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -16,8 +16,9 @@ @report = Reports::TotalInventoryValue.new(params, session) end - def orders_by_create_date_graph - @report = Order.group("date(created_at)").count + def graphs + @report_by_date = Reports::Graphs.order_count_by_day + @report_by_month = Reports::Graphs.order_count_by_month end private
Update controller to use new graphs models
diff --git a/app/controllers/sources_controller.rb b/app/controllers/sources_controller.rb index abc1234..def5678 100644 --- a/app/controllers/sources_controller.rb +++ b/app/controllers/sources_controller.rb @@ -13,9 +13,7 @@ end def create - SourceResolver.resolve(source) - - if source.persisted? + if SourceResolver.resolve(source) redirect_to sources_path else render :new
Use the return of the SourceResolver
diff --git a/app/controllers/v1/ping_controller.rb b/app/controllers/v1/ping_controller.rb index abc1234..def5678 100644 --- a/app/controllers/v1/ping_controller.rb +++ b/app/controllers/v1/ping_controller.rb @@ -1,5 +1,7 @@-class V1::PingController < ApplicationController - def ping - render json: { result: 'pong' } +module V1 + class PingController < ApplicationController + def ping + render json: { result: 'pong' } + end end end
Use nested module/class definitions in V1:PingController
diff --git a/lib/cloud_sesame/query/ast/string_value.rb b/lib/cloud_sesame/query/ast/string_value.rb index abc1234..def5678 100644 --- a/lib/cloud_sesame/query/ast/string_value.rb +++ b/lib/cloud_sesame/query/ast/string_value.rb @@ -3,8 +3,8 @@ module AST class StringValue < Abstract::Value - SINGLE_QUATE = /\'/ - ESCAPE_QUATE = "\\'" + SINGLE_QUATE = Regexp.new(/\'/) + ESCAPE_QUATE = Regexp.new("\\'") def self.parse(value) new(value.is_a?(String) ? value : value.to_s) if value
Replace regex in StringValue with compiled regex
diff --git a/lib/tasks/2018_10_03_remove_fc_from_procedure_presentation.rake b/lib/tasks/2018_10_03_remove_fc_from_procedure_presentation.rake index abc1234..def5678 100644 --- a/lib/tasks/2018_10_03_remove_fc_from_procedure_presentation.rake +++ b/lib/tasks/2018_10_03_remove_fc_from_procedure_presentation.rake @@ -0,0 +1,52 @@+namespace :'2018_10_03_remove_fc_from_procedure_presentation' do + task run: :environment do + Class.new do + def run + fix_displayed_fields + fix_sort + fix_filters + end + + def fix_displayed_fields + ProcedurePresentation.where(%q`displayed_fields @> '[{"table": "france_connect_information"}]'`).each do |procedure_presentation| + procedure_presentation.displayed_fields = procedure_presentation.displayed_fields.reject do |df| + df['table'] == 'france_connect_information' + end + + procedure_presentation.save(validate: false) + end + end + + def fix_sort + ProcedurePresentation.where(%q`sort @> '{"table": "france_connect_information"}'`).each do |procedure_presentation| + procedure_presentation.sort = { + "order" => "desc", + "table" => "notifications", + "column" => "notifications" + } + + procedure_presentation.save(validate: false) + end + end + + def fix_filters + ProcedurePresentation.find_by_sql( + <<~SQL + SELECT procedure_presentations.* + FROM procedure_presentations, LATERAL jsonb_each(filters) + WHERE value @> '[{"table": "france_connect_information"}]' + GROUP BY id; + SQL + ).each do |procedure_presentation| + procedure_presentation.filters.keys.each do |key| + procedure_presentation.filters[key] = procedure_presentation.filters[key].reject do |filter| + filter['table'] == 'france_connect_information' + end + end + + procedure_presentation.save + end + end + end.new.run + end +end
Migrate now obsolete displayed fields, filters and sorts
diff --git a/lib/hstore_radio_buttons/button_options.rb b/lib/hstore_radio_buttons/button_options.rb index abc1234..def5678 100644 --- a/lib/hstore_radio_buttons/button_options.rb +++ b/lib/hstore_radio_buttons/button_options.rb @@ -2,7 +2,7 @@ class ButtonOptions attr_accessor :name, :options def initialize(name, options) - self.name = name + self.name = name.to_s self.options = *options end end
Fix attempt for an integration project
diff --git a/lib/yard/server/commands/frames_command.rb b/lib/yard/server/commands/frames_command.rb index abc1234..def5678 100644 --- a/lib/yard/server/commands/frames_command.rb +++ b/lib/yard/server/commands/frames_command.rb @@ -6,7 +6,9 @@ def run main_url = request.path.gsub(/^(.+)?\/frames\/(#{path})$/, '\1/\2') - if path && !path.empty? + if path =~ %r{^file/} + page_title = "File: #{$'}" + elsif !path.empty? page_title = "Object: #{object_path}" elsif options[:files] && options[:files].size > 0 page_title = "File: #{options[:files].first.sub(/^#{library.source_path}\/?/, '')}"
Fix titles for File urls in frames
diff --git a/spec/controllers/groups_controller_spec.rb b/spec/controllers/groups_controller_spec.rb index abc1234..def5678 100644 --- a/spec/controllers/groups_controller_spec.rb +++ b/spec/controllers/groups_controller_spec.rb @@ -1,17 +1,23 @@ require 'rails_helper' RSpec.describe GroupsController, type: :controller do - describe 'GET groups/:id' do - let!(:user) { User.create!(name: "Matt", email: "matt@matt.com", password: 'password') } - let!(:group) { Group.create!(name: 'Grouptastic', admin_id: user.id) } + describe 'GET groups/:id' do + let!(:user) { User.create!(name: "Matt", email: "matt@matt.com", password: 'password') } + let!(:group) { Group.create!(name: 'Grouptastic', admin_id: user.id) } - before(:each) do - controller.session[:user_id] = user.id - get :show, :id => group.id - end + before(:each) do + controller.session[:user_id] = user.id + end - it 'Group does not have any hangouts' do - expect(assigns(:hangout_id)).to be nil - end + it 'Group does not have any hangouts' do + get :show, :id => group.id + expect(assigns(:hangout_id)).to be nil end + + xit 'Group gets assigned a hangout' do + hangout = Hangout.create!(creator_id: user.id, group_id: group.id) + get :show, :id => group.id + expect(assigns(:hangout_id)).to eq hangout.id + end + end end
Set second groups controller test to pending
diff --git a/test/unit/edition_clone_test.rb b/test/unit/edition_clone_test.rb index abc1234..def5678 100644 --- a/test/unit/edition_clone_test.rb +++ b/test/unit/edition_clone_test.rb @@ -0,0 +1,56 @@+require "test_helper" + +class EditionCloneTest < ActiveSupport::TestCase + def setup + @user = User.create :name => "Grandmaster Flash" + @other_user = User.create :name => "Furious Five" + + @artefact = FactoryGirl.create(:artefact, name: "Childcare", slug: "childcare") + end + + test "should clone a published GuideEdition to an AnswerEdition" do + stub_register_published_content + + guide_edition = FactoryGirl.create(:guide_edition, slug: "childcare", title: "One", panopticon_id: @artefact.id) + guide_edition.save + + @user.start_work(guide_edition) + @user.request_review(guide_edition,{comment: "Review this guide please."}) + @other_user.approve_review(guide_edition, {comment: "I've reviewed it"}) + @user.send_fact_check(guide_edition,{comment: "Review this guide please.", email_addresses: 'test@test.com'}) + @user.receive_fact_check(guide_edition, {comment: "No changes needed, this is all correct"}) + @other_user.approve_fact_check(guide_edition, {comment: "Looks good to me"}) + @user.publish(guide_edition, {comment: "First edition"}) + + answer_edition = guide_edition.build_clone(AnswerEdition) + answer_edition.save! + + assert_equal GuideEdition, guide_edition.class + assert_equal AnswerEdition, answer_edition.class + + assert_equal guide_edition.title, answer_edition.title + end + + test "should be able to switch from an AnswerEdition to a GuideEdition" do + stub_register_published_content + + answer_edition = FactoryGirl.create(:answer_edition, slug: "childcare", title: "One", panopticon_id: @artefact.id) + answer_edition.save + + @user.start_work(answer_edition) + @user.request_review(answer_edition,{comment: "Review this guide please."}) + @other_user.approve_review(answer_edition, {comment: "I've reviewed it"}) + @user.send_fact_check(answer_edition,{comment: "Review this guide please.", email_addresses: 'test@test.com'}) + @user.receive_fact_check(answer_edition, {comment: "No changes needed, this is all correct"}) + @other_user.approve_fact_check(answer_edition, {comment: "Looks good to me"}) + @user.publish(answer_edition, {comment: "First edition"}) + + guide_edition = answer_edition.build_clone(GuideEdition) + guide_edition.save! + + assert_equal AnswerEdition, answer_edition.class + assert_equal GuideEdition, guide_edition.class + + assert_equal guide_edition.title, answer_edition.title + end +end
Add better tests for Edition.build_clone method This method is likely to become more important as part of a feature to allow switching between different Edition types through the publisher admin UI. These tests aim to make sure that Edition.build_clone does what it says it does.
diff --git a/db/migrate/20141110212737_create_schools.rb b/db/migrate/20141110212737_create_schools.rb index abc1234..def5678 100644 --- a/db/migrate/20141110212737_create_schools.rb +++ b/db/migrate/20141110212737_create_schools.rb @@ -0,0 +1,22 @@+class CreateSchools < ActiveRecord::Migration + def change + create_table :schools do |t| + t.string :name + t.string :dbn + t.string :total_students + t.string :lat + t.string :long + t.string :boro + t.string :street_address + t.string :zip + t.text :overview + t.string :website + t.string :phone_number + t.string :grade_span_min + t.string :grade_span_max + t.text :program_highlights + + t.timestamps + end + end +end
Add create schools migration file
diff --git a/Formula/guile.rb b/Formula/guile.rb index abc1234..def5678 100644 --- a/Formula/guile.rb +++ b/Formula/guile.rb @@ -3,10 +3,10 @@ class Guile < Formula homepage 'http://www.gnu.org/software/guile/' url 'ftp://ftp.gnu.org/gnu/guile/guile-1.8.7.tar.gz' - head 'ftp://ftp.gnu.org/pub/gnu/guile/guile-2.0.0.tar.gz' + head 'ftp://ftp.gnu.org/pub/gnu/guile/guile-2.0.1.tar.gz' if ARGV.build_head? - sha1 'e266b79b17a04a98c438e9d5dabb5210fb368d77' + sha1 '3276a826f17a5edc0baf2eedc4821a771824141b' else sha1 '24cd2f06439c76d41d982a7384fe8a0fe5313b54' end
Update Guile head to 2.0.1 Signed-off-by: Adam Vandenberg <34c2b6407fd5a10249a15d699d40f9ed1782e98c@gmail.com>
diff --git a/db/migrate/20160316151832_create_accounts.rb b/db/migrate/20160316151832_create_accounts.rb index abc1234..def5678 100644 --- a/db/migrate/20160316151832_create_accounts.rb +++ b/db/migrate/20160316151832_create_accounts.rb @@ -1,7 +1,8 @@ class CreateAccounts < ActiveRecord::Migration def change create_table :accounts do |t| - + t.integer 'user_id' + t.decimal 'balance' t.timestamps null: false end end
Add balance to the accounts
diff --git a/db/migrate/20211219153054_create_profiles.rb b/db/migrate/20211219153054_create_profiles.rb index abc1234..def5678 100644 --- a/db/migrate/20211219153054_create_profiles.rb +++ b/db/migrate/20211219153054_create_profiles.rb @@ -11,14 +11,14 @@ t.timestamps end - User.find_each do |user| - Profile.create!( - user_id: user.id, - display_name: user.display_name, - description: user.bio, - location: user.location, - website: user.website, - ) + transaction do + execute 'INSERT INTO profiles (user_id, display_name, description, location, website, motivation_header, created_at, updated_at) SELECT users.id as user_id, users.display_name, users.bio as description, users.location, users.website, users.motivation_header, users.created_at, users.updated_at FROM users;' + + remove_column :users, :display_name + remove_column :users, :bio + remove_column :users, :location + remove_column :users, :website + remove_column :users, :motivation_header end end end
Use an INSERT INTO ... SELECT to move profile data and drop the old columns
diff --git a/spec/unit/inspect_spec.rb b/spec/unit/inspect_spec.rb index abc1234..def5678 100644 --- a/spec/unit/inspect_spec.rb +++ b/spec/unit/inspect_spec.rb @@ -12,6 +12,15 @@ event :stop, :yellow => :red } end - expect(fsm.inspect).to match(/^<#FiniteMachine::StateMachine:0x#{fsm.object_id.to_s(16)} @states=\[:none, :green, :yellow, :red\], @events=\[:init, :slow, :stop\], @transitions=\[{:none=>:green}, {:green=>:yellow}, {:yellow=>:red}\]>$/) + inspected = fsm.inspect + expect(inspected).to match(/^<#FiniteMachine::StateMachine:0x#{fsm.object_id.to_s(16)} @states=\[.*\], @events=\[.*\], @transitions=\[.*\]>$/) + + event_names = eval inspected[/events=\[(.*?)\]/] + states = eval inspected[/states=\[(.*?)\]/] + transitions = eval inspected[/transitions=\[(.*?)\]/] + + expect(event_names).to match_array([:init, :slow, :stop]) + expect(states).to match_array([:none, :green, :yellow, :red]) + expect(transitions).to match_array([{:none => :green}, {:green => :yellow}, {:yellow => :red}]) end end
Change to be less brittle
diff --git a/SwiftReorder.podspec b/SwiftReorder.podspec index abc1234..def5678 100644 --- a/SwiftReorder.podspec +++ b/SwiftReorder.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'SwiftReorder' - s.version = '3.0.1' + s.version = '3.1.0' s.license = 'MIT' s.summary = 'Easy drag-and-drop reordering for UITableViews' s.homepage = 'https://github.com/adamshin/SwiftReorder'
Update podspec for version 3.1.0
diff --git a/app/controllers/admin/guides_controller.rb b/app/controllers/admin/guides_controller.rb index abc1234..def5678 100644 --- a/app/controllers/admin/guides_controller.rb +++ b/app/controllers/admin/guides_controller.rb @@ -1,6 +1,6 @@ class Admin::GuidesController < InheritedResources::Base - before_filter :authenticate_user! + # before_filter :authenticate_user! defaults :route_prefix => 'admin' def index @@ -22,17 +22,20 @@ def progress @guide = resource @latest_edition = resource.latest_edition - + notes = '' + case params[:activity] - when 'request review' - current_user.request_review(@latest_edition) + when 'request_review' + current_user.request_review(@latest_edition, notes) when 'review' - current_user.review(@latest_edition) + current_user.review(@latest_edition, notes) when 'okay' - current_user.okay(@latest_edition) + current_user.okay(@latest_edition, notes) when 'publish' - current_user.publish(@latest_edition) + current_user.publish(@latest_edition, notes) end + + @latest_edition.save redirect_to admin_guide_path(@guide), :notice => 'Guide updated' end
Update progress action to store some notes, and save the edition at the end
diff --git a/app/controllers/announcements_controller.rb b/app/controllers/announcements_controller.rb index abc1234..def5678 100644 --- a/app/controllers/announcements_controller.rb +++ b/app/controllers/announcements_controller.rb @@ -1,5 +1,4 @@ class AnnouncementsController < PublicFacingController - def index params[:page] ||= 1 params[:direction] ||= "before" @@ -8,9 +7,6 @@ format.html format.json do render json: AnnouncementFilterJsonPresenter.new(@filter) - end - format.atom do - @publications = @filter.documents.by_published_at end end end @@ -21,5 +17,4 @@ Announcement.published .includes(:document, :organisations) end - end
Remove broken and untested announcement atom feed
diff --git a/app/controllers/travel_advice_controller.rb b/app/controllers/travel_advice_controller.rb index abc1234..def5678 100644 --- a/app/controllers/travel_advice_controller.rb +++ b/app/controllers/travel_advice_controller.rb @@ -23,7 +23,7 @@ private def fetch_artefact_and_publication_for_country(country) - params[:slug] = "travel-advice/" + params[:slug] + params[:slug] = "travel-advice/" + country artefact = fetch_artefact publication = PublicationPresenter.new(artefact)
Use the country parameter instead of params[:slug in fetch method
diff --git a/app/presenters/tree_builder_report_roles.rb b/app/presenters/tree_builder_report_roles.rb index abc1234..def5678 100644 --- a/app/presenters/tree_builder_report_roles.rb +++ b/app/presenters/tree_builder_report_roles.rb @@ -16,7 +16,7 @@ def root_options user = User.current_user title = if user.super_admin_user? - _("All EVM Grouops") + _("All EVM Groups") else _("My EVM Groups") end
Fix typo in Edit Report Menus tree https://bugzilla.redhat.com/show_bug.cgi?id=1443502
diff --git a/app/models/persistent_volume.rb b/app/models/persistent_volume.rb index abc1234..def5678 100644 --- a/app/models/persistent_volume.rb +++ b/app/models/persistent_volume.rb @@ -3,4 +3,7 @@ include NewWithTypeStiMixin serialize :capacity, Hash delegate :name, :to => :parent, :prefix => true + has_many :container_volumes, :through => :persistent_volume_claim + has_many :parents, -> { distinct }, :through => :container_volumes, :source_type => 'ContainerGroup' + alias_attribute :container_groups, :parents end
Add relationship between pods and persistent volumes Refactored code Added refactoring to persistent volume page to support UI Added small refactoring
diff --git a/Casks/the-unarchiver.rb b/Casks/the-unarchiver.rb index abc1234..def5678 100644 --- a/Casks/the-unarchiver.rb +++ b/Casks/the-unarchiver.rb @@ -1,5 +1,5 @@ class TheUnarchiver < Cask - url 'http://theunarchiver.googlecode.com/files/TheUnarchiver3.3.zip' + url 'http://theunarchiver.googlecode.com/files/TheUnarchiver3.4.zip' homepage 'http://unarchiver.c3.cx/' - version '3.3' -end+ version '3.4' +end
Update to version 3.4 of the unarchiver. This version, unlike the preceeding 3.3, is sandboxed so it can be included in the App Store.
diff --git a/rails/app/models/policy_member_distance.rb b/rails/app/models/policy_member_distance.rb index abc1234..def5678 100644 --- a/rails/app/models/policy_member_distance.rb +++ b/rails/app/models/policy_member_distance.rb @@ -13,6 +13,11 @@ belongs_to :policy, foreign_key: :dream_id belongs_to :member, foreign_key: :person, primary_key: :person + # TODO: Rename these attributes. + # These are disabled because we can't use these yet thanks to the missing primary key ass hattery below + # alias_attribute :distance_a, :distance + # alias_attribute :distance_b, :distance_without_abstentions + # Use update_all because we don't yet have a primary key on this model # TODO: Add a primary key and get rid of this function def increment!(attribute, by = 1)
Add a note about needing to rename these terrible attribute names
diff --git a/lib/cloud_foundry/language_pack/extensions.rb b/lib/cloud_foundry/language_pack/extensions.rb index abc1234..def5678 100644 --- a/lib/cloud_foundry/language_pack/extensions.rb +++ b/lib/cloud_foundry/language_pack/extensions.rb @@ -18,7 +18,7 @@ end def self.delimiter_for(prefix) - (prefix.end_with? '_') ? '' : DEPENDENCIES_TRANSLATION_DELIMITER + (prefix == "" || prefix.end_with?('_')) ? '' : DEPENDENCIES_TRANSLATION_DELIMITER end end end
Fix URL generation for custom URL assets
diff --git a/lib/travis/api/v3/services/requests/create.rb b/lib/travis/api/v3/services/requests/create.rb index abc1234..def5678 100644 --- a/lib/travis/api/v3/services/requests/create.rb +++ b/lib/travis/api/v3/services/requests/create.rb @@ -1,7 +1,7 @@ module Travis::API::V3 class Services::Requests::Create < Service TIME_FRAME = 1.hour - LIMIT = 10 + LIMIT = 50 private_constant :TIME_FRAME, :LIMIT result_type :request
Increase requests creation limit to 50
diff --git a/app/controllers/api/posts_controller.rb b/app/controllers/api/posts_controller.rb index abc1234..def5678 100644 --- a/app/controllers/api/posts_controller.rb +++ b/app/controllers/api/posts_controller.rb @@ -7,7 +7,7 @@ current_site.posts end - posts = scope.published.page(params.dig(:page, :number)).per(params.dig(:page, :size)) + posts = scope.published.order_by_recently.page(params.dig(:page, :number)).per(params.dig(:page, :size)) render json: posts, include: "category" end
Order by recently for posts API
diff --git a/app/controllers/portfolio_controller.rb b/app/controllers/portfolio_controller.rb index abc1234..def5678 100644 --- a/app/controllers/portfolio_controller.rb +++ b/app/controllers/portfolio_controller.rb @@ -2,15 +2,6 @@ unloadable layout 'portfolio' - - PRIVATE_ACCESS = [ - :user_setup, - :check_if_login_required, - :check_password_change - ] - - skip_before_filter *PRIVATE_ACCESS, :only => :index - before_filter :public_access?, :only => :index helper :all @@ -18,9 +9,4 @@ @projects = Project.portfolio end - protected - def public_access? - PRIVATE_ACCESS.map{ |v| send(v) }.all? unless Portfolio::Redmine.public_access? - end - end
Revert "Re enable anonymous mode" This reverts commit 3d88c55560f8905a7d131d829add6c4dfa2aa000.
diff --git a/app/helpers/concerns_helper/sessions.rb b/app/helpers/concerns_helper/sessions.rb index abc1234..def5678 100644 --- a/app/helpers/concerns_helper/sessions.rb +++ b/app/helpers/concerns_helper/sessions.rb @@ -11,7 +11,7 @@ def reset_session_and_refresh_security_code reset_session - @user.update #refresh security code + @user.save #refresh security code end def sign_in_user
Change refresh security code method
diff --git a/app/presenters/ci/pipeline_presenter.rb b/app/presenters/ci/pipeline_presenter.rb index abc1234..def5678 100644 --- a/app/presenters/ci/pipeline_presenter.rb +++ b/app/presenters/ci/pipeline_presenter.rb @@ -1,6 +1,13 @@ module Ci class PipelinePresenter < Gitlab::View::Presenter::Delegated - presents :pipeline + FAILURE_REASONS = {} + + def failure_reason + return unless pipeline.failure_reason? + + FAILURE_REASONS[pipeline.failure_reason.to_sym] || + pipeline.failure_reason + end def status_title if auto_canceled?
Move part of pipeline presenter to main CE file
diff --git a/test/controllers/items_controller_test.rb b/test/controllers/items_controller_test.rb index abc1234..def5678 100644 --- a/test/controllers/items_controller_test.rb +++ b/test/controllers/items_controller_test.rb @@ -9,6 +9,11 @@ @base_title = "RailsOnlineShop" end + test "should get root" do + get root_url + assert_response :success + end + test "should get new item form page" do get new_item_url assert_response :success
Create test for getting the rot_url
diff --git a/test/controllers/items_controller_test.rb b/test/controllers/items_controller_test.rb index abc1234..def5678 100644 --- a/test/controllers/items_controller_test.rb +++ b/test/controllers/items_controller_test.rb @@ -5,9 +5,13 @@ # assert true # end + def setup + @base_title = "RailsOnlineShop" + end + test "should get new item form page" do get new_item_url assert_response :success - assert_select "title", "RailsOnlineShop" + assert_select "title", "#{@base_title}" end end
Create special function "setup" to have ability to use instance variables throughout tests. This runs before running any of the tests, helps to refactor if certain things will be used multiple times
diff --git a/test/support/coerceable_test_sqlserver.rb b/test/support/coerceable_test_sqlserver.rb index abc1234..def5678 100644 --- a/test/support/coerceable_test_sqlserver.rb +++ b/test/support/coerceable_test_sqlserver.rb @@ -11,15 +11,11 @@ module ClassMethods - def coerce_tests(*methods) + def coerce_tests!(*methods) methods.each do |method| self.coerced_tests.push(method) coerced_test_warning(method) end - end - - def coerce_test!(method) - coerced_test_warning(method) end def coerce_all_tests! @@ -32,14 +28,11 @@ STDOUT.puts "Info: Undefined all tests: #{self.name}" end - def method_added(method) - coerced_test_warning(method) if coerced_tests.include?(method.to_sym) - end - private def coerced_test_warning(method) - result = undef_method(method) rescue nil + method = instance_methods(false).detect { |m| m =~ method } if method.is_a?(Regexp) + result = undef_method(method) if method && method_defined?(method) STDOUT.puts "Info: Undefined coerced test: #{self.name}##{method}" unless result.blank? end
Allow coerced tests to be a Regexp.
diff --git a/crass.gemspec b/crass.gemspec index abc1234..def5678 100644 --- a/crass.gemspec +++ b/crass.gemspec @@ -16,8 +16,7 @@ s.require_paths = ['lib'] - s.files = `git ls-files`.split($/) - s.test_files = s.files.grep(%r{^(test|spec|features)/}) + s.files = `git ls-files -z`.split("\x0").grep_v(%r{^test/}) # Development dependencies. s.add_development_dependency 'minitest', '~> 5.0.8'
Remove test files and omit them
diff --git a/lib/warden_oauth_provider/token_strategy.rb b/lib/warden_oauth_provider/token_strategy.rb index abc1234..def5678 100644 --- a/lib/warden_oauth_provider/token_strategy.rb +++ b/lib/warden_oauth_provider/token_strategy.rb @@ -11,14 +11,14 @@ if !request_token or request_token.invalidated? fail! else - if request_token.authorize!(env['warden'].user) + if request_token.authorize!(env['warden'].user) redirect_url = URI.parse(request_token.oob? ? request_token.client_application.callback_url : request_token.callback_url) redirect_url.query ||= "" redirect_url.query += "&" unless redirect_url.query.blank? redirect_url.query += "oauth_token=#{request_token.token}&oauth_verifier=#{request_token.verifier}" env['oauth.redirect_url'] = redirect_url.to_s - success!(request_token) + success!(env['warden'].user) else fail!("Token authorization failed!") end
Fix for 404 redirect error
diff --git a/lib/zendesk_apps_support/app_requirement.rb b/lib/zendesk_apps_support/app_requirement.rb index abc1234..def5678 100644 --- a/lib/zendesk_apps_support/app_requirement.rb +++ b/lib/zendesk_apps_support/app_requirement.rb @@ -2,7 +2,7 @@ module ZendeskAppsSupport class AppRequirement TYPES = %w(automations channel_integrations - macros targets views ticket_fields triggers - user_fields organization_fields).freeze + macros targets views ticket_fields triggers + user_fields organization_fields).freeze end end
Align array elements for Rubocop
diff --git a/test/integration/pushing_gems/path_test.rb b/test/integration/pushing_gems/path_test.rb index abc1234..def5678 100644 --- a/test/integration/pushing_gems/path_test.rb +++ b/test/integration/pushing_gems/path_test.rb @@ -11,3 +11,15 @@ should_push_gem end + +class PathWithTrailingSlashTest < Geminabox::TestCase + url "http://localhost/foo/" + + app do + map "/foo" do + run Geminabox + end + end + + should_push_gem +end
Test coverage for URLs with trailing slashes.
diff --git a/rubygems-code_finder.gemspec b/rubygems-code_finder.gemspec index abc1234..def5678 100644 --- a/rubygems-code_finder.gemspec +++ b/rubygems-code_finder.gemspec @@ -18,6 +18,6 @@ spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] - spec.add_development_dependency "bundler", "~> 1.6" + spec.add_development_dependency "bundler", ">= 1.3" spec.add_development_dependency "rake" end
Set bundler lower version limit
diff --git a/relax.gemspec b/relax.gemspec index abc1234..def5678 100644 --- a/relax.gemspec +++ b/relax.gemspec @@ -17,4 +17,5 @@ s.add_development_dependency 'rake' s.add_development_dependency 'mocha' + s.add_development_dependency 'sqlite3' end
Add Sqlite3 to dev dependency
diff --git a/recipes/root_shell_bash.rb b/recipes/root_shell_bash.rb index abc1234..def5678 100644 --- a/recipes/root_shell_bash.rb +++ b/recipes/root_shell_bash.rb @@ -0,0 +1,7 @@+execute "set the root user shell to bash" do + command "dscl . -create /Users/root UserShell /bin/bash" +end + +link "/root" do + to "/var/root" +end
Change the root shell to bash
diff --git a/app/controllers/spree/admin/admin_controller_decorator.rb b/app/controllers/spree/admin/admin_controller_decorator.rb index abc1234..def5678 100644 --- a/app/controllers/spree/admin/admin_controller_decorator.rb +++ b/app/controllers/spree/admin/admin_controller_decorator.rb @@ -1,17 +1,5 @@ require File.expand_path('../../base_controller_decorator', __FILE__) Spree::Admin::BaseController.class_eval do - before_filter :authorize_admin - - def authorize_admin - begin - record = model_class.new - rescue - record = Object.new - end - authorize! :admin, record - authorize! params[:action].to_sym, record - end - protected def model_class "Spree::#{controller_name.classify}".constantize
Remove authorize_admin filter from Admin::BaseController, as this is now in Spree
diff --git a/cl.rb b/cl.rb index abc1234..def5678 100644 --- a/cl.rb +++ b/cl.rb @@ -8,10 +8,12 @@ deindenters = [] last_tag = nil +last_lists = [] +lists = {} tags.each do |tag| - indent_level = 0 - puts tag + lists[tag] = {} + current_list = lists[tag]['root'] = [] rev_spec = last_tag ? "#{last_tag}..#{tag}" : "#{tag}" revs = `git rev-list --topo-order --parents #{rev_spec}`.split("\n") revs.each do |rev| @@ -19,15 +21,30 @@ commit = commits[0] parents = commits[1..-1] if commit == deindenters.last - indent_level -= 1 deindenters.pop + current_list = last_lists.pop end - puts "#{' ' * indent_level}- #{commit}" + current_list << commit if parents.length > 1 deindenters << parents[0] - indent_level += 1 + last_lists << current_list + current_list = lists[tag][commit] = [] end end last_tag = tag +end + +def print_lists(lists_for_tag, commit, indent = 0) + lists_for_tag[commit].reverse.each do |c| + puts "#{' ' * indent} - #{c}" + if lists_for_tag[c] + print_lists(lists_for_tag, c, indent + 1) + end + end +end + +tags.reverse.each do |tag| + puts tag + print_lists(lists[tag], 'root') puts end
Store commits and print in reverse
diff --git a/lib/oxford/learners/dictionaries/english.rb b/lib/oxford/learners/dictionaries/english.rb index abc1234..def5678 100644 --- a/lib/oxford/learners/dictionaries/english.rb +++ b/lib/oxford/learners/dictionaries/english.rb @@ -1,13 +1,20 @@+require 'nokogiri' +require 'open-uri' + module Oxford module Learners module Dictionaries class English - attr_reader :definition, :word, :page + attr_reader :definition, :url, :word, :page def initialize word @word = word - @page = Nokogiri::HTML(open("http://www.oxfordlearnersdictionaries.com/definition/english/#{word}")) + @url = "http://www.oxfordlearnersdictionaries.com/definition/english/#{word}" @definition = Hash.new + end + + def look_up + @page = Nokogiri::HTML(open(@url)) parse end @@ -21,7 +28,7 @@ end def unique_definition - @definition[:definition] = @page.css(".d").text + @definition[:definition_0] = @page.css(".d").text end def multiple_definitions
Add look_up method instead of parsing in initialize
diff --git a/lib/processing_framework/compress_helper.rb b/lib/processing_framework/compress_helper.rb index abc1234..def5678 100644 --- a/lib/processing_framework/compress_helper.rb +++ b/lib/processing_framework/compress_helper.rb @@ -1,16 +1,20 @@ module ProcessingFramework - class CompressHelper - def CompressHelper.uncompress(x) - case (x.split('.').last) - when 'gz' - system('gunzip', x) - return File.basename(x, '.gz') - when 'bz2' - system('bunzip2', x) - return File.basename(x, '.bz2') + module CompressHelper + include ShellOutHelper + + def uncompress(file) + filename = case File.extname(file) + when '.gz' + shell_out!("gunzip #{file}", live_stream: false) + File.basename(x, '.gz') + when '.bz2' + shell_out!("bunzip2 #{file}", live_stream: false) + File.basename(x, '.bz2') else - return x + file end + + filename end end end
Use new shell_out! methods for system commands
diff --git a/spec/json_world/property_definable_spec.rb b/spec/json_world/property_definable_spec.rb index abc1234..def5678 100644 --- a/spec/json_world/property_definable_spec.rb +++ b/spec/json_world/property_definable_spec.rb @@ -28,6 +28,16 @@ subject do klass.as_json_schema end + + it "returns the JSON Schema representation of the receiver class" do + is_expected.to eq( + properties: nil, + required: [ + :id, + :name, + ], + ) + end end describe ".property" do
Add an test example for .as_json_schema
diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index abc1234..def5678 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -1,2 +1,9 @@ module UsersHelper + def account_types + User.account_types.keys.to_a + end + + def display_account_type + @user.profile.account_type + end end
Create users helper to display account types
diff --git a/bosh-director/lib/bosh/director/models/release_version.rb b/bosh-director/lib/bosh/director/models/release_version.rb index abc1234..def5678 100644 --- a/bosh-director/lib/bosh/director/models/release_version.rb +++ b/bosh-director/lib/bosh/director/models/release_version.rb @@ -6,9 +6,9 @@ many_to_many :deployments def validate + validates_format VALID_ID, :version validates_presence [:release_id, :version] validates_unique [:release_id, :version] - validates_format VALID_ID, :version end def dependencies(package_name)
Validate format before validating presence Signed-off-by: Maria Shaldibina <a39f51a90bfcf8ca23756ef12127e1cf20796cba@pivotallabs.com>
diff --git a/lib/sitemap_generator/adapters/s3_adapter.rb b/lib/sitemap_generator/adapters/s3_adapter.rb index abc1234..def5678 100644 --- a/lib/sitemap_generator/adapters/s3_adapter.rb +++ b/lib/sitemap_generator/adapters/s3_adapter.rb @@ -9,11 +9,13 @@ @fog_provider = opts[:fog_provider] || ENV['FOG_PROVIDER'] @fog_directory = opts[:fog_directory] || ENV['FOG_DIRECTORY'] @fog_region = opts[:fog_region] || ENV['FOG_REGION'] + @file_adapter = opts[:file_adapter] || SitemapGenerator::FileAdapter.new() end # Call with a SitemapLocation and string data def write(location, raw_data) - SitemapGenerator::FileAdapter.new.write(location, raw_data) + #SitemapGenerator::FileAdapter.new.write(location, raw_data) + @file_adapter.write(location, raw_data) credentials = { :aws_access_key_id => @aws_access_key_id,
Allow callers to override the file adapter with an enhanced version
diff --git a/tab_manager.rb b/tab_manager.rb index abc1234..def5678 100644 --- a/tab_manager.rb +++ b/tab_manager.rb @@ -17,9 +17,11 @@ def next @index = (@index + 1) % @tabs.count + current_tab.refresh_window end def previous @index = (@index - 1) % @tabs.count + current_tab.refresh_window end end
Implement window refresh after switching tab
diff --git a/config/projects/codethink-compiler-flags.rb b/config/projects/codethink-compiler-flags.rb index abc1234..def5678 100644 --- a/config/projects/codethink-compiler-flags.rb +++ b/config/projects/codethink-compiler-flags.rb @@ -8,14 +8,16 @@ compiler_flags = case platform when "aix" - # Use GCC instead of xlC on AIX. - # For now we don't force a 64-bit build, it probably makes sense to do that though. + # Chef Software use the IBM compiler on AIX, but it's probably more + # reliable for us to compile GCC with GCC. { - "CC" => "gcc", - "CXX" => "g++", + "ARFLAGS" => "-X64", + "CC" => "gcc -maix64", + "CXX" => "g++ -maix64", "CFLAGS" => "-I#{install_dir}/embedded/include -O2", "LDFLAGS" => "-L#{install_dir}/embedded/lib", "LD" => "ld", + "OBJECT_MODE" => "64", } when "solaris2" # We do a 32-bit build for now, something breaks in GMP when
Fix AIX build, and make it a 64-bit one
diff --git a/omnibus/config/projects/chef-server-fips.rb b/omnibus/config/projects/chef-server-fips.rb index abc1234..def5678 100644 --- a/omnibus/config/projects/chef-server-fips.rb +++ b/omnibus/config/projects/chef-server-fips.rb @@ -13,8 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # -chef_server_contents = IO.read(File.expand_path('../chef-server.rb', __FILE__)) -self.instance_eval(chef_server_contents) +chef_server_path = File.expand_path('../chef-server.rb', __FILE__) +instance_eval(IO.read(chef_server_path), chef_server_path) name "chef-server-fips" package_name "chef-server-fips-core"
Fix `omnibus cache missing` etc Seems like the _second parameter_ to `instance_eval` is not *only* > used when reporting compilation errors but also fixes the __FILE__ references. Without this change, omnibus cache missing would end up trying to read omnibus_overrides.rb from a path relative to the CWD, and therefore fail. Signed-off-by: Stephan Renatus <3d1a7d0a294b6d8e799ad6e122143905f17f9530@chef.io>
diff --git a/SwiftyBluetooth.podspec b/SwiftyBluetooth.podspec index abc1234..def5678 100644 --- a/SwiftyBluetooth.podspec +++ b/SwiftyBluetooth.podspec @@ -6,7 +6,7 @@ s.authors = { 'Jordane Belanger' => 'jordane.belanger@gmail.com' } s.summary = 'Fully featured closures based library for CoreBluetooth' s.source = { :git => 'https://github.com/jordanebelanger/SwiftyBluetooth.git', :tag => s.version } - s.source_files = 'SwiftyBluetooth/Source/*.swift' + s.source_files = 'Sources/*.swift' s.requires_arc = true s.ios.deployment_target = '10.0' end
Fix Podspec to point to correct sources location
diff --git a/core/db/migrate/20140315053743_add_timestamps_to_spree_assets.rb b/core/db/migrate/20140315053743_add_timestamps_to_spree_assets.rb index abc1234..def5678 100644 --- a/core/db/migrate/20140315053743_add_timestamps_to_spree_assets.rb +++ b/core/db/migrate/20140315053743_add_timestamps_to_spree_assets.rb @@ -0,0 +1,6 @@+class AddTimestampsToSpreeAssets < ActiveRecord::Migration + def change + add_column :spree_assets, :created_at, :datetime + add_column :spree_assets, :updated_at, :datetime + end +end
Add timestamps fields to spree_assets Initial motivation here was make assets_spec green. As of Rails 4.0.4 touching an object without timestamps won't touch its associations. Plus timestamps are usually handy so no reason for not having them in spree_assets too See https://github.com/rails/rails/commit/73ba2c14cd7d7dfb2d132b18c47ade995401736f
diff --git a/spec/models/provider_spec.rb b/spec/models/provider_spec.rb index abc1234..def5678 100644 --- a/spec/models/provider_spec.rb +++ b/spec/models/provider_spec.rb @@ -22,5 +22,13 @@ require 'rails_helper' RSpec.describe Provider, type: :model do - pending "add some examples to (or delete) #{__FILE__}" + it 'assigns a type' do + provider = create :provider, name: 'Demo', registered_provider_id: 3 + expect(provider.type).to eq('Provider::Type1') + end + + it 'sets the registered_provider_id field'do + provider = create :provider, name: 'Azure', type: 'Azure', registered_provider_id: 5 + expect(provider.registered_provider_id).to eq(5) + end end
Add tests for provider model
diff --git a/spec/synchronization_spec.rb b/spec/synchronization_spec.rb index abc1234..def5678 100644 --- a/spec/synchronization_spec.rb +++ b/spec/synchronization_spec.rb @@ -7,6 +7,16 @@ it { should validate_presence_of(:model_name) } it { should validate_presence_of(:last_record_updated_at) } it { should validate_presence_of(:last_record_id) } - it { should have_named_scope("for('User')") } + + describe "named scope 'for'" do + before do + @user_synchronization = HasRemote::Synchronization.create! :model_name => 'User', :last_record_updated_at => 1.day.ago, :last_record_id => 1 + @book_synchronization = HasRemote::Synchronization.create! :model_name => 'Book', :last_record_updated_at => 1.day.ago, :last_record_id => 2 + end + + it "should return synchronization records scoped by model_name" do + HasRemote::Synchronization.for('User').should == [@user_synchronization] + end + end end
Replace usage of have_named_sope matcher which was removed from Shoulda.
diff --git a/lib/agharta/file_recipe.rb b/lib/agharta/file_recipe.rb index abc1234..def5678 100644 --- a/lib/agharta/file_recipe.rb +++ b/lib/agharta/file_recipe.rb @@ -13,12 +13,8 @@ @path = recipe_path end - def load! + def execute eval(File.read(path), binding) - end - - def execute - load! super end end
Join load method to execute method.
diff --git a/spec/factories/course_survey_responses.rb b/spec/factories/course_survey_responses.rb index abc1234..def5678 100644 --- a/spec/factories/course_survey_responses.rb +++ b/spec/factories/course_survey_responses.rb @@ -6,8 +6,11 @@ course end survey { build(:survey, course: course) } + points_awarded nil trait :submitted do + after(:build, &:submit) + transient do submitted_time { 1.day.ago } end
Fix survey response factory awarding random exp
diff --git a/lib/mail_job.rb b/lib/mail_job.rb index abc1234..def5678 100644 --- a/lib/mail_job.rb +++ b/lib/mail_job.rb @@ -6,11 +6,17 @@ end def perform + # TODO: Put this in a transaction so if the forwarding fails it doesn't save the email email = Email.create!(from: message_hash[:from].match("<(.*)>")[1], to: message_hash[:to].map{|t| t.match("<(.*)>")[1]}, data: message_hash[:data]) - # Simple pass the message to a local SMTP server (mailcatcher for the time being) - email.forward('localhost', 1025) + if Rails.env == "development" + # In development send the mails to mailcatcher + email.forward('localhost', 1025) + else + # Otherwise use whatever the local smtp server is + email.forward('localhost', 25) + end end end
Send the message to a different place depending on the environment
diff --git a/spec/services/files/multi_service_spec.rb b/spec/services/files/multi_service_spec.rb index abc1234..def5678 100644 --- a/spec/services/files/multi_service_spec.rb +++ b/spec/services/files/multi_service_spec.rb @@ -0,0 +1,54 @@+require "spec_helper" + +describe Files::MultiService do + subject { described_class.new(project, user, commit_params) } + + let(:project) { create(:project, :repository) } + let(:user) { create(:user) } + let(:branch_name) { project.default_branch } + let(:action) { 'update' } + + let(:actions) do + [ + { + action: action, + file_path: 'files/ruby/popen.rb', + content: 'New content' + } + ] + end + + let(:commit_params) do + { + commit_message: "Update File", + branch_name: branch_name, + start_branch: branch_name, + actions: actions + } + end + + before do + project.team << [user, :master] + end + + describe '#execute' do + context 'with a valid action' do + it 'returns a hash with the :success status ' do + results = subject.execute + + expect(results[:status]).to eq(:success) + end + end + + context 'with an invalid action' do + let(:action) { 'rename' } + + it 'returns a hash with the :error status ' do + results = subject.execute + + expect(results[:status]).to eq(:error) + expect(results[:message]).to match(/Unknown action/) + end + end + end +end
Add some initial specs for Files::MultiService class
diff --git a/lib/nyny/app.rb b/lib/nyny/app.rb index abc1234..def5678 100644 --- a/lib/nyny/app.rb +++ b/lib/nyny/app.rb @@ -30,7 +30,7 @@ def run! port=9292 use Rack::CommonLogger use BetterErrors::Middleware unless NYNY.env.production? - Rack::Handler.pick(['puma', 'webrick']).run new, :Port => port + Rack::Handler.pick(['puma', 'thin', 'webrick']).run new, :Port => port end end end
Include puma in priority list