Skip to content

Commit

Permalink
Fix tenant to default to the lti_key (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
bfcoder committed Feb 14, 2017
1 parent 6aeccb8 commit 4652e02
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/application_instance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def set_lti
self.lti_type ||= ApplicationInstance.lti_types[:basic]
self.lti_key = (lti_key || application.name).try(:parameterize).try(:dasherize)
self.lti_secret = ::SecureRandom::hex(64) unless lti_secret.present?
self.tenant = ::SecureRandom::hex(4) unless tenant.present?
self.tenant ||= lti_key
end

def create_schema
Expand Down
15 changes: 15 additions & 0 deletions spec/models/application_instance_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,21 @@
expect(@application_instance.lti_secret).to be_present
end

it "sets a default tenant to the lti_key" do
@application_instance = described_class.create!(site: @site, application: @application)
expect(@application_instance.tenant).to eq(@application_instance.lti_key)
end

it "doesn't change the tenant" do
@application_instance = described_class.create!(
site: @site,
application: @application,
tenant: "bfcoder",
)
expect(@application_instance.tenant).to_not eq(@application_instance.lti_key)
expect(@application_instance.tenant).to eq("bfcoder")
end

it "sets a valid lti_key using the name" do
name = "A Test"
application = FactoryGirl.create(:application, name: name)
Expand Down

0 comments on commit 4652e02

Please sign in to comment.