clarify Slug vs. UUID and fix event stream

refs CNVS-13987

what was called CanvasUuid was *not* generating UUIDs. it was generating
slugs. by default, its generate method only creates 4 character slugs.
these should obviously not be used as UUIDs. the misnomer already caused
a bug in EventStream where it used these slugs as UUIDs, causing
collisions. to fix:

 (1) rename canvas_uuid gem to canvas_slug, and rename it's primary
     class CanvasUuid to CanvasSlug
 (2) create new canvas_uuid gem, with class CanvasUUID, extracted from
     lib/uuid_singleton for actual UUID generation
 (3) fix event stream use CanvasUUID, rather than following the rename
     of CanvasUuid to CanvasSlug

test-plan:
 - have cassandra set up for audit logs
 - create an audit log entry (e.g. change a grade)
 - look at the generated audit log entry's id field; it should be a UUID
   value, not a 4 character slug

Change-Id: I19758fff4433cd6cb2e21219217dced19ee05c5a
Reviewed-on: https://gerrit.instructure.com/37506
Reviewed-by: Rob Orton <rob@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: August Thornton <august@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Brian Palmer <brianp@instructure.com>
This commit is contained in:
Jacob Fugal 2014-07-10 11:22:01 -06:00 committed by Brian Palmer
parent ba00b0154a
commit d9c6e2a0cd
55 changed files with 130 additions and 111 deletions

View File

@ -129,6 +129,7 @@ gem 'event_stream', :path => 'gems/event_stream'
gem 'canvas_mimetype_fu', :path => 'gems/canvas_mimetype_fu'
gem 'canvas_quiz_statistics', :path => 'gems/canvas_quiz_statistics'
gem 'canvas_sanitize', :path => 'gems/canvas_sanitize'
gem 'canvas_slug', :path => 'gems/canvas_slug'
gem 'canvas_sort', :path => 'gems/canvas_sort'
gem 'canvas_statsd', :path => 'gems/canvas_statsd'
gem 'canvas_stringex', :path => 'gems/canvas_stringex'

View File

@ -148,7 +148,7 @@ class UsersController < ApplicationController
:service => 'google_docs',
:token => request_token.token,
:secret => request_token.secret,
:user_secret => CanvasUuid::Uuid.generate(nil, 16),
:user_secret => CanvasSlug.generate(nil, 16),
:return_url => return_to_url,
:user => @real_current_user || @current_user,
:original_host_with_port => request.host_with_port
@ -186,7 +186,7 @@ class UsersController < ApplicationController
elsif params[:service] == "facebook"
oauth_request = OauthRequest.create(
:service => 'facebook',
:secret => CanvasUuid::Uuid.generate("fb", 10),
:secret => CanvasSlug.generate("fb", 10),
:return_url => return_to_url,
:user => @current_user,
:original_host_with_port => request.host_with_port

View File

@ -24,7 +24,7 @@ class RequestContextGenerator
def call(env)
# This is a crummy way to plumb this data through to the logger
request_id = UUIDSingleton.instance.generate
request_id = CanvasUUID.generate
session_id = (env['rack.session.options'] || {})[:id]
Thread.current[:context] = {
:request_id => request_id,

View File

@ -71,7 +71,7 @@ class AccessToken < ActiveRecord::Base
def generate_token(overwrite=false)
if overwrite || !self.crypted_token
self.token = CanvasUuid::Uuid.generate(nil, TOKEN_SIZE)
self.token = CanvasSlug.generate(nil, TOKEN_SIZE)
end
end

View File

@ -320,7 +320,7 @@ class Account < ActiveRecord::Base
end
def ensure_defaults
self.uuid ||= CanvasUuid::Uuid.generate_securish_uuid
self.uuid ||= CanvasSlug.generate_securish_uuid
self.lti_guid ||= self.uuid if self.respond_to?(:lti_guid)
end

View File

@ -43,7 +43,7 @@ class AssessmentRequest < ActiveRecord::Base
has_a_broadcast_policy
def infer_uuid
self.uuid ||= CanvasUuid::Uuid.generate_securish_uuid
self.uuid ||= CanvasSlug.generate_securish_uuid
end
protected :infer_uuid

View File

@ -942,7 +942,7 @@ class Assignment < ActiveRecord::Base
:media_comment_id => (opts.delete :media_comment_id),
:media_comment_type => (opts.delete :media_comment_type),
}
comment[:group_comment_id] = CanvasUuid::Uuid.generate_securish_uuid if group_comment && group
comment[:group_comment_id] = CanvasSlug.generate_securish_uuid if group_comment && group
submissions = []
find_or_create_submissions(students) do |submission|
submission_updated = false
@ -1051,7 +1051,7 @@ class Assignment < ActiveRecord::Base
res = find_or_create_submissions(students) do |s|
s.group = group
s.save! if s.changed?
opts[:group_comment_id] = CanvasUuid::Uuid.generate_securish_uuid if group
opts[:group_comment_id] = CanvasSlug.generate_securish_uuid if group
s.add_comment(opts)
# this is lame, SubmissionComment updates the submission directly in the db
# in an after_save, and of course Rails doesn't preload the reverse association
@ -1124,7 +1124,7 @@ class Assignment < ActiveRecord::Base
context_module_action(homework.student, homework.workflow_state.to_sym)
if comment && (group_comment || homework == primary_homework)
hash = {:comment => comment, :author => original_student}
hash[:group_comment_id] = CanvasUuid::Uuid.generate_securish_uuid if group_comment && group
hash[:group_comment_id] = CanvasSlug.generate_securish_uuid if group_comment && group
homework.add_comment(hash)
end
end
@ -1377,7 +1377,7 @@ class Assignment < ActiveRecord::Base
attachments: attachments,
}
group, students = group_students(user)
comment[:group_comment_id] = CanvasUuid::Uuid.generate_securish_uuid if group
comment[:group_comment_id] = CanvasSlug.generate_securish_uuid if group
find_or_create_submissions(students).map do |submission|
submission.add_comment(comment)
end

View File

@ -737,7 +737,7 @@ class Attachment < ActiveRecord::Base
before_save :assign_uuid
def assign_uuid
self.uuid ||= CanvasUuid::Uuid.generate_securish_uuid
self.uuid ||= CanvasSlug.generate_securish_uuid
end
protected :assign_uuid

View File

@ -278,7 +278,7 @@ class Collaboration < ActiveRecord::Base
#
# Returns a UUID string.
def assign_uuid
self.uuid ||= CanvasUuid::Uuid.generate_securish_uuid
self.uuid ||= CanvasSlug.generate_securish_uuid
end
protected :assign_uuid

View File

@ -206,9 +206,9 @@ class CommunicationChannel < ActiveRecord::Base
def set_confirmation_code(reset=false)
self.confirmation_code = nil if reset
if self.path_type == TYPE_EMAIL or self.path_type.nil?
self.confirmation_code ||= CanvasUuid::Uuid.generate(nil, 25)
self.confirmation_code ||= CanvasSlug.generate(nil, 25)
else
self.confirmation_code ||= CanvasUuid::Uuid.generate
self.confirmation_code ||= CanvasSlug.generate
end
true
end

View File

@ -954,7 +954,7 @@ class Course < ActiveRecord::Base
end
def self.create_unique(uuid=nil, account_id=nil, root_account_id=nil)
uuid ||= CanvasUuid::Uuid.generate_securish_uuid
uuid ||= CanvasSlug.generate_securish_uuid
course = find_or_initialize_by_uuid(uuid)
course = Course.new if course.deleted?
course.name = self.default_name if course.new_record?
@ -999,7 +999,7 @@ class Course < ActiveRecord::Base
end
def assign_uuid
self.uuid ||= CanvasUuid::Uuid.generate_securish_uuid
self.uuid ||= CanvasSlug.generate_securish_uuid
end
protected :assign_uuid

View File

@ -38,7 +38,7 @@ class DeveloperKey < ActiveRecord::Base
end
def generate_api_key(overwrite=false)
self.api_key = CanvasUuid::Uuid.generate(nil, 64) if overwrite || !self.api_key
self.api_key = CanvasSlug.generate(nil, 64) if overwrite || !self.api_key
end
def self.default

View File

@ -927,13 +927,13 @@ class Enrollment < ActiveRecord::Base
def assign_uuid
# DON'T use ||=, because that will cause an immediate save to the db if it
# doesn't already exist
self.uuid = CanvasUuid::Uuid.generate_securish_uuid if !read_attribute(:uuid)
self.uuid = CanvasSlug.generate_securish_uuid if !read_attribute(:uuid)
end
protected :assign_uuid
def uuid
if !read_attribute(:uuid)
self.update_attribute(:uuid, CanvasUuid::Uuid.generate_securish_uuid)
self.update_attribute(:uuid, CanvasSlug.generate_securish_uuid)
end
read_attribute(:uuid)
end

View File

@ -47,7 +47,7 @@ class Eportfolio < ActiveRecord::Base
before_create :assign_uuid
def assign_uuid
self.uuid ||= CanvasUuid::Uuid.generate_securish_uuid
self.uuid ||= CanvasSlug.generate_securish_uuid
end
protected :assign_uuid

View File

@ -327,7 +327,7 @@ class Group < ActiveRecord::Base
:updated_at => current_time
}.merge(options)
GroupMembership.bulk_insert(users.map{ |user|
options.merge({:user_id => user.id, :uuid => CanvasUuid::Uuid.generate_securish_uuid})
options.merge({:user_id => user.id, :uuid => CanvasSlug.generate_securish_uuid})
})
end
@ -381,8 +381,8 @@ class Group < ActiveRecord::Base
end
def ensure_defaults
self.name ||= CanvasUuid::Uuid.generate_securish_uuid
self.uuid ||= CanvasUuid::Uuid.generate_securish_uuid
self.name ||= CanvasSlug.generate_securish_uuid
self.uuid ||= CanvasSlug.generate_securish_uuid
self.group_category ||= GroupCategory.student_organized_for(self.context)
self.join_level ||= 'invitation_only'
self.is_public ||= false

View File

@ -93,7 +93,7 @@ class GroupMembership < ActiveRecord::Base
end
def assign_uuid
self.uuid ||= CanvasUuid::Uuid.generate_securish_uuid
self.uuid ||= CanvasSlug.generate_securish_uuid
end
protected :assign_uuid

View File

@ -167,7 +167,7 @@ class Pseudonym < ActiveRecord::Base
if !self.persistence_token || self.persistence_token == ''
# Some pseudonyms can end up without a persistence token if they were created
# using the SIS, for example.
self.persistence_token = CanvasUuid::Uuid.generate('pseudo', 15)
self.persistence_token = CanvasSlug.generate('pseudo', 15)
self.save
end

View File

@ -87,7 +87,7 @@ class ReportSnapshot < ActiveRecord::Base
installation_uuid = Setting.get("installation_uuid", "")
if installation_uuid == ""
installation_uuid = CanvasUuid::Uuid.generate_securish_uuid
installation_uuid = CanvasSlug.generate_securish_uuid
Setting.set("installation_uuid", installation_uuid)
end

View File

@ -47,7 +47,7 @@ class Thumbnail < ActiveRecord::Base
before_save :assign_uuid
def assign_uuid
self.uuid ||= CanvasUuid::Uuid.generate_securish_uuid
self.uuid ||= CanvasSlug.generate_securish_uuid
end
protected :assign_uuid
end

View File

@ -558,7 +558,7 @@ class User < ActiveRecord::Base
def assign_uuid
# DON'T use ||=, because that will cause an immediate save to the db if it
# doesn't already exist
self.uuid = CanvasUuid::Uuid.generate_securish_uuid if !read_attribute(:uuid)
self.uuid = CanvasSlug.generate_securish_uuid if !read_attribute(:uuid)
end
protected :assign_uuid
@ -1433,7 +1433,7 @@ class User < ActiveRecord::Base
def uuid
if !read_attribute(:uuid)
self.update_attribute(:uuid, CanvasUuid::Uuid.generate_securish_uuid)
self.update_attribute(:uuid, CanvasSlug.generate_securish_uuid)
end
read_attribute(:uuid)
end

View File

@ -171,7 +171,7 @@ class WebConference < ActiveRecord::Base
end
def assign_uuid
self.uuid ||= CanvasUuid::Uuid.generate_securish_uuid
self.uuid ||= CanvasSlug.generate_securish_uuid
end
protected :assign_uuid

View File

@ -3,7 +3,7 @@
<p><%= t 'notices.uploading_progress_info', 'Uploading and processing your zip file, if there are a lot of files in the zip file or it is very large, this may take a while.' %></p>
</div>
<%= form_for((@zfi || ZipFileImport.new), :url => context_url(@context, :context_zip_file_imports_url), :html => { :id => "zip_file_import_form", :multipart => true }) do |form| %>
<input type="hidden" name="batch_id" value="<%= CanvasUuid::Uuid.generate(@current_user.asset_string, 10) %>" id="zip_import_batch_id"/>
<input type="hidden" name="batch_id" value="<%= CanvasSlug.generate(@current_user.asset_string, 10) %>" id="zip_import_batch_id"/>
<%= form.error_messages %>
<div>
<input type="file" name="zip_file" id="zip_file"/><br/>

View File

@ -6,7 +6,7 @@ class AddThumbnailUuid < ActiveRecord::Migration
add_index :thumbnails, [:id, :uuid]
Thumbnail.find_each do |t|
t.uuid ||= CanvasUuid::Uuid.generate_securish_uuid
t.uuid ||= CanvasSlug.generate_securish_uuid
t.save
end
end

View File

@ -2,7 +2,7 @@ source 'https://rubygems.org'
gem 'canvas_sort', :path => '../canvas_sort'
gem 'canvas_http', :path => '../canvas_http'
gem 'canvas_uuid', :path => '../canvas_uuid'
gem 'canvas_slug', :path => '../canvas_slug'
gem 'multipart', :path => '../multipart'
gemspec

View File

@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
spec.add_dependency "canvas_http"
spec.add_dependency "canvas_sort"
spec.add_dependency "multipart"
spec.add_dependency "canvas_uuid"
spec.add_dependency "canvas_slug"
spec.add_development_dependency "bundler", "~> 1.5"
spec.add_development_dependency "rake"

3
gems/canvas_slug/Gemfile Normal file
View File

@ -0,0 +1,3 @@
source 'https://rubygems.org'
gemspec

View File

@ -0,0 +1 @@
require "bundler/gem_tasks"

View File

@ -0,0 +1,20 @@
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
Gem::Specification.new do |spec|
spec.name = "canvas_slug"
spec.version = "0.0.1"
spec.authors = ["Raphael Weiner"]
spec.email = ["rweiner@pivotallabs.com"]
spec.summary = %q{Canvas Slug generation}
spec.files = Dir.glob("{lib,test}/**/*") + %w(Rakefile)
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]
spec.add_development_dependency "bundler", "~> 1.5"
spec.add_development_dependency "rake"
end

View File

@ -16,8 +16,9 @@
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
module CanvasUuid
class Uuid
require "securerandom"
class CanvasSlug
class << self
CHARS = ('0'..'9').to_a + ('a'..'z').to_a + ('A'..'Z').to_a
@ -32,5 +33,10 @@ module CanvasUuid
slug
end
end
end
end
# TODO: stub until other references to CanvasUuid outside core canvas-lms
# are replaced with CanvasSlug. remove when those are updated.
module CanvasUuid
Uuid = CanvasSlug
end

View File

@ -6,8 +6,8 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
Gem::Specification.new do |spec|
spec.name = "canvas_uuid"
spec.version = "0.0.1"
spec.authors = ["Raphael Weiner"]
spec.email = ["rweiner@pivotallabs.com"]
spec.authors = ["Jacob Fugal"]
spec.email = ["jacob@instructure.com"]
spec.summary = %q{Canvas UUID generation}
spec.files = Dir.glob("{lib,test}/**/*") + %w(Rakefile)
@ -17,4 +17,6 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "bundler", "~> 1.5"
spec.add_development_dependency "rake"
spec.add_dependency "uuid", "2.3.2"
end

View File

@ -16,8 +16,20 @@
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
require "securerandom"
require "uuid"
module CanvasUuid
require "canvas_uuid/uuid"
# Creating a testable Singleton for UUID
class CanvasUUID < ::UUID
def self.instance
@@uuid_singleton ||= new
end
def self.generate
instance.generate
end
end
# Disable the UUID lib's state file thing. Across all processes, defaults to
# /var/tmp/ruby-uuid? *boggle*. We could do a tempfile thing, but this lib
# doesn't clean up after itself.
CanvasUUID.state_file = false

View File

@ -35,7 +35,7 @@ class EventStream::Record < Struct.new(:attributes)
attributes['request_id'] = request_id.to_s
end
attributes['id'] ||= CanvasUuid::Uuid.generate
attributes['id'] ||= CanvasUUID.generate
attributes['created_at'] ||= Time.zone.now
attributes['created_at'] = Time.zone.at(attributes['created_at'].to_i)
attributes['event_type'] ||= self.class.name.gsub("::#{self.class.name.demodulize}", '').demodulize.underscore

View File

@ -26,7 +26,7 @@ describe EventStream::Failure do
end
before do
@request_id = CanvasUuid::Uuid.generate
@request_id = CanvasUUID.generate
@event = EventRecord.new(
'attribute1' => 'value1',
'attribute2' => 'value2',
@ -43,9 +43,9 @@ describe EventStream::Failure do
it "allows overrided default values" do
attributes = {
'id' => CanvasUuid::Uuid.generate,
'id' => CanvasUUID.generate,
'event_type' => 'other_type',
'request_id' => CanvasUuid::Uuid.generate,
'request_id' => CanvasUUID.generate,
'created_at' => Time.zone.now
}
event = EventRecord.new(attributes)
@ -68,7 +68,7 @@ describe EventStream::Failure do
request_id = 42
attributes = {
'id' => CanvasUuid::Uuid.generate,
'id' => CanvasUUID.generate,
'event_type' => 'other_type',
'request_id' => request_id,
'created_at' => Time.zone.now

View File

@ -2,4 +2,4 @@ source 'https://rubygems.org'
gemspec
gem "canvas_uuid", path: "../canvas_uuid"
gem "canvas_slug", path: "../canvas_slug"

View File

@ -8,7 +8,7 @@
### NOW:
## Everything wrong is due to keith@oreilly.com
require "canvas_uuid"
require "canvas_slug"
require "mime/types"
require "net/http"
require "cgi"

View File

@ -1,6 +1,6 @@
module Multipart
class Post
BOUNDARY = CanvasUuid::Uuid.generate('canvas-rules', 15)
BOUNDARY = ::CanvasSlug.generate('canvas-rules', 15)
HEADER = {"Content-type" => "multipart/form-data, boundary=" + BOUNDARY}
def prepare_query (params, field_priority=[])

View File

@ -15,7 +15,7 @@ Gem::Specification.new do |spec|
spec.require_paths = ["lib"]
spec.add_dependency "mime-types", "1.17.2"
spec.add_dependency "canvas_uuid"
spec.add_dependency "canvas_slug"
spec.add_development_dependency "bundler", "~> 1.5"
spec.add_development_dependency "rake"

View File

@ -2,7 +2,7 @@ module UserContent
def self.escape(str, current_host = nil)
html = Nokogiri::HTML::DocumentFragment.parse(str)
find_user_content(html) do |obj, uc|
uuid = UUIDSingleton.instance.generate
uuid = CanvasUUID.generate
child = Nokogiri::XML::Node.new("iframe", html)
child['class'] = 'user_content_iframe'
child['name'] = uuid

View File

@ -1,30 +1,4 @@
#
# Copyright (C) 2011 Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Creating a testable Singleton for UUID
class UUIDSingleton < UUID
def self.instance
@@uuid_singleton ||= new
end
end
# Disable the UUID lib's state file thing. Across all processes, defaults to
# /var/tmp/ruby-uuid? *boggle*. We could do a tempfile thing, but this lib
# doesn't clean up after itself.
UUIDSingleton.state_file = false
# TODO: stub file until other references to UUIDSingleton outside core
# canvas-lms are replaced with CanvasUUID. remove when those are updated.
UUIDSingleton = CanvasUUID

View File

@ -68,9 +68,9 @@ class ZipExtractor
alias :dirname :make_safe_haven
def safe_haven_name
dirname = "/tmp/#{CanvasUuid::Uuid.generate}"
dirname = "/tmp/#{CanvasSlug.generate}"
while File.exist?(dirname)
dirname = "/tmp/#{CanvasUuid::Uuid.generate}"
dirname = "/tmp/#{CanvasSlug.generate}"
end
dirname
end

View File

@ -41,7 +41,7 @@ describe "AuthenticationAudit API", type: :request do
before do
Setting.set('enable_page_views', 'cassandra')
@request_id = UUIDSingleton.instance.generate
@request_id = CanvasUUID.generate
RequestContextGenerator.stubs( :request_id => @request_id )
@viewing_user = site_admin_user(user: user_with_pseudonym(account: Account.site_admin))
@ -267,7 +267,7 @@ describe "AuthenticationAudit API", type: :request do
before do
@event2 = @pseudonym.shard.activate do
record = Auditors::Authentication::Record.new(
'id' => UUIDSingleton.instance.generate,
'id' => CanvasUUID.generate,
'created_at' => 1.day.ago,
'pseudonym' => @pseudonym,
'event_type' => 'logout')

View File

@ -40,7 +40,7 @@ describe "CourseAudit API", type: :request do
include_examples "cassandra audit logs"
before do
@request_id = UUIDSingleton.instance.generate
@request_id = CanvasUUID.generate
RequestContextGenerator.stubs( :request_id => @request_id )
@domain_root_account = Account.default

View File

@ -42,7 +42,7 @@ describe "GradeChangeAudit API", type: :request do
include_examples "cassandra audit logs"
before do
@request_id = UUIDSingleton.instance.generate
@request_id = CanvasUUID.generate
RequestContextGenerator.stubs( :request_id => @request_id )
@domain_root_account = Account.default

View File

@ -146,7 +146,7 @@ describe EportfolioEntriesController do
eportfolio_category
eportfolio_entry(@category)
begin
get 'attachment', :eportfolio_id => @portfolio.id, :entry_id => @entry.id, :attachment_id => UUIDSingleton.instance.generate
get 'attachment', :eportfolio_id => @portfolio.id, :entry_id => @entry.id, :attachment_id => CanvasUUID.generate
rescue => e
e.to_s.should eql("Not Found")
end

View File

@ -66,7 +66,7 @@ describe UsersController do
Facebook::Connection.config = Proc.new do
{}
end
CanvasUuid::Uuid.stubs(:generate).returns("some_uuid")
CanvasSlug.stubs(:generate).returns("some_uuid")
user_with_pseudonym
user_session(@user)

View File

@ -23,7 +23,7 @@ end
def valid_page_view_attributes
{
:url => "http://www.example.com/courses/1",
:request_id => UUIDSingleton.instance.generate,
:request_id => CanvasUUID.generate,
:user => @user || user
}
end

View File

@ -24,10 +24,10 @@ end
# Re-generate these because I need a Unique ID
def valid_pseudonym_attributes
{
:unique_id => "#{UUIDSingleton.instance.generate}@example.com",
:unique_id => "#{CanvasUUID.generate}@example.com",
:password => "password",
:password_confirmation => "password",
:persistence_token => "pt_#{UUIDSingleton.instance.generate}",
:persistence_token => "pt_#{CanvasUUID.generate}",
:perishable_token => "value for perishable_token",
:login_count => 1,
:failed_login_count => 0,

View File

@ -40,7 +40,7 @@ describe Api::V1::CourseEvent do
before do
pending("needs auditors cassandra keyspace configured") unless Auditors::Course::Stream.available?
@request_id = UUIDSingleton.instance.generate
@request_id = CanvasUUID.generate
RequestContextGenerator.stubs( :request_id => @request_id )
@domain_root_account = Account.default

View File

@ -48,7 +48,7 @@ describe Api::V1::GradeChangeEvent do
before do
pending("needs auditors cassandra keyspace configured") unless Auditors::GradeChange::Stream.available?
@request_id = UUIDSingleton.instance.generate
@request_id = CanvasUUID.generate
RequestContextGenerator.stubs( :request_id => @request_id )
@domain_root_account = Account.default

View File

@ -22,7 +22,7 @@ describe Api::V1::PageView do
include Api::V1::PageView
before do
@request_id = UUIDSingleton.instance.generate
@request_id = CanvasUUID.generate
RequestContextGenerator.stubs( :request_id => @request_id )
@domain_root_account = Account.default

View File

@ -324,7 +324,7 @@ describe Attachment do
context "submit_to_scribd!" do
before do
ScribdAPI.stubs(:upload).returns(UUIDSingleton.instance.generate)
ScribdAPI.stubs(:upload).returns(CanvasUUID.generate)
end
describe "submit_to_scribd job" do

View File

@ -107,7 +107,7 @@ describe Auditors::Authentication do
before do
@event2 = @pseudonym.shard.activate do
record = Auditors::Authentication::Record.new(
'id' => UUIDSingleton.instance.generate,
'id' => CanvasUUID.generate,
'created_at' => 1.day.ago,
'pseudonym' => @pseudonym,
'event_type' => 'login')

View File

@ -102,7 +102,7 @@ describe CommunicationChannel do
end
it "should set a confirmation code unless one has been set" do
CanvasUuid::Uuid.expects(:generate).at_least(1).returns('abc123')
CanvasSlug.expects(:generate).at_least(1).returns('abc123')
communication_channel_model
@cc.confirmation_code.should eql('abc123')
end

View File

@ -1452,7 +1452,7 @@ end
@request_id = opts[:request_id] || RequestContextGenerator.request_id
unless @request_id
@request_id = UUIDSingleton.instance.generate
@request_id = CanvasUUID.generate
RequestContextGenerator.stubs(:request_id => @request_id)
end

View File

@ -482,7 +482,7 @@ class Job
end
def create
self.id ||= UUIDSingleton.instance.generate
self.id ||= CanvasUUID.generate
self.created_at = self.updated_at = Time.now.utc
save_job_to_redis
update_queues