souls 0.24.0 → 0.24.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/Gemfile.lock +1 -1
- data/api_v0.0.1.tar.gz +0 -0
- data/apps/api/.env.sample +7 -0
- data/apps/api/.gitignore +32 -0
- data/apps/api/.irbrc +1 -0
- data/apps/api/.rspec +3 -0
- data/apps/api/.rubocop.yml +132 -0
- data/apps/api/.ruby-version +1 -0
- data/apps/api/CODE_OF_CONDUCT.md +74 -0
- data/apps/api/Dockerfile +16 -0
- data/apps/api/Dockerfile.dev +17 -0
- data/apps/api/Gemfile +50 -0
- data/apps/api/Gemfile.lock +412 -0
- data/apps/api/LICENSE.txt +67 -0
- data/apps/api/Procfile +2 -0
- data/apps/api/Procfile.dev +2 -0
- data/apps/api/README.md +37 -0
- data/apps/api/Rakefile +5 -0
- data/apps/api/app.rb +114 -0
- data/apps/api/app/engines/notification_engine.rb +5 -0
- data/apps/api/app/graphql/mutations/.keep +0 -0
- data/apps/api/app/graphql/mutations/base/article/create_article.rb +30 -0
- data/apps/api/app/graphql/mutations/base/article/delete_article.rb +17 -0
- data/apps/api/app/graphql/mutations/base/article/destroy_delete_article.rb +17 -0
- data/apps/api/app/graphql/mutations/base/article/update_article.rb +30 -0
- data/apps/api/app/graphql/mutations/base/article_category/create_article_category.rb +21 -0
- data/apps/api/app/graphql/mutations/base/article_category/delete_article_category.rb +17 -0
- data/apps/api/app/graphql/mutations/base/article_category/destroy_delete_article_category.rb +17 -0
- data/apps/api/app/graphql/mutations/base/article_category/update_article_category.rb +21 -0
- data/apps/api/app/graphql/mutations/base/user/create_user.rb +31 -0
- data/apps/api/app/graphql/mutations/base/user/delete_user.rb +17 -0
- data/apps/api/app/graphql/mutations/base/user/destroy_delete_user.rb +17 -0
- data/apps/api/app/graphql/mutations/base/user/update_user.rb +31 -0
- data/apps/api/app/graphql/mutations/base_mutation.rb +65 -0
- data/apps/api/app/graphql/mutations/managers/user_manager/add_user_role.rb +22 -0
- data/apps/api/app/graphql/mutations/managers/user_manager/remove_user_role.rb +22 -0
- data/apps/api/app/graphql/mutations/managers/user_manager/sign_in_user.rb +45 -0
- data/apps/api/app/graphql/queries/article.rb +13 -0
- data/apps/api/app/graphql/queries/article_categories.rb +11 -0
- data/apps/api/app/graphql/queries/article_category.rb +13 -0
- data/apps/api/app/graphql/queries/articles.rb +11 -0
- data/apps/api/app/graphql/queries/base_query.rb +12 -0
- data/apps/api/app/graphql/queries/me.rb +11 -0
- data/apps/api/app/graphql/queries/user.rb +13 -0
- data/apps/api/app/graphql/queries/users.rb +11 -0
- data/apps/api/app/graphql/resolvers/article_category_search.rb +41 -0
- data/apps/api/app/graphql/resolvers/article_search.rb +57 -0
- data/apps/api/app/graphql/resolvers/base.rb +17 -0
- data/apps/api/app/graphql/resolvers/user_search.rb +63 -0
- data/apps/api/app/graphql/souls_api_schema.rb +43 -0
- data/apps/api/app/graphql/types/.keep +0 -0
- data/apps/api/app/graphql/types/article_category_type.rb +12 -0
- data/apps/api/app/graphql/types/article_type.rb +30 -0
- data/apps/api/app/graphql/types/base/base_argument.rb +4 -0
- data/apps/api/app/graphql/types/base/base_enum.rb +4 -0
- data/apps/api/app/graphql/types/base/base_field.rb +5 -0
- data/apps/api/app/graphql/types/base/base_input_object.rb +5 -0
- data/apps/api/app/graphql/types/base/base_interface.rb +7 -0
- data/apps/api/app/graphql/types/base/base_object.rb +6 -0
- data/apps/api/app/graphql/types/base/base_scalar.rb +4 -0
- data/apps/api/app/graphql/types/base/base_union.rb +4 -0
- data/apps/api/app/graphql/types/base/mutation_type.rb +26 -0
- data/apps/api/app/graphql/types/base/query_type.rb +18 -0
- data/apps/api/app/graphql/types/connections/article_category_connection.rb +3 -0
- data/apps/api/app/graphql/types/connections/article_connection.rb +3 -0
- data/apps/api/app/graphql/types/connections/base_connection.rb +14 -0
- data/apps/api/app/graphql/types/connections/user_connection.rb +3 -0
- data/apps/api/app/graphql/types/edges/article_category_edge.rb +5 -0
- data/apps/api/app/graphql/types/edges/article_edge.rb +5 -0
- data/apps/api/app/graphql/types/edges/base_edge.rb +4 -0
- data/apps/api/app/graphql/types/edges/user_edge.rb +5 -0
- data/apps/api/app/graphql/types/user_type.rb +24 -0
- data/apps/api/app/models/article.rb +4 -0
- data/apps/api/app/models/article_category.rb +3 -0
- data/apps/api/app/models/user.rb +19 -0
- data/apps/api/app/policies/application_policy.rb +40 -0
- data/apps/api/app/policies/article_category_policy.rb +31 -0
- data/apps/api/app/policies/article_policy.rb +31 -0
- data/apps/api/app/policies/user_policy.rb +35 -0
- data/apps/api/app/utils/association_loader.rb +50 -0
- data/apps/api/app/utils/fire_store.rb +9 -0
- data/apps/api/app/utils/firebase_id_token.rb +4 -0
- data/apps/api/app/utils/json_web_token.rb +13 -0
- data/apps/api/app/utils/record_loader.rb +10 -0
- data/apps/api/app/utils/souls_helper.rb +18 -0
- data/apps/api/cloudbuild.yml +32 -0
- data/apps/api/config.ru +17 -0
- data/apps/api/config/database.yml +33 -0
- data/apps/api/config/souls.rb +10 -0
- data/apps/api/constants/areas.rb +71 -0
- data/apps/api/constants/column_name_ja.rb +27 -0
- data/apps/api/db/migrate/20200006095538_create_users.rb +30 -0
- data/apps/api/db/migrate/20200712180236_create_article_categories.rb +12 -0
- data/apps/api/db/migrate/20200714215521_create_articles.rb +22 -0
- data/apps/api/db/schema.rb +78 -0
- data/apps/api/db/seeds.rb +44 -0
- data/apps/api/github/workflows/delivery.yml +81 -0
- data/apps/api/log/.keep +0 -0
- data/apps/api/spec/factories/article_categories.rb +9 -0
- data/apps/api/spec/factories/articles.rb +17 -0
- data/apps/api/spec/factories/users.rb +23 -0
- data/apps/api/spec/models/article_category_spec.rb +7 -0
- data/apps/api/spec/models/article_spec.rb +7 -0
- data/apps/api/spec/models/user_spec.rb +7 -0
- data/apps/api/spec/mutations/base/article_category_spec.rb +46 -0
- data/apps/api/spec/mutations/base/article_spec.rb +70 -0
- data/apps/api/spec/mutations/base/user_spec.rb +76 -0
- data/apps/api/spec/policies/article_category_policy_spec.rb +25 -0
- data/apps/api/spec/policies/article_policy_spec.rb +25 -0
- data/apps/api/spec/policies/user_policy_spec.rb +5 -0
- data/apps/api/spec/queries/article_category_spec.rb +39 -0
- data/apps/api/spec/queries/article_spec.rb +53 -0
- data/apps/api/spec/queries/user_spec.rb +59 -0
- data/apps/api/spec/resolvers/article_category_search_spec.rb +54 -0
- data/apps/api/spec/resolvers/article_search_spec.rb +68 -0
- data/apps/api/spec/resolvers/user_search_spec.rb +74 -0
- data/apps/api/spec/spec_helper.rb +110 -0
- data/apps/api/tmp/.keep +0 -0
- data/apps/worker/.env.sample +9 -0
- data/apps/worker/.gitignore +32 -0
- data/apps/worker/.irbrc +1 -0
- data/apps/worker/.rspec +3 -0
- data/apps/worker/.rubocop.yml +132 -0
- data/apps/worker/.ruby-version +1 -0
- data/apps/worker/CODE_OF_CONDUCT.md +74 -0
- data/apps/worker/Dockerfile +16 -0
- data/apps/worker/Dockerfile.dev +17 -0
- data/apps/worker/Gemfile +49 -0
- data/apps/worker/Gemfile.lock +396 -0
- data/apps/worker/LICENSE.txt +67 -0
- data/apps/worker/Procfile +1 -0
- data/apps/worker/Procfile.dev +1 -0
- data/apps/worker/README.md +37 -0
- data/apps/worker/Rakefile +5 -0
- data/apps/worker/app.rb +101 -0
- data/apps/worker/app/engines/notification_engine.rb +5 -0
- data/apps/worker/app/graphql/mutations/.keep +0 -0
- data/apps/worker/app/graphql/mutations/base_mutation.rb +16 -0
- data/apps/worker/app/graphql/mutations/workers/send_user_mail_job.rb +31 -0
- data/apps/worker/app/graphql/souls_api_schema.rb +43 -0
- data/apps/worker/app/graphql/types/.keep +0 -0
- data/apps/worker/app/graphql/types/base/base_argument.rb +4 -0
- data/apps/worker/app/graphql/types/base/base_enum.rb +4 -0
- data/apps/worker/app/graphql/types/base/base_field.rb +5 -0
- data/apps/worker/app/graphql/types/base/base_input_object.rb +5 -0
- data/apps/worker/app/graphql/types/base/base_interface.rb +7 -0
- data/apps/worker/app/graphql/types/base/base_object.rb +5 -0
- data/apps/worker/app/graphql/types/base/base_scalar.rb +4 -0
- data/apps/worker/app/graphql/types/base/base_union.rb +4 -0
- data/apps/worker/app/graphql/types/base/mutation_type.rb +12 -0
- data/apps/worker/app/graphql/types/base/query_type.rb +6 -0
- data/apps/worker/app/models/article.rb +4 -0
- data/apps/worker/app/models/article_category.rb +3 -0
- data/apps/worker/app/models/user.rb +19 -0
- data/apps/worker/app/utils/fire_store.rb +9 -0
- data/apps/worker/app/utils/souls_helper.rb +96 -0
- data/apps/worker/cloudbuild.yml +32 -0
- data/apps/worker/config.ru +17 -0
- data/apps/worker/config/database.yml +33 -0
- data/apps/worker/config/souls.rb +10 -0
- data/apps/worker/db/migrate/20200006095538_create_users.rb +30 -0
- data/apps/worker/db/migrate/20200712180236_create_article_categories.rb +12 -0
- data/apps/worker/db/migrate/20200714215521_create_articles.rb +22 -0
- data/apps/worker/db/schema.rb +78 -0
- data/apps/worker/db/seeds.rb +44 -0
- data/apps/worker/github/workflows/delivery.yml +81 -0
- data/apps/worker/log/.keep +0 -0
- data/apps/worker/spec/factories/article_categories.rb +9 -0
- data/apps/worker/spec/factories/articles.rb +17 -0
- data/apps/worker/spec/factories/users.rb +23 -0
- data/apps/worker/spec/models/article_category_spec.rb +7 -0
- data/apps/worker/spec/models/article_spec.rb +7 -0
- data/apps/worker/spec/models/user_spec.rb +7 -0
- data/apps/worker/spec/spec_helper.rb +110 -0
- data/apps/worker/tmp/.keep +0 -0
- data/exe/souls +0 -2
- data/lib/souls.rb +0 -18
- data/lib/souls/init.rb +1 -1
- data/lib/souls/version.rb +1 -1
- data/souls_api2.tar.gz +0 -0
- metadata +176 -1
@@ -0,0 +1,78 @@
|
|
1
|
+
# This file is auto-generated from the current state of the database. Instead
|
2
|
+
# of editing this file, please use the migrations feature of Active Record to
|
3
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
4
|
+
#
|
5
|
+
# This file is the source Rails uses to define your schema when running `bin/rails
|
6
|
+
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
|
7
|
+
# be faster and is potentially less error prone than running all of your
|
8
|
+
# migrations from scratch. Old migrations may fail to apply correctly if those
|
9
|
+
# migrations use external dependencies or application code.
|
10
|
+
#
|
11
|
+
# It's strongly recommended that you check this file into your version control system.
|
12
|
+
|
13
|
+
ActiveRecord::Schema.define(version: 2020_07_14_215521) do
|
14
|
+
|
15
|
+
# These are extensions that must be enabled in order to support this database
|
16
|
+
enable_extension "plpgsql"
|
17
|
+
|
18
|
+
create_table "article_categories", force: :cascade do |t|
|
19
|
+
t.string "name", null: false
|
20
|
+
t.text "tags", default: [], array: true
|
21
|
+
t.boolean "is_deleted", default: false, null: false
|
22
|
+
t.datetime "created_at", precision: 6, null: false
|
23
|
+
t.datetime "updated_at", precision: 6, null: false
|
24
|
+
t.index ["is_deleted"], name: "index_article_categories_on_is_deleted"
|
25
|
+
t.index ["name"], name: "index_article_categories_on_name"
|
26
|
+
end
|
27
|
+
|
28
|
+
create_table "articles", force: :cascade do |t|
|
29
|
+
t.bigint "user_id"
|
30
|
+
t.string "title", null: false
|
31
|
+
t.text "body", default: "", null: false
|
32
|
+
t.string "thumnail_url", default: "", null: false
|
33
|
+
t.datetime "public_date", default: "2021-08-18 18:14:54", null: false
|
34
|
+
t.bigint "article_category_id", null: false
|
35
|
+
t.boolean "is_public", default: false, null: false
|
36
|
+
t.boolean "just_created", default: true, null: false
|
37
|
+
t.string "slag", null: false
|
38
|
+
t.text "tags", default: [], array: true
|
39
|
+
t.boolean "is_deleted", default: false, null: false
|
40
|
+
t.datetime "created_at", precision: 6, null: false
|
41
|
+
t.datetime "updated_at", precision: 6, null: false
|
42
|
+
t.index ["article_category_id"], name: "index_articles_on_article_category_id"
|
43
|
+
t.index ["is_deleted"], name: "index_articles_on_is_deleted"
|
44
|
+
t.index ["is_public"], name: "index_articles_on_is_public"
|
45
|
+
t.index ["slag"], name: "index_articles_on_slag", unique: true
|
46
|
+
t.index ["title"], name: "index_articles_on_title", unique: true
|
47
|
+
t.index ["user_id"], name: "index_articles_on_user_id"
|
48
|
+
end
|
49
|
+
|
50
|
+
create_table "users", force: :cascade do |t|
|
51
|
+
t.string "uid", null: false
|
52
|
+
t.string "username", default: "", null: false
|
53
|
+
t.string "screen_name", default: "", null: false
|
54
|
+
t.string "last_name", default: "", null: false
|
55
|
+
t.string "first_name", default: "", null: false
|
56
|
+
t.string "last_name_kanji", default: "", null: false
|
57
|
+
t.string "first_name_kanji", default: "", null: false
|
58
|
+
t.string "last_name_kana", default: "", null: false
|
59
|
+
t.string "first_name_kana", default: "", null: false
|
60
|
+
t.string "email", null: false
|
61
|
+
t.string "tel", default: "", null: false
|
62
|
+
t.string "icon_url", default: "", null: false
|
63
|
+
t.string "birthday", default: "", null: false
|
64
|
+
t.string "gender", default: "", null: false
|
65
|
+
t.string "lang", default: "ja", null: false
|
66
|
+
t.string "category", default: "user", null: false
|
67
|
+
t.integer "roles_mask", default: 1, null: false
|
68
|
+
t.boolean "is_deleted", default: false, null: false
|
69
|
+
t.datetime "created_at", precision: 6, null: false
|
70
|
+
t.datetime "updated_at", precision: 6, null: false
|
71
|
+
t.index ["email"], name: "index_users_on_email", unique: true
|
72
|
+
t.index ["is_deleted"], name: "index_users_on_is_deleted"
|
73
|
+
t.index ["screen_name"], name: "index_users_on_screen_name"
|
74
|
+
t.index ["uid"], name: "index_users_on_uid"
|
75
|
+
t.index ["username"], name: "index_users_on_username"
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require "./app"
|
2
|
+
|
3
|
+
Dir[File.expand_path("#{Rack::Directory.new('').root}/spec/factories/*.rb")]
|
4
|
+
.each { |file| require file }
|
5
|
+
|
6
|
+
def create_user
|
7
|
+
gimei = Gimei.name
|
8
|
+
user =
|
9
|
+
FactoryBot.create(
|
10
|
+
:user,
|
11
|
+
username: gimei.kanji,
|
12
|
+
last_name: gimei.last.hiragana,
|
13
|
+
first_name: gimei.first.hiragana,
|
14
|
+
last_name_kanji: gimei.last.kanji,
|
15
|
+
first_name_kanji: gimei.first.kanji,
|
16
|
+
last_name_kana: gimei.last.katakana,
|
17
|
+
first_name_kana: gimei.first.katakana,
|
18
|
+
gender: gimei.gender
|
19
|
+
)
|
20
|
+
puts(user.to_json)
|
21
|
+
return user.id if user
|
22
|
+
end
|
23
|
+
|
24
|
+
def create_article_category
|
25
|
+
article_category = FactoryBot.create(:article_category)
|
26
|
+
"Article Category Created!\n #{article_category.to_json}" if article_category
|
27
|
+
end
|
28
|
+
|
29
|
+
def create_article(user_id, article_category_id)
|
30
|
+
article = FactoryBot.create(:article, user_id: user_id, article_category_id: article_category_id)
|
31
|
+
"Article Created!\n #{article.to_json}" if article
|
32
|
+
end
|
33
|
+
|
34
|
+
%w[お知らせ 特集 レシピ].each do |name|
|
35
|
+
puts ArticleCategory.create(name: name).to_json
|
36
|
+
end
|
37
|
+
|
38
|
+
10.times { create_user }
|
39
|
+
|
40
|
+
100.times do |_i|
|
41
|
+
user_id = User.find(rand(5).to_i + 1).id
|
42
|
+
article_category_id = ArticleCategory.find(rand(3).to_i + 1).id
|
43
|
+
puts create_article(user_id, article_category_id)
|
44
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
name: Delivery
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
|
8
|
+
jobs:
|
9
|
+
build:
|
10
|
+
|
11
|
+
runs-on: ubuntu-20.04
|
12
|
+
|
13
|
+
services:
|
14
|
+
db:
|
15
|
+
image: postgres:13
|
16
|
+
ports: ["5433:5432"]
|
17
|
+
env:
|
18
|
+
POSTGRES_PASSWORD: postgres
|
19
|
+
options: >-
|
20
|
+
--health-cmd pg_isready
|
21
|
+
--health-interval 10s
|
22
|
+
--health-timeout 5s
|
23
|
+
--health-retries 5
|
24
|
+
|
25
|
+
steps:
|
26
|
+
- uses: actions/checkout@v2
|
27
|
+
- name: Set up Ruby 3.0
|
28
|
+
uses: actions/setup-ruby@v1
|
29
|
+
with:
|
30
|
+
ruby-version: 3.0
|
31
|
+
- name: Build and test with Rake
|
32
|
+
env:
|
33
|
+
PGHOST: 127.0.0.1
|
34
|
+
PGUSER: postgres
|
35
|
+
RACK_ENV: test
|
36
|
+
run: |
|
37
|
+
sudo apt-get -yqq install libpq-dev
|
38
|
+
gem install bundler
|
39
|
+
bundle install --jobs 4 --retry 3
|
40
|
+
bundle exec rake db:create RACK_ENV=test
|
41
|
+
bundle exec rake db:migrate RACK_ENV=test
|
42
|
+
bundle exec rspec
|
43
|
+
|
44
|
+
- name: Checkout the repository
|
45
|
+
uses: actions/checkout@v2
|
46
|
+
|
47
|
+
- name: GCP Authenticate
|
48
|
+
uses: google-github-actions/setup-gcloud@master
|
49
|
+
with:
|
50
|
+
version: "323.0.0"
|
51
|
+
project_id: ${{ secrets.GCP_PROJECT_ID }}
|
52
|
+
service_account_key: ${{ secrets.GCP_SA_KEY }}
|
53
|
+
export_default_credentials: true
|
54
|
+
|
55
|
+
- name: Configure Docker
|
56
|
+
run: gcloud auth configure-docker --quiet
|
57
|
+
|
58
|
+
- name: Build Docker container
|
59
|
+
run: docker build . -t gcr.io/${{ secrets.GCP_PROJECT_ID }}/${{secrets.APP_NAME}}
|
60
|
+
|
61
|
+
- name: Push to Container Resistory
|
62
|
+
run: docker push gcr.io/${{ secrets.GCP_PROJECT_ID }}/${{secrets.APP_NAME}}
|
63
|
+
|
64
|
+
- name: Deploy to Cloud Run
|
65
|
+
run: |
|
66
|
+
gcloud run deploy ${{ secrets.APP_NAME }} \
|
67
|
+
--image=gcr.io/${{ secrets.GCP_PROJECT_ID }}/${{secrets.APP_NAME}} \
|
68
|
+
--memory=4Gi \
|
69
|
+
--region=asia-northeast1 \
|
70
|
+
--allow-unauthenticated \
|
71
|
+
--platform=managed \
|
72
|
+
--quiet \
|
73
|
+
--concurrency=80 \
|
74
|
+
--port=8080 \
|
75
|
+
--set-cloudsql-instances=${{ secrets.GCLOUDSQL_INSTANCE }} \
|
76
|
+
--set-env-vars="DB_USER=${{ secrets.DB_USER }}" \
|
77
|
+
--set-env-vars="DB_PW=${{ secrets.DB_PW }}" \
|
78
|
+
--set-env-vars="DB_HOST=${{ secrets.DB_HOST }}" \
|
79
|
+
--set-env-vars="TZ=${{ secrets.TZ }}" \
|
80
|
+
--set-env-vars="SLACK=${{ secrets.SLACK }}" \
|
81
|
+
--set-env-vars="SECRET_KEY_BASE=${{ secrets.SECRET_KEY_BASE }}" \
|
data/apps/api/log/.keep
ADDED
File without changes
|
@@ -0,0 +1,17 @@
|
|
1
|
+
FactoryBot.define do
|
2
|
+
factory :article do
|
3
|
+
association :user, factory: :user
|
4
|
+
title { Faker::Book.unique.title }
|
5
|
+
body { Faker::Quote.matz }
|
6
|
+
thumnail_url { Faker::Internet.url }
|
7
|
+
public_date { Time.now }
|
8
|
+
association :article_category, factory: :article_category
|
9
|
+
is_public { false }
|
10
|
+
just_created { false }
|
11
|
+
slag { Faker::Internet.password(min_length: 16) }
|
12
|
+
tags { %w[tag1 tag2 tag3] }
|
13
|
+
is_deleted { false }
|
14
|
+
created_at { Time.now }
|
15
|
+
updated_at { Time.now }
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "gimei"
|
2
|
+
FactoryBot.define do
|
3
|
+
factory :user do
|
4
|
+
uid { Faker::Internet.password }
|
5
|
+
username { Gimei.kanji }
|
6
|
+
screen_name { Faker::Internet.unique.username }
|
7
|
+
last_name { Gimei.last.hiragana }
|
8
|
+
first_name { Gimei.first.hiragana }
|
9
|
+
last_name_kanji { Gimei.last.kanji }
|
10
|
+
first_name_kanji { Gimei.first.kanji }
|
11
|
+
last_name_kana { Gimei.last.katakana }
|
12
|
+
first_name_kana { Gimei.last.katakana }
|
13
|
+
email { Faker::Internet.unique.email }
|
14
|
+
tel { Faker::PhoneNumber.subscriber_number(length: 10) }
|
15
|
+
icon_url { "https://picsum.photos/200" }
|
16
|
+
birthday { Faker::Date.birthday(min_age: 18, max_age: 65) }
|
17
|
+
gender { Gimei.male }
|
18
|
+
lang { "ja" }
|
19
|
+
category { "user" }
|
20
|
+
roles_mask { :normal }
|
21
|
+
is_deleted { false }
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
RSpec.describe("ArticleCategory Mutation テスト") do
|
2
|
+
describe "ArticleCategory データを登録する" do
|
3
|
+
let(:article_category) { FactoryBot.attributes_for(:article_category) }
|
4
|
+
|
5
|
+
let(:mutation) do
|
6
|
+
%(mutation {
|
7
|
+
createArticleCategory(input: {
|
8
|
+
name: "#{article_category[:name]}"
|
9
|
+
tags: #{article_category[:tags]}
|
10
|
+
isDeleted: #{article_category[:is_deleted]}
|
11
|
+
}) {
|
12
|
+
articleCategoryEdge {
|
13
|
+
node {
|
14
|
+
id
|
15
|
+
name
|
16
|
+
tags
|
17
|
+
isDeleted
|
18
|
+
}
|
19
|
+
}
|
20
|
+
}
|
21
|
+
}
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
subject(:result) do
|
26
|
+
SoulsApiSchema.execute(mutation).as_json
|
27
|
+
end
|
28
|
+
|
29
|
+
it "return ArticleCategory Data" do
|
30
|
+
begin
|
31
|
+
a1 = result.dig("data", "createArticleCategory", "articleCategoryEdge", "node")
|
32
|
+
raise unless a1.present?
|
33
|
+
rescue StandardError
|
34
|
+
raise(StandardError, result)
|
35
|
+
end
|
36
|
+
expect(a1).to(
|
37
|
+
include(
|
38
|
+
"id" => be_a(String),
|
39
|
+
"name" => be_a(String),
|
40
|
+
"tags" => be_all(String),
|
41
|
+
"isDeleted" => be_in([true, false])
|
42
|
+
)
|
43
|
+
)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
RSpec.describe("Article Mutation テスト") do
|
2
|
+
describe "Article データを登録する" do
|
3
|
+
let(:user) { FactoryBot.create(:user) }
|
4
|
+
let(:article_category) { FactoryBot.create(:article_category) }
|
5
|
+
let(:article) do
|
6
|
+
FactoryBot.attributes_for(:article, article_category_id: get_global_key("ArticleCategory", article_category.id))
|
7
|
+
end
|
8
|
+
|
9
|
+
let(:mutation) do
|
10
|
+
%(mutation {
|
11
|
+
createArticle(input: {
|
12
|
+
title: "#{article[:title]}"
|
13
|
+
body: "#{article[:body]}"
|
14
|
+
thumnailUrl: "#{article[:thumnail_url]}"
|
15
|
+
publicDate: "#{article[:public_date]}"
|
16
|
+
articleCategoryId: "#{article[:article_category_id]}"
|
17
|
+
isPublic: #{article[:is_public]}
|
18
|
+
justCreated: #{article[:just_created]}
|
19
|
+
slag: "#{article[:slag]}"
|
20
|
+
tags: #{article[:tags]}
|
21
|
+
isDeleted: #{article[:is_deleted]}
|
22
|
+
}) {
|
23
|
+
articleEdge {
|
24
|
+
node {
|
25
|
+
id
|
26
|
+
title
|
27
|
+
body
|
28
|
+
thumnailUrl
|
29
|
+
publicDate
|
30
|
+
isPublic
|
31
|
+
justCreated
|
32
|
+
slag
|
33
|
+
tags
|
34
|
+
isDeleted
|
35
|
+
}
|
36
|
+
}
|
37
|
+
}
|
38
|
+
}
|
39
|
+
)
|
40
|
+
end
|
41
|
+
|
42
|
+
subject(:result) do
|
43
|
+
context = { user: user }
|
44
|
+
SoulsApiSchema.execute(mutation, context: context).as_json
|
45
|
+
end
|
46
|
+
|
47
|
+
it "return Article Data" do
|
48
|
+
begin
|
49
|
+
a1 = result.dig("data", "createArticle", "articleEdge", "node")
|
50
|
+
raise unless a1.present?
|
51
|
+
rescue StandardError
|
52
|
+
raise(StandardError, result)
|
53
|
+
end
|
54
|
+
expect(a1).to(
|
55
|
+
include(
|
56
|
+
"id" => be_a(String),
|
57
|
+
"title" => be_a(String),
|
58
|
+
"body" => be_a(String),
|
59
|
+
"thumnailUrl" => be_a(String),
|
60
|
+
"publicDate" => be_a(String),
|
61
|
+
"isPublic" => be_in([true, false]),
|
62
|
+
"justCreated" => be_in([true, false]),
|
63
|
+
"slag" => be_a(String),
|
64
|
+
"tags" => be_all(String),
|
65
|
+
"isDeleted" => be_in([true, false])
|
66
|
+
)
|
67
|
+
)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
RSpec.describe("User Mutation テスト") do
|
2
|
+
describe "User データを登録する" do
|
3
|
+
let(:user) { FactoryBot.attributes_for(:user) }
|
4
|
+
|
5
|
+
let(:mutation) do
|
6
|
+
%(mutation {
|
7
|
+
createUser(input: {
|
8
|
+
uid: "#{user[:uid]}"
|
9
|
+
username: "#{user[:username]}"
|
10
|
+
screenName: "#{user[:screen_name]}"
|
11
|
+
lastName: "#{user[:last_name]}"
|
12
|
+
firstName: "#{user[:first_name]}"
|
13
|
+
lastNameKanji: "#{user[:last_name_kanji]}"
|
14
|
+
firstNameKanji: "#{user[:first_name_kanji]}"
|
15
|
+
lastNameKana: "#{user[:last_name_kana]}"
|
16
|
+
firstNameKana: "#{user[:first_name_kana]}"
|
17
|
+
email: "#{user[:email]}"
|
18
|
+
tel: "#{user[:tel]}"
|
19
|
+
iconUrl: "#{user[:icon_url]}"
|
20
|
+
birthday: "#{user[:birthday]}"
|
21
|
+
}) {
|
22
|
+
userEdge {
|
23
|
+
node {
|
24
|
+
id
|
25
|
+
uid
|
26
|
+
username
|
27
|
+
screenName
|
28
|
+
lastName
|
29
|
+
firstName
|
30
|
+
lastNameKanji
|
31
|
+
firstNameKanji
|
32
|
+
lastNameKana
|
33
|
+
firstNameKana
|
34
|
+
email
|
35
|
+
tel
|
36
|
+
iconUrl
|
37
|
+
birthday
|
38
|
+
}
|
39
|
+
}
|
40
|
+
}
|
41
|
+
}
|
42
|
+
)
|
43
|
+
end
|
44
|
+
|
45
|
+
subject(:result) do
|
46
|
+
SoulsApiSchema.execute(mutation).as_json
|
47
|
+
end
|
48
|
+
|
49
|
+
it "return User Data" do
|
50
|
+
begin
|
51
|
+
a1 = result.dig("data", "createUser", "userEdge", "node")
|
52
|
+
raise unless a1.present?
|
53
|
+
rescue StandardError
|
54
|
+
raise(StandardError, result)
|
55
|
+
end
|
56
|
+
expect(a1).to(
|
57
|
+
include(
|
58
|
+
"id" => be_a(String),
|
59
|
+
"uid" => be_a(String),
|
60
|
+
"username" => be_a(String),
|
61
|
+
"screenName" => be_a(String),
|
62
|
+
"lastName" => be_a(String),
|
63
|
+
"firstName" => be_a(String),
|
64
|
+
"lastNameKanji" => be_a(String),
|
65
|
+
"firstNameKanji" => be_a(String),
|
66
|
+
"lastNameKana" => be_a(String),
|
67
|
+
"firstNameKana" => be_a(String),
|
68
|
+
"email" => be_a(String),
|
69
|
+
"tel" => be_a(String),
|
70
|
+
"iconUrl" => be_a(String),
|
71
|
+
"birthday" => be_a(String)
|
72
|
+
)
|
73
|
+
)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|