Merge pull request #4738 from svbergerem/remove-unused-spv-files

Remove unused beta code
This commit is contained in:
Jonne Haß 2014-01-24 04:19:22 -08:00
commit f9c230dd31
26 changed files with 1 additions and 1043 deletions

View file

@ -2,6 +2,7 @@
## Refactor
* Drop number of followers from tags page [#4717](https://github.com/diaspora/diaspora/issues/4717)
* Remove some unused beta code [#4738](https://github.com/diaspora/diaspora/issues/4738)
## Bug fixes
* Improve time agos by updating the plugin [#4280](https://github.com/diaspora/diaspora/issues/4280)

View file

@ -11,7 +11,6 @@
//= require_tree ./pages
//= require_tree ./collections
//= require_tree ./views
//= require_tree ./forms
var app = {
collections: {},

View file

@ -1,59 +0,0 @@
app.forms.PictureBase = app.views.Base.extend({
events : {
'ajax:complete .new_photo' : "photoUploaded",
"change input[name='photo[user_file]']" : "submitForm"
},
onSubmit : $.noop,
uploadSuccess : $.noop,
postRenderTemplate : function(){
this.$("input[name=authenticity_token]").val($("meta[name=csrf-token]").attr("content"))
},
submitForm : function (){
this.$("form").submit();
this.onSubmit();
},
photoUploaded : function(evt, xhr) {
resp = JSON.parse(xhr.responseText)
if(resp.success) {
this.uploadSuccess(resp)
} else {
alert("Upload failed! Please try again. " + resp.error);
}
}
});
/* multi photo uploader */
app.forms.Picture = app.forms.PictureBase.extend({
templateName : "picture-form",
initialize : function() {
this.photos = this.model.photos || new Backbone.Collection()
this.photos.bind("add", this.render, this)
},
postRenderTemplate : function(){
this.$("input[name=authenticity_token]").val($("meta[name=csrf-token]").attr("content"))
this.$("input[name=photo_ids]").val(this.photos.pluck("id"))
this.renderPhotos();
},
onSubmit : function (){
this.$(".photos").append($('<span class="loader" style="margin-left: 80px;"></span>'))
},
uploadSuccess : function(resp) {
this.photos.add(new Backbone.Model(resp.data))
},
renderPhotos : function(){
var photoContainer = this.$(".photos")
this.photos.each(function(photo){
var photoView = new app.views.Photo({model : photo}).render().el
photoContainer.append(photoView)
})
}
});

View file

@ -1,18 +0,0 @@
app.forms.Post = app.views.Base.extend({
templateName : "post-form",
className : "post-form",
subviews : {
".new_picture" : "pictureForm"
},
initialize : function() {
this.pictureForm = new app.forms.Picture({model: this.model});
},
postRenderTemplate : function() {
Mentions.initialize(this.$("textarea.text"));
Mentions.fetchContacts(); //mentions should use app.currentUser
this.$('textarea').autoResize({minHeight: '200', maxHeight:'300', animate: false});
}
});

View file

@ -1,68 +0,0 @@
app.pages.Stream = app.views.Base.extend({
templateName : "stream",
events : {
'activate .stream-frame-wrapper' : 'triggerInteractionLoad'
},
subviews : {
"#stream-content" : "streamView",
"#stream-interactions" : "interactionsView"
},
initialize : function(){
this.stream = this.model = new app.models.Stream()
this.stream.preloadOrFetch()
this.streamView = new app.pages.Stream.InfiniteScrollView({ model : this.stream })
this.interactionsView = new app.views.StreamInteractions()
this.streamView.on('loadMore', this.updateUrlState, this);
this.stream.on("fetched", this.refreshScrollSpy, this)
this.stream.on("frame:interacted", this.selectFrame, this)
},
selectFrame : function(post){
if(this.selectedPost == post) { return }
this.selectedPost = post
this.$(".stream-frame-wrapper").removeClass("selected-frame")
this.$(".stream-frame-wrapper[data-id=" + this.selectedPost.id +"]").addClass("selected-frame")
this.interactionsView.setInteractions(this.selectedPost)
},
updateUrlState : function(){
var post = this.stream.items.last();
if(post){
this.navigateToPost(post)
}
},
navigateToPost : function(post){
app.router.navigate(location.pathname + "?max_time=" + post.createdAt(), {replace: true})
},
triggerInteractionLoad : function(evt){
this._throttledInteractions = this._throttledInteractions || _.bind(_.throttle(function(id){
this.selectFrame(this.stream.items.get(id))
}, 500), this)
this._throttledInteractions($(evt.target).data("id"))
},
refreshScrollSpy : function(){
_.defer($('body').scrollspy('refresh'))
}
},
//static methods
{
InfiniteScrollView : app.views.InfScroll.extend({
initialize: function(){
this.stream = this.model
this.collection = this.stream.items
this.postClass = app.views.Post.StreamFrame
this.setupInfiniteScroll()
}
})
});

View file

@ -1,67 +0,0 @@
/**
* the aspects dropdown specifies the scope of a posted status message.
*
* this view is part of the publisher where users are presented the options
* 'public', 'all aspects' and a list of their personal aspects, for limiting
* 'the audience of created contents.
*/
app.views.AspectsDropdown = app.views.Base.extend({
templateName : "aspects-dropdown",
events : {
"change .dropdown-menu input" : "setVisibility"
},
presenter : function(){
var selectedAspects = this.model.get("aspect_ids")
, parsedIds = _.map(selectedAspects, parseInt)
return {
aspects : _.map(app.currentUser.get('aspects'), function(aspect){
return _.extend({}, aspect, {checked :_.include(parsedIds, aspect.id) })
}),
public :_.include(selectedAspects, "public"),
'all-aspects' :_.include(selectedAspects, "all_aspects")
}
},
postRenderTemplate : function(){
if(this.model.get("aspect_ids")) {
this.setDropdownText()
} else {
this.setVisibility({target : this.$("input[value='public']").first()})
}
},
setVisibility : function(evt){
var input = $(evt.target).closest("input")
if(_.include(['public', 'all_aspects'], input.val())) {
this.$("input").attr("checked", false)
input.attr("checked", "checked")
} else {
this.$("input.public, input.all_aspects").attr("checked", false)
}
this.setDropdownText()
},
setDropdownText : function(){
var selected = this.$("input").serializeArray()
, text;
switch (selected.length) {
case 0:
text = "Private"
break
case 1:
text = selected[0].name
break
default:
text = ["In", selected.length, "aspects"].join(" ")
break
}
$.trim(this.$(".dropdown-toggle .text").text(text))
}
});

View file

@ -1,66 +0,0 @@
//= require ./small_frame
app.views.Post.CanvasFrame = app.views.Post.SmallFrame.extend({
SINGLE_COLUMN_WIDTH : 265,
DOUBLE_COLUMN_WIDTH : 560,
events : {
"click .info" : "goToPost", // the only event copied from SmallFrame
"click .content" : "favoritePost",
"click .delete" : "killPost"
},
adjustedImageHeight : function() {
if(!(this.model.get("photos") || [])[0]) { return }
var modifiers = [this.dimensionsClass(), this.colorClass()].join(' ')
, width;
/* mobile width
*
* currently does not re-calculate on orientation change */
if($(window).width() <= 767) {
width = $(window).width();
}
var firstPhoto = this.model.get("photos")[0]
, width = width || (modifiers.search("x2") != -1 ? this.DOUBLE_COLUMN_WIDTH : this.SINGLE_COLUMN_WIDTH)
, ratio = width / firstPhoto.dimensions.width;
return(ratio * firstPhoto.dimensions.height)
},
presenter : function(){
return _.extend(this.smallFramePresenter(), {
adjustedImageHeight : this.adjustedImageHeight()
})
},
favoritePost : function(evt) {
if(evt) {
/* follow links instead of faving the targeted post */
if($(evt.target).is('a')) { return }
evt.stopImmediatePropagation(); evt.preventDefault();
}
var prevDimension = this.dimensionsClass();
this.model.toggleFavorite({save : this.model.get("author").diaspora_id == app.currentUser.get("diaspora_id")})
this.$el.removeClass(prevDimension)
this.render()
app.page.stream.trigger("reLayout")
//trigger moar relayouts in the case of images WHOA GROSS HAX
_.delay(function(){app.page.stream.trigger("reLayout")}, 200)
// track the action
app.instrument("track", "Resize Frame")
},
killPost : function(){
this.destroyModel()
_.delay(function(){app.page.stream.trigger("reLayout")}, 0)
}
});

View file

@ -1,83 +0,0 @@
//= require "../post_view"
app.views.Post.SmallFrame = app.views.Post.extend({
className : "canvas-frame",
templateName : "small-frame/default", // default to fall back to
events : {
"click .info" : "goToPost"
},
subviews : {
'.embed-frame' : "oEmbedView",
'.open-graph-frame' : 'openGraphView'
},
initialize : function(options) {
this.stream = options.stream;
this.addStylingClasses()
},
oEmbedView : function(){
return new app.views.OEmbed({model : this.model})
},
openGraphView : function(){
return new app.views.OpenGraph({model : this.model})
},
smallFramePresenter : function(){
//todo : we need to have something better for small frame text, probably using the headline() scenario.
return _.extend(this.defaultPresenter(),
{
text : this.model && app.helpers.textFormatter(this.model.get("text"), this.model),
likesCount : this.model.interactions.likesCount(),
resharesCount : this.model.interactions.resharesCount(),
commentsCount : this.model.interactions.commentsCount()
})
},
postRenderTemplate : function() {
this.addStylingClasses()
},
addStylingClasses : function() {
this.$el.addClass([this.dimensionsClass(), this.colorClass(), this.frameClass()].join(' '))
},
frameClass : function(){
var name = this.model.get("frame_name") || ""
return name.toLowerCase()
},
colorClass : function() {
var text = this.model.get("text")
, baseClass = $.trim(text).length == 0 ? "no-text" : "has-text";
if(this.model.get("photos").length > 0 || this.model.get("o_embed_cache") || this.model.get("open_graph_cache"))
baseClass += " has-media";
if(baseClass == "no-text" || this.model.get("photos").length > 0 || this.model.get("o_embed_cache") || this.model.get("open_graph_cache")) { return baseClass }
var randomColor = _.first(_.shuffle(['cyan', 'green', 'yellow', 'purple', 'lime-green', 'orange', 'red', 'turquoise', 'sand']));
var textClass = randomColor;
if(text.length < 40) {
textClass += " big-text"
}
return [baseClass, textClass].join(" ")
},
dimensionsClass : function() {
return (this.model.get("favorite")) ? "x2 width height" : ""
},
goToPost : function(evt) {
if(evt) { evt.preventDefault() && evt.stopImmediatePropagation(); }
app.setPreload('post',this.model.attributes)
app.router.navigate(this.model.url(), true)
}
});

View file

@ -1,29 +0,0 @@
app.views.Post.StreamFrame = app.views.Base.extend({
className : "stream-frame",
templateName : "stream-frame",
subviews : {
".small-frame" : "smallFrameView",
".stream-frame-feedback" : "feedbackView"
},
initialize : function(options) {
this.stream = options.stream
this.smallFrameView = new app.views.Post.SmallFrame({model : this.model})
this.feedbackView = new app.views.FeedbackActions({ model: this.model })
},
events : {
'click .content' : 'triggerInteracted',
"click a.permalink" : "goToPost"
},
triggerInteracted : function() {
this.stream.trigger("frame:interacted", this.model)
},
goToPost : function(evt) {
this.smallFrameView.goToPost(evt)
}
});

View file

@ -1,20 +0,0 @@
app.views.StreamInteractions = app.views.Base.extend({
id : "post-info",
subviews:{
".comments" : "comments",
".new-comment" : "newCommentView"
},
templateName : "stream-interactions",
setInteractions : function (model) {
model.interactions.fetch().done(
_.bind(function () {
this.render()
}, this));
this.comments = new app.views.PostViewerReactions({ model: model.interactions })
this.newCommentView = new app.views.PostViewerNewComment({ model : model })
}
});

View file

@ -1,42 +0,0 @@
app.views.PostViewerNewComment = app.views.Base.extend({
templateName: "single-post-viewer/new-comment",
events : {
"click button" : "createComment",
"focus textarea" : "scrollToBottom"
},
scrollableArea : "#post-reactions",
initialize : function(){
this.model.interactions.comments.bind("sync", this.clearAndReactivateForm, this)
},
postRenderTemplate : function() {
this.$("textarea").placeholder();
this.$("textarea").autoResize({'extraSpace' : 0});
},
createComment: function(evt) {
if(evt){ evt.preventDefault(); }
this.toggleFormState()
this.model.comment(this.$("textarea").val());
},
clearAndReactivateForm : function() {
this.toggleFormState()
this.$("textarea").val("")
.css('height', '18px')
.focus()
},
toggleFormState : function() {
this.$("form").children().toggleClass('disabled')
},
scrollToBottom : function() {
$(this.scrollableArea).scrollTop($(this.scrollableArea).prop("scrollHeight"))
}
});

View file

@ -1,45 +0,0 @@
app.views.PostViewerReactions = app.views.Base.extend({
className : "",
templateName: "single-post-viewer/reactions",
tooltipSelector : ".avatar",
initialize : function() {
this.model.on('change', this.render, this);
this.model.comments.bind("add", this.appendComment, this)
},
presenter : function(){
return {
likes : this.model.likes.toJSON(),
comments : this.model.comments.toJSON(),
reshares : this.model.reshares.toJSON()
}
},
postRenderTemplate : function() {
this.populateComments()
},
/* copy pasta from commentStream */
populateComments : function() {
this.model.comments.each(this.appendComment, this)
},
/* copy pasta from commentStream */
appendComment: function(comment) {
// Set the post as the comment's parent, so we can check on post ownership in the Comment view.
// model was post on old view, is interactions on new view
var parent = this.model.get("post_type") ? this.model.toJSON : this.model.post.toJSON()
comment.set({parent : parent})
this.$("#post-comments").append(new app.views.Comment({
model: comment,
className : "post-comment media",
templateName : "post-viewer/comment"
}).render().el);
}
});

View file

@ -1,33 +0,0 @@
<a href="#" rel="auth-required" class="label like" title="{{#if userLike}} {{t "viewer.unlike"}} {{else}} {{t "viewer.like"}} {{/if}}">
{{#if userLike}}
<i class="icon-heart icon-red"></i>
{{else}}
<i class="icon-heart icon-white"></i>
{{/if}}
{{likesCount}}
</a>
{{#if userCanReshare}}
<a href="#" rel="auth-required" class="label reshare" title="{{#if userReshare}} {{t "viewer.reshared"}} {{else}} {{t "viewer.reshare"}} {{/if}}">
{{#if userReshare}}
<i class="icon-retweet icon-blue"></i>
{{else}}
<i class="icon-retweet icon-white"></i>
{{/if}}
{{resharesCount}}
</a>
{{else}}
<a class="label reshare-viewonly" title="{{#if userReshare}} {{t "viewer.reshared"}} {{else}} {{t "viewer.reshare"}} {{/if}}">
{{#if userReshare}}
<i class="icon-retweet icon-blue"></i>
{{else}}
<i class="icon-retweet icon-white"></i>
{{/if}}
{{resharesCount}}
</a>
{{/if}}
<a href="#" class="label comment" rel="invoke-interaction-pane" title="{{t "viewer.comment"}}">
<i class="icon-comment icon-white"></i>
{{commentsCount}}
</a>

View file

@ -1,23 +0,0 @@
<div class="container">
<section class="photo_viewer"></section>
<!--Temp hacks-->
{{#if o_embed_cache}}
{{#if o_embed_cache.data}}
{{{o_embed_cache.data.html}}}
{{/if}}
{{else}}
{{#if open_graph_cache}}
<div class="opengraph">
<a href="{{open_graph_cache.url}}" target="_blank">
<h2>{{{open_graph_cache.title}}}</h2>
<img src="{{open_graph_cache.image}}"/>
<p>{{open_graph_cache.description}}</p>
</a>
</div>
{{/if}}
{{/if}}
<header>{{{headline}}}</header>
<section class="body">{{{body}}}</section>
</div>

View file

@ -1,13 +0,0 @@
<form accept-charset="UTF-8" action="/photos" class="new_photo" data-remote="true" enctype="multipart/form-data" method="post">
<input name="authenticity_token" type="hidden"/>
<div style="margin:0;padding:0;display:inline">
<input name="utf8" type="hidden" value="✓"/>
</div>
<div class="photos well">
<div id='photo_upload_button'>
<a class='btn'><i class="icon-camera" style="margin-right:4px;"></i>Add Photos</a>
<input name="photo[user_file]" type="file"/>
</div>
</div>
</form>

View file

@ -1,8 +0,0 @@
<div class="new_picture"/>
<form class="new-post">
<fieldset>
<textarea name="text" id='post_text' class="text span8" placeholder="Add Text">{{text}}</textarea>
<textarea id="text_with_markup" style="display:none;"/>
</fieldset>
</form>

View file

@ -1,8 +0,0 @@
<div id="new-post-comment-container">
<form class="form-inline">
<textarea class="new-comment-text" id="new-comment-text" placeholder="{{t "stream.comment"}}"></textarea>
<button type="submit" class="btn btn-small">
{{t "stream.comment"}}
</button>
</form>
</div>

View file

@ -1,36 +0,0 @@
{{# if likes}}
<div id="post-likes">
<div class="well media">
<div class="img">
<i class="icon-heart icon-red"></i>
</div>
<div class="bd">
{{#each likes}}
{{#linkToPerson author}}
{{{personImage this "small" "micro"}}}
{{/linkToPerson}}
{{/each}}
</div>
</div>
</div>
{{/if}}
{{# if reshares}}
<div id="post-reshares">
<div class="well media">
<div class="img">
<i class="icon-retweet icon-blue"></i>
</div>
<div class="bd">
{{#each reshares}}
{{#linkToPerson author}}
{{{personImage this "small" "micro"}}}
{{/linkToPerson}}
{{/each}}
</div>
</div>
</div>
{{/if}}
<div id="post-comments"> </div>

View file

@ -1,52 +0,0 @@
<div class="content">
{{#if photos}}
<div class="image-container">
{{#each photos}}
<img src="{{sizes.large}}" {{#if ../../adjustedImageHeight}}style="height:{{../../adjustedImageHeight}}px;"{{/if}} />
{{/each}}
</div>
{{/if}}
{{#if object_url}}
<div class="image-container">
<a href="{{object_url}}" class="stream-photo-link">
<img src="{{image_url}}" data-small-photo="{{image_url}}" data-full-photo="{{image_url}}" class="stream-photo" />
</a>
</div>
{{/if}}
<div class="embed-frame" />
<div class="open-graph-frame" />
{{#if text}}
<div class="text-content">
{{{text}}}
</div>
<div class="background-color"></div>
{{else}}
<div class="text-content">
<p></p>
</div>
{{/if}}
<!--Handlebars partial territory-->
<div class=controls>
<a href="#" class="delete"></a>
</div>
<div class="info permalink">
{{#if root}}
{{#linkToPerson root.author}}
{{{personImage this}}
{{/linkToPerson}}
{{/if}}
<i class="icon-time timestamp" title="{{created_at}}" rel="tooltip"></i>
<i class="icon-chevron-right permalink" title="View Post" rel="tooltip"></i>
<i class="icon-heart"></i> {{likesCount}}
<i class="icon-retweet"></i> {{resharesCount}}
<i class="icon-comment"></i> {{commentsCount}}
</div>
</div>

View file

@ -1,3 +0,0 @@
<div class="feedback"/>
<div class="comments"/>
<div class="new-comment"/>

View file

@ -1,57 +0,0 @@
describe("app.forms.Picture", function(){
beforeEach(function(){
$("<meta/>", {
"name" : "csrf-token",
"content" : "supersecrettokenlol"
}).prependTo("head")
this.form = new app.forms.Picture({model: factory.statusMessage()}).render()
});
it("sets the authenticity token from the meta tag", function(){
expect(this.form.$("input[name='authenticity_token']").val()).toBe("supersecrettokenlol")
});
describe("selecting a photo", function(){
it("submits the form", function(){
var submitSpy = jasmine.createSpy();
this.form.$("form").submit(function(event){
event.preventDefault();
submitSpy();
});
this.form.$("input[name='photo[user_file]']").change()
expect(submitSpy).toHaveBeenCalled();
})
});
describe("when a photo is suceessfully submitted", function(){
beforeEach(function(){
this.photoAttrs = { name : "Obama rides a bicycle" }
this.respond = function() {
this.form.$(".new_photo").trigger("ajax:complete", {
responseText : JSON.stringify({success : true, data : this.photoAttrs})
})
}
})
it("adds a new model to the photos", function(){
expect(this.form.$(".photos .photo").length).toBe(0);
this.respond()
expect(this.form.$(".photos .photo").length).toBeGreaterThan(0);
})
})
describe("when a photo is unsuccessfully submitted", function(){
beforeEach(function(){
this.response = {responseText : JSON.stringify({success : false, message : "I like to eat basketballs"}) }
})
it("adds a new model to the photos", function(){
spyOn(window, "alert")
this.form.$(".new_photo").trigger("ajax:complete", this.response)
expect(window.alert).toHaveBeenCalled();
})
})
});

View file

@ -1,33 +0,0 @@
describe("app.Pages.Stream", function(){
beforeEach(function(){
app.setPreload("stream", [factory.post().attributes])
this.page = new app.pages.Stream()
this.post = this.page.model.items.models[0]
expect(this.post).toBeTruthy()
})
describe("rendering", function(){
beforeEach(function(){
this.page.render()
})
context("clicking the content", function(){
it("triggers frame interacted", function(){
spyOn(this.post.interactions, "fetch").andReturn(new $.Deferred)
this.page.$('.canvas-frame:first .content').click()
expect(this.post.interactions.fetch).toHaveBeenCalled()
})
})
})
context("when more posts are loaded", function(){
it("navigates to the last post in the stream's max_time", function(){
spyOn(app.router, 'navigate')
var url = location.pathname + "?max_time=" + this.post.createdAt()
, options = {replace: true}
this.page.streamView.trigger('loadMore')
expect(app.router.navigate).toHaveBeenCalledWith(url, options)
})
})
});

View file

@ -1,126 +0,0 @@
describe("app.views.AspectsDropdown", function () {
function selectedAspects(view){
return _.pluck(view.$("input.aspect_ids").serializeArray(), "value")
}
beforeEach(function () {
loginAs({
aspects:[
{ id:3, name:"sauce" },
{ id:5, name:"conf" },
{ id:7, name:"lovers" }
]
})
this.view = new app.views.AspectsDropdown({model:factory.statusMessage({aspect_ids:undefined})})
})
describe("rendering", function () {
beforeEach(function () {
this.view.render()
})
it("sets aspect_ids to 'public' by default", function () {
expect(this.view.$("input.aspect_ids:checked").val()).toBe("public")
})
it("defaults to Public Visibility", function () {
expect(this.view.$("input.aspect_ids.public")).toBeChecked()
expect($.trim(this.view.$(".dropdown-toggle .text").text())).toBe("Public")
})
it("sets aspect_ids to 'public'", function () {
expect(selectedAspects(this.view)).toEqual(["public"])
})
it("sets the dropdown title to 'public'", function () {
expect(this.view.$(".dropdown-toggle .text").text()).toBe("Public")
})
describe("setVisibility", function () {
function checkInput(input){
input.attr("checked", "checked")
input.trigger("change")
}
function uncheckInput(input){
input.attr("checked", false)
input.trigger("change")
}
describe("selecting All Aspects", function () {
beforeEach(function () {
this.input = this.view.$("input#aspect_ids_all_aspects")
checkInput(this.input)
})
it("calls set aspect_ids to 'all'", function () {
expect(selectedAspects(this.view)).toEqual(["all_aspects"])
})
it("sets the dropdown title to 'public'", function () {
expect($.trim(this.view.$(".dropdown-toggle .text").text())).toBe("All Aspects")
})
})
describe("selecting An Aspect", function () {
beforeEach(function () {
this.input = this.view.$("input[name='lovers']")
checkInput(this.input)
})
it("sets the dropdown title to the aspect title", function () {
expect($.trim(this.view.$(".dropdown-toggle .text").text())).toBe("lovers")
})
it("sets aspect_ids to to the aspect id", function () {
expect(selectedAspects(this.view)).toEqual(["7"])
})
describe("selecting another aspect", function () {
beforeEach(function () {
this.input = this.view.$("input[name='sauce']")
checkInput(this.input)
})
it("sets aspect_ids to the selected aspects", function () {
expect(selectedAspects(this.view)).toEqual(["3", "7"])
})
it("sets the button text to the number of selected aspects", function () {
expect($.trim(this.view.$(".dropdown-toggle .text").text())).toBe("In 2 aspects")
checkInput(this.view.$("input[name='conf']"))
expect($.trim(this.view.$(".dropdown-toggle .text").text())).toBe("In 3 aspects")
uncheckInput(this.view.$("input[name='conf']"))
expect($.trim(this.view.$(".dropdown-toggle .text").text())).toBe("In 2 aspects")
})
describe("deselecting another aspect", function () {
it("removes the clicked aspect", function () {
expect(selectedAspects(this.view)).toEqual(["3", "7"])
expect($.trim(this.view.$(".dropdown-toggle .text").text())).toBe("In 2 aspects")
uncheckInput(this.view.$("input[name='lovers']"))
expect(selectedAspects(this.view)).toEqual(["3"])
expect($.trim(this.view.$(".dropdown-toggle .text").text())).toBe("sauce")
})
})
describe("selecting all_aspects", function () {
it("sets aspect_ids to all_aspects", function () {
expect(selectedAspects(this.view)).toEqual(["3", "7"])
checkInput(this.view.$("input[name='All Aspects']"))
expect(selectedAspects(this.view)).toEqual(["all_aspects"])
})
})
describe("selecting public", function () {
it("sets aspect_ids to public", function () {
expect(selectedAspects(this.view)).toEqual(["3", "7"])
checkInput(this.view.$("input[name='Public']"))
expect(selectedAspects(this.view)).toEqual(["public"])
})
})
})
})
})
})
})

View file

@ -1,31 +0,0 @@
describe("app.views.Post.CanvasFrame", function(){
beforeEach(function(){
this.model = factory.post({
photos : [
factory.photoAttrs({sizes : {
large : "http://tieguy.org/me.jpg"
},
dimensions : {
width : 100,
height : 200 }
}),
factory.photoAttrs({sizes : {large : "http://whatthefuckiselizabethstarkupto.com/none_knows.gif"}}) //SIC
]
})
this.view = new app.views.Post.CanvasFrame({model : this.model})
})
context("images", function() {
it("appends the correct dimensions to an image, given a model with an image", function(){
var firstPhoto = this.model.get("photos")[0]
this.view.SINGLE_COLUMN_WIDTH = 100
expect(this.view.adjustedImageHeight(firstPhoto)).toBe(200)
this.view.SINGLE_COLUMN_WIDTH = 200
expect(this.view.adjustedImageHeight(firstPhoto)).toBe(400)
this.view.SINGLE_COLUMN_WIDTH = 50
expect(this.view.adjustedImageHeight(firstPhoto)).toBe(100)
})
})
});

View file

@ -1,85 +0,0 @@
describe("app.views.Post.SmallFrame", function(){
var open_graph_cache = {
"url": "http://example.com/articles/123",
"title": "Example title",
"description": "Test description",
"image": "http://example.com/thumb.jpg",
"ob_type": "article"
};
var o_embed_cache = {
"data":{
"html":"this is a crazy oemebed lol"
}
};
beforeEach(function(){
this.model = factory.post({
photos : [
factory.photoAttrs({sizes : {
large : "http://tieguy.org/me.jpg"
},
dimensions : {
width : 100,
height : 200 }
}),
factory.photoAttrs({sizes : {large : "http://whatthefuckiselizabethstarkupto.com/none_knows.gif"}}) //SIC
],
o_embed_cache: o_embed_cache,
open_graph_cache: open_graph_cache
})
this.view = new app.views.Post.SmallFrame({model : this.model})
})
it("passes the model down to the oembed view", function(){
expect(this.view.oEmbedView().model).toBe(this.model)
})
it("passes the model down to the opengraph view", function(){
expect(this.view.openGraphView().model).toBe(this.model)
})
describe("rendering with oembed and opengraph", function(){
beforeEach(function(){
this.view.render()
});
it("has the oembed", function(){ //integration test
expect($.trim(this.view.$(".embed-frame").text())).toContain(o_embed_cache.data.html)
})
it("doesn't have opengraph preview", function(){
expect($.trim(this.view.$(".embed-frame").text())).not.toContain(open_graph_cache.title)
})
})
describe("rendering with opengraph only", function(){
beforeEach(function(){
this.view = new app.views.Post.SmallFrame({
model : factory.post({
open_graph_cache: open_graph_cache
})
})
this.view.render()
});
it("displays opengraph preview", function(){
expect($.trim(this.view.$(".open-graph-frame").text())).toContain(open_graph_cache.title)
});
})
describe("redirecting to a post", function(){
beforeEach(function(){
app.page = { editMode : false }
app.router = new app.Router()
window.gon.preloads = {}
spyOn(app.router, "navigate")
})
it("redirects", function() {
this.view.goToPost()
expect(app.router.navigate).toHaveBeenCalled()
})
})
});

View file

@ -1,37 +0,0 @@
describe("app.views.Post.StreamFrame", function(){
beforeEach(function(){
this.post = factory.post()
this.stream = new Backbone.Model
this.view = new app.views.Post.StreamFrame({model : this.post, stream: this.stream })
});
describe("rendering", function(){
beforeEach(function(){
this.view.render()
});
context("clicking the content", function(){
it("triggers frame interacted", function(){
var spy = jasmine.createSpy()
this.stream.on("frame:interacted", spy)
this.view.$('.content').click()
expect(spy).toHaveBeenCalledWith(this.post)
})
})
});
describe("going to a post", function(){
beforeEach(function(){
this.view.render()
})
context("clicking the permalink", function(){
it("calls goToPost on the smallFrame view", function(){
spyOn(app.router, "navigate").andReturn(true)
spyOn(this.view.smallFrameView, "goToPost")
this.view.$(".permalink").click()
expect(this.view.smallFrameView.goToPost).toHaveBeenCalled()
})
})
})
});