Skip to content

Commit 1695205

Browse files
committed
Increased test coverage
1 parent 0cbd524 commit 1695205

File tree

4 files changed

+129
-0
lines changed

4 files changed

+129
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# frozen_string_literal: true
2+
3+
require 'rails_helper'
4+
5+
RSpec.describe 'BetterTogether::Geography::RegionSettlementsController', 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/geography/region_settlements' do
14+
it 'renders index' do
15+
get better_together.geography_region_settlements_path(locale:)
16+
expect(response).to have_http_status(:ok)
17+
end
18+
end
19+
20+
describe 'GET /:locale/.../host/geography/region_settlements/:id' do
21+
let!(:region_settlement) { create(:region_settlement) }
22+
23+
it 'renders show' do
24+
get better_together.geography_region_settlement_path(locale:, id: region_settlement.id)
25+
expect(response).to have_http_status(:ok)
26+
end
27+
end
28+
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::Metrics::LinkClickReportsController download', 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 'downloads an attached report file' do
14+
report = BetterTogether::Metrics::LinkClickReport.create!(file_format: 'csv')
15+
report.report_file.attach(
16+
io: StringIO.new('a,b\n1,2\n'),
17+
filename: 'report.csv',
18+
content_type: 'text/csv'
19+
)
20+
21+
get better_together.download_metrics_link_click_report_path(locale:, id: report.id)
22+
expect(response).to have_http_status(:ok)
23+
expect(response.header['Content-Type']).to include('text/csv')
24+
end
25+
end
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# frozen_string_literal: true
2+
3+
require 'rails_helper'
4+
5+
RSpec.describe 'BetterTogether::PeopleController', 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/p/:id' do
14+
let!(:person) { create(:better_together_person) }
15+
16+
it 'renders show' do
17+
get better_together.person_path(locale:, id: person.slug)
18+
expect(response).to have_http_status(:ok)
19+
end
20+
21+
it 'renders edit' do
22+
get better_together.edit_person_path(locale:, id: person.slug)
23+
expect(response).to have_http_status(:ok)
24+
end
25+
end
26+
27+
describe 'PATCH /:locale/.../host/p/:id' do
28+
let!(:person) { create(:better_together_person) }
29+
30+
it 'updates name and redirects' do
31+
patch better_together.person_path(locale:, id: person.slug), params: {
32+
person: { name: 'Updated Name' }
33+
}
34+
expect(response).to have_http_status(:see_other)
35+
follow_redirect!
36+
expect(response).to have_http_status(:ok)
37+
end
38+
end
39+
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::PlatformsController', 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/platforms' do
14+
it 'renders index' do
15+
get better_together.platforms_path(locale:)
16+
expect(response).to have_http_status(:ok)
17+
end
18+
19+
it 'renders show for host platform' do
20+
host_platform = BetterTogether::Platform.find_by(host: true)
21+
get better_together.platform_path(locale:, id: host_platform.slug)
22+
expect(response).to have_http_status(:ok)
23+
end
24+
end
25+
26+
describe 'PATCH /:locale/.../host/platforms/:id' do
27+
it 'updates settings and redirects' do
28+
host_platform = BetterTogether::Platform.find_by(host: true)
29+
patch better_together.platform_path(locale:, id: host_platform.slug), params: {
30+
platform: { url: host_platform.url, time_zone: host_platform.time_zone, requires_invitation: true }
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

0 commit comments

Comments
 (0)