diaspora_federation-test 0.0.12 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/diaspora_federation/test.rb +0 -47
- data/lib/diaspora_federation/test/factories.rb +32 -23
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9499524c854db4efe1a050de1a31b81367d46636
|
4
|
+
data.tar.gz: 250bbaf16de1b756777d2d5f6d55c48be51c3a37
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec1957eef8d63640e3f7b83984427094862d0669f930a02520c3d35ad286bf2b28352d4008e5ca26dc554743c517c3e68fb048b88af1aa3ce831446e805b27f3
|
7
|
+
data.tar.gz: 5b875304bd33102d38916c68f5381605922cb85fb5eff75b00aff1fd5a2030520d0d82853839070e737d8163f7c594431ad8555c49aa713bbec216043f61c7b9
|
@@ -3,52 +3,5 @@ require "diaspora_federation/test/factories"
|
|
3
3
|
module DiasporaFederation
|
4
4
|
# This module encapsulates helper functions maybe wanted by a testsuite of a diaspora_federation gem user application
|
5
5
|
module Test
|
6
|
-
# Sort hash according to an entity class's property sequence.
|
7
|
-
# This is used for rspec tests in order to generate correct input hash to
|
8
|
-
# compare results with.
|
9
|
-
#
|
10
|
-
# @param [Hash] data input hash for sorting
|
11
|
-
# @param [Entity.Class] klass entity type to sort according to
|
12
|
-
# @return [Hash] sorted hash
|
13
|
-
def self.sort_hash(data, klass)
|
14
|
-
Hash[klass.class_props.map { |prop|
|
15
|
-
[prop[:name], data[prop[:name]]] unless data[prop[:name]].nil?
|
16
|
-
}.compact]
|
17
|
-
end
|
18
|
-
|
19
|
-
# Generates attributes for entity constructor with correct signatures in it
|
20
|
-
#
|
21
|
-
# @param [Symbol] factory_name the factory to generate attributes for (normally entity name)
|
22
|
-
# @return [Hash] hash with correct signatures
|
23
|
-
def self.relayable_attributes_with_signatures(factory_name)
|
24
|
-
klass = FactoryGirl.factory_by_name(factory_name).build_class
|
25
|
-
sort_hash(FactoryGirl.attributes_for(factory_name), klass).tap do |data|
|
26
|
-
DiasporaFederation::Entities::Relayable.update_signatures!(data, klass)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
# Generates attributes for signed retraction entity constructor with correct signatures in it
|
31
|
-
#
|
32
|
-
# @return [Hash] hash with correct signatures
|
33
|
-
def self.signed_retraction_attributes_with_signatures
|
34
|
-
sort_hash(FactoryGirl.attributes_for(:signed_retraction_entity), Entities::SignedRetraction).tap do |data|
|
35
|
-
Entities::SignedRetraction.update_signatures!(data)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
# Generates attributes for relayable retraction entity constructor with correct signatures in it
|
40
|
-
#
|
41
|
-
# @return [Hash] hash with correct signatures
|
42
|
-
def self.relayable_retraction_attributes_with_signatures
|
43
|
-
sort_hash(
|
44
|
-
FactoryGirl.attributes_for(
|
45
|
-
:relayable_retraction_entity,
|
46
|
-
target_author_signature: "false sig"
|
47
|
-
),
|
48
|
-
Entities::RelayableRetraction
|
49
|
-
).tap do |data|
|
50
|
-
Entities::RelayableRetraction.update_signatures!(data)
|
51
|
-
end
|
52
|
-
end
|
53
6
|
end
|
54
7
|
end
|
@@ -3,7 +3,9 @@ require "factory_girl"
|
|
3
3
|
|
4
4
|
module DiasporaFederation
|
5
5
|
module Test
|
6
|
+
# Factories for federation entities
|
6
7
|
module Factories
|
8
|
+
# defines the federation entity factories
|
7
9
|
def self.federation_factories
|
8
10
|
FactoryGirl.define do
|
9
11
|
initialize_with { new(attributes) }
|
@@ -40,16 +42,16 @@ module DiasporaFederation
|
|
40
42
|
|
41
43
|
factory :person_entity, class: DiasporaFederation::Entities::Person do
|
42
44
|
guid
|
43
|
-
diaspora_id
|
45
|
+
author { generate(:diaspora_id) }
|
44
46
|
url "http://localhost:3000/"
|
45
47
|
exported_key { generate(:public_key) }
|
46
48
|
profile {
|
47
|
-
FactoryGirl.build(:profile_entity,
|
49
|
+
FactoryGirl.build(:profile_entity, author: author)
|
48
50
|
}
|
49
51
|
end
|
50
52
|
|
51
53
|
factory :profile_entity, class: DiasporaFederation::Entities::Profile do
|
52
|
-
diaspora_id
|
54
|
+
author { generate(:diaspora_id) }
|
53
55
|
first_name "my name"
|
54
56
|
last_name nil
|
55
57
|
image_url "/assets/user/default.png"
|
@@ -72,7 +74,7 @@ module DiasporaFederation
|
|
72
74
|
|
73
75
|
factory :photo_entity, class: DiasporaFederation::Entities::Photo do
|
74
76
|
guid
|
75
|
-
diaspora_id
|
77
|
+
author { generate(:diaspora_id) }
|
76
78
|
public(true)
|
77
79
|
created_at { Time.now.utc }
|
78
80
|
remote_photo_path "https://diaspora.example.tld/uploads/images/"
|
@@ -89,84 +91,91 @@ module DiasporaFederation
|
|
89
91
|
|
90
92
|
factory :participation_entity,
|
91
93
|
class: DiasporaFederation::Entities::Participation, parent: :relayable_entity do
|
94
|
+
author { generate(:diaspora_id) }
|
92
95
|
guid
|
93
|
-
|
94
|
-
diaspora_id
|
96
|
+
parent_type "Post"
|
95
97
|
end
|
96
98
|
|
97
99
|
factory :status_message_entity, class: DiasporaFederation::Entities::StatusMessage do
|
98
100
|
raw_message "i am a very interesting status update"
|
101
|
+
author { generate(:diaspora_id) }
|
99
102
|
guid
|
100
|
-
diaspora_id
|
101
103
|
public(true)
|
102
104
|
created_at { Time.now.utc }
|
103
105
|
end
|
104
106
|
|
105
107
|
factory :request_entity, class: DiasporaFederation::Entities::Request do
|
106
|
-
|
107
|
-
|
108
|
+
author { generate(:diaspora_id) }
|
109
|
+
recipient { generate(:diaspora_id) }
|
110
|
+
end
|
111
|
+
|
112
|
+
factory :contact_entity, class: DiasporaFederation::Entities::Contact do
|
113
|
+
author { generate(:diaspora_id) }
|
114
|
+
recipient { generate(:diaspora_id) }
|
115
|
+
following true
|
116
|
+
sharing true
|
108
117
|
end
|
109
118
|
|
110
119
|
factory :comment_entity, class: DiasporaFederation::Entities::Comment, parent: :relayable_entity do
|
120
|
+
author { generate(:diaspora_id) }
|
111
121
|
guid
|
112
122
|
text "this is a very informative comment"
|
113
|
-
diaspora_id
|
114
123
|
end
|
115
124
|
|
116
125
|
factory :like_entity, class: DiasporaFederation::Entities::Like, parent: :relayable_entity do
|
117
126
|
positive true
|
127
|
+
author { generate(:diaspora_id) }
|
118
128
|
guid
|
119
|
-
|
120
|
-
diaspora_id
|
129
|
+
parent_type "Post"
|
121
130
|
end
|
122
131
|
|
123
132
|
factory :account_deletion_entity, class: DiasporaFederation::Entities::AccountDeletion do
|
124
|
-
diaspora_id
|
133
|
+
author { generate(:diaspora_id) }
|
125
134
|
end
|
126
135
|
|
127
136
|
factory :conversation_entity, class: DiasporaFederation::Entities::Conversation do
|
137
|
+
author { generate(:diaspora_id) }
|
128
138
|
guid
|
129
139
|
subject "this is a very informative subject"
|
130
140
|
created_at { Time.now.utc }
|
131
141
|
messages []
|
132
|
-
diaspora_id
|
133
|
-
participant_ids { 3.times.map { generate(:diaspora_id) }.join(";") }
|
142
|
+
participants { Array.new(3) { generate(:diaspora_id) }.join(";") }
|
134
143
|
end
|
135
144
|
|
136
145
|
factory :message_entity, class: DiasporaFederation::Entities::Message, parent: :relayable_entity do
|
137
146
|
guid
|
147
|
+
author { generate(:diaspora_id) }
|
138
148
|
text "this is a very informative text"
|
139
149
|
created_at { Time.now.utc }
|
140
|
-
diaspora_id
|
141
150
|
conversation_guid { generate(:guid) }
|
142
151
|
end
|
143
152
|
|
144
153
|
factory :relayable_retraction_entity, class: DiasporaFederation::Entities::RelayableRetraction do
|
154
|
+
author { generate(:diaspora_id) }
|
145
155
|
target_guid { generate(:guid) }
|
146
156
|
target_type "Comment"
|
147
|
-
diaspora_id
|
148
157
|
end
|
149
158
|
|
150
159
|
factory :reshare_entity, class: DiasporaFederation::Entities::Reshare do
|
151
|
-
|
160
|
+
root_author { generate(:diaspora_id) }
|
152
161
|
root_guid { generate(:guid) }
|
153
162
|
guid
|
154
|
-
diaspora_id
|
163
|
+
author { generate(:diaspora_id) }
|
155
164
|
public(true)
|
156
165
|
created_at { Time.now.utc }
|
157
166
|
provider_display_name { "the testsuite" }
|
158
167
|
end
|
159
168
|
|
160
169
|
factory :retraction_entity, class: DiasporaFederation::Entities::Retraction do
|
170
|
+
author { generate(:diaspora_id) }
|
161
171
|
target_guid { generate(:guid) }
|
162
|
-
diaspora_id
|
163
172
|
target_type "Post"
|
164
173
|
end
|
165
174
|
|
166
175
|
factory :signed_retraction_entity, class: DiasporaFederation::Entities::SignedRetraction do
|
176
|
+
author { generate(:diaspora_id) }
|
167
177
|
target_guid { generate(:guid) }
|
168
178
|
target_type "Post"
|
169
|
-
diaspora_id
|
170
179
|
end
|
171
180
|
|
172
181
|
factory :poll_answer_entity, class: DiasporaFederation::Entities::PollAnswer do
|
@@ -177,13 +186,13 @@ module DiasporaFederation
|
|
177
186
|
factory :poll_entity, class: DiasporaFederation::Entities::Poll do
|
178
187
|
guid
|
179
188
|
question { "Select an answer" }
|
180
|
-
poll_answers { 3
|
189
|
+
poll_answers { Array.new(3) { FactoryGirl.build(:poll_answer_entity) } }
|
181
190
|
end
|
182
191
|
|
183
192
|
factory :poll_participation_entity,
|
184
193
|
class: DiasporaFederation::Entities::PollParticipation, parent: :relayable_entity do
|
194
|
+
author { generate(:diaspora_id) }
|
185
195
|
guid
|
186
|
-
diaspora_id
|
187
196
|
poll_answer_guid { generate(:guid) }
|
188
197
|
end
|
189
198
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: diaspora_federation-test
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Benjamin Neff
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: diaspora_federation
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.0.
|
19
|
+
version: 0.0.13
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.0.
|
26
|
+
version: 0.0.13
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: factory_girl
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|