Sha256: d4ea1da7ee9f3dabc525da9efa831c9ba5f2584368ae709f1d95783e1efa7bed

Contents?: true

Size: 1.89 KB

Versions: 3

Compression:

Stored size: 1.89 KB

Contents

require 'spec_helper'

describe CoalescingPanda::LtiController, type: :controller do
  routes { CoalescingPanda::Engine.routes }

  describe '#lti_config' do
    before :each do
      CoalescingPanda.class_variable_set(:@@lti_navigation, {})
      CoalescingPanda.lti_environments = { test_domain: 'test' }
    end

    it 'generates lti xml config'do
      controller.main_app.stub(:test_action_url) {'foo'}
      get(:lti_config)
      xml = Nokogiri::XML(response.body)
      xml.at_xpath('//blti:title').text.should == 'LTI Tool'
      xml.at_xpath('//lticm:property[@name="domain"]').text.should_not == nil
      xml.at_xpath('//lticm:property[@name="privacy_level"]').text.should == 'public'
    end

    it 'generates lti nav config' do
      controller.main_app.stub(:test_action_url) {'foo'}
      CoalescingPanda.stage_navigation(:account, {
        url: 'test_action',
        text: 'My Title',
        enabled: false
      })
      CoalescingPanda.register_navigation(:account)
      CoalescingPanda.propagate_lti_navigation
      get(:lti_config)
      xml = Nokogiri::XML(response.body)
      account_nav = xml.at_xpath('//lticm:options[@name="account_navigation"]')
      account_nav.at_xpath('lticm:property[@name="enabled"]').text.should == 'false'
      account_nav.at_xpath('lticm:property[@name="text"]').text.should == 'My Title'
      account_nav.at_xpath('lticm:property[@name="url"]').text.should == 'foo'
    end

    it 'includes environment information' do
      get(:lti_config)
      xml = Nokogiri::XML(response.body)
      environments = xml.at_xpath('//lticm:options[@name="environments"]')
      environments.at_xpath('lticm:property[@name="test_domain"]').text.should == 'test'
    end

  end

  it 'get the url, from the action string' do
    controller.main_app.stub(:test_action_url) {'foo'}
    options = controller.send(:ext_params, {url:'test_action'})
    options[:url].should == 'foo'
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
coalescing_panda-1.4.1 spec/controllers/coalescing_panda/lti_controller_spec.rb
coalescing_panda-1.4.0 spec/controllers/coalescing_panda/lti_controller_spec.rb
coalescing_panda-1.3.0 spec/controllers/coalescing_panda/lti_controller_spec.rb