followers_steps.rb
1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
Given /^the user "(.+)" has the following categories to follow$/ do |user_name,table|
person = User.find_by(:login => user_name).person
table.hashes.each do |category|
Circle.create!(:person => person, :name => category[:name])
end
end
Then /^"(.+)" should be a follower of "(.+)" (?:with no category|with category "(.+)")$/ do |person, profile, category|
profile = Profile.find_by(identifier: profile)
followers = profile.followers
person = Person.find_by(identifier: person)
followers.should include(person)
# TODO fix profile follower follower
if category
ProfileFollower.find_by(:follower => person, :profile => profile).follow_category.name.should == category
else
ProfileFollower.find_by(:follower => person, :profile => profile).follow_category.should == nil
end
end
Then /^"(.+)" should not be a follower of "(.+)"$/ do |person, profile|
profile = Profile.find_by(identifier: profile)
followers = profile.followers
person = Person.find_by(identifier: person)
followers.should_not include(person)
end
Given /^"(.+)" is a follower of "(.+)" (?:with no category|with category "(.+)")$/ do |person, profile, category|
profile = Profile.find_by(identifier: profile)
person = Person.find_by(identifier: person)
params = {:follower => person, :profile => profile}
# TODO fix profile follower follower
if category
category = Circle.find_by(:name => category, :person => person)
params.merge!({:follow_category => category})
end
ProfileFollower.create!(params)
end