parent
9b4fbde1be
commit
a6a23e4b9c
@ -1,49 +0,0 @@
|
||||
/**
|
||||
* Public header, dance starts!
|
||||
*
|
||||
*/
|
||||
cdb.open.Header = cdb.core.View.extend({
|
||||
|
||||
initialize: function() {
|
||||
this.vis = this.options.vis;
|
||||
this.template = cdb.templates.getTemplate('public/views/public_header');
|
||||
this._initBinds();
|
||||
},
|
||||
|
||||
render: function() {
|
||||
this.clearSubViews();
|
||||
this.$el.html(
|
||||
this.template(
|
||||
_.defaults({
|
||||
vis_url: this.vis && this.vis.viewUrl(this.model) || '',
|
||||
isMobileDevice: this.options.isMobileDevice,
|
||||
owner_username: this.options.owner_username,
|
||||
current_view: this.options.current_view
|
||||
}, this.model.attributes)
|
||||
)
|
||||
);
|
||||
this._initViews();
|
||||
return this;
|
||||
},
|
||||
|
||||
_initBinds: function() {
|
||||
this.model.bind('change', this.render, this);
|
||||
},
|
||||
|
||||
_initViews: function() {
|
||||
if (this.$('.account').length > 0) {
|
||||
var dropdown = new cdb.open.AccountDropdown({
|
||||
target: this.$('a.account'),
|
||||
model: this.model,
|
||||
vertical_offset: 20,
|
||||
width: 166
|
||||
});
|
||||
|
||||
this.addView(dropdown);
|
||||
cdb.god.bind("closeDialogs", dropdown.hide, dropdown);
|
||||
this.add_related_model(cdb.god);
|
||||
$('body').append(dropdown.render().el);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
@ -1,75 +0,0 @@
|
||||
describe("Public pages header tests", function() {
|
||||
|
||||
var view, $el, model;
|
||||
|
||||
beforeEach(function() {
|
||||
|
||||
$el = $('<header>').addClass("cartodb-public-header");
|
||||
|
||||
model = new cdb.open.AuthenticatedUser({});
|
||||
table = new cdb.admin.CartoDBTableMetadata({ name: 'test_table', geometry_types: ['st_polygon'] });
|
||||
|
||||
view = new cdb.open.Header({
|
||||
el: $el,
|
||||
model: model,
|
||||
vis: table,
|
||||
current_view: "dashboard",
|
||||
owner_username: "test",
|
||||
isMobileDevice: false
|
||||
});
|
||||
|
||||
cdb.config.set({
|
||||
//Testing that it's SaaS (Related info: app/helpers/application_helper.rb)
|
||||
cartodb_com_hosted: false
|
||||
});
|
||||
})
|
||||
|
||||
afterEach(function() {
|
||||
view.clean();
|
||||
});
|
||||
|
||||
it("should render properly when authenticated users are 'empty'", function() {
|
||||
view.render();
|
||||
expect(view.$('ul.options li a').size()).toBe(3);
|
||||
expect(view.$('ul.options li a.account').size()).toBe(0);
|
||||
expect(view.$('ul.options li a.login').size()).toBe(1);
|
||||
});
|
||||
|
||||
it("should render properly when authenticated users are 'empty' and it is a mobile device", function() {
|
||||
view.options.isMobileDevice = true;
|
||||
view.render();
|
||||
expect(view.$('ul.options li a').size()).toBe(2);
|
||||
expect(view.$('ul.options li a.account').size()).toBe(0);
|
||||
expect(view.$('ul.options li a.login').size()).toBe(1);
|
||||
expect(view.$('ul.options li a.signup').size()).toBe(1);
|
||||
});
|
||||
|
||||
it("should render properly when authenticated user is filled and it is in dashboard view", function() {
|
||||
model.set({ urls: ['http://test.carto.com/dashboard'], username: "test" });
|
||||
|
||||
expect(view.$('ul.options li a').size()).toBe(1);
|
||||
expect(view.$('ul.options li a.account').size()).toBe(1);
|
||||
expect(view.$('ul.options li a.login').size()).toBe(0);
|
||||
expect(view.$('ul.options li a.signup').size()).toBe(0);
|
||||
});
|
||||
|
||||
it("should render properly when authenticated user is filled and it is in table or visualization view, edit button should appear", function() {
|
||||
view.options.current_view = 'table';
|
||||
model.set({ urls: ['http://test.carto.com/dashboard'], username: "test" });
|
||||
|
||||
expect(view.$('ul.options li a').size()).toBe(1);
|
||||
expect(view.$('ul.options li a.account').size()).toBe(1);
|
||||
expect(view.$('ul.options li a.login').size()).toBe(0);
|
||||
expect(view.$('ul.options li a.signup').size()).toBe(0);
|
||||
|
||||
view.options.current_view = 'visualization';
|
||||
view.vis = new cdb.open.PublicVisualization({ id: 'aaaa-bbbb-cccc-dddd', name: "fake_2" });
|
||||
view.render();
|
||||
|
||||
expect(view.$('ul.options li a').size()).toBe(1);
|
||||
expect(view.$('ul.options li a.account').size()).toBe(1);
|
||||
expect(view.$('ul.options li a.login').size()).toBe(0);
|
||||
expect(view.$('ul.options li a.signup').size()).toBe(0);
|
||||
});
|
||||
|
||||
});
|
Loading…
Reference in new issue