Skip to content

Commit 9de48ef

Browse files
committed
reorder mutation and query specs. now its same as modules under app folder
1 parent 8a9d730 commit 9de48ef

11 files changed

+289
-267
lines changed

spec/graphql/devise/logout_mutation_spec.rb

Lines changed: 0 additions & 48 deletions
This file was deleted.

spec/graphql/devise/token_login_mutation_spec.rb

Lines changed: 0 additions & 48 deletions
This file was deleted.

spec/graphql/devise/update_user_mutation_spec.rb

Lines changed: 0 additions & 84 deletions
This file was deleted.
Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,57 @@
1-
require 'rails_helper'
1+
# frozen_string_literal: true
22

3-
RSpec.describe GraphqlSchema do
3+
require 'rails_helper'
44

5-
before{
5+
RSpec.describe Mutations::User::Login do
6+
before do
67
# reset vars and context
78
prepare_query_variables({})
89
prepare_context({})
910

1011
# set query
1112
prepare_query("
12-
mutation login($email: String!, $password: String!){
13-
login(email: $email, password: $password) {
14-
email
15-
}
13+
mutation login($email: String!, $password: String!){
14+
login(email: $email, password: $password) {
15+
email
16+
}
1617
}
1718
")
18-
}
19+
end
1920

2021
let(:password) { SecureRandom.uuid }
2122

2223
describe 'login' do
2324
context 'when no user exists' do
24-
before{
25+
before do
2526
prepare_query_variables(
26-
email: Faker::Internet.email,
27+
email: Faker::Internet.email,
2728
password: password
2829
)
29-
}
30+
end
31+
3032
it 'is nil' do
3133
expect(graphql!['data']['login']).to eq(nil)
3234
end
3335
end
3436

35-
3637
context 'when there\'s a matching user' do
37-
let(:user) { create(:user, email: Faker::Internet.email, password: password, password_confirmation: password) }
38-
39-
before {
40-
prepare_query_variables(email: user.email, password: password)
41-
}
42-
38+
let(:user) do
39+
create(
40+
:user,
41+
email: Faker::Internet.email,
42+
password: password,
43+
password_confirmation: password
44+
)
45+
end
46+
47+
before do
48+
prepare_query_variables(email: user.email, password: password)
49+
end
50+
4351
it 'returns user object' do
4452
user_email = graphql!['data']['login']['email']
4553
expect(user_email).to eq(user.email)
4654
end
4755
end
4856
end
49-
50-
end
57+
end
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# frozen_string_literal: true
2+
3+
require 'rails_helper'
4+
5+
RSpec.describe Mutations::User::Logout do
6+
before do
7+
# reset vars and context
8+
prepare_query_variables({})
9+
prepare_context({})
10+
11+
# set query
12+
prepare_query("
13+
mutation logout{
14+
logout
15+
}
16+
")
17+
end
18+
19+
let(:password) { SecureRandom.uuid }
20+
21+
describe 'logout' do
22+
context 'when no user exists' do
23+
it 'is false' do
24+
expect(graphql!['data']['logout']).to be false
25+
end
26+
end
27+
28+
context 'when there\'s a matching user' do
29+
let(:current_user) do
30+
create(
31+
:user,
32+
email: Faker::Internet.email,
33+
password: password,
34+
password_confirmation: password
35+
)
36+
end
37+
38+
before do
39+
prepare_context({ current_user: current_user })
40+
end
41+
42+
it 'returns user object' do
43+
jti_before = current_user.jti
44+
graphql!
45+
current_user.reload
46+
expect(current_user.jti).not_to eq jti_before
47+
end
48+
end
49+
end
50+
end

0 commit comments

Comments
 (0)