Skip to content

Commit 7d11b30

Browse files
committed
Adds tests to other RepoController's actions
1 parent 360ebc3 commit 7d11b30

File tree

2 files changed

+41
-11
lines changed

2 files changed

+41
-11
lines changed

test/fixtures/repos.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ scene_hub_v2:
7373
issues_count: 0
7474

7575
deleted_repo:
76-
user_name: repo
76+
user_name: empty
7777
name: deleted
78-
full_name: repo/deleted
78+
full_name: empty/deleted
7979
language: Ruby
8080
created_at: 2014-12-19T02:33:42Z
8181
updated_at: 2015-01-21T22:08:43Z
@@ -84,9 +84,9 @@ deleted_repo:
8484

8585

8686
archived_repo:
87-
user_name: repo
87+
user_name: empty
8888
name: archived
89-
full_name: repo/archived
89+
full_name: empty/archived
9090
language: Ruby
9191
created_at: 2014-12-19T02:33:42Z
9292
updated_at: 2015-01-21T22:08:43Z

test/integration/repos_test.rb

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,48 @@ class ReposTest < ActionDispatch::IntegrationTest
2828
)
2929
end
3030

31-
test "valid repo" do
31+
test "access valid repo" do
3232
get repo_url 'rails/rails'
3333
assert_response :success
3434
end
3535

36-
test "deleted_from_github repo" do
37-
get repo_url 'repo/deleted'
38-
assert_redirected_to new_repo_url(user_name: 'repo', name: 'deleted')
36+
test "access deleted_from_github repo" do
37+
get repo_url 'empty/deleted'
38+
assert_redirected_to new_repo_url(user_name: 'empty', name: 'deleted')
3939
end
4040

41-
test "archived repo" do
42-
get repo_url 'repo/archived'
43-
assert_redirected_to new_repo_url(user_name: 'repo', name: 'archived')
41+
test "access archived repo" do
42+
get repo_url 'empty/archived'
43+
assert_redirected_to new_repo_url(user_name: 'empty', name: 'archived')
44+
end
45+
46+
test "edit repo where user is not the owner" do
47+
login_as(users(:empty))
48+
get edit_repo_url 'rails/rails'
49+
assert_redirected_to root_path
50+
end
51+
52+
test "edit deleted_from_github repo" do
53+
login_as(users(:empty))
54+
get edit_repo_url 'empty/deleted'
55+
assert_response :success
56+
end
57+
58+
test "edit archived repo" do
59+
login_as(users(:empty))
60+
get edit_repo_url 'empty/archived'
61+
assert_response :success
62+
end
63+
64+
test "update repo" do
65+
login_as(users(:empty))
66+
repo = repos(:archived_repo)
67+
assert_changes -> {
68+
repo.notes
69+
} do
70+
patch repo_url 'empty/archived', params: { repo: { notes: 'Updated notes' } }
71+
repo.reload
72+
end
73+
assert_redirected_to repo_url 'empty/archived'
4474
end
4575
end

0 commit comments

Comments
 (0)