Skip to content

Commit 9fa90ea

Browse files
committed
Increase test coverage to 58.31%
1 parent a3bbe5f commit 9fa90ea

File tree

6 files changed

+137
-2
lines changed

6 files changed

+137
-2
lines changed

spec/factories/better_together/resource_permissions.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
factory :better_together_resource_permission,
77
class: 'BetterTogether::ResourcePermission',
88
aliases: %i[resource_permission] do
9-
action { 'MyString' }
10-
resource_type { 'MyString' }
9+
action { BetterTogether::ResourcePermission::ACTIONS.sample }
10+
resource_type { BetterTogether::Resourceful::RESOURCE_CLASSES.sample }
11+
# Derive target from the resource_type (e.g., 'BetterTogether::Community' => 'community')
12+
target { resource_type.demodulize.underscore }
1113
end
1214
end
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# frozen_string_literal: true
2+
3+
require 'rails_helper'
4+
5+
RSpec.describe 'BetterTogether::CalendarsController', type: :request do
6+
let(:locale) { I18n.default_locale }
7+
8+
before do
9+
configure_host_platform
10+
login('[email protected]', 'password12345')
11+
end
12+
13+
it 'renders index' do
14+
get better_together.calendars_path(locale:)
15+
expect(response).to have_http_status(:ok)
16+
end
17+
end
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# frozen_string_literal: true
2+
3+
require 'rails_helper'
4+
5+
RSpec.describe 'BetterTogether::CommunitiesController', type: :request do # rubocop:todo Metrics/BlockLength
6+
let(:locale) { I18n.default_locale }
7+
8+
before do
9+
configure_host_platform
10+
login('[email protected]', 'password12345')
11+
end
12+
13+
describe 'GET /:locale/.../host/communities' do
14+
it 'renders index' do
15+
get better_together.communities_path(locale:)
16+
expect(response).to have_http_status(:found)
17+
end
18+
19+
it 'renders show for a community' do
20+
community = create(:better_together_community)
21+
get better_together.community_path(locale:, id: community.slug)
22+
expect(response).to have_http_status(:found)
23+
end
24+
end
25+
26+
describe 'PATCH /:locale/.../host/communities/:id' do
27+
it 'updates and redirects' do
28+
community = create(:better_together_community)
29+
patch better_together.community_path(locale:, id: community.slug), params: {
30+
community: { privacy: 'public', name_en: 'Updated Name' }
31+
}
32+
expect(response).to have_http_status(:found)
33+
follow_redirect!
34+
expect(response).to have_http_status(:ok)
35+
end
36+
end
37+
end
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# frozen_string_literal: true
2+
3+
require 'rails_helper'
4+
5+
RSpec.describe 'BetterTogether::ResourcePermissionsController', type: :request do
6+
let(:locale) { I18n.default_locale }
7+
8+
before do
9+
configure_host_platform
10+
login('[email protected]', 'password12345')
11+
end
12+
13+
describe 'GET /:locale/.../host/permissions' do
14+
it 'renders index' do
15+
get better_together.resource_permissions_path(locale:)
16+
expect(response).to have_http_status(:ok)
17+
end
18+
19+
it 'renders show for a permission' do
20+
permission = create(:better_together_resource_permission)
21+
get better_together.resource_permission_path(locale:, id: permission.slug)
22+
expect(response).to have_http_status(:ok)
23+
end
24+
end
25+
end
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# frozen_string_literal: true
2+
3+
require 'rails_helper'
4+
5+
RSpec.describe 'BetterTogether::RolesController', type: :request do # rubocop:todo Metrics/BlockLength
6+
let(:locale) { I18n.default_locale }
7+
8+
before do
9+
configure_host_platform
10+
login('[email protected]', 'password12345')
11+
end
12+
13+
describe 'GET /:locale/.../host/roles' do
14+
it 'renders index' do
15+
get better_together.roles_path(locale:)
16+
expect(response).to have_http_status(:ok)
17+
end
18+
19+
it 'renders show for a role' do
20+
role = create(:better_together_role)
21+
get better_together.role_path(locale:, id: role.slug)
22+
expect(response).to have_http_status(:ok)
23+
end
24+
end
25+
26+
describe 'PATCH /:locale/.../host/roles/:id' do
27+
it 'updates and redirects' do
28+
role = create(:better_together_role, protected: false)
29+
patch better_together.role_path(locale:, id: role.slug), params: {
30+
role: { name: 'New Name' }
31+
}
32+
expect(response).to have_http_status(:see_other)
33+
follow_redirect!
34+
expect(response).to have_http_status(:ok)
35+
end
36+
end
37+
end
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# frozen_string_literal: true
2+
3+
require 'rails_helper'
4+
5+
RSpec.describe 'BetterTogether::SearchController', type: :request do
6+
let(:locale) { I18n.default_locale }
7+
8+
before do
9+
configure_host_platform
10+
login('[email protected]', 'password12345')
11+
end
12+
13+
it 'renders search results page' do
14+
get better_together.search_path(locale:), params: { q: 'test' }
15+
expect(response).to have_http_status(:ok)
16+
end
17+
end

0 commit comments

Comments
 (0)