about summary refs log tree commit diff
path: root/spec/routing/api_routing_spec.rb
blob: 2683ccb8d121e0dd64985350b07aee7c57819d1a (plain) (blame)
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
101
102
103
# frozen_string_literal: true

require 'rails_helper'

describe 'API routes' do
  describe 'Credentials routes' do
    it 'routes to verify credentials' do
      expect(get('/api/v1/accounts/verify_credentials')).
        to route_to('api/v1/accounts/credentials#show')
    end

    it 'routes to update credentials' do
      expect(patch('/api/v1/accounts/update_credentials')).
        to route_to('api/v1/accounts/credentials#update')
    end
  end

  describe 'Account routes' do
    it 'routes to statuses' do
      expect(get('/api/v1/accounts/user/statuses')).
        to route_to('api/v1/accounts/statuses#index', account_id: 'user')
    end

    it 'routes to followers' do
      expect(get('/api/v1/accounts/user/followers')).
        to route_to('api/v1/accounts/follower_accounts#index', account_id: 'user')
    end

    it 'routes to following' do
      expect(get('/api/v1/accounts/user/following')).
        to route_to('api/v1/accounts/following_accounts#index', account_id: 'user')
    end

    it 'routes to search' do
      expect(get('/api/v1/accounts/search')).
        to route_to('api/v1/accounts/search#show')
    end

    it 'routes to relationships' do
      expect(get('/api/v1/accounts/relationships')).
        to route_to('api/v1/accounts/relationships#index')
    end
  end

  describe 'Statuses routes' do
    it 'routes reblogged_by' do
      expect(get('/api/v1/statuses/123/reblogged_by')).
        to route_to('api/v1/statuses/reblogged_by_accounts#index', status_id: '123')
    end

    it 'routes favourited_by' do
      expect(get('/api/v1/statuses/123/favourited_by')).
        to route_to('api/v1/statuses/favourited_by_accounts#index', status_id: '123')
    end

    it 'routes reblog' do
      expect(post('/api/v1/statuses/123/reblog')).
        to route_to('api/v1/statuses/reblogs#create', status_id: '123')
    end

    it 'routes unreblog' do
      expect(post('/api/v1/statuses/123/unreblog')).
        to route_to('api/v1/statuses/reblogs#destroy', status_id: '123')
    end

    it 'routes favourite' do
      expect(post('/api/v1/statuses/123/favourite')).
        to route_to('api/v1/statuses/favourites#create', status_id: '123')
    end

    it 'routes unfavourite' do
      expect(post('/api/v1/statuses/123/unfavourite')).
        to route_to('api/v1/statuses/favourites#destroy', status_id: '123')
    end

    it 'routes mute' do
      expect(post('/api/v1/statuses/123/mute')).
        to route_to('api/v1/statuses/mutes#create', status_id: '123')
    end

    it 'routes unmute' do
      expect(post('/api/v1/statuses/123/unmute')).
        to route_to('api/v1/statuses/mutes#destroy', status_id: '123')
    end
  end

  describe 'Timeline routes' do
    it 'routes to home timeline' do
      expect(get('/api/v1/timelines/home')).
        to route_to('api/v1/timelines/home#show')
    end

    it 'routes to public timeline' do
      expect(get('/api/v1/timelines/public')).
        to route_to('api/v1/timelines/public#show')
    end

    it 'routes to tag timeline' do
      expect(get('/api/v1/timelines/tag/test')).
        to route_to('api/v1/timelines/tag#show', id: 'test')
    end
  end
end