Skip to content

Commit

Permalink
format code
Browse files Browse the repository at this point in the history
  • Loading branch information
jiangplus committed Sep 10, 2024
1 parent 5b3a539 commit 489a283
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
8 changes: 3 additions & 5 deletions test/controllers/api/group_controller_test.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
require "test_helper"

class Api::GroupControllerTest < ActionDispatch::IntegrationTest

test "api#group/create" do
profile = Profile.find_by(handle: "cookie")
auth_token = profile.gen_auth_token
Expand All @@ -11,7 +10,7 @@ class Api::GroupControllerTest < ActionDispatch::IntegrationTest
timezone: "asia/shanghai",
can_publish_event: "all",
can_join_event: "all",
can_view_event: "all",
can_view_event: "all"
} }
assert_response :success
group = Group.find_by(handle: "newworld")
Expand All @@ -30,7 +29,7 @@ class Api::GroupControllerTest < ActionDispatch::IntegrationTest

post api_group_update_url,
params: { auth_token: auth_token, id: group.id, group: {
timezone: "asia/hongkong",
timezone: "asia/hongkong"
} }
assert_response :success
end
Expand Down Expand Up @@ -277,7 +276,7 @@ class Api::GroupControllerTest < ActionDispatch::IntegrationTest

post api_group_send_invite_url,
params: { auth_token: auth_token, group_id: group.id,
receivers: [profile2.handle], role: 'member', message: "welcome" }
receivers: [ profile2.handle ], role: "member", message: "welcome" }
assert_response :success

group_invite = GroupInvite.find_by(receiver: profile2)
Expand All @@ -288,5 +287,4 @@ class Api::GroupControllerTest < ActionDispatch::IntegrationTest

assert group.is_member(profile2.id)
end

end
19 changes: 8 additions & 11 deletions test/controllers/api/group_invite_controller_test.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
require "test_helper"

class Api::GroupInviteControllerTest < ActionDispatch::IntegrationTest

test "api/group/send_invite" do
profile = Profile.find_by(handle: "cookie")
auth_token = profile.gen_auth_token
group = Group.find_by(handle: "guildx")

assert_difference 'GroupInvite.count', 1 do
assert_difference "GroupInvite.count", 1 do
post api_group_send_invite_url, params: {
auth_token: auth_token,
group_id: group.id,
role: "member",
receivers: ["mooncake"],
receivers: [ "mooncake" ],
message: "please join the group"
}
end
Expand All @@ -29,12 +28,12 @@ class Api::GroupInviteControllerTest < ActionDispatch::IntegrationTest

Membership.create(profile_id: profile2.id, group_id: group.id, role: "member", status: "active")

assert_difference 'GroupInvite.count', 0 do
assert_difference "GroupInvite.count", 0 do
post api_group_send_invite_url, params: {
auth_token: auth_token,
group_id: group.id,
role: "manager",
receivers: ["mooncake"],
receivers: [ "mooncake" ],
message: "please join the group"
}
end
Expand All @@ -50,12 +49,12 @@ class Api::GroupInviteControllerTest < ActionDispatch::IntegrationTest

Membership.create(profile_id: profile2.id, group_id: group.id, role: "manager", status: "active")

assert_difference 'GroupInvite.count', 0 do
assert_difference "GroupInvite.count", 0 do
post api_group_send_invite_url, params: {
auth_token: auth_token,
group_id: group.id,
role: "member",
receivers: ["mooncake"],
receivers: [ "mooncake" ],
message: "please join the group"
}
end
Expand All @@ -69,12 +68,12 @@ class Api::GroupInviteControllerTest < ActionDispatch::IntegrationTest
auth_token = profile.gen_auth_token
group = Group.find_by(handle: "guildx")

assert_difference 'GroupInvite.count', 1 do
assert_difference "GroupInvite.count", 1 do
post api_group_send_invite_url, params: {
auth_token: auth_token,
group_id: group.id,
role: "manager",
receivers: ["[email protected]"],
receivers: [ "[email protected]" ],
message: "please join the group"
}
end
Expand Down Expand Up @@ -162,7 +161,6 @@ class Api::GroupInviteControllerTest < ActionDispatch::IntegrationTest
assert_equal "requesting", group_invite.status
assert_equal "member", group_invite.role
assert_equal "I would like to join the group", group_invite.message

end

test "api/group/accept_request" do
Expand All @@ -185,5 +183,4 @@ class Api::GroupInviteControllerTest < ActionDispatch::IntegrationTest
assert membership
assert_equal "member", membership.role
end

end

0 comments on commit 489a283

Please sign in to comment.