forked from hotsh/rstat.us
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfollowing_remote_users_test.rb
100 lines (78 loc) · 2.63 KB
/
following_remote_users_test.rb
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
require 'require_relative' if RUBY_VERSION[0,3] == '1.8'
require_relative 'acceptance_helper'
describe "following remote users" do
include AcceptanceHelper
def follow_remote_user!(webfinger_id = "[email protected]")
visit "/"
click_link "Follow Remote User"
VCR.use_cassette('subscribe_remote') do
fill_in 'subscribe_to', :with => webfinger_id
click_button "Follow"
end
end
describe "success" do
before do
log_in_as_some_user
end
it "follows users on other sites" do
follow_remote_user!
assert "/", current_path
within flash do
assert has_content? "Now following steveklabnik."
end
end
it "has users on other sites on /following" do
follow_remote_user!
visit "/users/#{@u.username}/following"
within "#content" do
assert has_content? "steveklabnik"
end
end
it "unfollows users from other sites" do
follow_remote_user!
visit "/users/#{@u.username}/following"
VCR.use_cassette('unsubscribe_remote') do
click_button "Unfollow"
end
within flash do
assert has_content? "No longer following steveklabnik"
end
end
it "doesn't follow those you already follow, and reports an error" do
follow_remote_user!
follow_remote_user!
within flash do
assert has_content? "You're already following steveklabnik."
end
end
end
describe "failure" do
before do
log_in_as_some_user
end
it "doesn't look up something that doesn't look like either a webfinger id or a URL" do
visit "/"
click_link "Follow Remote User"
follow_remote_page = page.current_url
fill_in 'subscribe_to', :with => "justinbieber"
click_button "Follow"
# Should still be on this page
page.current_url.must_equal(follow_remote_page)
within flash do
assert has_content?("There was a problem following justinbieber. Please specify the whole ID for the person you would like to follow, including both their username and the domain of the site they're on. It should look like an email address-- for example, [email protected]")
end
end
it "especially doesn't look up something that looks like a local file" do
visit "/"
click_link "Follow Remote User"
follow_remote_page = page.current_url
fill_in 'subscribe_to', :with => "Gemfile"
click_button "Follow"
# Should still be on this page
page.current_url.must_equal(follow_remote_page)
within flash do
assert has_content?("There was a problem following Gemfile.")
end
end
end
end