diff --git a/spec/controllers/aspects_controller_spec.rb b/spec/controllers/aspects_controller_spec.rb index 6f65ee9a5ce215102ba193b3695926e9c3e5498b..b75b48d881622a3b873a2510c7ed2bf3c9e888d2 100644 --- a/spec/controllers/aspects_controller_spec.rb +++ b/spec/controllers/aspects_controller_spec.rb @@ -36,96 +36,6 @@ describe AspectsController do end describe "#index" do - context 'jasmine fixtures' do - before do - Stream::Aspect.any_instance.stub(:ajax_stream?).and_return(false) - end - - it "generates a jasmine fixture", :fixture => true do - get :index - save_fixture(html_for("body"), "aspects_index") - end - - it "generates a jasmine fixture with a prefill", :fixture => true do - get :index, :prefill => "reshare things" - save_fixture(html_for("body"), "aspects_index_prefill") - end - - it 'generates a jasmine fixture with services', :fixture => true do - alice.services << Services::Facebook.create(:user_id => alice.id) - alice.services << Services::Twitter.create(:user_id => alice.id) - get :index, :prefill => "reshare things" - save_fixture(html_for("body"), "aspects_index_services") - end - - it 'generates a jasmine fixture with posts', :fixture => true do - bob.post(:status_message, :text => "Is anyone out there?", :to => @bob.aspects.where(:name => "generic").first.id) - message = alice.post(:status_message, :text => "hello "*800, :to => @alices_aspect_2.id) - 5.times { bob.comment("what", :post => message) } - get :index - save_fixture(html_for("body"), "aspects_index_with_posts") - end - - it 'generates a jasmine fixture with only posts', :fixture => true do - 2.times { bob.post(:status_message, :text => "Is anyone out there?", :to => @bob.aspects.where(:name => "generic").first.id) } - - get :index, :only_posts => true - - save_fixture(response.body, "aspects_index_only_posts") - end - - it "generates a jasmine fixture with a post with comments", :fixture => true do - message = bob.post(:status_message, :text => "HALO WHIRLED", :to => @bob.aspects.where(:name => "generic").first.id) - 5.times { bob.comment("what", :post => message) } - get :index - save_fixture(html_for("body"), "aspects_index_post_with_comments") - end - - it 'generates a jasmine fixture with a followed tag', :fixture => true do - @tag = ActsAsTaggableOn::Tag.create!(:name => "partytimeexcellent") - TagFollowing.create!(:tag => @tag, :user => alice) - get :index - save_fixture(html_for("body"), "aspects_index_with_one_followed_tag") - end - - it "generates a jasmine fixture with a post containing a video", :fixture => true do - stub_request( - :get, - "http://gdata.youtube.com/feeds/api/videos/UYrkQL1bX4A?v=2" - ).with( - :headers => {'Accept'=>'*/*'} - ).to_return( - :status => 200, - :body => "<title>LazyTown song - Cooking By The Book</title>", - :headers => {} - ) - - stub_request( - :get, - "http://www.youtube.com/oembed?format=json&frame=1&iframe=1&maxheight=420&maxwidth=420&url=http://www.youtube.com/watch?v=UYrkQL1bX4A" - ).with( - :headers => {'Accept'=>'*/*'} - ).to_return( - :status => 200, - :body => '{ "title": "LazyTown song - Cooking By The Boo" }', - :headers => {} - ) - - alice.post(:status_message, :text => "http://www.youtube.com/watch?v=UYrkQL1bX4A", :to => @alices_aspect_2.id) - get :index - save_fixture(html_for("body"), "aspects_index_with_video_post") - end - - it "generates a jasmine fixture with a post that has been liked", :fixture => true do - message = alice.post(:status_message, :text => "hello "*800, :to => @alices_aspect_2.id) - alice.build_like(:positive => true, :target => message).save - bob.build_like(:positive => true, :target => message).save - - get :index - save_fixture(html_for("body"), "aspects_index_with_a_post_with_likes") - end - end - it 'renders just the stream with the infinite scroll param set' do get :index, :only_posts => true response.should render_template('shared/_stream') diff --git a/spec/controllers/comments_controller_spec.rb b/spec/controllers/comments_controller_spec.rb index 8c8a8804e2874285f258442d8b46ad5b4f91fa4c..e2560fd77cfd70d374bc40f856ccfa1afba5288a 100644 --- a/spec/controllers/comments_controller_spec.rb +++ b/spec/controllers/comments_controller_spec.rb @@ -130,13 +130,6 @@ describe CommentsController do @message = bob.post(:status_message, :text => "hey", :to => aspect_to_post.id) end - it 'generates a jasmine fixture', :fixture => true do - 2.times { alice.comment("hey", :post => @message) } - get :index, :post_id => @message.id - - save_fixture(response.body, "ajax_comments_on_post") - end - it 'works for mobile' do get :index, :post_id => @message.id, :format => 'mobile' response.should be_success diff --git a/spec/controllers/contacts_controller_spec.rb b/spec/controllers/contacts_controller_spec.rb index 28ae29caf4c3c6938275a853bfa0a749d2fd99d4..fc094dfc544cbe545df9fd35f9946b1500ffd004 100644 --- a/spec/controllers/contacts_controller_spec.rb +++ b/spec/controllers/contacts_controller_spec.rb @@ -63,10 +63,6 @@ describe ContactsController do response.should be_success end - it "generates a jasmine fixture", :fixture => true do - get :index - save_fixture(html_for("body"), "aspects_manage") - end it 'does not select duplicate contacts' do aspect = bob.aspects.create(:name => 'hilarious people') diff --git a/spec/controllers/jasmine_fixtures/aspects_spec.rb b/spec/controllers/jasmine_fixtures/aspects_spec.rb new file mode 100644 index 0000000000000000000000000000000000000000..0092b431e890b04d96fa33fb7d9ed79f7b6dc681 --- /dev/null +++ b/spec/controllers/jasmine_fixtures/aspects_spec.rb @@ -0,0 +1,106 @@ +# Copyright (c) 2010-2011, Diaspora Inc. This file is +# licensed under the Affero General Public License version 3 or later. See +# the COPYRIGHT file. + +require 'spec_helper' + +describe AspectsController do + describe '#index' do + before do + sign_in :user, alice + @alices_aspect_2 = alice.aspects.create(:name => "another aspect") + + request.env["HTTP_REFERER"] = 'http://' + request.host + end + + context 'jasmine fixtures' do + before do + Stream::Aspect.any_instance.stub(:ajax_stream?).and_return(false) + end + + it "generates a jasmine fixture", :fixture => true do + get :index + save_fixture(html_for("body"), "aspects_index") + end + + it "generates a jasmine fixture with a prefill", :fixture => true do + get :index, :prefill => "reshare things" + save_fixture(html_for("body"), "aspects_index_prefill") + end + + it 'generates a jasmine fixture with services', :fixture => true do + alice.services << Services::Facebook.create(:user_id => alice.id) + alice.services << Services::Twitter.create(:user_id => alice.id) + get :index, :prefill => "reshare things" + save_fixture(html_for("body"), "aspects_index_services") + end + + it 'generates a jasmine fixture with posts', :fixture => true do + bob.post(:status_message, :text => "Is anyone out there?", :to => @bob.aspects.where(:name => "generic").first.id) + message = alice.post(:status_message, :text => "hello "*800, :to => @alices_aspect_2.id) + 5.times { bob.comment("what", :post => message) } + get :index + save_fixture(html_for("body"), "aspects_index_with_posts") + end + + it 'generates a jasmine fixture with only posts', :fixture => true do + 2.times { bob.post(:status_message, :text => "Is anyone out there?", :to => @bob.aspects.where(:name => "generic").first.id) } + + get :index, :only_posts => true + + save_fixture(response.body, "aspects_index_only_posts") + end + + it "generates a jasmine fixture with a post with comments", :fixture => true do + message = bob.post(:status_message, :text => "HALO WHIRLED", :to => @bob.aspects.where(:name => "generic").first.id) + 5.times { bob.comment("what", :post => message) } + get :index + save_fixture(html_for("body"), "aspects_index_post_with_comments") + end + + it 'generates a jasmine fixture with a followed tag', :fixture => true do + @tag = ActsAsTaggableOn::Tag.create!(:name => "partytimeexcellent") + TagFollowing.create!(:tag => @tag, :user => alice) + get :index + save_fixture(html_for("body"), "aspects_index_with_one_followed_tag") + end + + it "generates a jasmine fixture with a post containing a video", :fixture => true do + stub_request( + :get, + "http://gdata.youtube.com/feeds/api/videos/UYrkQL1bX4A?v=2" + ).with( + :headers => {'Accept'=>'*/*'} + ).to_return( + :status => 200, + :body => "<title>LazyTown song - Cooking By The Book</title>", + :headers => {} + ) + + stub_request( + :get, + "http://www.youtube.com/oembed?format=json&frame=1&iframe=1&maxheight=420&maxwidth=420&url=http://www.youtube.com/watch?v=UYrkQL1bX4A" + ).with( + :headers => {'Accept'=>'*/*'} + ).to_return( + :status => 200, + :body => '{ "title": "LazyTown song - Cooking By The Boo" }', + :headers => {} + ) + + alice.post(:status_message, :text => "http://www.youtube.com/watch?v=UYrkQL1bX4A", :to => @alices_aspect_2.id) + get :index + save_fixture(html_for("body"), "aspects_index_with_video_post") + end + + it "generates a jasmine fixture with a post that has been liked", :fixture => true do + message = alice.post(:status_message, :text => "hello "*800, :to => @alices_aspect_2.id) + alice.build_like(:positive => true, :target => message).save + bob.build_like(:positive => true, :target => message).save + + get :index + save_fixture(html_for("body"), "aspects_index_with_a_post_with_likes") + end + end + end +end diff --git a/spec/controllers/jasmine_fixtures/comments_spec.rb b/spec/controllers/jasmine_fixtures/comments_spec.rb new file mode 100644 index 0000000000000000000000000000000000000000..7c8b3201a8f6c297fdb3f1b83ba91780c1a3cf52 --- /dev/null +++ b/spec/controllers/jasmine_fixtures/comments_spec.rb @@ -0,0 +1,26 @@ +# Copyright (c) 2010-2011, Diaspora Inc. This file is +# licensed under the Affero General Public License version 3 or later. See +# the COPYRIGHT file. + +require 'spec_helper' + +describe CommentsController do + describe '#index' do + before do + sign_in :user, alice + end + + it 'generates a jasmine fixture', :fixture => true do + aspect_to_post = bob.aspects.where(:name => "generic").first + message = bob.post(:status_message, :text => "hey", :to => aspect_to_post.id) + + 2.times do + alice.comment("hey", :post => message) + end + + get :index, :post_id => message.id + save_fixture(response.body, "ajax_comments_on_post") + end + end + +end diff --git a/spec/controllers/jasmine_fixtures/contacts_spec.rb b/spec/controllers/jasmine_fixtures/contacts_spec.rb new file mode 100644 index 0000000000000000000000000000000000000000..d2a5321de6c24799a2e3af2e2db0799f2f9c8b37 --- /dev/null +++ b/spec/controllers/jasmine_fixtures/contacts_spec.rb @@ -0,0 +1,18 @@ +# Copyright (c) 2010-2011, Diaspora Inc. This file is +# licensed under the Affero General Public License version 3 or later. See +# the COPYRIGHT file. + +require 'spec_helper' + +describe ContactsController do + describe '#index' do + before do + sign_in :user, bob + end + + it "generates a jasmine fixture", :fixture => true do + get :index + save_fixture(html_for("body"), "aspects_manage") + end + end +end diff --git a/spec/controllers/jasmine_fixtures/stream_spec.rb b/spec/controllers/jasmine_fixtures/stream_spec.rb index 89a5f42b58a4d571216ee950152bd2dd88eefe3b..ff9a2a16afe29533da94a02367f2db520c2a623a 100644 --- a/spec/controllers/jasmine_fixtures/stream_spec.rb +++ b/spec/controllers/jasmine_fixtures/stream_spec.rb @@ -10,7 +10,7 @@ describe MultisController do sign_in :user, alice end - it 'generates the multti_stream_json fixture' do + it 'generates the multi_stream_json fixture', :fixture => true do alice.post(:status_message, :text => "hella infos yo!", :to => alice.aspects.first.id) alice.post(:reshare, :root_guid => Factory(:status_message, :public => true).guid, :to => 'all') post_to_be_liked = alice.post(:status_message, :text => "you're gonna love this.'", :to => alice.aspects.first.id) diff --git a/spec/controllers/jasmine_fixtures/template_spec.rb b/spec/controllers/jasmine_fixtures/template_spec.rb index 3be7d6b7056b381dbc2ba8a4de93af9133f1802e..fd38163a273af27d4745aadd43c62a5fdafe388f 100644 --- a/spec/controllers/jasmine_fixtures/template_spec.rb +++ b/spec/controllers/jasmine_fixtures/template_spec.rb @@ -1,7 +1,7 @@ require "spec_helper" describe "template generation" do - it "generates templates" do + it "generates templates", :fixture => true do extend JasmineFixtureGeneration templates = Haml::Engine.new(Rails.root.join("app", "views", "templates", "_templates.haml").read).render save_fixture(templates, "underscore_templates")