-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update schema_cleaner.rb #118
Conversation
AlexeyMatskevich
commented
Jun 16, 2023
undefined method `empty?' for nil:NilClass
Codecov Report
@@ Coverage Diff @@
## master #118 +/- ##
=======================================
Coverage 65.88% 65.88%
=======================================
Files 31 31
Lines 686 686
=======================================
Hits 452 452
Misses 234 234
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Apply rubocop offenses
Would you elaborate the test code and OpenAPI file cause that error? |
Yes, i just run
I don't know with which openapi specs and with which tests (rspec) this happens, because the error occurs after the suite. |
I find some example ( I use Hanami 2.0 and rom.rb) # [openapi](openapi: {authenticate: true}) it's self written plugin for rspec-openapi
RSpec.describe "AnswerAttempts#create", type: :request, openapi: {authenticate: true} do
let(:test) { ReviewerFactory[:test] }
let(:block) { ReviewerFactory[:block] }
let(:question) { ReviewerFactory[:question, block: block] }
let!(:correct_answer) { ReviewerFactory[:answer_option, question: question, correct: true] }
let!(:wrong_answer) { ReviewerFactory[:answer_option, question: question] }
let(:session) do
Reviewer::Persistence::Repositories::Sessions.new.sessions.command(:create).call(
{
started_at: Time.now,
finished_at: Time.now + Duration.new(minutes: 30).total
}
)
end
let(:data) {
{
data: {
answer_option_ids: [
correct_answer.id,
wrong_answer.id
]
}
}
}
let(:user) { { login: "[email protected]", password: "CrypTyPassword123456" } }
before do
Reviewer::Persistence::Repositories::TestBlocks.new.test_blocks.command(:create).call({ test_id: test.id, block_id: block.id})
Reviewer::Authentication::App.rodauth(:reviewer).create_account(user)
DB[:accounts].where(email: user[:login]).update(status: 2)
account = Reviewer::Persistence::Repositories::Accounts.new.accounts.where(email: "[email protected]").one
Reviewer::Persistence::Repositories::AccountTests.new.account_tests.command(:create).call(
{
test_id: test.id,
account_id: account.id,
session_id: session.id
}
)
end
context "when user is authenticated", openapi: {enable_example: false} do
before do
json_post "/reviewer/auth/login", user
json_post "/reviewer/api/questions/#{question.id}/answer_attempts", data
end
it "has status 201" do
expect(last_response.status).to eq(201)
end
end
context "when user is not authenticated" do
before { json_post "/reviewer/api/questions/#{question.id}/answer_attempts" }
it "has status 401" do
expect(last_response.status).to eq(401)
end
end
end and openapi spec for that ---
openapi: 3.0.3
info:
title: app
version: 0.0.1
servers:
- url: http://localhost:2300
paths:
"/reviewer/api/questions/{question_id}/answer_attempts":
post:
summary: POST /reviewer/api/questions/{question_id}/answer_attempts
tags:
- questions
security:
- CookieAuth: []
parameters:
- name: question_id
in: path
required: true
schema:
type: integer
example: 2
requestBody:
content:
application/json:
schema:
type: object
properties: {}
examples:
Closed question:
value:
data:
answer_option_ids:
- 31
- 32
Open question:
value:
data:
answer: Test answer text for open question
responses:
'401':
description: when user is not authenticated it has status 401
'201':
description: when user is authenticated it has status 201
components:
securitySchemes:
CookieAuth:
type: apiKey
in: cookie
name: roda.session I run |
I tried to add test cases for this but could not. |