Skip to content
Extraits de code Groupes Projets
Valider 8e3db3ae rédigé par Dennis Collinson's avatar Dennis Collinson
Parcourir les fichiers

make jasmine view tests work, load templates, party

parent 4883c70a
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -74,8 +74,7 @@
%header{:class=>('landing' unless current_user)}
= render 'layouts/header'
- if @backbone
= render 'templates/templates'
= render 'templates/templates'
.container{:style=> "#{yield(:break_the_mold)}"}
- if @aspsect == :getting_started || @page == :logged_out
......
......@@ -34,41 +34,41 @@
<time class="timeago" datetime="<%= created_at %>"/>
</a>
</span>
</div>
<p>
<%= text %>
</p>
<p class="post-text">
<%= text %>
</p>
<div class="info">
<% if(provider_display_name != null) { %>
<span class="via">
via <%= provider_display_name %>
-
</span>
<% } %>
<span class="post_scope">
<%= public === true ? "Public" : "Limited" %>
<div class="info">
<% if(provider_display_name != null) { %>
<span class="via">
via <%= provider_display_name %>
-
</span>
<a href="#" class="focus_comment_textarea">
Comment
</a>
</div>
<% } %>
<span class="post_scope">
<%= public === true ? "Public" : "Limited" %>
-
</span>
<a href="#" class="focus_comment_textarea">
Comment
</a>
</div>
<div class="likes on_post">
<div class="likes_container">
<% if(likes_count > 0){ %>
<img alt="Heart" src="/images/icons/heart.png?1322618579">
<a href="/posts/<%= id %>/likes" class="expand_likes">
<%= likes_count %> like
</a>
<span class="hidden likes_list"></span>
<% } %>
</div>
<div class="likes on_post">
<div class="likes_container">
<% if(likes_count > 0){ %>
<img alt="Heart" src="/images/icons/heart.png?1322618579">
<a href="/posts/<%= id %>/likes" class="expand_likes">
<%= likes_count %> like
</a>
<span class="hidden likes_list"></span>
<% } %>
</div>
</div>
<div class="comments"> </div>
<div class="comments"> </div>
</div>
</div>
</div>
......@@ -17,7 +17,7 @@ describe MultisController do
describe 'jasmine fixtures' do
it 'generate' do
status_message = alice.post(:status_message, :text => "hey", :to => alice.aspects.first.id)
status_message = alice.post(:status_message, :text => "hella infos yo!", :to => alice.aspects.first.id)
get :index, :format => :json
save_fixture(response.body, "multi_stream_json")
end
......
require "spec_helper"
describe "template generation" do
it "generates templates" do
extend JasmineFixtureGeneration
templates = Haml::Engine.new(Rails.root.join("app", "views", "templates", "_templates.haml").read).render
save_fixture(templates, "underscore_templates")
end
end
......@@ -2,14 +2,18 @@ describe("App.views.Stream", function(){
describe("#render", function(){
beforeEach(function(){
// should be jasmine helper
window.current_user = App.user({name: "alice", avatar : {small : "http://avatar.com"}});
//hella hax
spec.loadFixture("multi_stream_json")
var fixtureStream = $.parseJSON($("#jasmine_content").html())
spec.loadFixture("multi_stream_json");
var posts = $.parseJSON($("#jasmine_content").html())["posts"]
spec.loadFixture("underscore_templates");
this.statusMessage = new App.Models.Post(fixtureStream["posts"][0] );
this.collection = new App.Collections.Stream(posts)
this.statusMessage = this.collection.models[0];
// this.picture = new App.Models.Post({post_type : "ActivityStreams::Photo", image_url : "http://amazonks.com/pretty_picture_lol.gif"});
this.collection = new App.Collections.Stream([this.statusMessage]);
this.view = new App.Views.Stream({collection : this.collection});
this.view.render();
this.statusElement = $(this.view.$("#" + this.statusMessage.get("guid")));
......@@ -18,8 +22,7 @@ describe("App.views.Stream", function(){
context("when rendering a Status Mesasage", function(){
it("shows the status message in the content area", function(){
// we need to load the underscore templates here, otherwise our views won't render!
expect(this.statusElement.find(".post-content p")).toBe("hella infos yo!")
expect($.trim(this.statusElement.find(".content p.post-text").text())).toBe("hella infos yo!")
})
})
......
RSpec::Rails::ControllerExampleGroup.class_eval do
module JasmineFixtureGeneration
# Saves the markup to a fixture file using the given name
def save_fixture(markup, name, fixture_path=nil )
fixture_path = File.join(Rails.root, 'tmp', 'js_dom_fixtures') unless fixture_path
......@@ -41,3 +40,7 @@ RSpec::Rails::ControllerExampleGroup.class_eval do
end
end
RSpec::Rails::ControllerExampleGroup.class_eval do
include JasmineFixtureGeneration
end
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter