This repository was archived by the owner on Nov 8, 2022. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork20
refactor(post-meta): isEdited state for posts#306
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
5 commits Select commitHold shift + click to select a range
c9e096d
refactor(article): add basic default meta map to post
mydearxymb64840a
refactor(post-meta): basic isEdited logic
mydearxymea02dbc
refactor(post-meta): basic frontend(GQL) workflow
mydearxym065d5b9
refactor(post-meta): fix update info not sync && warnings
mydearxym7595488
fix(post-meta): exsiting post has no meta
mydearxymFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
27 changes: 20 additions & 7 deletionslib/groupher_server/cms/delegates/article_curd.ex
This file contains hidden or 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
34 changes: 34 additions & 0 deletionslib/groupher_server/cms/delegates/article_operation.ex
This file contains hidden or 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
4 changes: 3 additions & 1 deletionlib/groupher_server/cms/post.ex
This file contains hidden or 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
26 changes: 21 additions & 5 deletionslib/groupher_server_web/resolvers/cms_resolver.ex
This file contains hidden or 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
25 changes: 25 additions & 0 deletionslib/groupher_server_web/schema/cms/cms_types.ex
This file contains hidden or 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
29 changes: 26 additions & 3 deletionslib/helper/utils.ex
This file contains hidden or 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
2 changes: 1 addition & 1 deletionmix.exs
This file contains hidden or 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
9 changes: 9 additions & 0 deletionspriv/repo/migrations/20210324064013_add_meta_to_posts.exs
This file contains hidden or 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,9 @@ | ||
defmodule GroupherServer.Repo.Migrations.AddMetaToPosts do | ||
use Ecto.Migration | ||
def change do | ||
alter table(:cms_posts) do | ||
add(:meta, :map) | ||
end | ||
end | ||
end |
52 changes: 52 additions & 0 deletionstest/groupher_server/cms/post_meta_test.exs
This file contains hidden or 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,52 @@ | ||
defmodule GroupherServer.Test.CMS.PostMeta do | ||
use GroupherServer.TestTools | ||
alias Helper.ORM | ||
alias GroupherServer.CMS | ||
alias Helper.Utils | ||
@default_article_meta CMS.Delegate.ArticleOperation.default_article_meta() | ||
setup do | ||
{:ok, user} = db_insert(:user) | ||
# {:ok, post} = db_insert(:post) | ||
{:ok, community} = db_insert(:community) | ||
post_attrs = mock_attrs(:post, %{community_id: community.id}) | ||
{:ok, ~m(user community post_attrs)a} | ||
end | ||
describe "[cms post meta info]" do | ||
alias CMS.{Author, Post} | ||
@tag :wip | ||
test "can get default meta info", ~m(user community post_attrs)a do | ||
assert {:error, _} = ORM.find_by(Author, user_id: user.id) | ||
{:ok, post} = CMS.create_content(community, :post, post_attrs, user) | ||
{:ok, post} = ORM.find_by(Post, id: post.id) | ||
assert @default_article_meta == Utils.keys_to_atoms(post.meta) | ||
end | ||
@tag :wip | ||
test "isEdited flag should set to true after post updated", ~m(user community post_attrs)a do | ||
{:ok, post} = CMS.create_content(community, :post, post_attrs, user) | ||
{:ok, post} = ORM.find_by(Post, id: post.id) | ||
assert post.meta["isEdited"] == false | ||
{:ok, _} = CMS.update_content(post, %{"title" => "new title"}) | ||
{:ok, post} = ORM.find_by(Post, id: post.id) | ||
assert post.meta["isEdited"] == true | ||
end | ||
# test "post with image should have imageCount in meta" do | ||
# end | ||
# test "post with video should have imageCount in meta" do | ||
# end | ||
end | ||
end |
2 changes: 1 addition & 1 deletiontest/groupher_server/cms/post_test.exs
This file contains hidden or 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
18 changes: 18 additions & 0 deletionstest/groupher_server_web/mutation/cms/post_test.exs
This file contains hidden or 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
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.