-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from Dainii/improve-tests
Improve test suite
- Loading branch information
Showing
22 changed files
with
724 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,4 +16,6 @@ class BaseJob < ApplicationJob | |
def name | ||
'Undefined' | ||
end | ||
|
||
def perform; end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe FeedbackUploadsController do | ||
context 'with an unauthenticated user' do | ||
describe 'GET /feedback_uploads/new' do | ||
before do | ||
get :new | ||
end | ||
|
||
it { is_expected.to respond_with(302) } | ||
end | ||
|
||
describe 'POST /feedback_uploads' do | ||
context 'with valid params' do | ||
before do | ||
post :create, params: { | ||
archives: file_fixture_upload( | ||
Rails.root.join('spec', 'examples', 'reports', 'report_google.com.xml'), | ||
'text/xml' | ||
) | ||
} | ||
end | ||
|
||
it { is_expected.to respond_with(302) } | ||
end | ||
end | ||
end | ||
|
||
context 'with an authenticated user' do | ||
let(:account) { Account.create!(email: 'user@example.com', password: 'secret123', status: 2) } | ||
|
||
before do | ||
sign_in(account) | ||
end | ||
|
||
def sign_in(account) | ||
@controller.rodauth.account_from_login(account.email) # rubocop:disable RSpec/InstanceVariable | ||
@controller.rodauth.login_session('secret123') # rubocop:disable RSpec/InstanceVariable | ||
end | ||
|
||
describe 'GET /feedback_uploads/new' do | ||
before do | ||
get :new | ||
end | ||
|
||
it { is_expected.to respond_with(200) } | ||
end | ||
|
||
describe 'POST /feedback_uploads' do | ||
context 'with valid params' do | ||
before do | ||
post :create, params: { | ||
feedback_upload: { | ||
archives: file_fixture_upload( | ||
Rails.root.join('spec', 'examples', 'reports', 'report_google.com.xml'), | ||
'text/xml' | ||
) | ||
} | ||
} | ||
end | ||
|
||
it { is_expected.to respond_with(302) } | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe FeedbacksController do | ||
context 'with an unauthenticated user' do | ||
let(:domain) { Domain.create!(name: 'controller.domain') } | ||
let(:feedback) { Feedback.create!(domain:) } | ||
|
||
describe 'GET /domains/:domain_id/feedbacks/:id' do | ||
before do | ||
get :show, params: { domain_id: domain.id, id: feedback.id } | ||
end | ||
|
||
it { is_expected.to respond_with(302) } | ||
it { is_expected.to use_before_action(:set_feedback) } | ||
end | ||
end | ||
|
||
context 'with an authenticated user' do | ||
let(:account) { Account.create!(email: 'user@example.com', password: 'secret123', status: 2) } | ||
let(:domain) { Domain.create!(name: 'controller.domain') } | ||
let(:feedback) { Feedback.create!(domain:) } | ||
|
||
before do | ||
sign_in(account) | ||
end | ||
|
||
def sign_in(account) | ||
@controller.rodauth.account_from_login(account.email) # rubocop:disable RSpec/InstanceVariable | ||
@controller.rodauth.login_session('secret123') # rubocop:disable RSpec/InstanceVariable | ||
end | ||
|
||
describe 'GET /domains/:domain_id/feedbacks/:id' do | ||
before do | ||
get :show, params: { domain_id: domain.id, id: feedback.id } | ||
end | ||
|
||
it { is_expected.to respond_with(200) } | ||
it { is_expected.to use_before_action(:set_feedback) } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe JobsController do | ||
context 'with an unauthenticated user' do | ||
let(:job) do | ||
sq_job = SolidQueue::Job.create(queue_name: 'default', class_name: 'BaseJob') | ||
|
||
Job.create!( | ||
job_id: '123456789', | ||
name: 'test job', | ||
solid_queue_job: sq_job | ||
) | ||
end | ||
|
||
describe 'GET /jobs' do | ||
before do | ||
get :index | ||
end | ||
|
||
it { is_expected.to respond_with(302) } | ||
end | ||
|
||
describe 'GET /jobs/:id' do | ||
before do | ||
get :show, params: { id: job.id } | ||
end | ||
|
||
it { is_expected.to respond_with(302) } | ||
it { is_expected.to use_before_action(:set_job) } | ||
end | ||
end | ||
|
||
context 'with an authenticated user' do | ||
let(:job) do | ||
sq_job = SolidQueue::Job.create(queue_name: 'default', class_name: 'BaseJob') | ||
|
||
Job.create!( | ||
job_id: '123456789', | ||
name: 'test job', | ||
solid_queue_job: sq_job | ||
) | ||
end | ||
let(:account) { Account.create!(email: 'user@example.com', password: 'secret123', status: 2) } | ||
|
||
before do | ||
sign_in(account) | ||
end | ||
|
||
def sign_in(account) | ||
@controller.rodauth.account_from_login(account.email) # rubocop:disable RSpec/InstanceVariable | ||
@controller.rodauth.login_session('secret123') # rubocop:disable RSpec/InstanceVariable | ||
end | ||
|
||
describe 'GET /' do | ||
before do | ||
get :index | ||
end | ||
|
||
it { is_expected.to respond_with(200) } | ||
end | ||
|
||
describe 'GET /jobs/:id' do | ||
before do | ||
get :show, params: { id: job.id } | ||
end | ||
|
||
it { is_expected.to respond_with(200) } | ||
it { is_expected.to use_before_action(:set_job) } | ||
end | ||
end | ||
end |
Oops, something went wrong.