Commit d11c92d7 by cahrens

Set the URL on the collection instead of the model.

parent 9ceee362
describe "CMS.Models.Asset", ->
beforeEach ->
CMS.URL.UPDATE_ASSET = "/update_asset/"
@model = new CMS.Models.Asset({id: "/c4x/id"})
afterEach ->
delete CMS.URL.UPDATE_ASSET
it "should have a url set", ->
expect(@model.url()).toEqual("/update_asset//c4x/id")
......@@ -9,6 +9,7 @@ describe "CMS.Views.Asset", ->
@model = new CMS.Models.Asset({display_name: "test asset", url: 'actual_asset_url', portable_url: 'portable_url', date_added: 'date', thumbnail: null, id: 'id'})
spyOn(@model, "destroy").andCallThrough()
@collection = new CMS.Models.AssetCollection([@model])
@collection.url = "update-asset-url"
@view = new CMS.Views.Asset({model: @model})
@promptSpies = spyOnConstructor(CMS.Views.Prompt, "Warning", ["show", "hide"])
......@@ -82,6 +83,7 @@ describe "CMS.Views.Assets", ->
{display_name: "test asset 1", url: 'actual_asset_url_1', portable_url: 'portable_url_1', date_added: 'date_1', thumbnail: null, id: 'id_1'},
{display_name: "test asset 2", url: 'actual_asset_url_2', portable_url: 'portable_url_2', date_added: 'date_2', thumbnail: null, id: 'id_2'}
])
@collection.url = "update-asset-url"
@view = new CMS.Views.Assets({collection: @collection, el: $('#asset_table_body')})
@promptSpies = spyOnConstructor(CMS.Views.Prompt, "Warning", ["show", "hide"])
......
......@@ -9,9 +9,5 @@ CMS.Models.Asset = Backbone.Model.extend({
url: "",
portable_url: "",
is_locked: false
},
url: function() {
return CMS.URL.UPDATE_ASSET + this.id;
}
});
......@@ -18,8 +18,8 @@
<script src="${static.url('js/vendor/jQuery-File-Upload/js/jquery.fileupload.js')}"> </script>
<script type="text/javascript">
CMS.URL.UPDATE_ASSET = "${update_asset_callback_url}";
var assets = new CMS.Models.AssetCollection(${asset_list});
assets.url = "${update_asset_callback_url}";
var assetsView = new CMS.Views.Assets({collection: assets, el: $('#asset_table_body')});
$(document).ready(function() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment