Merge pull request #16 from cmrd-senya/tests-gem
Introduce diaspora_federation-tests gem.
This commit is contained in:
commit
91546d7919
13 changed files with 250 additions and 220 deletions
|
|
@ -10,6 +10,9 @@ PATH
|
||||||
diaspora_federation-rails (0.0.8)
|
diaspora_federation-rails (0.0.8)
|
||||||
diaspora_federation (= 0.0.8)
|
diaspora_federation (= 0.0.8)
|
||||||
rails (~> 4.2)
|
rails (~> 4.2)
|
||||||
|
diaspora_federation-test (0.0.8)
|
||||||
|
diaspora_federation (= 0.0.8)
|
||||||
|
factory_girl (~> 4.5.0)
|
||||||
|
|
||||||
GEM
|
GEM
|
||||||
remote: https://rubygems.org/
|
remote: https://rubygems.org/
|
||||||
|
|
@ -276,6 +279,7 @@ DEPENDENCIES
|
||||||
codeclimate-test-reporter
|
codeclimate-test-reporter
|
||||||
diaspora_federation!
|
diaspora_federation!
|
||||||
diaspora_federation-rails!
|
diaspora_federation-rails!
|
||||||
|
diaspora_federation-test!
|
||||||
factory_girl_rails (~> 4.5.0)
|
factory_girl_rails (~> 4.5.0)
|
||||||
fixture_builder (~> 0.4.1)
|
fixture_builder (~> 0.4.1)
|
||||||
fuubar (= 2.0.0)
|
fuubar (= 2.0.0)
|
||||||
|
|
@ -301,4 +305,4 @@ DEPENDENCIES
|
||||||
yard
|
yard
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
1.10.5
|
1.10.6
|
||||||
|
|
|
||||||
24
diaspora_federation-test.gemspec
Normal file
24
diaspora_federation-test.gemspec
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
$LOAD_PATH.push File.expand_path("../lib", __FILE__)
|
||||||
|
|
||||||
|
# Maintain your gem's version:
|
||||||
|
require "diaspora_federation/version"
|
||||||
|
|
||||||
|
# Describe your gem and declare its dependencies:
|
||||||
|
Gem::Specification.new do |s|
|
||||||
|
s.name = "diaspora_federation-test"
|
||||||
|
s.version = DiasporaFederation::VERSION
|
||||||
|
s.authors = ["Benjamin Neff"]
|
||||||
|
s.email = ["benjamin@coding4.coffee"]
|
||||||
|
s.homepage = "https://github.com/SuperTux88/diaspora_federation"
|
||||||
|
s.summary = "diaspora* federation test utils"
|
||||||
|
s.description = "This gem provides some supplimentary code (factory definitions), that"\
|
||||||
|
"helps to build tests for users of the diaspora_federation gem."
|
||||||
|
s.license = "AGPL 3.0 - http://www.gnu.org/licenses/agpl-3.0.html"
|
||||||
|
|
||||||
|
s.files = Dir["lib/diaspora_federation/test.rb", "lib/diaspora_federation/test/*"]
|
||||||
|
|
||||||
|
s.required_ruby_version = "~> 2.0"
|
||||||
|
|
||||||
|
s.add_dependency "diaspora_federation", DiasporaFederation::VERSION
|
||||||
|
s.add_dependency "factory_girl", "~> 4.5.0"
|
||||||
|
end
|
||||||
|
|
@ -16,7 +16,7 @@ Gem::Specification.new do |s|
|
||||||
"among the various installations of Diaspora*"
|
"among the various installations of Diaspora*"
|
||||||
s.license = "AGPL 3.0 - http://www.gnu.org/licenses/agpl-3.0.html"
|
s.license = "AGPL 3.0 - http://www.gnu.org/licenses/agpl-3.0.html"
|
||||||
|
|
||||||
s.files = Dir["lib/**/*", "LICENSE", "README.md"] - Dir["lib/diaspora_federation/{engine,rails}.rb"]
|
s.files = Dir["lib/**/*", "LICENSE", "README.md"] - Dir["lib/diaspora_federation/{engine,rails,test}.rb", "lib/diaspora_federation/test/*"]
|
||||||
|
|
||||||
s.required_ruby_version = "~> 2.0"
|
s.required_ruby_version = "~> 2.0"
|
||||||
|
|
||||||
|
|
|
||||||
21
lib/diaspora_federation/test.rb
Normal file
21
lib/diaspora_federation/test.rb
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
require "diaspora_federation/test/factories"
|
||||||
|
|
||||||
|
module DiasporaFederation
|
||||||
|
module Test
|
||||||
|
# Sort hash according to an entity class's property sequence.
|
||||||
|
# This is used for rspec tests in order to generate correct input hash to
|
||||||
|
# compare results with.
|
||||||
|
#
|
||||||
|
def self.sort_hash(data, klass)
|
||||||
|
klass.class_props.map { |prop|
|
||||||
|
[prop[:name], data[prop[:name]]] unless data[prop[:name]].nil?
|
||||||
|
}.compact.to_h
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.relayable_attributes_with_signatures(entity_type)
|
||||||
|
DiasporaFederation::Entities::Relayable.update_signatures!(
|
||||||
|
sort_hash(FactoryGirl.attributes_for(entity_type), FactoryGirl.factory_by_name(entity_type).build_class)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
191
lib/diaspora_federation/test/factories.rb
Normal file
191
lib/diaspora_federation/test/factories.rb
Normal file
|
|
@ -0,0 +1,191 @@
|
||||||
|
require "factory_girl"
|
||||||
|
|
||||||
|
FactoryGirl.define do
|
||||||
|
initialize_with { new(attributes) }
|
||||||
|
sequence(:guid) { UUID.generate :compact }
|
||||||
|
sequence(:diaspora_id) {|n| "person-#{n}-#{SecureRandom.hex(3)}@localhost:3000" }
|
||||||
|
sequence(:public_key) { OpenSSL::PKey::RSA.generate(1024).public_key.export }
|
||||||
|
sequence(:signature) do |i|
|
||||||
|
abc = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||||
|
ltr = abc[i % abc.length]
|
||||||
|
"#{ltr * 6}=="
|
||||||
|
end
|
||||||
|
|
||||||
|
factory :webfinger, class: DiasporaFederation::Discovery::WebFinger do
|
||||||
|
guid
|
||||||
|
acct_uri { "acct:#{generate(:diaspora_id)}" }
|
||||||
|
alias_url "http://localhost:3000/people/0123456789abcdef"
|
||||||
|
hcard_url "http://localhost:3000/hcard/users/user"
|
||||||
|
seed_url "http://localhost:3000/"
|
||||||
|
profile_url "http://localhost:3000/u/user"
|
||||||
|
atom_url "http://localhost:3000/public/user.atom"
|
||||||
|
salmon_url "http://localhost:3000/receive/users/0123456789abcdef"
|
||||||
|
public_key
|
||||||
|
end
|
||||||
|
|
||||||
|
factory :h_card, class: DiasporaFederation::Discovery::HCard do
|
||||||
|
guid
|
||||||
|
nickname "some_name"
|
||||||
|
full_name "my name"
|
||||||
|
first_name "my name"
|
||||||
|
last_name nil
|
||||||
|
url "http://localhost:3000/"
|
||||||
|
public_key
|
||||||
|
photo_large_url "/assets/user/default.png"
|
||||||
|
photo_medium_url "/assets/user/default.png"
|
||||||
|
photo_small_url "/assets/user/default.png"
|
||||||
|
searchable true
|
||||||
|
end
|
||||||
|
|
||||||
|
factory :person_entity, class: DiasporaFederation::Entities::Person do
|
||||||
|
guid
|
||||||
|
diaspora_id
|
||||||
|
url "http://localhost:3000/"
|
||||||
|
exported_key { generate(:public_key) }
|
||||||
|
profile {
|
||||||
|
FactoryGirl.build(:profile_entity, diaspora_id: diaspora_id)
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
factory :profile_entity, class: DiasporaFederation::Entities::Profile do
|
||||||
|
diaspora_id
|
||||||
|
first_name "my name"
|
||||||
|
last_name nil
|
||||||
|
image_url "/assets/user/default.png"
|
||||||
|
image_url_medium "/assets/user/default.png"
|
||||||
|
image_url_small "/assets/user/default.png"
|
||||||
|
birthday "1988-07-15"
|
||||||
|
gender "Male"
|
||||||
|
bio "some text about me"
|
||||||
|
location "github"
|
||||||
|
searchable true
|
||||||
|
nsfw false
|
||||||
|
tag_string "#i #love #tags"
|
||||||
|
end
|
||||||
|
|
||||||
|
factory :location_entity, class: DiasporaFederation::Entities::Location do
|
||||||
|
address "Vienna, Austria"
|
||||||
|
lat 48.208174.to_s
|
||||||
|
lng 16.373819.to_s
|
||||||
|
end
|
||||||
|
|
||||||
|
factory :photo_entity, class: DiasporaFederation::Entities::Photo do
|
||||||
|
guid
|
||||||
|
diaspora_id
|
||||||
|
public(true)
|
||||||
|
created_at { Time.zone.now }
|
||||||
|
remote_photo_path "https://diaspora.example.tld/uploads/images/"
|
||||||
|
remote_photo_name "f2a41e9d2db4d9a199c8.jpg"
|
||||||
|
text "what you see here..."
|
||||||
|
status_message_guid { generate(:guid) }
|
||||||
|
height 480
|
||||||
|
width 800
|
||||||
|
end
|
||||||
|
|
||||||
|
factory :relayable_entity, class: DiasporaFederation::Entities::Relayable do
|
||||||
|
parent_guid { generate(:guid) }
|
||||||
|
end
|
||||||
|
|
||||||
|
factory :participation_entity, class: DiasporaFederation::Entities::Participation, parent: :relayable_entity do
|
||||||
|
guid
|
||||||
|
target_type "Post"
|
||||||
|
diaspora_id
|
||||||
|
end
|
||||||
|
|
||||||
|
factory :status_message_entity, class: DiasporaFederation::Entities::StatusMessage do
|
||||||
|
raw_message "i am a very interesting status update"
|
||||||
|
guid
|
||||||
|
diaspora_id
|
||||||
|
public(true)
|
||||||
|
created_at { Time.zone.now }
|
||||||
|
end
|
||||||
|
|
||||||
|
factory :request_entity, class: DiasporaFederation::Entities::Request do
|
||||||
|
sender_id { generate(:diaspora_id) }
|
||||||
|
recipient_id { generate(:diaspora_id) }
|
||||||
|
end
|
||||||
|
|
||||||
|
factory :comment_entity, class: DiasporaFederation::Entities::Comment, parent: :relayable_entity do
|
||||||
|
guid
|
||||||
|
text "this is a very informative comment"
|
||||||
|
diaspora_id
|
||||||
|
end
|
||||||
|
|
||||||
|
factory :like_entity, class: DiasporaFederation::Entities::Like, parent: :relayable_entity do
|
||||||
|
positive true
|
||||||
|
guid
|
||||||
|
target_type "Post"
|
||||||
|
diaspora_id
|
||||||
|
end
|
||||||
|
|
||||||
|
factory :account_deletion_entity, class: DiasporaFederation::Entities::AccountDeletion do
|
||||||
|
diaspora_id
|
||||||
|
end
|
||||||
|
|
||||||
|
factory :conversation_entity, class: DiasporaFederation::Entities::Conversation do
|
||||||
|
guid
|
||||||
|
subject "this is a very informative subject"
|
||||||
|
created_at { DateTime.now.utc }
|
||||||
|
messages []
|
||||||
|
diaspora_id
|
||||||
|
participant_ids { 3.times.map { generate(:diaspora_id) }.join(";") }
|
||||||
|
end
|
||||||
|
|
||||||
|
factory :message_entity, class: DiasporaFederation::Entities::Message, parent: :relayable_entity do
|
||||||
|
guid
|
||||||
|
text "this is a very informative text"
|
||||||
|
created_at { DateTime.now.utc }
|
||||||
|
diaspora_id
|
||||||
|
conversation_guid { generate(:guid) }
|
||||||
|
end
|
||||||
|
|
||||||
|
factory :relayable_retraction_entity, class: DiasporaFederation::Entities::RelayableRetraction do
|
||||||
|
parent_author_signature { generate(:signature) }
|
||||||
|
target_guid { generate(:guid) }
|
||||||
|
target_type "Post"
|
||||||
|
sender_id { generate(:diaspora_id) }
|
||||||
|
target_author_signature { generate(:signature) }
|
||||||
|
end
|
||||||
|
|
||||||
|
factory :reshare_entity, class: DiasporaFederation::Entities::Reshare do
|
||||||
|
root_diaspora_id { generate(:diaspora_id) }
|
||||||
|
root_guid { generate(:guid) }
|
||||||
|
guid
|
||||||
|
diaspora_id
|
||||||
|
public(true)
|
||||||
|
created_at { DateTime.now.utc }
|
||||||
|
provider_display_name { "the testsuite" }
|
||||||
|
end
|
||||||
|
|
||||||
|
factory :retraction_entity, class: DiasporaFederation::Entities::Retraction do
|
||||||
|
post_guid { generate(:guid) }
|
||||||
|
diaspora_id
|
||||||
|
type "Post"
|
||||||
|
end
|
||||||
|
|
||||||
|
factory :signed_retraction_entity, class: DiasporaFederation::Entities::SignedRetraction do
|
||||||
|
target_guid { generate(:guid) }
|
||||||
|
target_type "Post"
|
||||||
|
sender_id { generate(:diaspora_id) }
|
||||||
|
target_author_signature { generate(:signature) }
|
||||||
|
end
|
||||||
|
|
||||||
|
factory :poll_answer_entity, class: DiasporaFederation::Entities::PollAnswer do
|
||||||
|
guid
|
||||||
|
answer { "Obama is a bicycle" }
|
||||||
|
end
|
||||||
|
|
||||||
|
factory :poll_entity, class: DiasporaFederation::Entities::Poll do
|
||||||
|
guid
|
||||||
|
question { "Select an answer" }
|
||||||
|
poll_answers { 3.times.map { FactoryGirl.build(:poll_answer_entity) } }
|
||||||
|
end
|
||||||
|
|
||||||
|
factory :poll_participation_entity,
|
||||||
|
class: DiasporaFederation::Entities::PollParticipation,
|
||||||
|
parent: :relayable_entity do
|
||||||
|
guid
|
||||||
|
diaspora_id
|
||||||
|
poll_answer_guid { generate(:guid) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -1,219 +1,8 @@
|
||||||
require "factory_girl"
|
|
||||||
|
|
||||||
def r_str
|
|
||||||
SecureRandom.hex(3)
|
|
||||||
end
|
|
||||||
|
|
||||||
#
|
|
||||||
# Sort hash according to an entity class's property sequence.
|
|
||||||
# This is used for rspec tests in order to generate correct input hash to
|
|
||||||
# compare results with.
|
|
||||||
#
|
|
||||||
def sort_hash(data, klass)
|
|
||||||
klass.class_props.map { |prop|
|
|
||||||
[prop[:name], data[prop[:name]]] unless data[prop[:name]].nil?
|
|
||||||
}.compact.to_h
|
|
||||||
end
|
|
||||||
|
|
||||||
def relayable_attributes_with_signatures(entity_type)
|
|
||||||
DiasporaFederation::Entities::Relayable.update_signatures!(
|
|
||||||
sort_hash(FactoryGirl.attributes_for(entity_type), FactoryGirl.factory_by_name(entity_type).build_class)
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
FactoryGirl.define do
|
FactoryGirl.define do
|
||||||
initialize_with { new(attributes) }
|
|
||||||
sequence(:guid) { UUID.generate :compact }
|
|
||||||
sequence(:diaspora_id) {|n| "person-#{n}-#{r_str}@localhost:3000" }
|
|
||||||
sequence(:public_key) { OpenSSL::PKey::RSA.generate(1024).public_key.export }
|
|
||||||
sequence(:signature) do |i|
|
|
||||||
abc = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
|
||||||
ltr = abc[i % abc.length]
|
|
||||||
"#{ltr * 6}=="
|
|
||||||
end
|
|
||||||
|
|
||||||
factory :person do
|
factory :person do
|
||||||
diaspora_id
|
diaspora_id
|
||||||
url "http://localhost:3000/"
|
url "http://localhost:3000/"
|
||||||
serialized_public_key { generate(:public_key) }
|
serialized_public_key { generate(:public_key) }
|
||||||
after(:create, &:save)
|
after(:create, &:save)
|
||||||
end
|
end
|
||||||
|
|
||||||
factory :webfinger, class: DiasporaFederation::Discovery::WebFinger do
|
|
||||||
guid
|
|
||||||
acct_uri { "acct:#{generate(:diaspora_id)}" }
|
|
||||||
alias_url "http://localhost:3000/people/0123456789abcdef"
|
|
||||||
hcard_url "http://localhost:3000/hcard/users/user"
|
|
||||||
seed_url "http://localhost:3000/"
|
|
||||||
profile_url "http://localhost:3000/u/user"
|
|
||||||
atom_url "http://localhost:3000/public/user.atom"
|
|
||||||
salmon_url "http://localhost:3000/receive/users/0123456789abcdef"
|
|
||||||
public_key
|
|
||||||
end
|
|
||||||
|
|
||||||
factory :h_card, class: DiasporaFederation::Discovery::HCard do
|
|
||||||
guid
|
|
||||||
nickname "some_name"
|
|
||||||
full_name "my name"
|
|
||||||
first_name "my name"
|
|
||||||
last_name nil
|
|
||||||
url "http://localhost:3000/"
|
|
||||||
public_key
|
|
||||||
photo_large_url "/assets/user/default.png"
|
|
||||||
photo_medium_url "/assets/user/default.png"
|
|
||||||
photo_small_url "/assets/user/default.png"
|
|
||||||
searchable true
|
|
||||||
end
|
|
||||||
|
|
||||||
factory :person_entity, class: DiasporaFederation::Entities::Person do
|
|
||||||
guid
|
|
||||||
diaspora_id
|
|
||||||
url "http://localhost:3000/"
|
|
||||||
exported_key { generate(:public_key) }
|
|
||||||
profile {
|
|
||||||
FactoryGirl.build(:profile_entity, diaspora_id: diaspora_id)
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
factory :profile_entity, class: DiasporaFederation::Entities::Profile do
|
|
||||||
diaspora_id
|
|
||||||
first_name "my name"
|
|
||||||
last_name nil
|
|
||||||
image_url "/assets/user/default.png"
|
|
||||||
image_url_medium "/assets/user/default.png"
|
|
||||||
image_url_small "/assets/user/default.png"
|
|
||||||
birthday "1988-07-15"
|
|
||||||
gender "Male"
|
|
||||||
bio "some text about me"
|
|
||||||
location "github"
|
|
||||||
searchable true
|
|
||||||
nsfw false
|
|
||||||
tag_string "#i #love #tags"
|
|
||||||
end
|
|
||||||
|
|
||||||
factory :location_entity, class: DiasporaFederation::Entities::Location do
|
|
||||||
address "Vienna, Austria"
|
|
||||||
lat 48.208174.to_s
|
|
||||||
lng 16.373819.to_s
|
|
||||||
end
|
|
||||||
|
|
||||||
factory :photo_entity, class: DiasporaFederation::Entities::Photo do
|
|
||||||
guid
|
|
||||||
diaspora_id
|
|
||||||
public(true)
|
|
||||||
created_at { Time.zone.now }
|
|
||||||
remote_photo_path "https://diaspora.example.tld/uploads/images/"
|
|
||||||
remote_photo_name "f2a41e9d2db4d9a199c8.jpg"
|
|
||||||
text "what you see here..."
|
|
||||||
status_message_guid { generate(:guid) }
|
|
||||||
height 480
|
|
||||||
width 800
|
|
||||||
end
|
|
||||||
|
|
||||||
factory :relayable_entity, class: DiasporaFederation::Entities::Relayable do
|
|
||||||
parent_guid { generate(:guid) }
|
|
||||||
end
|
|
||||||
|
|
||||||
factory :participation_entity, class: DiasporaFederation::Entities::Participation, parent: :relayable_entity do
|
|
||||||
guid
|
|
||||||
target_type "StatusMessage"
|
|
||||||
diaspora_id
|
|
||||||
end
|
|
||||||
|
|
||||||
factory :status_message_entity, class: DiasporaFederation::Entities::StatusMessage do
|
|
||||||
raw_message "i am a very interesting status update"
|
|
||||||
guid
|
|
||||||
diaspora_id
|
|
||||||
public(true)
|
|
||||||
created_at { Time.zone.now }
|
|
||||||
end
|
|
||||||
|
|
||||||
factory :request_entity, class: DiasporaFederation::Entities::Request do
|
|
||||||
sender_id { generate(:diaspora_id) }
|
|
||||||
recipient_id { generate(:diaspora_id) }
|
|
||||||
end
|
|
||||||
|
|
||||||
factory :comment_entity, class: DiasporaFederation::Entities::Comment, parent: :relayable_entity do
|
|
||||||
guid
|
|
||||||
text "this is a very informative comment"
|
|
||||||
diaspora_id
|
|
||||||
end
|
|
||||||
|
|
||||||
factory :like_entity, class: DiasporaFederation::Entities::Like, parent: :relayable_entity do
|
|
||||||
positive 1
|
|
||||||
guid
|
|
||||||
target_type "StatusMessage"
|
|
||||||
diaspora_id
|
|
||||||
end
|
|
||||||
|
|
||||||
factory :account_deletion_entity, class: DiasporaFederation::Entities::AccountDeletion do
|
|
||||||
diaspora_id
|
|
||||||
end
|
|
||||||
|
|
||||||
factory :conversation_entity, class: DiasporaFederation::Entities::Conversation do
|
|
||||||
guid
|
|
||||||
subject "this is a very informative subject"
|
|
||||||
created_at { DateTime.now.utc }
|
|
||||||
messages []
|
|
||||||
diaspora_id
|
|
||||||
participant_ids { 3.times.map { generate(:diaspora_id) }.join(";") }
|
|
||||||
end
|
|
||||||
|
|
||||||
factory :message_entity, class: DiasporaFederation::Entities::Message, parent: :relayable_entity do
|
|
||||||
guid
|
|
||||||
text "this is a very informative text"
|
|
||||||
created_at { DateTime.now.utc }
|
|
||||||
diaspora_id
|
|
||||||
conversation_guid { generate(:guid) }
|
|
||||||
end
|
|
||||||
|
|
||||||
factory :relayable_retraction_entity, class: DiasporaFederation::Entities::RelayableRetraction do
|
|
||||||
parent_author_signature { generate(:signature) }
|
|
||||||
target_guid { generate(:guid) }
|
|
||||||
target_type "StatusMessage"
|
|
||||||
sender_id { generate(:diaspora_id) }
|
|
||||||
target_author_signature { generate(:signature) }
|
|
||||||
end
|
|
||||||
|
|
||||||
factory :reshare_entity, class: DiasporaFederation::Entities::Reshare do
|
|
||||||
root_diaspora_id { generate(:diaspora_id) }
|
|
||||||
root_guid { generate(:guid) }
|
|
||||||
guid
|
|
||||||
diaspora_id
|
|
||||||
public(true)
|
|
||||||
created_at { DateTime.now.utc }
|
|
||||||
provider_display_name { "the testsuite" }
|
|
||||||
end
|
|
||||||
|
|
||||||
factory :retraction_entity, class: DiasporaFederation::Entities::Retraction do
|
|
||||||
post_guid { generate(:guid) }
|
|
||||||
diaspora_id
|
|
||||||
type "StatusMessage"
|
|
||||||
end
|
|
||||||
|
|
||||||
factory :signed_retraction_entity, class: DiasporaFederation::Entities::SignedRetraction do
|
|
||||||
target_guid { generate(:guid) }
|
|
||||||
target_type "StatusMessage"
|
|
||||||
sender_id { generate(:diaspora_id) }
|
|
||||||
target_author_signature { generate(:signature) }
|
|
||||||
end
|
|
||||||
|
|
||||||
factory :poll_answer_entity, class: DiasporaFederation::Entities::PollAnswer do
|
|
||||||
guid
|
|
||||||
answer { "Obama is a bicycle" }
|
|
||||||
end
|
|
||||||
|
|
||||||
factory :poll_entity, class: DiasporaFederation::Entities::Poll do
|
|
||||||
guid
|
|
||||||
question { "Select an answer" }
|
|
||||||
poll_answers { 3.times.map { FactoryGirl.build(:poll_answer_entity) } }
|
|
||||||
end
|
|
||||||
|
|
||||||
factory :poll_participation_entity,
|
|
||||||
class: DiasporaFederation::Entities::PollParticipation,
|
|
||||||
parent: :relayable_entity do
|
|
||||||
guid
|
|
||||||
diaspora_id
|
|
||||||
poll_answer_guid { generate(:guid) }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
module DiasporaFederation
|
module DiasporaFederation
|
||||||
describe Entities::Comment do
|
describe Entities::Comment do
|
||||||
let(:data) { relayable_attributes_with_signatures(:comment_entity) }
|
let(:data) { Test.relayable_attributes_with_signatures(:comment_entity) }
|
||||||
|
|
||||||
let(:xml) {
|
let(:xml) {
|
||||||
<<-XML
|
<<-XML
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
module DiasporaFederation
|
module DiasporaFederation
|
||||||
describe Entities::Conversation do
|
describe Entities::Conversation do
|
||||||
let(:msg1_data) { relayable_attributes_with_signatures(:message_entity) }
|
let(:msg1_data) { Test.relayable_attributes_with_signatures(:message_entity) }
|
||||||
let(:msg2_data) { relayable_attributes_with_signatures(:message_entity) }
|
let(:msg2_data) { Test.relayable_attributes_with_signatures(:message_entity) }
|
||||||
let(:msg1) { FactoryGirl.build(:message_entity, msg1_data) }
|
let(:msg1) { FactoryGirl.build(:message_entity, msg1_data) }
|
||||||
let(:msg2) { FactoryGirl.build(:message_entity, msg2_data) }
|
let(:msg2) { FactoryGirl.build(:message_entity, msg2_data) }
|
||||||
let(:data) {
|
let(:data) {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
module DiasporaFederation
|
module DiasporaFederation
|
||||||
describe Entities::Like do
|
describe Entities::Like do
|
||||||
let(:data) { relayable_attributes_with_signatures(:like_entity) }
|
let(:data) { Test.relayable_attributes_with_signatures(:like_entity) }
|
||||||
|
|
||||||
let(:xml) {
|
let(:xml) {
|
||||||
<<-XML
|
<<-XML
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
module DiasporaFederation
|
module DiasporaFederation
|
||||||
describe Entities::Message do
|
describe Entities::Message do
|
||||||
let(:data) { relayable_attributes_with_signatures(:message_entity) }
|
let(:data) { Test.relayable_attributes_with_signatures(:message_entity) }
|
||||||
|
|
||||||
let(:xml) {
|
let(:xml) {
|
||||||
<<-XML
|
<<-XML
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
module DiasporaFederation
|
module DiasporaFederation
|
||||||
describe Entities::Participation do
|
describe Entities::Participation do
|
||||||
let(:data) { relayable_attributes_with_signatures(:participation_entity) }
|
let(:data) { Test.relayable_attributes_with_signatures(:participation_entity) }
|
||||||
|
|
||||||
let(:xml) {
|
let(:xml) {
|
||||||
<<-XML
|
<<-XML
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
module DiasporaFederation
|
module DiasporaFederation
|
||||||
describe Entities::PollParticipation do
|
describe Entities::PollParticipation do
|
||||||
let(:data) { relayable_attributes_with_signatures(:poll_participation_entity) }
|
let(:data) { Test.relayable_attributes_with_signatures(:poll_participation_entity) }
|
||||||
|
|
||||||
let(:xml) {
|
let(:xml) {
|
||||||
<<-XML
|
<<-XML
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ require "rspec/rails"
|
||||||
require "webmock/rspec"
|
require "webmock/rspec"
|
||||||
|
|
||||||
# load factory girl factories
|
# load factory girl factories
|
||||||
|
require "diaspora_federation/test"
|
||||||
require "factories"
|
require "factories"
|
||||||
|
|
||||||
# load test entities
|
# load test entities
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue