-
Notifications
You must be signed in to change notification settings - Fork 0
/
repositories_controller_test.rb
61 lines (44 loc) · 1.22 KB
/
repositories_controller_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
# frozen_string_literal: true
require 'test_helper'
class Web::RepositoriesControllerTest < ActionDispatch::IntegrationTest
setup do
@user = users(:jane)
@repository = repositories(:node)
sign_in @user
end
test '#index' do
get repositories_path
assert_response :success
end
test '#new' do
get new_repository_path
assert_response :success
end
test '#show' do
get repository_path(@repository)
assert_response :success
end
test '#create' do
response = load_fixture('files/repo_javascript.json')
uri_template = Addressable::Template.new 'https://api.github.com/repos/{user}/{repo}'
stub_request(:get, uri_template)
.to_return(
status: 200,
body: response,
headers: { content_type: 'application/json' }
)
attrs = {
github_id: 307_194_079
}
post repositories_path, params: { repository: attrs }
repository = Repository.find_by attrs
assert { repository.present? }
assert_redirected_to repository_path(repository)
end
test '#destroy' do
delete repository_path(@repository)
assert_response :redirect
repository = Repository.find_by id: @repository.id
assert { repository.blank? }
end
end