From f0d6b49a4308651bb80da4be075f325617c6ea3b Mon Sep 17 00:00:00 2001 From: Trey Pendragon Date: Wed, 26 Jul 2017 13:44:30 -0700 Subject: [PATCH] Add coverage. --- Gemfile | 1 + Gemfile.lock | 10 ++++++++++ app/channels/application_cable/channel.rb | 5 ----- app/channels/application_cable/connection.rb | 5 ----- app/helpers/flashes_helper.rb | 6 ------ app/jobs/application_job.rb | 3 --- app/mailers/application_mailer.rb | 5 ----- bin/rspec | 5 ----- spec/controllers/catalog_controller_spec.rb | 1 + spec/models/user_spec.rb | 13 ++++++++++++- spec/rails_helper.rb | 13 +++++++++++++ valhalla/app/mailers/valhalla/application_mailer.rb | 7 ------- 12 files changed, 37 insertions(+), 37 deletions(-) delete mode 100644 app/channels/application_cable/channel.rb delete mode 100644 app/channels/application_cable/connection.rb delete mode 100644 app/helpers/flashes_helper.rb delete mode 100644 app/jobs/application_job.rb delete mode 100644 app/mailers/application_mailer.rb delete mode 100644 valhalla/app/mailers/valhalla/application_mailer.rb diff --git a/Gemfile b/Gemfile index 738276bb10..d9726b759a 100644 --- a/Gemfile +++ b/Gemfile @@ -30,6 +30,7 @@ group :development, :test do gem "bixby" gem "bullet" gem "bundler-audit", ">= 0.5.0", require: false + gem 'coveralls' gem "dotenv-rails" gem "factory_girl_rails" gem "pry-byebug" diff --git a/Gemfile.lock b/Gemfile.lock index 0840c29902..bd2aafc498 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -151,6 +151,12 @@ GEM cliver (0.3.2) coderay (1.1.1) concurrent-ruby (1.0.5) + coveralls (0.8.21) + json (>= 1.8, < 3) + simplecov (~> 0.14.1) + term-ansicolor (~> 1.3) + thor (~> 0.19.4) + tins (~> 1.6) crack (0.4.3) safe_yaml (~> 1.0.0) database_cleaner (1.6.1) @@ -493,10 +499,13 @@ GEM string_rtl (0.1.0) sxp (1.0.0) rdf (~> 2.0) + term-ansicolor (1.6.0) + tins (~> 1.0) thor (0.19.4) thread_safe (0.3.6) tilt (2.0.8) timecop (0.9.1) + tins (1.15.0) title (0.0.7) i18n rails (>= 3.1) @@ -539,6 +548,7 @@ DEPENDENCIES blacklight bullet bundler-audit (>= 0.5.0) + coveralls database_cleaner devise devise-guests! diff --git a/app/channels/application_cable/channel.rb b/app/channels/application_cable/channel.rb deleted file mode 100644 index 51e3e936bd..0000000000 --- a/app/channels/application_cable/channel.rb +++ /dev/null @@ -1,5 +0,0 @@ -# frozen_string_literal: true -module ApplicationCable - class Channel < ActionCable::Channel::Base - end -end diff --git a/app/channels/application_cable/connection.rb b/app/channels/application_cable/connection.rb deleted file mode 100644 index fa70319da2..0000000000 --- a/app/channels/application_cable/connection.rb +++ /dev/null @@ -1,5 +0,0 @@ -# frozen_string_literal: true -module ApplicationCable - class Connection < ActionCable::Connection::Base - end -end diff --git a/app/helpers/flashes_helper.rb b/app/helpers/flashes_helper.rb deleted file mode 100644 index f2222afd18..0000000000 --- a/app/helpers/flashes_helper.rb +++ /dev/null @@ -1,6 +0,0 @@ -# frozen_string_literal: true -module FlashesHelper - def user_facing_flashes - flash.to_hash.slice("alert", "error", "notice", "success") - end -end diff --git a/app/jobs/application_job.rb b/app/jobs/application_job.rb deleted file mode 100644 index 32fe70b8e4..0000000000 --- a/app/jobs/application_job.rb +++ /dev/null @@ -1,3 +0,0 @@ -# frozen_string_literal: true -class ApplicationJob < ActiveJob::Base -end diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb deleted file mode 100644 index 24289009a9..0000000000 --- a/app/mailers/application_mailer.rb +++ /dev/null @@ -1,5 +0,0 @@ -# frozen_string_literal: true -class ApplicationMailer < ActionMailer::Base - default from: 'from@example.com' - layout 'mailer' -end diff --git a/bin/rspec b/bin/rspec index 6e6709219a..d72fadf396 100755 --- a/bin/rspec +++ b/bin/rspec @@ -1,8 +1,3 @@ #!/usr/bin/env ruby -begin - load File.expand_path('../spring', __FILE__) -rescue LoadError => e - raise unless e.message.include?('spring') -end require 'bundler/setup' load Gem.bin_path('rspec-core', 'rspec') diff --git a/spec/controllers/catalog_controller_spec.rb b/spec/controllers/catalog_controller_spec.rb index cd6e4839e2..b2e88db3e7 100644 --- a/spec/controllers/catalog_controller_spec.rb +++ b/spec/controllers/catalog_controller_spec.rb @@ -4,6 +4,7 @@ RSpec.describe CatalogController do let(:persister) { Valkyrie::MetadataAdapter.find(:indexing_persister).persister } describe "#index" do + render_views it "finds all public documents" do persister.save(resource: FactoryGirl.build(:scanned_resource)) diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 5b11d82949..f5d1871186 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -2,5 +2,16 @@ require 'rails_helper' RSpec.describe User, type: :model do - pending "add some examples to (or delete) #{__FILE__}" + subject(:user) { FactoryGirl.create(:user) } + describe "#to_s" do + it "returns the user's email" do + expect(user.to_s).to eq user.email + end + end + describe "#admin?" do + subject(:user) { FactoryGirl.create(:admin) } + it "returns true" do + expect(user).to be_admin + end + end end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 32fd65ffec..4a740697dd 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -1,5 +1,17 @@ # frozen_string_literal: true ENV["RACK_ENV"] = "test" +require 'simplecov' +require 'coveralls' + +SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new( + [ + SimpleCov::Formatter::HTMLFormatter, + Coveralls::SimpleCov::Formatter + ] +) +SimpleCov.start "rails" do + add_filter '/valhalla/' +end require File.expand_path("../../config/environment", __FILE__) abort("DATABASE_URL environment variable is set") if ENV["DATABASE_URL"] @@ -18,6 +30,7 @@ module Features config.infer_base_class_for_anonymous_controllers = false config.infer_spec_type_from_file_location! config.use_transactional_fixtures = false + config.fixture_path = "#{::Rails.root}/spec/fixtures" end ActiveRecord::Migration.maintain_test_schema! diff --git a/valhalla/app/mailers/valhalla/application_mailer.rb b/valhalla/app/mailers/valhalla/application_mailer.rb deleted file mode 100644 index 4f1e0f9415..0000000000 --- a/valhalla/app/mailers/valhalla/application_mailer.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true -module Valhalla - class ApplicationMailer < ActionMailer::Base - default from: 'from@example.com' - layout 'mailer' - end -end