Skip tests that require plugin unless plugin installed
fixes CNVS-36355 Test plan: - docker-compose build --pull - docker-compose run --rm web bundle exec rspec \ spec/{apis,controllers,helpers,initializers,integration,lib,message,\ middleware,migrations,models,observers,presenters,serializers,views}\ /**/*_spec.rb Change-Id: I4220a314dbc2e343dae26e6e522806f4f2666f85 Reviewed-on: https://gerrit.instructure.com/120671 Reviewed-by: Cody Cutrer <cody@instructure.com> Tested-by: Jenkins Product-Review: Cody Cutrer <cody@instructure.com> QA-Review: Cody Cutrer <cody@instructure.com> Product-Review: Jon Jensen <jon@instructure.com> QA-Review: Jon Jensen <jon@instructure.com>
This commit is contained in:
parent
f7b1decd2f
commit
0536054715
|
@ -142,9 +142,7 @@ module AttachmentFu # :nodoc:
|
|||
def self.included(base) #:nodoc:
|
||||
require 'aws-sdk-s3'
|
||||
|
||||
s3_config_path = base.attachment_options[:s3_config_path] || (Rails.root + 'config/amazon_s3.yml')
|
||||
s3_config = YAML.load(ERB.new(File.read(s3_config_path)).result)[Rails.env].symbolize_keys
|
||||
|
||||
s3_config = load_s3_config(base.attachment_options[:s3_config_path])
|
||||
bucket_name = s3_config.delete(:bucket_name)
|
||||
|
||||
s3 = Aws::S3::Resource.new(Canvas::AWS.validate_v2_config(s3_config, 'amazon_s3.yml'))
|
||||
|
@ -153,6 +151,11 @@ module AttachmentFu # :nodoc:
|
|||
base.before_update :rename_file
|
||||
end
|
||||
|
||||
def self.load_s3_config(path = nil)
|
||||
s3_config_path = path || (Rails.root + 'config/amazon_s3.yml')
|
||||
YAML.load(ERB.new(File.read(s3_config_path)).result)[Rails.env].symbolize_keys
|
||||
end
|
||||
|
||||
# Overwrites the base filename writer in order to store the old filename
|
||||
def filename=(value)
|
||||
@old_filename = filename unless filename.nil? || @old_filename
|
||||
|
|
|
@ -105,6 +105,8 @@ describe Moodle::Converter do
|
|||
|
||||
context "modules" do
|
||||
it "should convert modules and module items" do
|
||||
skip 'Requires QtiMigrationTool' unless Qti.qti_enabled?
|
||||
|
||||
expect(@course.context_modules.count).to eq 8
|
||||
expect(@course.context_module_tags.where(:content_type => "Assignment", :title => "Assignment Name")).to be_exists
|
||||
expect(@course.context_module_tags.where(:content_type => "WikiPage", :title => "My Sample Page")).to be_exists
|
||||
|
|
|
@ -427,6 +427,8 @@ describe MasterCourses::MasterTemplatesController, type: :request do
|
|||
end
|
||||
|
||||
it "returns change information from the minion side" do
|
||||
skip 'Requires QtiMigrationTool' unless Qti.qti_enabled?
|
||||
|
||||
minion = @minions.first
|
||||
minion_migration = minion.content_migrations.last
|
||||
minion_page = minion.wiki.wiki_pages.where(migration_id: @template.migration_id_for(@page)).first
|
||||
|
|
|
@ -20,6 +20,8 @@ require_relative '../spec_helper.rb'
|
|||
|
||||
describe ConfigFile do
|
||||
describe ".cache_object" do
|
||||
before { ConfigFile.unstub }
|
||||
|
||||
it "caches objects" do
|
||||
expect(File).to receive(:exist?).and_return(true)
|
||||
expect(File).to receive(:read).and_return('test: {}')
|
||||
|
|
|
@ -433,6 +433,8 @@ describe ContentMigration do
|
|||
end
|
||||
|
||||
it "should not break link resolution in quiz_data" do
|
||||
skip 'Requires QtiMigrationTool' unless Qti.qti_enabled?
|
||||
|
||||
topic = @copy_from.discussion_topics.create!(:title => "some topic", :message => "<p>some text</p>")
|
||||
|
||||
html = "<a href='/courses/#{@copy_from.id}/discussion_topics/#{topic.id}'>link</a>"
|
||||
|
|
|
@ -55,6 +55,8 @@ describe ContentMigration do
|
|||
end
|
||||
|
||||
it "should translate ids for copied course content" do
|
||||
skip 'Requires QtiMigrationTool' unless Qti.qti_enabled?
|
||||
|
||||
assmt = @copy_from.assignments.create!
|
||||
topic = @copy_from.discussion_topics.create!(:message => "hi", :title => "discussion title")
|
||||
ann = @copy_from.announcements.create!(:message => "goodbye")
|
||||
|
|
|
@ -125,6 +125,8 @@ describe ContentMigration do
|
|||
end
|
||||
|
||||
it "should not re-unpublish module items on re-copy" do
|
||||
skip 'Requires QtiMigrationTool' unless Qti.qti_enabled?
|
||||
|
||||
mod = @copy_from.context_modules.create!(:name => "some module")
|
||||
tags = []
|
||||
|
||||
|
|
|
@ -433,6 +433,8 @@ describe ContentMigration do
|
|||
end
|
||||
|
||||
it "should correclty handle media comment resolution in quizzes" do
|
||||
skip 'Requires QtiMigrationTool' unless Qti.qti_enabled?
|
||||
|
||||
course_with_teacher
|
||||
cm = ContentMigration.new(:context => @course, :user => @user)
|
||||
cm.migration_type = 'canvas_cartridge_importer'
|
||||
|
|
|
@ -119,6 +119,10 @@ describe UserObserver do
|
|||
end
|
||||
|
||||
it "should not enroll the observer in institutions where they lack a login" do
|
||||
unless has_sharding?
|
||||
skip 'Sharding specs fail without additional support from a multi-tenancy plugin'
|
||||
end
|
||||
|
||||
a1 = account_model
|
||||
c1 = course_factory(account: a1, active_all: true)
|
||||
e1 = student_in_course(course: c1, user: student, active_all: true)
|
||||
|
|
|
@ -20,13 +20,23 @@ require 'switchman/r_spec_helper'
|
|||
require_relative 'spec_helper'
|
||||
require_relative 'support/onceler/sharding'
|
||||
|
||||
def specs_require_sharding
|
||||
include Switchman::RSpecHelper
|
||||
include Onceler::Sharding
|
||||
def has_sharding?
|
||||
User.instance_method(:associated_shards).owner != User
|
||||
end
|
||||
|
||||
before :all do
|
||||
Shard.with_each_shard do
|
||||
Role.ensure_built_in_roles!
|
||||
def specs_require_sharding
|
||||
if has_sharding?
|
||||
include Switchman::RSpecHelper
|
||||
include Onceler::Sharding
|
||||
|
||||
before :all do
|
||||
Shard.with_each_shard do
|
||||
Role.ensure_built_in_roles!
|
||||
end
|
||||
end
|
||||
else
|
||||
before(:once) do
|
||||
skip 'Sharding specs fail without additional support from a multi-tenancy plugin'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -48,6 +48,7 @@ module WebMock::API
|
|||
end
|
||||
|
||||
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
|
||||
require_relative 'sharding_spec_helper'
|
||||
|
||||
# nuke the db (say, if `rake db:migrate RAILS_ENV=test` created records),
|
||||
# and then ensure people aren't creating records outside the rspec
|
||||
|
@ -398,6 +399,10 @@ RSpec.configure do |config|
|
|||
Timecop.safe_mode = true
|
||||
end
|
||||
|
||||
config.before do
|
||||
allow(AttachmentFu::Backends::S3Backend).to receive(:load_s3_config) { StubS3::AWS_CONFIG.dup }
|
||||
end
|
||||
|
||||
# this runs on post-merge builds to capture dependencies of each spec;
|
||||
# we then use that data to run just the bare minimum subset of selenium
|
||||
# specs on the patchset builds
|
||||
|
@ -661,21 +666,20 @@ RSpec.configure do |config|
|
|||
end
|
||||
|
||||
module StubS3
|
||||
AWS_CONFIG = {
|
||||
access_key_id: 'stub_id',
|
||||
secret_access_key: 'stub_key',
|
||||
region: 'us-east-1',
|
||||
stub_responses: true,
|
||||
bucket_name: 'no-bucket'
|
||||
}.freeze
|
||||
|
||||
def self.stubbed?
|
||||
false
|
||||
end
|
||||
|
||||
def load(file, *args)
|
||||
if StubS3.stubbed? && file == 'amazon_s3'
|
||||
return {
|
||||
access_key_id: 'stub_id',
|
||||
secret_access_key: 'stub_key',
|
||||
region: 'us-east-1',
|
||||
stub_responses: true,
|
||||
bucket_name: 'no-bucket'
|
||||
}
|
||||
end
|
||||
|
||||
return AWS_CONFIG.dup if StubS3.stubbed? && file == 'amazon_s3'
|
||||
super
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue