-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b767cdd
commit 5e2472b
Showing
5 changed files
with
64 additions
and
6 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 |
---|---|---|
|
@@ -3,6 +3,5 @@ | |
title { Faker::Quote.yoda } | ||
body { Faker::Lorem.paragraph } | ||
difficulty { rand(1..10) } | ||
theme_id { nil } | ||
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,41 @@ | ||
require 'rails_helper' | ||
|
||
describe 'Create Node', type: :request do | ||
describe 'POST /themes' do | ||
let!(:user) { create(:user) } | ||
|
||
context 'authorized' do | ||
context 'valid attributes' do | ||
before { | ||
sign_in user | ||
post '/themes', params: { title: Faker::Educator.subject } | ||
} | ||
|
||
it_behaves_like 'status 200' | ||
it_behaves_like 'success data' | ||
end | ||
|
||
context 'invalid attributes' do | ||
before { | ||
sign_in user | ||
post '/themes', params: { title: nil } | ||
} | ||
|
||
it 'return status 422' do | ||
expect(response.status).to eq 422 | ||
end | ||
|
||
it 'return errors in the response' do | ||
expect(json_response).to have_jsonapi_errors | ||
end | ||
end | ||
end | ||
|
||
context 'unauthorized' do | ||
it 'return 401 status if user is not authorized' do | ||
post '/themes' | ||
expect(response.status).to eq 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