summaryrefslogtreecommitdiff
path: root/features/messages.feature
blob: 69c56372160ac4d3f810318a6b0e80c89eebeea9 (plain)
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
Feature: Receive messages for the user

  In order to stay in touch with the provider
  As an authenticated user
  I want to receive messages from the provider

  Background:
    Given I authenticated
    Given I set headers:
      | Accept       | application/json |
      | Content-Type | application/json |
      | Authorization | Token token="MY_AUTH_TOKEN" |

  Scenario: There are no messages yet
    When I send a GET request to "/1/messages.json"
    Then the response status should be "200"
    And the response should be:
      """
      []
      """

  Scenario: Fetch the unread messages
    Given there is a message for me with:
      | id   | 1a2b3c4d |
      | text | Your provider says hi ! |
    When I send a GET request to "/1/messages.json"
    Then the response status should be "200"
    And the response should be:
      """
      [{
       "id": "1a2b3c4d",
       "text": "Your provider says hi !"
      }]
      """

  Scenario: Send unread messages until marked as read
    Given there is a message for me
    And I have sent a GET request to "/1/messages.json"
    When I send a GET request to "/1/messages.json"
    Then the response status should be "200"
    And the response should include that message

  Scenario: Mark message as read
    Given there is a message for me with:
      | id   | 1a2b3c4d |
    When I send a PUT request to "/1/messages/1a2b3c4d.json"
    Then that message should be marked as read
    And the response status should be "200"
    And the response should have "success" with "marked_as_read"
    And the response should have "message"

  Scenario: Message not found
    When I send a PUT request to "/1/messages/1a2b3c4d.json"
    Then the response status should be "404"
    And the response should have "error" with "not_found"
    And the response should have "message"

  Scenario: Do not send read messages
    Given there is a message for me
    And that message is marked as read
    When I send a GET request to "/1/messages.json"
    Then the response status should be "200"
    And the response should be:
      """
      []
      """