bearcat 1.6.0.beta1 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 88b94b32414c5a59f1fd3be18678f529de9bef97ee3e10116db68062edeebad2
4
- data.tar.gz: 62e2edd04e91abc3c4b328e81e54e2f9545be448c62497d01e509c54fd6aeb27
3
+ metadata.gz: 2c07b05ef9a13345ec573729530858cfc0572aaf1e81f8b708b7c4e809d16635
4
+ data.tar.gz: 62f84a5dff7c6f990caff1b026c7756eb7669f60b08a5db9a53d88a2ba70adfe
5
5
  SHA512:
6
- metadata.gz: 374c77ba34fcc3583710cdf54984a5806d328ed0cc1d23edfed8c90051ab4a1225c079243c50497edeeaeb4eac11979aa794403550d33312a5906ab33f5d1cc2
7
- data.tar.gz: cc6690b3e892cafa054c1a4f775d0ee39c3bcf7f8ea0834f023c345c8e6416e22c03aa40f2bb1dbd9605f91ef6d48db3a7a2fd811b70b24913b6bc254d1cd4ed
6
+ metadata.gz: 80ab1c45eab1f52f7951155926a0286d622b1cc300330e7fc9f467304786bff985f7c37edcd480b6a5db2c271603c50a7cfbd40f3f8aa19b9c957deb60a664b9
7
+ data.tar.gz: c596d8cc4dfa6af924515e75fc2eaa3184a6e8134375bea0513247afab1900899373de0f94e965ec7b989b5c592afe8b6640a773dd2b38995cd16d2ab7e4991b
data/bearcat.gemspec CHANGED
@@ -34,5 +34,5 @@ Gem::Specification.new do |gem|
34
34
 
35
35
  gem.add_dependency "activesupport"
36
36
  gem.add_dependency "footrest", ">= 0.2.2"
37
- gem.add_dependency "connection_pool", ">= 2.2.0", "< 3.0"
37
+ gem.add_dependency "rediconn", "~> 0.1.0"
38
38
  end
@@ -71,6 +71,18 @@ module Badgrcat
71
71
  delete :delete_assertion
72
72
  end
73
73
  end
74
+
75
+ prefix "v2/backpack" do
76
+ prefix "/assertions" do
77
+ get :backpack_assertions
78
+ end
79
+ end
80
+
81
+ prefix "v2/users" do
82
+ prefix "/self" do
83
+ get :get_user_profile
84
+ end
85
+ end
74
86
  end
75
87
  end
76
88
  end
@@ -198,7 +198,7 @@ module Bearcat
198
198
  path = response.env[:url].path
199
199
  if path.match(/.*\/(courses||groups)\/\d+\/conferences/)
200
200
  key = 'conferences'
201
- elsif path.match(/.*\/accounts\/(?:(?:\d+~)?\d+|self)\/terms/)
201
+ elsif path.match(/.*\/accounts\/[^\/]+\/terms/)
202
202
  key = 'enrollment_terms'
203
203
  end
204
204
  end
@@ -1,17 +1,67 @@
1
1
  module Bearcat
2
+ class GraphqlError < StandardError
3
+ attr_reader :response
4
+
5
+ def initialize(message, response: nil)
6
+ super(message)
7
+ @response = response
8
+ end
9
+ end
10
+
2
11
  class Client < Footrest::Client
3
- # Request body format should be: { query: "query string" }. More info in README.md
12
+ # Request body format should be:
13
+ # - { query: "query string" }
14
+ # - "query string"
15
+ # - "path/to/gql/file", may be absolute, relative to application root, or relative to `app/graphql`. `.gql` extension is optional.
4
16
  module GraphQL
5
-
6
- def graphql_query(query)
17
+ def graphql_query(query, args = {})
7
18
  if query.is_a?(String)
19
+ if /\A\w+\Z/.match?(query) && !query.include?("{")
20
+ query = query.underscore
21
+ @@gql_cache ||= {}
22
+
23
+ query = cache_on_class("gql:#{query}") do
24
+ paths = []
25
+
26
+ pn = Pathname.new(query)
27
+ if pn.absolute?
28
+ paths << query
29
+ else
30
+ paths << Rails.root.join("app", "graphql", query)
31
+ paths << Rails.root.join(query)
32
+ end
33
+
34
+ paths = paths.flat_map do |path|
35
+ [path, "#{path}.gql"]
36
+ end
37
+
38
+ query = paths.find do |path|
39
+ File.exist?(path)
40
+ end
41
+
42
+ File.read(query)
43
+ end
44
+ end
45
+
46
+ args.symbolize_keys!
47
+
48
+ query = query.gsub(/\{\{(.*?)\}\}/) do |_m|
49
+ match = Regexp.last_match
50
+ key = match[1].strip.to_sym
51
+ args[key]
52
+ end
53
+
8
54
  query = {
9
55
  query: query
10
56
  }
11
57
  end
12
- post('/api/graphql', query)
13
- end
14
58
 
59
+ result = post('/api/graphql', query)
60
+ raise GraphqlError.new("Error running GraphQL query:\n#{result["errors"].to_json}", response: result) if result["errors"].present?
61
+
62
+ # TODO: It'd be nice to unwrap and return result["data"] directly, but we want to keep backwards compatibility
63
+ result
64
+ end
15
65
  end
16
66
  end
17
67
  end
@@ -1,54 +1,31 @@
1
- require 'csv'
2
-
3
1
  module Bearcat
4
2
  class Client < Footrest::Client
5
3
  module Reports
6
4
  extend ClientModule
7
5
 
8
- PREFIX = "/api/v1/accounts"
9
-
10
- prefix "#{PREFIX}/:account/reports/" do
6
+ prefix "/api/v1/accounts/:account/reports/" do
11
7
  get :report_list
8
+ post :start_report, ":report_name"
12
9
  get :report_history, ":report_name"
13
10
  get :report_status, ":report_name/:report_id"
14
11
  delete :delete_report, ":report_name/:report_id"
15
12
  end
16
13
 
17
- def start_report(canvas_account_id, report_name, payload)
18
- post("#{PREFIX}/#{canvas_account_id}/reports/#{report_name}", payload)
19
- rescue Bearcat::MiscExceptions::Conflict => e
20
- JSON.parse(e.response.response_body)
21
- end
22
-
23
14
  def download_report(url, save_location=nil)
24
- #This method takes the verified URL returned in a Canvas report (attachment['url']), and if
25
- #a save_location is included, it will download it in chunks to the disk to save memory. You
26
- #can also download the report to memory if you do not include a save location.
27
- attempts = 0
28
- begin
29
- uri = URI.parse(url)
30
- http = Net::HTTP.new(uri.host, uri.port)
31
- http.use_ssl = true if url.start_with?('https')
32
- response = http.head(uri.to_s)
33
- url = response['Location']
34
- attempts += 1
35
- end while attempts <= 5 && (response.code == '301' || response.code == '302' || response.code == '307')
36
- http = Net::HTTP.new(uri.host, uri.port)
37
- http.use_ssl = true if uri.to_s.start_with?('https')
15
+ require 'open-uri'
16
+ open_uri_stream = URI.open(url, {
17
+ 'User-Agent' => "Bearcat/#{Bearcat::VERSION} (#{RUBY_PLATFORM})",
18
+ 'Authorization' => "Bearer #{config[:token]}"
19
+ })
20
+
38
21
  if save_location
39
- File.open(save_location, 'wb') do |file|
40
- http.request_get(uri.to_s) do |resp|
41
- resp.read_body do |segment|
42
- file.write(segment)
43
- end
44
- end
45
- end
22
+ save_location = save_location.path if save_location.respond_to?(:path)
23
+ IO.copy_stream(open_uri_stream, save_location)
24
+ save_location
46
25
  else
47
- response = http.request_get(uri.to_s)
48
- CSV.parse(response.read_body, headers: true)
26
+ CSV.parse(open_uri_stream.read, headers: true)
49
27
  end
50
28
  end
51
-
52
29
  end
53
30
  end
54
31
  end
File without changes
@@ -2,7 +2,6 @@ require 'active_support/core_ext/hash'
2
2
  require 'footrest/client'
3
3
  require_relative 'rate_limiting'
4
4
  require_relative 'client_module'
5
- require_relative 'redis_connection'
6
5
 
7
6
  module Bearcat
8
7
  class Client < Footrest::Client
@@ -37,9 +36,19 @@ module Bearcat
37
36
  super
38
37
  connection.builder.insert(Footrest::RaiseFootrestErrors, ExtendedRaiseFootrestErrors)
39
38
  connection.builder.delete(Footrest::RaiseFootrestErrors)
39
+ end
40
+
41
+ def self.cache_on_self(key, &block)
42
+ @cache ||= {}
43
+ if Rails.env.development? || Rails.env.test?
44
+ block.call
45
+ else
46
+ @cache[key] ||= block.call
47
+ end
48
+ end
40
49
 
41
- connection.builder.insert(Faraday::Request::UrlEncoded, Faraday::Request::JSON)
42
- connection.builder.delete(Faraday::Request::UrlEncoded)
50
+ def cache_on_class(key, &block)
51
+ self.class.cache_on_self(key, &block)
43
52
  end
44
53
 
45
54
  protected
@@ -97,10 +97,13 @@ module Bearcat::SpecHelpers
97
97
  end
98
98
  when String
99
99
  raise "Cannot use method :auto when passing string endpoint" if method == :auto
100
- { method: method, url: Regexp.escape(endpoint) }
100
+ endpoint = Regexp.escape(endpoint)
101
+ endpoint = endpoint.gsub("\\*\\*", ".+")
102
+ endpoint = endpoint.gsub("\\*", "[^/]+")
103
+ { method: method, url: endpoint }
101
104
  when Regexp
102
105
  raise "Cannot use method :auto when passing regex endpoint" if method == :auto
103
- { method: method, url: Regexp.escape(endpoint) }
106
+ { method: method, url: endpoint.to_s }
104
107
  end
105
108
  end
106
109
 
@@ -1,3 +1,3 @@
1
1
  module Bearcat
2
- VERSION = '1.6.0.beta1' unless defined?(Bearcat::VERSION)
2
+ VERSION = '1.6.0' unless defined?(Bearcat::VERSION)
3
3
  end
data/lib/bearcat.rb CHANGED
@@ -1,18 +1,20 @@
1
1
  require 'bearcat/version'
2
2
  require 'bearcat/client'
3
- require 'bearcat/misc_exceptions/conflict'
4
3
 
5
4
  module Bearcat
6
5
  class << self
7
6
  require 'logger'
8
7
  attr_accessor :master_rate_limit
9
- attr_writer :rate_limit_min, :rate_limits, :max_sleep_seconds, :min_sleep_seconds, :logger
8
+ attr_writer :rate_limit_min, :rate_limits, :max_sleep_seconds,
9
+ :min_sleep_seconds, :logger, :rate_limiter
10
10
 
11
11
  def configure
12
12
  yield self if block_given?
13
13
  end
14
14
 
15
- attr_accessor :rate_limiter
15
+ def rate_limiter
16
+ @rate_limiter
17
+ end
16
18
 
17
19
  def rate_limit_min
18
20
  @rate_limit_min ||= 175
@@ -28,21 +30,18 @@ module Bearcat
28
30
 
29
31
  def logger
30
32
  return @logger if defined? @logger
31
-
32
33
  @logger = Logger.new(STDOUT)
33
34
  @logger.level = Logger::DEBUG
34
35
  @logger
35
36
  end
36
37
 
37
38
  def redis_pool
38
- require 'bearcat/redis_connection'
39
- @redis_pool ||= Bearcat::RedisConnection.create(env_prefix: 'BEARCAT')
39
+ require 'rediconn'
40
+ @redis_pool ||= RediConn::RedisConnection.create(env_prefix: "BEARCAT")
40
41
  end
41
42
 
42
- def redis(&block)
43
- raise ArgumentError, 'requires a block' unless block_given?
44
-
45
- redis_pool.with(&block)
43
+ def redis(&blk)
44
+ redis_pool.lazy_with(&blk)
46
45
  end
47
46
  end
48
47
  end
@@ -48,7 +48,6 @@ describe Bearcat::Client::Reports do
48
48
  it 'downloads a report to disk' do
49
49
  report = IO.read(fixture('file.csv'))
50
50
  tempfile = Tempfile.new('report')
51
- stub_request(:head, 'https://canvas.instructure.com/files/1/download?download_frd=1&verifier=string').to_return(status: 200, body: report)
52
51
  stub_request(:get,'https://canvas.instructure.com/files/1/download?download_frd=1&verifier=string').to_return(status: 200, body: report)
53
52
  @client.download_report('https://canvas.instructure.com/files/1/download?download_frd=1&verifier=string', tempfile)
54
53
  csv = CSV.read(tempfile, headers: true)
@@ -59,12 +58,10 @@ describe Bearcat::Client::Reports do
59
58
  it 'follows redirects' do
60
59
  report = IO.read(fixture('file.csv'))
61
60
  tempfile = Tempfile.new('report')
62
- stub_request(:head, 'https://canvas.instructure.com/files/1/download?download_frd=1&verifier=string')
61
+ stub_request(:get, 'https://canvas.instructure.com/files/1/download?download_frd=1&verifier=string')
63
62
  .to_return(status: 302, body: 'You are being redirected',headers: {'Location' => 'https://cluster1-files.instructure.com/files/1/download?download_frd=1&sf_verifier=verifier=1478139862&user_id=1&verifier=verifier'})
64
- stub_request(:head, 'https://cluster1-files.instructure.com/files/1/download?download_frd=1&sf_verifier=verifier=1478139862&user_id=1&verifier=verifier')
63
+ stub_request(:get, 'https://cluster1-files.instructure.com/files/1/download?download_frd=1&sf_verifier=verifier=1478139862&user_id=1&verifier=verifier')
65
64
  .to_return(status: 302, body: 'You are being redirected', headers: {'Location' => 'https://instructure-uploads.s3.amazonaws.com/account_1/attachments/1/assignment_submission.csv'})
66
- stub_request(:head, 'https://instructure-uploads.s3.amazonaws.com/account_1/attachments/1/assignment_submission.csv')
67
- .to_return(status: 200)
68
65
  stub_request(:get, 'https://instructure-uploads.s3.amazonaws.com/account_1/attachments/1/assignment_submission.csv')
69
66
  .to_return(status: 200, body: report)
70
67
  @client.download_report('https://canvas.instructure.com/files/1/download?download_frd=1&verifier=string', tempfile)
data/spec/helper.rb CHANGED
@@ -4,6 +4,7 @@ require 'rspec'
4
4
  require 'webmock/rspec'
5
5
  require 'json'
6
6
  require 'pry'
7
+ require 'csv'
7
8
 
8
9
  WebMock.disable_net_connect!
9
10
 
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bearcat
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0.beta1
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Instructure CustomDev
8
+ autorequire:
8
9
  bindir: bin
9
10
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
11
+ date: 2025-09-10 00:00:00.000000000 Z
11
12
  dependencies:
12
13
  - !ruby/object:Gem::Dependency
13
14
  name: rake
@@ -136,25 +137,19 @@ dependencies:
136
137
  - !ruby/object:Gem::Version
137
138
  version: 0.2.2
138
139
  - !ruby/object:Gem::Dependency
139
- name: connection_pool
140
+ name: rediconn
140
141
  requirement: !ruby/object:Gem::Requirement
141
142
  requirements:
142
- - - ">="
143
- - !ruby/object:Gem::Version
144
- version: 2.2.0
145
- - - "<"
143
+ - - "~>"
146
144
  - !ruby/object:Gem::Version
147
- version: '3.0'
145
+ version: 0.1.0
148
146
  type: :runtime
149
147
  prerelease: false
150
148
  version_requirements: !ruby/object:Gem::Requirement
151
149
  requirements:
152
- - - ">="
153
- - !ruby/object:Gem::Version
154
- version: 2.2.0
155
- - - "<"
150
+ - - "~>"
156
151
  - !ruby/object:Gem::Version
157
- version: '3.0'
152
+ version: 0.1.0
158
153
  description: Ruby interface for interacting with the canvas API
159
154
  email:
160
155
  - pseng@instructure.com
@@ -219,12 +214,10 @@ files:
219
214
  - lib/bearcat/client/tabs.rb
220
215
  - lib/bearcat/client/users.rb
221
216
  - lib/bearcat/client_module.rb
222
- - lib/bearcat/misc_exceptions/conflict.rb
223
217
  - lib/bearcat/rate_limiting.rb
224
218
  - lib/bearcat/rate_limiting/functions.lua
225
219
  - lib/bearcat/rate_limiting/increment_bucket.lua
226
220
  - lib/bearcat/rate_limiting/redis_script.rb
227
- - lib/bearcat/redis_connection.rb
228
221
  - lib/bearcat/spec_helpers.rb
229
222
  - lib/bearcat/version.rb
230
223
  - lib/catalogcat.rb
@@ -429,8 +422,10 @@ files:
429
422
  - spec/fixtures/user_page_views.json
430
423
  - spec/fixtures/user_profile.json
431
424
  - spec/helper.rb
425
+ homepage:
432
426
  licenses: []
433
427
  metadata: {}
428
+ post_install_message:
434
429
  rdoc_options: []
435
430
  require_paths:
436
431
  - lib
@@ -445,198 +440,199 @@ required_rubygems_version: !ruby/object:Gem::Requirement
445
440
  - !ruby/object:Gem::Version
446
441
  version: '0'
447
442
  requirements: []
448
- rubygems_version: 3.6.9
443
+ rubygems_version: 3.1.6
444
+ signing_key:
449
445
  specification_version: 4
450
446
  summary: Canvas API
451
447
  test_files:
448
+ - spec/bearcat_spec.rb
449
+ - spec/bearcat/client_spec.rb
452
450
  - spec/bearcat/api_array_spec.rb
453
- - spec/bearcat/client/accounts_spec.rb
454
- - spec/bearcat/client/analytics_spec.rb
455
- - spec/bearcat/client/assignment_groups_spec.rb
456
- - spec/bearcat/client/assignments_spec.rb
457
- - spec/bearcat/client/blueprint_courses_spec.rb
458
- - spec/bearcat/client/calendar_events_spec.rb
451
+ - spec/bearcat/rate_limiting_spec.rb
452
+ - spec/bearcat/stub_bearcat_spec.rb
459
453
  - spec/bearcat/client/canvas_files_spec.rb
454
+ - spec/bearcat/client/folders_spec.rb
460
455
  - spec/bearcat/client/conferences_spec.rb
461
- - spec/bearcat/client/content_exports_spec.rb
462
- - spec/bearcat/client/content_migrations_spec.rb
463
456
  - spec/bearcat/client/conversations_spec.rb
464
- - spec/bearcat/client/courses_spec.rb
465
- - spec/bearcat/client/custom_gradebook_columns_spec.rb
457
+ - spec/bearcat/client/outcome_groups_spec.rb
458
+ - spec/bearcat/client/assignment_groups_spec.rb
459
+ - spec/bearcat/client/assignments_spec.rb
460
+ - spec/bearcat/client/rubric_association_spec.rb
461
+ - spec/bearcat/client/o_auth2_spec.rb
462
+ - spec/bearcat/client/search_spec.rb
463
+ - spec/bearcat/client/calendar_events_spec.rb
464
+ - spec/bearcat/client/group_memberships_spec.rb
465
+ - spec/bearcat/client/pages_spec.rb
466
+ - spec/bearcat/client/modules_spec.rb
466
467
  - spec/bearcat/client/discussions_spec.rb
467
- - spec/bearcat/client/enrollments_spec.rb
468
- - spec/bearcat/client/external_tools_spec.rb
469
468
  - spec/bearcat/client/files_spec.rb
470
- - spec/bearcat/client/folders_spec.rb
469
+ - spec/bearcat/client/roles_spec.rb
471
470
  - spec/bearcat/client/graph_ql_spec.rb
472
471
  - spec/bearcat/client/group_categories_spec.rb
473
- - spec/bearcat/client/group_membership_spec.rb
474
- - spec/bearcat/client/group_memberships_spec.rb
475
- - spec/bearcat/client/groups_spec.rb
476
- - spec/bearcat/client/learning_outcomes_spec.rb
472
+ - spec/bearcat/client/rubric_assessment_spec.rb
473
+ - spec/bearcat/client/blueprint_courses_spec.rb
474
+ - spec/bearcat/client/submissions_spec.rb
477
475
  - spec/bearcat/client/module_items_spec.rb
478
- - spec/bearcat/client/modules_spec.rb
479
- - spec/bearcat/client/o_auth2_spec.rb
480
- - spec/bearcat/client/outcome_groups_spec.rb
476
+ - spec/bearcat/client/content_migrations_spec.rb
477
+ - spec/bearcat/client/custom_gradebook_columns_spec.rb
478
+ - spec/bearcat/client/enrollments_spec.rb
479
+ - spec/bearcat/client/analytics_spec.rb
480
+ - spec/bearcat/client/content_exports_spec.rb
481
+ - spec/bearcat/client/external_tools_spec.rb
482
+ - spec/bearcat/client/rubric_spec.rb
483
+ - spec/bearcat/client/accounts_spec.rb
484
+ - spec/bearcat/client/learning_outcomes_spec.rb
481
485
  - spec/bearcat/client/outcomes_spec.rb
482
- - spec/bearcat/client/pages_spec.rb
483
- - spec/bearcat/client/quizzes_spec.rb
486
+ - spec/bearcat/client/courses_spec.rb
484
487
  - spec/bearcat/client/reports_spec.rb
485
- - spec/bearcat/client/roles_spec.rb
486
- - spec/bearcat/client/rubric_assessment_spec.rb
487
- - spec/bearcat/client/rubric_association_spec.rb
488
- - spec/bearcat/client/rubric_spec.rb
489
- - spec/bearcat/client/search_spec.rb
490
- - spec/bearcat/client/sections_spec.rb
491
- - spec/bearcat/client/submissions_spec.rb
492
488
  - spec/bearcat/client/users_spec.rb
493
- - spec/bearcat/client_spec.rb
494
- - spec/bearcat/rate_limiting_spec.rb
495
- - spec/bearcat/stub_bearcat_spec.rb
496
- - spec/bearcat_spec.rb
497
- - spec/fixtures/access_token.json
498
- - spec/fixtures/account_admin_create.json
499
- - spec/fixtures/account_admin_delete.json
500
- - spec/fixtures/account_admins.json
501
- - spec/fixtures/account_courses.json
489
+ - spec/bearcat/client/sections_spec.rb
490
+ - spec/bearcat/client/group_membership_spec.rb
491
+ - spec/bearcat/client/groups_spec.rb
492
+ - spec/bearcat/client/quizzes_spec.rb
493
+ - spec/helper.rb
502
494
  - spec/fixtures/account_grading_standards.json
503
- - spec/fixtures/account_groups.json
504
- - spec/fixtures/account_reports.json
505
- - spec/fixtures/account_reports_index.json
506
- - spec/fixtures/account_reports_result_success.json
507
- - spec/fixtures/account_reports_start_result.json
508
- - spec/fixtures/account_role.json
509
- - spec/fixtures/account_roles.json
510
- - spec/fixtures/account_sis_imports.json
511
- - spec/fixtures/account_sub_accounts.json
512
- - spec/fixtures/account_user.json
513
- - spec/fixtures/account_users.json
514
- - spec/fixtures/accounts.json
515
495
  - spec/fixtures/add_custom_user_data.json
516
- - spec/fixtures/add_user.json
517
- - spec/fixtures/assignment.json
518
496
  - spec/fixtures/assignment_group.json
519
- - spec/fixtures/assignment_groups.json
520
- - spec/fixtures/assignment_section_override.json
497
+ - spec/fixtures/account_groups.json
498
+ - spec/fixtures/update_outcome.json
499
+ - spec/fixtures/section_enrollments.json
500
+ - spec/fixtures/outcome_groups.json
521
501
  - spec/fixtures/assignments.json
502
+ - spec/fixtures/course_files.json
503
+ - spec/fixtures/assignment_section_override.json
504
+ - spec/fixtures/delete_course.json
505
+ - spec/fixtures/course_folder.json
506
+ - spec/fixtures/ok.json
507
+ - spec/fixtures/account_sub_accounts.json
508
+ - spec/fixtures/course_sections.json
509
+ - spec/fixtures/merge_user.json
522
510
  - spec/fixtures/bearcat.jpg
523
- - spec/fixtures/blueprint_migration.json
524
- - spec/fixtures/blueprint_subscriptions.json
525
- - spec/fixtures/blueprint_template.json
526
- - spec/fixtures/blueprint_update_assocations_success.json
527
- - spec/fixtures/calendar_event.json
528
- - spec/fixtures/calendar_events.json
529
- - spec/fixtures/canvas_files/declare_file.json
530
- - spec/fixtures/canvas_files/upload_success.json
531
- - spec/fixtures/cc.imscc
511
+ - spec/fixtures/create_group_discussion.json
512
+ - spec/fixtures/course_enrollments.json
513
+ - spec/fixtures/account_users.json
514
+ - spec/fixtures/no_custom_data.json
532
515
  - spec/fixtures/communication_channels.json
533
- - spec/fixtures/conclude_enrollment.json
534
- - spec/fixtures/content_export.json
516
+ - spec/fixtures/edited_group_category.json
517
+ - spec/fixtures/rubric_assessment.json
518
+ - spec/fixtures/paged_body.json
519
+ - spec/fixtures/canvas_files/upload_success.json
520
+ - spec/fixtures/canvas_files/declare_file.json
521
+ - spec/fixtures/account_reports.json
522
+ - spec/fixtures/outcomes.json
523
+ - spec/fixtures/search_find_recipients.json
524
+ - spec/fixtures/content_migration_files/upload_success.json
535
525
  - spec/fixtures/content_migration_files/content_migration.json
536
526
  - spec/fixtures/content_migration_files/response.json
537
- - spec/fixtures/content_migration_files/upload_success.json
538
- - spec/fixtures/conversation.json
539
- - spec/fixtures/course.json
527
+ - spec/fixtures/created_assignment.json
540
528
  - spec/fixtures/course_conferences.json
541
- - spec/fixtures/course_copy.json
542
- - spec/fixtures/course_enrollments.json
543
- - spec/fixtures/course_files.json
544
- - spec/fixtures/course_folder.json
545
- - spec/fixtures/course_folders.json
546
- - spec/fixtures/course_grading_standards.json
547
- - spec/fixtures/course_groups.json
548
- - spec/fixtures/course_sections.json
549
- - spec/fixtures/course_settings.json
550
- - spec/fixtures/course_students.json
551
- - spec/fixtures/create_course_discussion.json
552
- - spec/fixtures/create_group_discussion.json
553
529
  - spec/fixtures/create_outcome_in_group.json
554
- - spec/fixtures/create_section.json
555
- - spec/fixtures/created_assignment.json
556
- - spec/fixtures/created_course.json
557
- - spec/fixtures/created_group.json
530
+ - spec/fixtures/delete_custom_data_scope.json
558
531
  - spec/fixtures/created_group_category.json
559
- - spec/fixtures/created_group_membership.json
560
- - spec/fixtures/created_module.json
532
+ - spec/fixtures/created_course.json
533
+ - spec/fixtures/assignment_groups.json
534
+ - spec/fixtures/section.json
535
+ - spec/fixtures/create_section.json
536
+ - spec/fixtures/user_page_views.json
537
+ - spec/fixtures/account_admin_create.json
538
+ - spec/fixtures/assignment.json
539
+ - spec/fixtures/calendar_event.json
540
+ - spec/fixtures/blueprint_subscriptions.json
541
+ - spec/fixtures/blueprint_update_assocations_success.json
542
+ - spec/fixtures/course.json
543
+ - spec/fixtures/rubric_association.json
544
+ - spec/fixtures/external_tools.json
545
+ - spec/fixtures/conversation.json
546
+ - spec/fixtures/external_tool.json
547
+ - spec/fixtures/course_students.json
548
+ - spec/fixtures/updated_course.json
549
+ - spec/fixtures/discussion_topics.json
550
+ - spec/fixtures/user_enrollments.json
551
+ - spec/fixtures/account_roles.json
552
+ - spec/fixtures/add_user.json
553
+ - spec/fixtures/discussion_entry_replies.json
554
+ - spec/fixtures/report_history.json
555
+ - spec/fixtures/gradebook_history.json
556
+ - spec/fixtures/account_sis_imports.json
557
+ - spec/fixtures/update_section.json
558
+ - spec/fixtures/conclude_enrollment.json
559
+ - spec/fixtures/start_report.json
561
560
  - spec/fixtures/custom_data.json
562
- - spec/fixtures/custom_food_data.json
563
- - spec/fixtures/custom_gradebook_columns/column_data.json
564
- - spec/fixtures/custom_gradebook_columns/custom_gradebook_column.json
565
- - spec/fixtures/custom_gradebook_columns/custom_gradebook_columns.json
566
- - spec/fixtures/custom_gradebook_columns/gradebook_column_progress.json
567
- - spec/fixtures/dashboard.json
568
- - spec/fixtures/delete_course.json
569
- - spec/fixtures/delete_custom_data_scope.json
561
+ - spec/fixtures/rubric.json
562
+ - spec/fixtures/account_role.json
563
+ - spec/fixtures/update_outcome_group.json
564
+ - spec/fixtures/module_item.json
565
+ - spec/fixtures/report_status.json
566
+ - spec/fixtures/enroll_student.json
567
+ - spec/fixtures/group_category.json
570
568
  - spec/fixtures/delete_group_category.json
571
- - spec/fixtures/delete_section.json
572
- - spec/fixtures/deleted_conversation.json
573
- - spec/fixtures/deleted_group.json
574
- - spec/fixtures/department_level_participation.json
575
- - spec/fixtures/department_level_statistics.json
576
- - spec/fixtures/discussion_entries.json
577
- - spec/fixtures/discussion_entry_replies.json
578
- - spec/fixtures/discussion_topic.json
579
- - spec/fixtures/discussion_topics.json
569
+ - spec/fixtures/dashboard.json
580
570
  - spec/fixtures/edited_group.json
581
- - spec/fixtures/edited_group_category.json
582
- - spec/fixtures/enroll_student.json
583
- - spec/fixtures/enrollment_terms.json
584
- - spec/fixtures/external_tool.json
585
- - spec/fixtures/external_tools.json
571
+ - spec/fixtures/department_level_participation.json
572
+ - spec/fixtures/outcome_result.json
586
573
  - spec/fixtures/file.csv
587
- - spec/fixtures/gradebook_history.json
588
- - spec/fixtures/graph_ql_scores.json
589
- - spec/fixtures/group.json
590
- - spec/fixtures/group_categories.json
591
- - spec/fixtures/group_category.json
592
- - spec/fixtures/group_category_groups.json
593
- - spec/fixtures/group_conferences.json
594
- - spec/fixtures/group_membership.json
595
- - spec/fixtures/learning_outcome.json
596
- - spec/fixtures/link_unlink_outcome.json
597
- - spec/fixtures/merge_user.json
598
- - spec/fixtures/module.json
599
- - spec/fixtures/module_item.json
574
+ - spec/fixtures/course_copy.json
575
+ - spec/fixtures/user_logins.json
600
576
  - spec/fixtures/module_item_sequence.json
577
+ - spec/fixtures/course_settings.json
578
+ - spec/fixtures/enrollment_terms.json
579
+ - spec/fixtures/blueprint_migration.json
580
+ - spec/fixtures/cc.imscc
581
+ - spec/fixtures/user_profile.json
582
+ - spec/fixtures/create_course_discussion.json
583
+ - spec/fixtures/custom_food_data.json
584
+ - spec/fixtures/created_module.json
585
+ - spec/fixtures/course_groups.json
586
+ - spec/fixtures/reactivate_enrollment.json
587
+ - spec/fixtures/blueprint_template.json
588
+ - spec/fixtures/account_courses.json
589
+ - spec/fixtures/calendar_events.json
590
+ - spec/fixtures/submissions/submission.json
591
+ - spec/fixtures/link_unlink_outcome.json
592
+ - spec/fixtures/account_reports_index.json
601
593
  - spec/fixtures/module_items.json
602
- - spec/fixtures/modules.json
603
- - spec/fixtures/no_custom_data.json
604
- - spec/fixtures/ok.json
594
+ - spec/fixtures/access_token.json
595
+ - spec/fixtures/progress.json
596
+ - spec/fixtures/module.json
597
+ - spec/fixtures/group_categories.json
598
+ - spec/fixtures/course_folders.json
599
+ - spec/fixtures/department_level_statistics.json
600
+ - spec/fixtures/account_admin_delete.json
601
+ - spec/fixtures/account_reports_result_success.json
602
+ - spec/fixtures/deleted_conversation.json
603
+ - spec/fixtures/learning_outcome.json
604
+ - spec/fixtures/user_details.json
605
605
  - spec/fixtures/outcome_group_import.json
606
- - spec/fixtures/outcome_groups.json
607
- - spec/fixtures/outcome_result.json
606
+ - spec/fixtures/modules.json
607
+ - spec/fixtures/group.json
608
608
  - spec/fixtures/outcome_subgroup.json
609
609
  - spec/fixtures/outcome_subgroups.json
610
- - spec/fixtures/outcomes.json
611
- - spec/fixtures/paged_body.json
612
- - spec/fixtures/pages.json
613
- - spec/fixtures/progress.json
614
- - spec/fixtures/quizzes/course_quiz.json
615
- - spec/fixtures/quizzes/course_quiz_questions.json
610
+ - spec/fixtures/delete_section.json
611
+ - spec/fixtures/account_user.json
612
+ - spec/fixtures/accounts.json
613
+ - spec/fixtures/account_admins.json
614
+ - spec/fixtures/report_list.json
615
+ - spec/fixtures/group_membership.json
616
616
  - spec/fixtures/quizzes/course_quizzes.json
617
+ - spec/fixtures/quizzes/course_quiz_questions.json
617
618
  - spec/fixtures/quizzes/quiz_assignment_override.json
618
619
  - spec/fixtures/quizzes/quiz_extension.json
619
- - spec/fixtures/reactivate_enrollment.json
620
- - spec/fixtures/report_history.json
621
- - spec/fixtures/report_list.json
622
- - spec/fixtures/report_status.json
623
- - spec/fixtures/rubric.json
624
- - spec/fixtures/rubric_assessment.json
625
- - spec/fixtures/rubric_association.json
626
- - spec/fixtures/search_find_recipients.json
627
- - spec/fixtures/section.json
628
- - spec/fixtures/section_enrollments.json
620
+ - spec/fixtures/quizzes/course_quiz.json
621
+ - spec/fixtures/content_export.json
622
+ - spec/fixtures/created_group.json
623
+ - spec/fixtures/pages.json
624
+ - spec/fixtures/discussion_entries.json
629
625
  - spec/fixtures/single_account.json
630
- - spec/fixtures/start_report.json
631
- - spec/fixtures/submissions/submission.json
632
- - spec/fixtures/update_outcome.json
633
- - spec/fixtures/update_outcome_group.json
634
- - spec/fixtures/update_section.json
635
- - spec/fixtures/updated_course.json
626
+ - spec/fixtures/group_category_groups.json
627
+ - spec/fixtures/created_group_membership.json
636
628
  - spec/fixtures/user_avatars.json
637
- - spec/fixtures/user_details.json
638
- - spec/fixtures/user_enrollments.json
639
- - spec/fixtures/user_logins.json
640
- - spec/fixtures/user_page_views.json
641
- - spec/fixtures/user_profile.json
642
- - spec/helper.rb
629
+ - spec/fixtures/graph_ql_scores.json
630
+ - spec/fixtures/custom_gradebook_columns/gradebook_column_progress.json
631
+ - spec/fixtures/custom_gradebook_columns/custom_gradebook_column.json
632
+ - spec/fixtures/custom_gradebook_columns/custom_gradebook_columns.json
633
+ - spec/fixtures/custom_gradebook_columns/column_data.json
634
+ - spec/fixtures/account_reports_start_result.json
635
+ - spec/fixtures/course_grading_standards.json
636
+ - spec/fixtures/group_conferences.json
637
+ - spec/fixtures/discussion_topic.json
638
+ - spec/fixtures/deleted_group.json
@@ -1,10 +0,0 @@
1
- module Bearcat
2
- module MiscExceptions
3
- # This exception is not part of the Footrest::HttpError module
4
- class Conflict < Footrest::HttpError::BadRequest
5
- def self.===(exception)
6
- exception.status == 409
7
- end
8
- end
9
- end
10
- end
@@ -1,106 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "connection_pool"
4
- require "redis"
5
- require "uri"
6
-
7
- # Adapted from Sidekiq 6.x Implementation
8
-
9
- module Bearcat
10
- module RedisConnection
11
- KNOWN_REDIS_URL_ENVS = %w[REDIS_URL REDISTOGO_URL REDISCLOUD_URL].freeze
12
-
13
- class << self
14
- def configured?(prefix, explicit: false)
15
- determine_redis_provider(prefix: prefix, explicit: true)
16
- end
17
-
18
- def create(options = {})
19
- symbolized_options = options.transform_keys(&:to_sym)
20
-
21
- if !symbolized_options[:url] && (u = determine_redis_provider(prefix: options[:env_prefix]))
22
- symbolized_options[:url] = u
23
- end
24
-
25
- size = if symbolized_options[:size]
26
- symbolized_options[:size]
27
- elsif symbolized_options[:env_prefix] && (v = ENV["#{symbolized_options[:env_prefix]}_REDIS_POOL_SIZE"])
28
- Integer(v)
29
- elsif ENV["RAILS_MAX_THREADS"]
30
- Integer(ENV["RAILS_MAX_THREADS"])
31
- else
32
- 5
33
- end
34
-
35
- pool_timeout = symbolized_options[:pool_timeout] || 1
36
-
37
- ConnectionPool.new(timeout: pool_timeout, size: size) do
38
- namespace = symbolized_options[:namespace]
39
- client = Redis.new client_opts(symbolized_options)
40
-
41
- if namespace
42
- begin
43
- require "redis/namespace"
44
- Redis::Namespace.new(namespace, redis: client)
45
- rescue LoadError
46
- Rails.logger.error("Your Redis configuration uses the namespace '#{namespace}' but the redis-namespace gem is not included in the Gemfile." \
47
- "Add the gem to your Gemfile to continue using a namespace. Otherwise, remove the namespace parameter.")
48
- exit(-127)
49
- end
50
- else
51
- client
52
- end
53
- end
54
- end
55
-
56
- private
57
-
58
- def client_opts(options)
59
- opts = options.dup
60
- if opts[:namespace]
61
- opts.delete(:namespace)
62
- end
63
-
64
- opts.delete(:size)
65
- opts.delete(:env_prefix)
66
-
67
- if opts[:network_timeout]
68
- opts[:timeout] = opts[:network_timeout]
69
- opts.delete(:network_timeout)
70
- end
71
-
72
- opts[:reconnect_attempts] ||= 1
73
-
74
- opts
75
- end
76
-
77
- def determine_redis_provider(prefix: nil, explicit: false)
78
- vars = []
79
-
80
- if prefix.present?
81
- if (ptr = ENV["#{prefix}_REDIS_PROVIDER"]).present?
82
- return ENV[ptr]
83
- else
84
- vars.push(*KNOWN_REDIS_URL_ENVS.map { |e| ENV["#{prefix}_#{e}"] })
85
- end
86
- end
87
-
88
- if !explicit || !prefix.present?
89
- if (ptr = ENV["REDIS_PROVIDER"]).present?
90
- vars << ptr # Intentionally not a return
91
- else
92
- vars.push(*KNOWN_REDIS_URL_ENVS)
93
- end
94
- end
95
-
96
- vars.select!(&:present?)
97
-
98
- vars.each do |e|
99
- return ENV[e] if ENV[e].present?
100
- end
101
-
102
- nil
103
- end
104
- end
105
- end
106
- end