Skip to content

Commit

Permalink
account-level tools couldn't be configured by url
Browse files Browse the repository at this point in the history
previously this would only work for course-level tools

fixes #6935

test plan:
- try adding a tool to an account by url configuration
- make sure it doesn't die

Change-Id: Id04a0619bd733d351098731cf2db67f8a26936dd
Reviewed-on: https://gerrit.instructure.com/8136
Tested-by: Hudson <[email protected]>
Reviewed-by: Bracken Mosbacker <[email protected]>
  • Loading branch information
whitmer committed Jan 18, 2012
1 parent f8ada30 commit e0a12c0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/context_external_tool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ def self.import_from_migration(hash, context, item=nil)
end

item.save!
context.imported_migration_items << item if context.imported_migration_items && item.new_record?
context.imported_migration_items << item if context.respond_to?(:imported_migration_items) && context.imported_migration_items && item.new_record?
item
end

Expand Down
16 changes: 16 additions & 0 deletions spec/models/context_external_tool_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -364,4 +364,20 @@ def new_external_tool(context)
(ContextExternalTool.find_for(tool.id, @course, :user_navigation) rescue nil).should be_nil
end
end

describe "import_from_migration" do
it "should work for course-level tools" do
course_model
tool = ContextExternalTool.import_from_migration({:title => 'tool', :url => 'http://example.com'}, @course)
tool.should_not be_nil
tool.context.should == @course
end

it "should work for account-level tools" do
course_model
tool = ContextExternalTool.import_from_migration({:title => 'tool', :url => 'http://example.com'}, @course.account)
tool.should_not be_nil
tool.context.should == @course.account
end
end
end

0 comments on commit e0a12c0

Please sign in to comment.