Skip to content

Commit d42350f

Browse files
committed
only see messages sent to me
1 parent 06c9526 commit d42350f

3 files changed

Lines changed: 35 additions & 16 deletions

File tree

features/messages.feature

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,4 @@
11
Feature: Messages
2-
Scenario: I can't send a message when not logged in
3-
Given I'm not logged in
4-
And there's a hacker with the username "fela"
5-
When I go to the hacker page for "fela"
6-
Then I should not see "Send fela a message"
7-
Scenario: I can see messages sent to me
8-
Given I'm logged in as "steve"
9-
And I send a message to "fela" that says "Hello, fela!"
10-
And I log out
11-
When I log in as "fela"
12-
And I go to my messages page
13-
Then I should see "Hello, fela!"
14-
And I should see "From: steve"
152
Scenario: I should have an inbox link
163
Given I'm logged in
174
Then I should see "Inbox"

spec/acceptance/messages_spec.rb

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22

33
feature "Messages" do
44

5-
background do
5+
scenario "can be sent" do
66
Pony.should_receive(:deliver)
7-
end
87

9-
scenario "can be sent" do
108
@hacker = Factory(:hacker)
119
log_in @hacker
1210

@@ -22,4 +20,35 @@
2220
should_be_on "/hackers/fela"
2321
page.should have_content "Message sent."
2422
end
23+
24+
25+
scenario "can only be sent when logged in" do
26+
@hacker = Factory(:hacker)
27+
visit "/logout"
28+
29+
@fela = Factory(:hacker, :username => "fela")
30+
31+
visit "/hackers/fela"
32+
page.should_not have_content "Send fela a message"
33+
end
34+
35+
scenario "can only see messages sent to me" do
36+
Pony.should_receive(:deliver)
37+
@steve = Factory(:hacker, :username => "steve")
38+
@fela = Factory(:hacker, :username => "fela")
39+
40+
Factory(:message,
41+
:sender => @steve.username,
42+
:recipient => @fela.username,
43+
:body => "Hello, fela!")
44+
45+
visit "/logout"
46+
47+
log_in @fela
48+
49+
visit "/messages"
50+
51+
page.should have_content "Hello, fela!"
52+
page.should have_content "From: steve"
53+
end
2554
end

spec/factories.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@
1515
u.password_confirmation {|user| user.password }
1616
u.admin false
1717
end
18+
19+
Factory.define :message do |m|
20+
end

0 commit comments

Comments
 (0)