Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit982e1dc

Browse files
committed
refactor(article-tags): add group field support
1 parent2edfe0c commit982e1dc

File tree

9 files changed

+28
-6
lines changed

9 files changed

+28
-6
lines changed

‎lib/groupher_server/cms/article_tag.ex‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ defmodule GroupherServer.CMS.ArticleTag do
1111
aliasCMS.{Author,Community}
1212

1313
@required_fields~w(thread title color author_id community_id)a
14-
@updatable_fields~w(thread title color community_id)a
14+
@updatable_fields~w(thread title color community_id group)a
1515

1616
@typet::%ArticleTag{}
1717
schema"article_tags"do
1818
field(:title,:string)
1919
field(:color,:string)
2020
field(:thread,:string)
21+
field(:group,:string)
22+
2123
belongs_to(:community,Community)
2224
belongs_to(:author,Author)
2325

@@ -26,7 +28,7 @@ defmodule GroupherServer.CMS.ArticleTag do
2628

2729
defchangeset(%ArticleTag{}=tag,attrs)do
2830
tag
29-
|>cast(attrs,@required_fields)
31+
|>cast(attrs,@required_fields++@updatable_fields)
3032
|>validate_required(@required_fields)
3133
|>foreign_key_constraint(:user_id)
3234
|>foreign_key_constraint(:community_id)

‎lib/groupher_server_web/schema/cms/cms_types.ex‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,8 @@ defmodule GroupherServerWeb.Schema.CMS.Types do
337337
field(:title,:string)
338338
field(:color,:string)
339339
field(:thread,:string)
340+
field(:group,:string)
341+
340342
field(:author,:user,resolve:dataloader(CMS,:author))
341343
field(:community,:community,resolve:dataloader(CMS,:community))
342344

‎lib/groupher_server_web/schema/cms/mutations/community.ex‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ defmodule GroupherServerWeb.Schema.CMS.Mutations.Community do
131131
arg(:title,non_null(:string))
132132
arg(:color,non_null(:rainbow_color))
133133
arg(:community_id,non_null(:id))
134+
arg(:group,:string)
134135
arg(:thread,:thread,default_value::post)
135136

136137
middleware(M.Authorize,:login)
@@ -146,6 +147,7 @@ defmodule GroupherServerWeb.Schema.CMS.Mutations.Community do
146147
arg(:community_id,non_null(:id))
147148
arg(:title,:string)
148149
arg(:color,:rainbow_color)
150+
arg(:group,:string)
149151
arg(:thread,:thread,default_value::post)
150152

151153
middleware(M.Authorize,:login)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
defmoduleGroupherServer.Repo.Migrations.AddGroupToArticleTagdo
2+
useEcto.Migration
3+
4+
defchangedo
5+
altertable(:article_tags)do
6+
add(:group,:string)
7+
end
8+
end
9+
end

‎test/groupher_server/cms/article_tags/job_tag_test.exs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ defmodule GroupherServer.Test.CMS.ArticleTag.JobTag do
2121
test"create article tag with valid data",~m(community article_tag_attrs user)ado
2222
{:ok,article_tag}=CMS.create_article_tag(community,:job,article_tag_attrs,user)
2323
assertarticle_tag.title==article_tag_attrs.title
24+
assertarticle_tag.group==article_tag_attrs.group
2425
end
2526

2627
test"can update an article tag",~m(community article_tag_attrs user)ado

‎test/groupher_server/cms/article_tags/post_tag_test.exs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ defmodule GroupherServer.Test.CMS.ArticleTag.PostTag do
1818
end
1919

2020
describe"[post tag CURD]"do
21+
@tag:wip2
2122
test"create article tag with valid data",~m(community article_tag_attrs user)ado
2223
{:ok,article_tag}=CMS.create_article_tag(community,:post,article_tag_attrs,user)
2324
assertarticle_tag.title==article_tag_attrs.title
25+
assertarticle_tag.group==article_tag_attrs.group
2426
end
2527

2628
test"can update an article tag",~m(community article_tag_attrs user)ado

‎test/groupher_server/cms/article_tags/repo_tag_test.exs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ defmodule GroupherServer.Test.CMS.ArticleTag.RepoTag do
2121
test"create article tag with valid data",~m(community article_tag_attrs user)ado
2222
{:ok,article_tag}=CMS.create_article_tag(community,:repo,article_tag_attrs,user)
2323
assertarticle_tag.title==article_tag_attrs.title
24+
assertarticle_tag.group==article_tag_attrs.group
2425
end
2526

2627
test"can update an article tag",~m(community article_tag_attrs user)ado

‎test/groupher_server_web/mutation/cms/article_tags/curd_test.exs‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ defmodule GroupherServer.Test.Mutation.CMS.ArticleArticleTags.CURD do
2323

2424
describe"[mutation cms tag]"do
2525
@create_tag_query"""
26-
mutation($thread: Thread!, $title: String!, $color: RainbowColor!, $communityId: ID!) {
27-
createArticleTag(thread: $thread, title: $title, color: $color, communityId: $communityId) {
26+
mutation($thread: Thread!, $title: String!, $color: RainbowColor!, $group: String, $communityId: ID!) {
27+
createArticleTag(thread: $thread, title: $title, color: $color,group: $group,communityId: $communityId) {
2828
id
2929
title
3030
color
@@ -37,14 +37,15 @@ defmodule GroupherServer.Test.Mutation.CMS.ArticleArticleTags.CURD do
3737
}
3838
}
3939
"""
40-
40+
@tag:wip2
4141
test"create tag with valid attrs, has default POST thread and default posts",
4242
~m(community)ado
4343
variables=%{
4444
title:"tag title",
4545
communityId:community.id,
4646
thread:"POST",
47-
color:"GREEN"
47+
color:"GREEN",
48+
group:"awesome"
4849
}
4950

5051
passport_rules=%{community.title=>%{"post.article_tag.create"=>true}}
@@ -58,6 +59,7 @@ defmodule GroupherServer.Test.Mutation.CMS.ArticleArticleTags.CURD do
5859

5960
assertcreated["id"]==to_string(found.id)
6061
assertfound.thread=="POST"
62+
assertfound.group=="awesome"
6163
assertbelong_community["id"]==to_string(community.id)
6264
end
6365

‎test/support/factory.ex‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ defmodule GroupherServer.Support.Factory do
197197
title:"#{Faker.Pizza.cheese()}#{unique_num}",
198198
thread:"POST",
199199
color:"YELLOW",
200+
group:"cool",
200201
# community: Faker.Pizza.topping(),
201202
community:mock(:community),
202203
author:mock(:author)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp