Skip to content
Extraits de code Groupes Projets
Valider e1e8856e rédigé par zaziemo's avatar zaziemo Validation de Dennis Schubert
Parcourir les fichiers

refactor more specs

parent e3fe3758
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -69,59 +69,65 @@ describe Comment, :type => :model do ...@@ -69,59 +69,65 @@ describe Comment, :type => :model do
end end
end end
# hier weiter
describe 'xml' do describe 'xml' do
let(:commenter) { create(:user) }
let(:commenter_aspect) { commenter.aspects.create(name: "bruisers") }
let(:post) { alice.post :status_message, text: "hello", to: alices_aspect.id }
let(:comment) { commenter.comment!(post, "Fool!") }
let(:xml) { comment.to_xml.to_s }
before do before do
@commenter = FactoryGirl.create(:user) connect_users(alice, alices_aspect, commenter, commenter_aspect)
@commenter_aspect = @commenter.aspects.create(:name => "bruisers")
connect_users(alice, alices_aspect, @commenter, @commenter_aspect)
@post = alice.post :status_message, :text => "hello", :to => alices_aspect.id
@comment = @commenter.comment!(@post, "Fool!")
@xml = @comment.to_xml.to_s
end end
it 'serializes the sender handle' do it 'serializes the sender handle' do
expect(@xml.include?(@commenter.diaspora_handle)).to be true expect(xml.include?(commenter.diaspora_handle)).to be true
end end
it 'serializes the post_guid' do it 'serializes the post_guid' do
expect(@xml).to include(@post.guid) expect(xml).to include(post.guid)
end end
describe 'marshalling' do describe 'marshalling' do
before do let(:marshalled_comment) { Comment.from_xml(xml) }
@marshalled_comment = Comment.from_xml(@xml)
end
it 'marshals the author' do it 'marshals the author' do
expect(@marshalled_comment.author).to eq(@commenter.person) expect(marshalled_comment.author).to eq(commenter.person)
end end
it 'marshals the post' do it 'marshals the post' do
expect(@marshalled_comment.post).to eq(@post) expect(marshalled_comment.post).to eq(post)
end end
it 'tries to fetch a missing parent' do it 'tries to fetch a missing parent' do
guid = @post.guid guid = post.guid
@post.destroy marshalled_comment
post.destroy
expect_any_instance_of(Comment).to receive(:fetch_parent).with(guid).and_return(nil) expect_any_instance_of(Comment).to receive(:fetch_parent).with(guid).and_return(nil)
Comment.from_xml(@xml) Comment.from_xml(xml)
end end
end end
end end
#Andy fragen - shared behaviour
describe 'it is relayable' do describe 'it is relayable' do
let(:remote_parent) { build(:status_message, author: @remote_raphael) }
let(:local_parent) { @local_luke.post :status_message, text: "hi", to: @local_luke.aspects.first }
let(:object_by_parent_author) { @local_luke.comment!(text: "yo!", post: local_parent) }
let(:object_by_recipient) { @local_leia.build_comment(text: "yo", post: local_parent) }
let(:dup_object_by_parent_author) { object_by_parent_author.dup }
let(:object_on_remote_parent) { @local_luke.comment!(remote_parent, "Yeah, it was great") }
before do before do
@local_luke, @local_leia, @remote_raphael = set_up_friends local_luke, @local_leia, @remote_raphael = set_up_friends
@remote_parent = FactoryGirl.build(:status_message, :author => @remote_raphael) # @remote_parent = FactoryGirl.build(:status_message, :author => @remote_raphael)
@local_parent = @local_luke.post :status_message, :text => "hi", :to => @local_luke.aspects.first # @local_parent = @local_luke.post :status_message, :text => "hi", :to => @local_luke.aspects.first
@object_by_parent_author = @local_luke.comment!(@local_parent, "yo") # @object_by_parent_author = @local_luke.comment!(@local_parent, "yo")
@object_by_recipient = @local_leia.build_comment(:text => "yo", :post => @local_parent) # @object_by_recipient = @local_leia.build_comment(:text => "yo", :post => @local_parent)
@dup_object_by_parent_author = @object_by_parent_author.dup # @dup_object_by_parent_author = @object_by_parent_author.dup
@object_on_remote_parent = @local_luke.comment!(@remote_parent, "Yeah, it was great") # @object_on_remote_parent = @local_luke.comment!(@remote_parent, "Yeah, it was great")
end end
let(:build_object) { alice.build_comment(:post => status_bob, :text => "why so formal?") } let(:build_object) { alice.build_comment(:post => status_bob, :text => "why so formal?") }
...@@ -129,9 +135,11 @@ describe Comment, :type => :model do ...@@ -129,9 +135,11 @@ describe Comment, :type => :model do
end end
describe 'tags' do describe 'tags' do
before do let(:object) { build(:comment) }
@object = FactoryGirl.build(:comment)
end # before do
# @object = FactoryGirl.build(:comment)
# end
it_should_behave_like 'it is taggable' it_should_behave_like 'it is taggable'
end 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