moved all jasmine fixture building into spec/controllers/jasmine_fixtures/
This commit is contained in:
parent
c95f4f30e7
commit
21eba82e76
8 changed files with 152 additions and 103 deletions
|
|
@ -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')
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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')
|
||||
|
|
|
|||
106
spec/controllers/jasmine_fixtures/aspects_spec.rb
Normal file
106
spec/controllers/jasmine_fixtures/aspects_spec.rb
Normal file
|
|
@ -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
|
||||
26
spec/controllers/jasmine_fixtures/comments_spec.rb
Normal file
26
spec/controllers/jasmine_fixtures/comments_spec.rb
Normal file
|
|
@ -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
|
||||
18
spec/controllers/jasmine_fixtures/contacts_spec.rb
Normal file
18
spec/controllers/jasmine_fixtures/contacts_spec.rb
Normal file
|
|
@ -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
|
||||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
Loading…
Reference in a new issue