Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Content extension implementation #30

Merged
merged 2 commits into from
Jan 10, 2015
Merged

Content extension implementation #30

merged 2 commits into from
Jan 10, 2015

Conversation

Tape
Copy link
Collaborator

@Tape Tape commented Jan 6, 2015

I'm just opening this PR for right now, but here's the base code for the content extension. I will be writing tests for it but I just wanted to go ahead and put this up here for now as I am currently stuck and can't for the life of me figure out a bug.

@@ -126,6 +127,9 @@ class Provider
@context_label = @body.context_label
@context_title = @body.context_title

# Load up the extensions!
extension.init(@) for extension_name, extension of extensions
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So oddly enough after this line an extension persists across all UNIQUE Provider objects that I create for testing. Here's a small test class I had set up, ContentExtension.coffee. For some reason the 2nd test case fails because it is referencing data from the first unrelated provider object? Maybe you have more insight @omsmith?

lti = require '../'


describe 'LTI.Extensions.Content', () ->
  describe 'Initialization', () ->
    it 'should initialize an object if ext_content_return_types is set', () ->
      provider = new lti.Provider 'key', 'secret'

      req =
        body:
          ext_content_return_types: 'file,iframe'

      provider.parse_request req
      provider.ext_content.should.exist

    it 'should be false if ext_content_return_types is missing', () ->
      provider = new lti.Provider 'key', 'secret'

      req = { body: {} }

      provider.parse_request req
      provider.ext_content.should.equal false

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Existing issue, it seems. Gross.

From c9dc4a939c3de7b703c6088ae902615cee98cb94 Mon Sep 17 00:00:00 2001
From: Owen Smith <owen@omsmith.ca>
Date: Tue, 6 Jan 2015 08:36:11 -0500
Subject: [PATCH 1/1] foo

---
 src/provider.coffee | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/provider.coffee b/src/provider.coffee
index 545a941..9d470fc 100644
--- a/src/provider.coffee
+++ b/src/provider.coffee
@@ -8,9 +8,6 @@ extensions        = require './extensions'

 class Provider

-  # Used as accessor to request parameters
-  body: {}
-
   constructor: (consumer_key, consumer_secret, nonceStore, signature_method=(new HMAC_SHA1()) ) ->

     if typeof consumer_key is 'undefined' or consumer_key is null
@@ -30,6 +27,8 @@ class Provider
     @signer           = signature_method
     @nonceStore       = nonceStore

+    @body = {}
+

   # Verify parameter and OAuth signature by passing the request object
   # Returns true/false if is valid
-- 
2.1.0

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are a lifesaver, I couldn't figure out what was going on for the life of me, thanks. I didn't even think to look in the object prototype. I'll finish up stuff when I get the time.

Tape pushed a commit that referenced this pull request Jan 10, 2015
@Tape Tape merged commit 6474c52 into master Jan 10, 2015
@Tape Tape deleted the extensions/content branch January 10, 2015 04:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants