Open platform to collect and prioritize feedback
refactoring: rename Support to Vote (#512)
Guilherme Oenning97baba7377cb
diff --git a/app/cmd/routes.go b/app/cmd/routes.goindex f5bb1dfb7..4276a8b74 100644--- a/app/cmd/routes.go+++ b/app/cmd/routes.go@@ -150,8 +150,8 @@ func routes(r *web.Engine) *web.Engine {api.Post("/api/v1/posts", apiv1.CreatePost())api.Post("/api/v1/posts/:number/comments", apiv1.PostComment())api.Put("/api/v1/posts/:number/comments/:id", apiv1.UpdateComment())- api.Post("/api/v1/posts/:number/support", apiv1.AddSupporter())- api.Delete("/api/v1/posts/:number/support", apiv1.RemoveSupporter())+ api.Post("/api/v1/posts/:number/votes", apiv1.AddVote())+ api.Delete("/api/v1/posts/:number/votes", apiv1.RemoveVote())api.Post("/api/v1/posts/:number/subscription", apiv1.Subscribe())api.Delete("/api/v1/posts/:number/subscription", apiv1.Unsubscribe())diff --git a/app/handlers/apiv1/post.go b/app/handlers/apiv1/post.goindex ac690ae21..1c446b21c 100644--- a/app/handlers/apiv1/post.go+++ b/app/handlers/apiv1/post.go@@ -37,7 +37,7 @@ func CreatePost() web.HandlerFunc {return c.Failure(err)}- if err := posts.AddSupporter(post, c.User()); err != nil {+ if err := posts.AddVote(post, c.User()); err != nil {return c.Failure(err)}@@ -173,17 +173,17 @@ func UpdateComment() web.HandlerFunc {}}-// AddSupporter adds current user to given post list of supporters-func AddSupporter() web.HandlerFunc {+// AddVote adds current user to given post list of votes+func AddVote() web.HandlerFunc {return func(c web.Context) error {- return addOrRemove(c, c.Services().Posts.AddSupporter)+ return addOrRemove(c, c.Services().Posts.AddVote)}}-// RemoveSupporter removes current user from given post list of supporters-func RemoveSupporter() web.HandlerFunc {+// RemoveVote removes current user from given post list of votes+func RemoveVote() web.HandlerFunc {return func(c web.Context) error {- return addOrRemove(c, c.Services().Posts.RemoveSupporter)+ return addOrRemove(c, c.Services().Posts.RemoveVote)}}diff --git a/app/handlers/apiv1/post_test.go b/app/handlers/apiv1/post_test.goindex 736c41b7f..098a26e1c 100644--- a/app/handlers/apiv1/post_test.go+++ b/app/handlers/apiv1/post_test.go@@ -26,7 +26,7 @@ func TestCreatePostHandler(t *testing.T) {Expect(code).Equals(http.StatusOK)Expect(err).IsNil()Expect(post.Title).Equals("My newest post :)")- Expect(post.TotalSupporters).Equals(1)+ Expect(post.TotalVotes).Equals(1)}func TestCreatePostHandler_WithoutTitle(t *testing.T) {@@ -136,7 +136,7 @@ func TestSetResponseHandler(t *testing.T) {services.SetCurrentTenant(mock.DemoTenant)services.SetCurrentUser(mock.AryaStark)post, _ := services.Posts.Add("The Post #1", "The Description #1")- services.Posts.AddSupporter(post, mock.AryaStark)+ services.Posts.AddVote(post, mock.AryaStark)code, _ := server.OnTenant(mock.DemoTenant).@@ -159,7 +159,7 @@ func TestSetResponseHandler_Unauthorized(t *testing.T) {services.SetCurrentTenant(mock.DemoTenant)services.SetCurrentUser(mock.AryaStark)post, _ := services.Posts.Add("The Post #1", "The Description #1")- services.Posts.AddSupporter(post, mock.AryaStark)+ services.Posts.AddVote(post, mock.AryaStark)code, _ := server.OnTenant(mock.DemoTenant).@@ -233,7 +233,7 @@ func TestSetResponseHandler_Duplicate_Itself(t *testing.T) {Expect(code).Equals(http.StatusBadRequest)}-func TestAddSupporterHandler(t *testing.T) {+func TestAddVoteHandler(t *testing.T) {RegisterT(t)server, services := mock.NewServer()@@ -246,17 +246,17 @@ func TestAddSupporterHandler(t *testing.T) {OnTenant(mock.DemoTenant).AsUser(mock.AryaStark).AddParam("number", second.Number).- Execute(apiv1.AddSupporter())+ Execute(apiv1.AddVote())first, _ = services.Posts.GetByNumber(1)second, _ = services.Posts.GetByNumber(2)Expect(code).Equals(http.StatusOK)- Expect(first.TotalSupporters).Equals(0)- Expect(second.TotalSupporters).Equals(1)+ Expect(first.TotalVotes).Equals(0)+ Expect(second.TotalVotes).Equals(1)}-func TestAddSupporterHandler_InvalidPost(t *testing.T) {+func TestAddVoteHandler_InvalidPost(t *testing.T) {RegisterT(t)server, _ := mock.NewServer()@@ -264,31 +264,31 @@ func TestAddSupporterHandler_InvalidPost(t *testing.T) {OnTenant(mock.DemoTenant).AsUser(mock.AryaStark).AddParam("number", 999).- Execute(apiv1.AddSupporter())+ Execute(apiv1.AddVote())Expect(code).Equals(http.StatusNotFound)}-func TestRemoveSupporterHandler(t *testing.T) {+func TestRemoveVoteHandler(t *testing.T) {RegisterT(t)server, services := mock.NewServer()services.SetCurrentTenant(mock.DemoTenant)services.SetCurrentUser(mock.JonSnow)post, _ := services.Posts.Add("The Post #1", "The Description #1")- services.Posts.AddSupporter(post, mock.JonSnow)- services.Posts.AddSupporter(post, mock.AryaStark)+ services.Posts.AddVote(post, mock.JonSnow)+ services.Posts.AddVote(post, mock.AryaStark)code, _ := server.OnTenant(mock.DemoTenant).AsUser(mock.AryaStark).AddParam("number", post.ID).- Execute(apiv1.RemoveSupporter())+ Execute(apiv1.RemoveVote())post, _ = services.Posts.GetByNumber(post.Number)Expect(code).Equals(http.StatusOK)- Expect(post.TotalSupporters).Equals(1)+ Expect(post.TotalVotes).Equals(1)}func TestDeletePostHandler_Authorized(t *testing.T) {diff --git a/app/models/feedback.go b/app/models/feedback.goindex e27512b2f..6c8fdcad6 100644--- a/app/models/feedback.go+++ b/app/models/feedback.go@@ -7,23 +7,23 @@ import (//Post represents an post on a tenant boardtype Post struct {- ID int `json:"id"`- Number int `json:"number"`- Title string `json:"title"`- Slug string `json:"slug"`- Description string `json:"description"`- CreatedOn time.Time `json:"createdOn"`- User *User `json:"user"`- ViewerSupported bool `json:"viewerSupported"`- TotalSupporters int `json:"totalSupporters"`- TotalComments int `json:"totalComments"`- Status int `json:"status"`- Response *PostResponse `json:"response"`- Tags []string `json:"tags"`-}--// CanBeSupported returns true if this post can be Supported/UnSupported-func (i *Post) CanBeSupported() bool {+ ID int `json:"id"`+ Number int `json:"number"`+ Title string `json:"title"`+ Slug string `json:"slug"`+ Description string `json:"description"`+ CreatedOn time.Time `json:"createdOn"`+ User *User `json:"user"`+ HasVoted bool `json:"hasVoted"`+ TotalVotes int `json:"totalVotes"`+ TotalComments int `json:"totalComments"`+ Status int `json:"status"`+ Response *PostResponse `json:"response"`+ Tags []string `json:"tags"`+}++// CanBeVoted returns true if this post can have its vote changed+func (i *Post) CanBeVoted() bool {return i.Status != PostCompleted && i.Status != PostDeclined && i.Status != PostDuplicate}diff --git a/app/pkg/csv/csv.go b/app/pkg/csv/csv.goindex 58a0ad578..a07a81057 100644--- a/app/pkg/csv/csv.go+++ b/app/pkg/csv/csv.go@@ -21,7 +21,7 @@ func FromPosts(posts []*models.Post) ([]byte, error) {"description","created_on","created_by",- "total_supporters",+ "total_votes","total_comments","status","responded_by",@@ -60,7 +60,7 @@ func FromPosts(posts []*models.Post) ([]byte, error) {post.Description,post.CreatedOn.Format(time.RFC3339),post.User.Name,- strconv.Itoa(post.TotalSupporters),+ strconv.Itoa(post.TotalVotes),strconv.Itoa(post.TotalComments),models.GetPostStatusName(post.Status),respondedBy,diff --git a/app/pkg/csv/csv_test.go b/app/pkg/csv/csv_test.goindex b1666c65f..5a2e7d61f 100644--- a/app/pkg/csv/csv_test.go+++ b/app/pkg/csv/csv_test.go@@ -59,9 +59,9 @@ var declinedPost = &models.Post{User: &models.User{Name: "Faceless",},- TotalSupporters: 4,- TotalComments: 2,- Status: models.PostDeclined,+ TotalVotes: 4,+ TotalComments: 2,+ Status: models.PostDeclined,Response: &models.PostResponse{Text: "Nothing we need to do",RespondedOn: time.Date(2018, 4, 4, 19, 48, 10, 0, time.UTC),@@ -80,9 +80,9 @@ var openPost = &models.Post{User: &models.User{Name: "Someone else",},- TotalSupporters: 4,- TotalComments: 2,- Status: models.PostOpen,+ TotalVotes: 4,+ TotalComments: 2,+ Status: models.PostOpen,}var duplicatePost = &models.Post{@@ -93,9 +93,9 @@ var duplicatePost = &models.Post{User: &models.User{Name: "Faceless",},- TotalSupporters: 4,- TotalComments: 2,- Status: models.PostDuplicate,+ TotalVotes: 4,+ TotalComments: 2,+ Status: models.PostDuplicate,Response: &models.PostResponse{Text: "This has already been suggested",RespondedOn: time.Date(2018, 3, 17, 10, 15, 42, 0, time.UTC),diff --git a/app/pkg/csv/testdata/empty.csv b/app/pkg/csv/testdata/empty.csvindex 09417e3d2..4da6c3c7b 100644--- a/app/pkg/csv/testdata/empty.csv+++ b/app/pkg/csv/testdata/empty.csv@@ -1 +1 @@-number,title,description,created_on,created_by,total_supporters,total_comments,status,responded_by,responded_on,response,original_number,original_title,tags+number,title,description,created_on,created_by,total_votes,total_comments,status,responded_by,responded_on,response,original_number,original_title,tagsdiff --git a/app/pkg/csv/testdata/more-posts.csv b/app/pkg/csv/testdata/more-posts.csvindex 8604b52c1..82bebfaa0 100755--- a/app/pkg/csv/testdata/more-posts.csv+++ b/app/pkg/csv/testdata/more-posts.csv@@ -1,4 +1,4 @@-number,title,description,created_on,created_by,total_supporters,total_comments,status,responded_by,responded_on,response,original_number,original_title,tags+number,title,description,created_on,created_by,total_votes,total_comments,status,responded_by,responded_on,response,original_number,original_title,tags10,Go is fast,Very tiny description,2018-03-23T19:33:22Z,Faceless,4,2,Declined,John Snow,2018-04-04T19:48:10Z,Nothing we need to do,,,"easy, ignored"15,Go is great,,2018-02-21T15:51:35Z,Someone else,4,2,Open,,,,,,20,Go is easy,,2018-01-12T01:46:59Z,Faceless,4,2,Duplicate,Arya Stark,2018-03-17T10:15:42Z,This has already been suggested,99,Go is very easy,"this-tag-has,comma"diff --git a/app/pkg/csv/testdata/one-post.csv b/app/pkg/csv/testdata/one-post.csvindex ea304ed93..82355dd4c 100755--- a/app/pkg/csv/testdata/one-post.csv+++ b/app/pkg/csv/testdata/one-post.csv@@ -1,2 +1,2 @@-number,title,description,created_on,created_by,total_supporters,total_comments,status,responded_by,responded_on,response,original_number,original_title,tags+number,title,description,created_on,created_by,total_votes,total_comments,status,responded_by,responded_on,response,original_number,original_title,tags10,Go is fast,Very tiny description,2018-03-23T19:33:22Z,Faceless,4,2,Declined,John Snow,2018-04-04T19:48:10Z,Nothing we need to do,,,"easy, ignored"diff --git a/app/storage/inmemory/post.go b/app/storage/inmemory/post.goindex 7522f9f91..8d259d2bc 100644--- a/app/storage/inmemory/post.go+++ b/app/storage/inmemory/post.go@@ -11,23 +11,23 @@ import (// PostStorage contains read and write operations for poststype PostStorage struct {- lastID int- lastCommentID int- posts []*models.Post- postsSupportedBy map[int][]int- postSubscribers map[int][]*models.User- postComments map[int][]*models.Comment- tenant *models.Tenant- user *models.User+ lastID int+ lastCommentID int+ posts []*models.Post+ postsVotedBy map[int][]int+ postSubscribers map[int][]*models.User+ postComments map[int][]*models.Comment+ tenant *models.Tenant+ user *models.User}// NewPostStorage creates a new PostStoragefunc NewPostStorage() *PostStorage {return &PostStorage{- posts: make([]*models.Post, 0),- postsSupportedBy: make(map[int][]int, 0),- postSubscribers: make(map[int][]*models.User, 0),- postComments: make(map[int][]*models.Comment, 0),+ posts: make([]*models.Post, 0),+ postsVotedBy: make(map[int][]int, 0),+ postSubscribers: make(map[int][]*models.User, 0),+ postComments: make(map[int][]*models.Comment, 0),}}@@ -110,7 +110,7 @@ func (s *PostStorage) Add(title, description string) (*models.Post, error) {User: s.user,}s.posts = append(s.posts, post)- s.postsSupportedBy[s.user.ID] = append(s.postsSupportedBy[s.user.ID], post.ID)+ s.postsVotedBy[s.user.ID] = append(s.postsVotedBy[s.user.ID], post.ID)s.AddSubscriber(post, s.user)return post, nil}@@ -153,22 +153,22 @@ func (s *PostStorage) UpdateComment(id int, content string) error {return nil}-// AddSupporter adds user to post list of supporters-func (s *PostStorage) AddSupporter(post *models.Post, user *models.User) error {- s.postsSupportedBy[user.ID] = append(s.postsSupportedBy[user.ID], post.ID)- post.TotalSupporters = post.TotalSupporters + 1+// AddVote adds user to post list of votes+func (s *PostStorage) AddVote(post *models.Post, user *models.User) error {+ s.postsVotedBy[user.ID] = append(s.postsVotedBy[user.ID], post.ID)+ post.TotalVotes = post.TotalVotes + 1return nil}-// RemoveSupporter removes user from post list of supporters-func (s *PostStorage) RemoveSupporter(post *models.Post, user *models.User) error {- for i, id := range s.postsSupportedBy[user.ID] {+// RemoveVote removes user from post list of votes+func (s *PostStorage) RemoveVote(post *models.Post, user *models.User) error {+ for i, id := range s.postsVotedBy[user.ID] {if id == post.ID {- s.postsSupportedBy[user.ID] = append(s.postsSupportedBy[user.ID][:i], s.postsSupportedBy[user.ID][i+1:]...)+ s.postsVotedBy[user.ID] = append(s.postsVotedBy[user.ID][:i], s.postsVotedBy[user.ID][i+1:]...)break}}- post.TotalSupporters = post.TotalSupporters - 1+ post.TotalVotes = post.TotalVotes - 1return nil}@@ -218,9 +218,9 @@ func (s *PostStorage) IsReferenced(post *models.Post) (bool, error) {return false, nil}-// SupportedBy returns a list of Post ID supported by given user-func (s *PostStorage) SupportedBy() ([]int, error) {- return s.postsSupportedBy[s.user.ID], nil+// VotedBy returns a list of Post ID voted by given user+func (s *PostStorage) VotedBy() ([]int, error) {+ return s.postsVotedBy[s.user.ID], nil}// AddSubscriber adds user to the post list of subscribersdiff --git a/app/storage/postgres/common.go b/app/storage/postgres/common.goindex b77d5cf30..2163e1bb8 100644--- a/app/storage/postgres/common.go+++ b/app/storage/postgres/common.go@@ -30,10 +30,10 @@ func getFilterData(filter string) (string, []int, string) {case "recent":sort = "id"case "my-votes":- condition = "AND viewer_supported = true"+ condition = "AND has_voted = true"sort = "id"case "most-wanted":- sort = "supporters"+ sort = "votes"case "most-discussed":sort = "comments"case "planned":@@ -60,7 +60,7 @@ func getFilterData(filter string) (string, []int, string) {case "trending":fallthroughdefault:- sort = "((COALESCE(recent_supporters, 0)*5 + COALESCE(recent_comments, 0) *3)-1) / pow((EXTRACT(EPOCH FROM current_timestamp - created_on)/3600) + 2, 1.4)"+ sort = "((COALESCE(recent_votes, 0)*5 + COALESCE(recent_comments, 0) *3)-1) / pow((EXTRACT(EPOCH FROM current_timestamp - created_on)/3600) + 2, 1.4)"}return condition, statuses, sort}diff --git a/app/storage/postgres/post.go b/app/storage/postgres/post.goindex 58198d90d..a4940983f 100644--- a/app/storage/postgres/post.go+++ b/app/storage/postgres/post.go@@ -15,43 +15,43 @@ import ()type dbPost struct {- ID int `db:"id"`- Number int `db:"number"`- Title string `db:"title"`- Slug string `db:"slug"`- Description string `db:"description"`- CreatedOn time.Time `db:"created_on"`- User *dbUser `db:"user"`- ViewerSupported bool `db:"viewer_supported"`- TotalSupporters int `db:"supporters"`- TotalComments int `db:"comments"`- RecentSupporters int `db:"recent_supporters"`- RecentComments int `db:"recent_comments"`- Status int `db:"status"`- Response sql.NullString `db:"response"`- RespondedOn dbx.NullTime `db:"response_date"`- ResponseUser *dbUser `db:"response_user"`- OriginalNumber sql.NullInt64 `db:"original_number"`- OriginalTitle sql.NullString `db:"original_title"`- OriginalSlug sql.NullString `db:"original_slug"`- OriginalStatus sql.NullInt64 `db:"original_status"`- Tags []string `db:"tags"`+ ID int `db:"id"`+ Number int `db:"number"`+ Title string `db:"title"`+ Slug string `db:"slug"`+ Description string `db:"description"`+ CreatedOn time.Time `db:"created_on"`+ User *dbUser `db:"user"`+ HasVoted bool `db:"has_voted"`+ TotalVotes int `db:"votes"`+ TotalComments int `db:"comments"`+ RecentVotes int `db:"recent_votes"`+ RecentComments int `db:"recent_comments"`+ Status int `db:"status"`+ Response sql.NullString `db:"response"`+ RespondedOn dbx.NullTime `db:"response_date"`+ ResponseUser *dbUser `db:"response_user"`+ OriginalNumber sql.NullInt64 `db:"original_number"`+ OriginalTitle sql.NullString `db:"original_title"`+ OriginalSlug sql.NullString `db:"original_slug"`+ OriginalStatus sql.NullInt64 `db:"original_status"`+ Tags []string `db:"tags"`}func (i *dbPost) toModel() *models.Post {post := &models.Post{- ID: i.ID,- Number: i.Number,- Title: i.Title,- Slug: i.Slug,- Description: i.Description,- CreatedOn: i.CreatedOn,- ViewerSupported: i.ViewerSupported,- TotalSupporters: i.TotalSupporters,- TotalComments: i.TotalComments,- Status: i.Status,- User: i.User.toModel(),- Tags: i.Tags,+ ID: i.ID,+ Number: i.Number,+ Title: i.Title,+ Slug: i.Slug,+ Description: i.Description,+ CreatedOn: i.CreatedOn,+ HasVoted: i.HasVoted,+ TotalVotes: i.TotalVotes,+ TotalComments: i.TotalComments,+ Status: i.Status,+ User: i.User.toModel(),+ Tags: i.Tags,}if i.Response.Valid {@@ -138,15 +138,15 @@ var (WHERE posts.tenant_id = $1GROUP BY post_id),- agg_supporters AS (+ agg_votes AS (SELECTpost_id,- COUNT(CASE WHEN post_supporters.created_on > CURRENT_DATE - INTERVAL '30 days' THEN 1 END) as recent,+ COUNT(CASE WHEN post_votes.created_on > CURRENT_DATE - INTERVAL '30 days' THEN 1 END) as recent,COUNT(*) as all- FROM post_supporters+ FROM post_votesINNER JOIN posts- ON posts.id = post_supporters.post_id- AND posts.tenant_id = post_supporters.tenant_id+ ON posts.id = post_votes.post_id+ AND posts.tenant_id = post_votes.tenant_idWHERE posts.tenant_id = $1GROUP BY post_id)@@ -156,9 +156,9 @@ var (p.slug,p.description,p.created_on,- COALESCE(agg_s.all, 0) as supporters,+ COALESCE(agg_s.all, 0) as votes,COALESCE(agg_c.all, 0) as comments,- COALESCE(agg_s.recent, 0) AS recent_supporters,+ COALESCE(agg_s.recent, 0) AS recent_votes,COALESCE(agg_c.recent, 0) AS recent_comments,p.status,u.id AS user_id,@@ -178,7 +178,7 @@ var (d.slug AS original_slug,d.status AS original_status,array_remove(array_agg(t.slug), NULL) AS tags,- COALESCE(%s, false) AS viewer_supported+ COALESCE(%s, false) AS has_votedFROM posts pINNER JOIN users uON u.id = p.user_id@@ -193,22 +193,22 @@ var (%sLEFT JOIN agg_comments agg_cON agg_c.post_id = p.id- LEFT JOIN agg_supporters agg_s+ LEFT JOIN agg_votes agg_sON agg_s.post_id = p.idWHERE p.status != ` + strconv.Itoa(models.PostDeleted) + ` AND %sGROUP BY p.id, u.id, r.id, d.id, agg_s.all, agg_c.all, agg_c.recent, agg_s.recent`)func (s *PostStorage) getPostQuery(filter string) string {- viewerSupportedSubQuery := "null"+ hasVotedSubQuery := "null"if s.user != nil {- viewerSupportedSubQuery = fmt.Sprintf("(SELECT true FROM post_supporters WHERE post_id = p.id AND user_id = %d)", s.user.ID)+ hasVotedSubQuery = fmt.Sprintf("(SELECT true FROM post_votes WHERE post_id = p.id AND user_id = %d)", s.user.ID)}tagCondition := `AND t.is_public = true`if s.user != nil && s.user.IsCollaborator() {tagCondition = ``}- return fmt.Sprintf(sqlSelectPostsWhere, viewerSupportedSubQuery, tagCondition, filter)+ return fmt.Sprintf(sqlSelectPostsWhere, hasVotedSubQuery, tagCondition, filter)}func (s *PostStorage) getSingle(query string, args ...interface{}) (*models.Post, error) {@@ -464,32 +464,32 @@ func (s *PostStorage) UpdateComment(id int, content string) error {return nil}-// AddSupporter adds user to post list of supporters-func (s *PostStorage) AddSupporter(post *models.Post, user *models.User) error {- if !post.CanBeSupported() {+// AddVote adds user to post list of votes+func (s *PostStorage) AddVote(post *models.Post, user *models.User) error {+ if !post.CanBeVoted() {return nil}_, err := s.trx.Execute(- `INSERT INTO post_supporters (tenant_id, user_id, post_id, created_on) VALUES ($1, $2, $3, $4) ON CONFLICT DO NOTHING`,+ `INSERT INTO post_votes (tenant_id, user_id, post_id, created_on) VALUES ($1, $2, $3, $4) ON CONFLICT DO NOTHING`,s.tenant.ID, user.ID, post.ID, time.Now())if err != nil {- return errors.Wrap(err, "failed add supporter to post")+ return errors.Wrap(err, "failed add vote to post")}return s.internalAddSubscriber(post, user, false)}-// RemoveSupporter removes user from post list of supporters-func (s *PostStorage) RemoveSupporter(post *models.Post, user *models.User) error {- if !post.CanBeSupported() {+// RemoveVote removes user from post list of votes+func (s *PostStorage) RemoveVote(post *models.Post, user *models.User) error {+ if !post.CanBeVoted() {return nil}- _, err := s.trx.Execute(`DELETE FROM post_supporters WHERE user_id = $1 AND post_id = $2 AND tenant_id = $3`, user.ID, post.ID, s.tenant.ID)+ _, err := s.trx.Execute(`DELETE FROM post_votes WHERE user_id = $1 AND post_id = $2 AND tenant_id = $3`, user.ID, post.ID, s.tenant.ID)if err != nil {- return errors.Wrap(err, "failed to delete post supporter")+ return errors.Wrap(err, "failed to remove vote from post")}return err@@ -640,13 +640,13 @@ func (s *PostStorage) MarkAsDuplicate(post *models.Post, original *models.Post)}var users []*dbUser- err := s.trx.Select(&users, "SELECT user_id AS id FROM post_supporters WHERE post_id = $1 AND tenant_id = $2", post.ID, s.tenant.ID)+ err := s.trx.Select(&users, "SELECT user_id AS id FROM post_votes WHERE post_id = $1 AND tenant_id = $2", post.ID, s.tenant.ID)if err != nil {- return errors.Wrap(err, "failed to get supporters of post with id '%d'", post.ID)+ return errors.Wrap(err, "failed to get votes of post with id '%d'", post.ID)}for _, u := range users {- if err := s.AddSupporter(original, u.toModel()); err != nil {+ if err := s.AddVote(original, u.toModel()); err != nil {return err}}@@ -689,11 +689,11 @@ func (s *PostStorage) IsReferenced(post *models.Post) (bool, error) {return exists, nil}-// SupportedBy returns a list of Post ID supported by given user-func (s *PostStorage) SupportedBy() ([]int, error) {- posts, err := s.trx.QueryIntArray("SELECT post_id FROM post_supporters WHERE user_id = $1 AND tenant_id = $2", s.user.ID, s.tenant.ID)+// VotedBy returns a list of Post ID voted by given user+func (s *PostStorage) VotedBy() ([]int, error) {+ posts, err := s.trx.QueryIntArray("SELECT post_id FROM post_votes WHERE user_id = $1 AND tenant_id = $2", s.user.ID, s.tenant.ID)if err != nil {- return nil, errors.Wrap(err, "failed to get user's supported posts")+ return nil, errors.Wrap(err, "failed to get user's voted posts")}return posts, nil}diff --git a/app/storage/postgres/post_test.go b/app/storage/postgres/post_test.goindex e25104a36..e9b0d27c3 100644--- a/app/storage/postgres/post_test.go+++ b/app/storage/postgres/post_test.go@@ -30,7 +30,7 @@ func TestPostStorage_GetAll(t *testing.T) {Expect(dbPosts[0].Number).Equals(2)Expect(dbPosts[0].Description).Equals("no description")Expect(dbPosts[0].User.Name).Equals("Arya Stark")- Expect(dbPosts[0].TotalSupporters).Equals(0)+ Expect(dbPosts[0].TotalVotes).Equals(0)Expect(dbPosts[0].Status).Equals(models.PostCompleted)Expect(dbPosts[1].Title).Equals("add twitter integration")@@ -38,7 +38,7 @@ func TestPostStorage_GetAll(t *testing.T) {Expect(dbPosts[1].Number).Equals(1)Expect(dbPosts[1].Description).Equals("Would be great to see it integrated with twitter")Expect(dbPosts[1].User.Name).Equals("Jon Snow")- Expect(dbPosts[1].TotalSupporters).Equals(0)+ Expect(dbPosts[1].TotalVotes).Equals(0)Expect(dbPosts[1].Status).Equals(models.PostStarted)dbPosts, err = posts.Search("twitter", "trending", "10", []string{})@@ -64,8 +64,8 @@ func TestPostStorage_AddAndGet(t *testing.T) {Expect(err).IsNil()Expect(dbPostByID.ID).Equals(post.ID)Expect(dbPostByID.Number).Equals(1)- Expect(dbPostByID.ViewerSupported).IsFalse()- Expect(dbPostByID.TotalSupporters).Equals(0)+ Expect(dbPostByID.HasVoted).IsFalse()+ Expect(dbPostByID.TotalVotes).Equals(0)Expect(dbPostByID.Status).Equals(models.PostOpen)Expect(dbPostByID.Title).Equals("My new post")Expect(dbPostByID.Description).Equals("with this description")@@ -78,8 +78,8 @@ func TestPostStorage_AddAndGet(t *testing.T) {Expect(err).IsNil()Expect(dbPostBySlug.ID).Equals(post.ID)Expect(dbPostBySlug.Number).Equals(1)- Expect(dbPostBySlug.ViewerSupported).IsFalse()- Expect(dbPostBySlug.TotalSupporters).Equals(0)+ Expect(dbPostBySlug.HasVoted).IsFalse()+ Expect(dbPostBySlug.TotalVotes).Equals(0)Expect(dbPostBySlug.Status).Equals(models.PostOpen)Expect(dbPostBySlug.Title).Equals("My new post")Expect(dbPostBySlug.Description).Equals("with this description")@@ -206,7 +206,7 @@ func TestPostStorage_Update(t *testing.T) {Expect(post.Slug).Equals("the-new-comment")}-func TestPostStorage_AddSupporter(t *testing.T) {+func TestPostStorage_AddVote(t *testing.T) {SetupDatabaseTest(t)defer TeardownDatabaseTest()@@ -217,23 +217,23 @@ func TestPostStorage_AddSupporter(t *testing.T) {post, err := posts.Add("My new post", "with this description")Expect(err).IsNil()- err = posts.AddSupporter(post, aryaStark)+ err = posts.AddVote(post, aryaStark)Expect(err).IsNil()dbPost, err := posts.GetByNumber(1)- Expect(dbPost.ViewerSupported).IsFalse()- Expect(dbPost.TotalSupporters).Equals(1)+ Expect(dbPost.HasVoted).IsFalse()+ Expect(dbPost.TotalVotes).Equals(1)- err = posts.AddSupporter(post, jonSnow)+ err = posts.AddVote(post, jonSnow)Expect(err).IsNil()dbPost, err = posts.GetByNumber(1)Expect(err).IsNil()- Expect(dbPost.ViewerSupported).IsTrue()- Expect(dbPost.TotalSupporters).Equals(2)+ Expect(dbPost.HasVoted).IsTrue()+ Expect(dbPost.TotalVotes).Equals(2)}-func TestPostStorage_AddSupporter_Twice(t *testing.T) {+func TestPostStorage_AddVote_Twice(t *testing.T) {SetupDatabaseTest(t)defer TeardownDatabaseTest()@@ -242,18 +242,18 @@ func TestPostStorage_AddSupporter_Twice(t *testing.T) {post, _ := posts.Add("My new post", "with this description")- err := posts.AddSupporter(post, jonSnow)+ err := posts.AddVote(post, jonSnow)Expect(err).IsNil()- err = posts.AddSupporter(post, jonSnow)+ err = posts.AddVote(post, jonSnow)Expect(err).IsNil()dbPost, err := posts.GetByNumber(1)Expect(err).IsNil()- Expect(dbPost.TotalSupporters).Equals(1)+ Expect(dbPost.TotalVotes).Equals(1)}-func TestPostStorage_RemoveSupporter(t *testing.T) {+func TestPostStorage_RemoveVote(t *testing.T) {SetupDatabaseTest(t)defer TeardownDatabaseTest()@@ -262,18 +262,18 @@ func TestPostStorage_RemoveSupporter(t *testing.T) {post, _ := posts.Add("My new post", "with this description")- err := posts.AddSupporter(post, jonSnow)+ err := posts.AddVote(post, jonSnow)Expect(err).IsNil()- err = posts.RemoveSupporter(post, jonSnow)+ err = posts.RemoveVote(post, jonSnow)Expect(err).IsNil()dbPost, err := posts.GetByNumber(1)Expect(err).IsNil()- Expect(dbPost.TotalSupporters).Equals(0)+ Expect(dbPost.TotalVotes).Equals(0)}-func TestPostStorage_RemoveSupporter_Twice(t *testing.T) {+func TestPostStorage_RemoveVote_Twice(t *testing.T) {SetupDatabaseTest(t)defer TeardownDatabaseTest()@@ -282,18 +282,18 @@ func TestPostStorage_RemoveSupporter_Twice(t *testing.T) {post, _ := posts.Add("My new post", "with this description")- err := posts.AddSupporter(post, jonSnow)+ err := posts.AddVote(post, jonSnow)Expect(err).IsNil()- err = posts.RemoveSupporter(post, jonSnow)+ err = posts.RemoveVote(post, jonSnow)Expect(err).IsNil()- err = posts.RemoveSupporter(post, jonSnow)+ err = posts.RemoveVote(post, jonSnow)Expect(err).IsNil()dbPost, err := posts.GetByNumber(1)Expect(err).IsNil()- Expect(dbPost.TotalSupporters).Equals(0)+ Expect(dbPost.TotalVotes).Equals(0)}func TestPostStorage_SetResponse(t *testing.T) {@@ -355,24 +355,24 @@ func TestPostStorage_SetResponse_AsDuplicate(t *testing.T) {posts.SetCurrentUser(jonSnow)post1, _ := posts.Add("My new post", "with this description")- posts.AddSupporter(post1, jonSnow)+ posts.AddVote(post1, jonSnow)posts.SetCurrentUser(aryaStark)post2, _ := posts.Add("My other post", "with similar description")- posts.AddSupporter(post2, aryaStark)+ posts.AddVote(post2, aryaStark)posts.SetCurrentUser(jonSnow)posts.MarkAsDuplicate(post2, post1)post1, _ = posts.GetByID(post1.ID)- Expect(post1.TotalSupporters).Equals(2)+ Expect(post1.TotalVotes).Equals(2)Expect(post1.Status).Equals(models.PostOpen)Expect(post1.Response).IsNil()post2, _ = posts.GetByID(post2.ID)Expect(post2.Response.Text).Equals("")- Expect(post2.TotalSupporters).Equals(1)+ Expect(post2.TotalVotes).Equals(1)Expect(post2.Status).Equals(models.PostDuplicate)Expect(post2.Response.User.ID).Equals(1)Expect(post2.Response.Original.Number).Equals(post1.Number)@@ -401,7 +401,7 @@ func TestPostStorage_SetResponse_AsDeleted(t *testing.T) {Expect(post2).IsNil()}-func TestPostStorage_AddSupporter_ClosedPost(t *testing.T) {+func TestPostStorage_AddVote_ClosedPost(t *testing.T) {SetupDatabaseTest(t)defer TeardownDatabaseTest()@@ -409,30 +409,30 @@ func TestPostStorage_AddSupporter_ClosedPost(t *testing.T) {posts.SetCurrentUser(jonSnow)post, _ := posts.Add("My new post", "with this description")posts.SetResponse(post, "We liked this post", models.PostCompleted)- posts.AddSupporter(post, jonSnow)+ posts.AddVote(post, jonSnow)dbPost, err := posts.GetByNumber(post.Number)Expect(err).IsNil()- Expect(dbPost.TotalSupporters).Equals(0)+ Expect(dbPost.TotalVotes).Equals(0)}-func TestPostStorage_RemoveSupporter_ClosedPost(t *testing.T) {+func TestPostStorage_RemoveVote_ClosedPost(t *testing.T) {SetupDatabaseTest(t)defer TeardownDatabaseTest()posts.SetCurrentTenant(demoTenant)posts.SetCurrentUser(jonSnow)post, _ := posts.Add("My new post", "with this description")- posts.AddSupporter(post, jonSnow)+ posts.AddVote(post, jonSnow)posts.SetResponse(post, "We liked this post", models.PostCompleted)- posts.RemoveSupporter(post, jonSnow)+ posts.RemoveVote(post, jonSnow)dbPost, err := posts.GetByNumber(post.Number)Expect(err).IsNil()- Expect(dbPost.TotalSupporters).Equals(1)+ Expect(dbPost.TotalVotes).Equals(1)}-func TestPostStorage_ListSupportedPosts(t *testing.T) {+func TestPostStorage_ListVotedPosts(t *testing.T) {SetupDatabaseTest(t)defer TeardownDatabaseTest()@@ -440,16 +440,16 @@ func TestPostStorage_ListSupportedPosts(t *testing.T) {posts.SetCurrentUser(jonSnow)post1, _ := posts.Add("My new post", "with this description")post2, _ := posts.Add("My other post", "with better description")- posts.AddSupporter(post1, aryaStark)- posts.AddSupporter(post2, aryaStark)+ posts.AddVote(post1, aryaStark)+ posts.AddVote(post2, aryaStark)posts.SetCurrentUser(jonSnow)- arr, err := posts.SupportedBy()+ arr, err := posts.VotedBy()Expect(err).IsNil()Expect(arr).Equals([]int{})posts.SetCurrentUser(aryaStark)- arr, err = posts.SupportedBy()+ arr, err = posts.VotedBy()Expect(err).IsNil()Expect(arr).Equals([]int{post1.ID, post2.ID})}diff --git a/app/storage/postgres/user.go b/app/storage/postgres/user.goindex 1c3c12114..53d5d3ee2 100644--- a/app/storage/postgres/user.go+++ b/app/storage/postgres/user.go@@ -307,7 +307,7 @@ func (s *UserStorage) Delete() error {{"user_settings", "user_id"},{"notifications", "user_id"},{"notifications", "author_id"},- {"post_supporters", "user_id"},+ {"post_votes", "user_id"},{"post_subscribers", "user_id"},{"email_verifications", "user_id"},}diff --git a/app/storage/storage.go b/app/storage/storage.goindex af4f8fa16..bdcbf4cae 100644--- a/app/storage/storage.go+++ b/app/storage/storage.go@@ -27,15 +27,15 @@ type Post interface {AddComment(post *models.Post, content string) (int, error)GetCommentByID(id int) (*models.Comment, error)UpdateComment(id int, content string) error- AddSupporter(post *models.Post, user *models.User) error- RemoveSupporter(post *models.Post, user *models.User) error+ AddVote(post *models.Post, user *models.User) error+ RemoveVote(post *models.Post, user *models.User) errorAddSubscriber(post *models.Post, user *models.User) errorRemoveSubscriber(post *models.Post, user *models.User) errorGetActiveSubscribers(number int, channel models.NotificationChannel, event models.NotificationEvent) ([]*models.User, error)SetResponse(post *models.Post, text string, status int) errorMarkAsDuplicate(post *models.Post, original *models.Post) errorIsReferenced(post *models.Post) (bool, error)- SupportedBy() ([]int, error)+ VotedBy() ([]int, error)}// User is used for user operationsdiff --git a/migrations/201808291958_rename_support_vote.sql b/migrations/201808291958_rename_support_vote.sqlnew file mode 100644index 000000000..23db25d78--- /dev/null+++ b/migrations/201808291958_rename_support_vote.sql@@ -0,0 +1,13 @@+ALTER TABLE post_supporters RENAME TO post_votes;+ALTER INDEX post_supporters_pkey RENAME TO post_votes_pkey;+ALTER TABLE post_votes RENAME CONSTRAINT post_supporters_post_id_fkey TO post_votes_post_id_fkey;+ALTER TABLE post_votes RENAME CONSTRAINT post_supporters_tenant_id_fkey TO post_votes_tenant_id_fkey;+ALTER TABLE post_votes RENAME CONSTRAINT post_supporters_user_id_fkey TO post_votes_user_id_fkey;++UPDATE tenants+SET custom_css = replace(custom_css, '.c-support-counter', '.c-vote-counter')+WHERE custom_css LIKE '%.c-support-counter%';++UPDATE tenants+SET custom_css = replace(custom_css, '.m-supported', '.m-voted')+WHERE custom_css LIKE '%.m-supported%';\ No newline at end of filediff --git a/public/components/SupportCounter.scss b/public/components/VoteCounter.scsssimilarity index 89%rename from public/components/SupportCounter.scssrename to public/components/VoteCounter.scssindex a765e73a4..aab6d31cc 100644--- a/public/components/SupportCounter.scss+++ b/public/components/VoteCounter.scss@@ -1,10 +1,10 @@@import '~@fider/assets/styles/variables.scss';-.c-support-counter {+.c-vote-counter {margin-right: 10px;button,- button.m-supported,+ button.m-voted,button.m-disabled {font-size: 18px;border: none;@@ -25,7 +25,7 @@@include disabled();}- button.m-supported,+ button.m-voted,button.no-touch:hover {color: $main-color;diff --git a/public/components/SupportCounter.spec.tsx b/public/components/VoteCounter.spec.tsxsimilarity index 61%rename from public/components/SupportCounter.spec.tsxrename to public/components/VoteCounter.spec.tsxindex 88cf87c38..3f3e5bbde 100644--- a/public/components/SupportCounter.spec.tsx+++ b/public/components/VoteCounter.spec.tsx@@ -1,7 +1,7 @@import * as React from "react";import { shallow } from "enzyme";import { Post, UserRole, PostStatus } from "@fider/models";-import { SupportCounter } from "@fider/components";+import { VoteCounter } from "@fider/components";import { httpMock, fiderMock, rerender } from "@fider/services/testing";let post: Post;@@ -20,41 +20,41 @@ beforeEach(() => {name: "John",role: UserRole.Collaborator},- viewerSupported: false,+ hasVoted: false,response: null,- totalSupporters: 5,+ totalVotes: 5,totalComments: 2,tags: []};});-describe("<SupportCounter />", () => {- test("when viewerSupported === true", () => {- post.viewerSupported = true;- post.totalSupporters = 9;- const wrapper = shallow(<SupportCounter post={post} />);+describe("<VoteCounter />", () => {+ test("when hasVoted === true", () => {+ post.hasVoted = true;+ post.totalVotes = 9;+ const wrapper = shallow(<VoteCounter post={post} />);const button = wrapper.find("button");expect(button.text()).toBe("9");- expect(button.hasClass("m-supported")).toBe(true);+ expect(button.hasClass("m-voted")).toBe(true);expect(button.hasClass("m-disabled")).toBe(false);});- test("when viewerSupported === false", () => {- post.viewerSupported = false;- post.totalSupporters = 2;- const wrapper = shallow(<SupportCounter post={post} />);+ test("when hasVoted === false", () => {+ post.hasVoted = false;+ post.totalVotes = 2;+ const wrapper = shallow(<VoteCounter post={post} />);const button = wrapper.find("button");expect(button.text()).toBe("2");- expect(button.hasClass("m-supported")).toBe(false);+ expect(button.hasClass("m-voted")).toBe(false);expect(button.hasClass("m-disabled")).toBe(false);});test("when post is closed", () => {post.status = PostStatus.Completed.value;- const wrapper = shallow(<SupportCounter post={post} />);+ const wrapper = shallow(<VoteCounter post={post} />);const button = wrapper.find("button");expect(button.text()).toBe("5");- expect(button.hasClass("m-supported")).toBe(false);+ expect(button.hasClass("m-voted")).toBe(false);expect(button.hasClass("m-disabled")).toBe(true);});@@ -63,7 +63,7 @@ describe("<SupportCounter />", () => {const mock = httpMock.alwaysOk();- const wrapper = shallow(<SupportCounter post={post} />);+ const wrapper = shallow(<VoteCounter post={post} />);wrapper.find("button").simulate("click");await rerender(wrapper);expect(wrapper.find("SignInModal").length).toBe(1);@@ -71,29 +71,29 @@ describe("<SupportCounter />", () => {expect(mock.delete).toHaveBeenCalledTimes(0);});- test("click when authenticated and viewerSupported === false", async () => {+ test("click when authenticated and hasVoted === false", async () => {fiderMock.authenticated();const mock = httpMock.alwaysOk();- const wrapper = shallow(<SupportCounter post={post} />);+ const wrapper = shallow(<VoteCounter post={post} />);wrapper.find("button").simulate("click");- expect(mock.post).toHaveBeenCalledWith("/api/v1/posts/10/support");+ expect(mock.post).toHaveBeenCalledWith("/api/v1/posts/10/votes");expect(mock.post).toHaveBeenCalledTimes(1);await rerender(wrapper);expect(wrapper.find("button").text()).toBe("6");});- test("click when authenticated and viewerSupported === true", async () => {- post.viewerSupported = true;+ test("click when authenticated and hasVoted === true", async () => {+ post.hasVoted = true;fiderMock.authenticated();const mock = httpMock.alwaysOk();- const wrapper = shallow(<SupportCounter post={post} />);+ const wrapper = shallow(<VoteCounter post={post} />);wrapper.find("button").simulate("click");- expect(mock.delete).toHaveBeenCalledWith("/api/v1/posts/10/support");+ expect(mock.delete).toHaveBeenCalledWith("/api/v1/posts/10/votes");expect(mock.delete).toHaveBeenCalledTimes(1);await rerender(wrapper);diff --git a/public/components/SupportCounter.tsx b/public/components/VoteCounter.tsxsimilarity index 59%rename from public/components/SupportCounter.tsxrename to public/components/VoteCounter.tsxindex 0a4f990c0..ccd877251 100644--- a/public/components/SupportCounter.tsx+++ b/public/components/VoteCounter.tsx@@ -1,43 +1,43 @@-import "./SupportCounter.scss";+import "./VoteCounter.scss";import * as React from "react";import { Post, PostStatus } from "@fider/models";import { actions, device, classSet, Fider } from "@fider/services";import { SignInModal } from "@fider/components";-interface SupportCounterProps {+interface VoteCounterProps {post: Post;}-interface SupportCounterState {- supported: boolean;+interface VoteCounterState {+ voted: boolean;total: number;showSignIn: boolean;}-export class SupportCounter extends React.Component<SupportCounterProps, SupportCounterState> {- constructor(props: SupportCounterProps) {+export class VoteCounter extends React.Component<VoteCounterProps, VoteCounterState> {+ constructor(props: VoteCounterProps) {super(props);this.state = {- supported: props.post.viewerSupported,- total: props.post.totalSupporters,+ voted: props.post.hasVoted,+ total: props.post.totalVotes,showSignIn: false};}- private supportOrUndo = async () => {+ private voteOrUndo = async () => {if (!Fider.session.isAuthenticated) {this.setState({ showSignIn: true });return;}- const action = this.state.supported ? actions.removeSupport : actions.addSupport;+ const action = this.state.voted ? actions.removeVote : actions.addVote;const response = await action(this.props.post.number);if (response.ok) {this.setState(state => ({- supported: !state.supported,- total: state.total + (state.supported ? -1 : 1)+ voted: !state.voted,+ total: state.total + (state.voted ? -1 : 1)}));}};@@ -46,13 +46,13 @@ export class SupportCounter extends React.Component<SupportCounterProps, Supportconst status = PostStatus.Get(this.props.post.status);const className = classSet({- "m-supported": !status.closed && this.state.supported,+ "m-voted": !status.closed && this.state.voted,"m-disabled": status.closed,"no-touch": !device.isTouch()});const vote = (- <button className={className} onClick={this.supportOrUndo}>+ <button className={className} onClick={this.voteOrUndo}><i className="caret up icon" />{this.state.total}</button>@@ -68,7 +68,7 @@ export class SupportCounter extends React.Component<SupportCounterProps, Supportreturn (<><SignInModal isOpen={this.state.showSignIn} />- <div className="c-support-counter">{status.closed ? disabled : vote}</div>+ <div className="c-vote-counter">{status.closed ? disabled : vote}</div></>);}diff --git a/public/components/index.tsx b/public/components/index.tsxindex c147fefa1..6321e6013 100644--- a/public/components/index.tsx+++ b/public/components/index.tsx@@ -1,5 +1,5 @@export * from "./ShowPostResponse";export * from "./ShowTag";export * from "./SignInModal";-export * from "./SupportCounter";+export * from "./VoteCounter";export * from "./common";diff --git a/public/models/post.ts b/public/models/post.tsindex f26d3f48a..e2c0c25ff 100644--- a/public/models/post.ts+++ b/public/models/post.ts@@ -9,9 +9,9 @@ export interface Post {createdOn: string;status: number;user: User;- viewerSupported: boolean;+ hasVoted: boolean;response: PostResponse | null;- totalSupporters: number;+ totalVotes: number;totalComments: number;tags: string[];}diff --git a/public/pages/Home/components/ListPosts.tsx b/public/pages/Home/components/ListPosts.tsxindex 73607c4a4..e831497c6 100644--- a/public/pages/Home/components/ListPosts.tsx+++ b/public/pages/Home/components/ListPosts.tsx@@ -5,7 +5,7 @@ import { Post, Tag, PostStatus, CurrentUser } from "@fider/models";import {ShowTag,ShowPostResponse,- SupportCounter,+ VoteCounter,Gravatar,MultiLineText,Moment,@@ -22,7 +22,7 @@ interface ListPostsProps {const ListPostItem = (props: { post: Post; user?: CurrentUser; tags: Tag[] }) => {return (<ListItem>- <SupportCounter post={props.post} />+ <VoteCounter post={props.post} /><div className="c-list-item-content">{props.post.totalComments > 0 && (<div className="info right">diff --git a/public/pages/ShowPost/ShowPost.page.scss b/public/pages/ShowPost/ShowPost.page.scssindex 2bae0c7eb..07df124a0 100644--- a/public/pages/ShowPost/ShowPost.page.scss+++ b/public/pages/ShowPost/ShowPost.page.scss@@ -55,7 +55,7 @@.c-response-form {.c-post-search {- .support {+ .votes {text-align: center;width: 50px;display: inline-block;diff --git a/public/pages/ShowPost/ShowPost.page.tsx b/public/pages/ShowPost/ShowPost.page.tsxindex e7a4f732a..5685e4e62 100644--- a/public/pages/ShowPost/ShowPost.page.tsx+++ b/public/pages/ShowPost/ShowPost.page.tsx@@ -7,7 +7,7 @@ import { actions, Failure, Fider } from "@fider/services";import { TagsPanel, DiscussionPanel, ResponseForm, NotificationsPanel, ModerationPanel } from "./";import {- SupportCounter,+ VoteCounter,ShowPostResponse,DisplayError,Button,@@ -86,7 +86,7 @@ export class ShowPostPage extends React.Component<ShowPostPageProps, ShowPostPag<div className="header-col"><List><ListItem>- <SupportCounter post={this.props.post} />+ <VoteCounter post={this.props.post} /><div className="post-header">{this.state.editMode ? (diff --git a/public/pages/ShowPost/components/PostSearch.tsx b/public/pages/ShowPost/components/PostSearch.tsxindex caef94824..c75bd18de 100644--- a/public/pages/ShowPost/components/PostSearch.tsx+++ b/public/pages/ShowPost/components/PostSearch.tsx@@ -55,9 +55,9 @@ export class PostSearch extends React.Component<PostSearchProps, PostSearchStatevalue: i.number,content: (<>- <span className="support">+ <span className="votes"><i className="caret up icon" />- {i.totalSupporters}+ {i.totalVotes}</span><span className={`status-label status-${status.slug}`}>{status.title}</span>{i.title}diff --git a/public/services/actions/post.ts b/public/services/actions/post.tsindex 48c61a5b3..3709e2508 100644--- a/public/services/actions/post.ts+++ b/public/services/actions/post.ts@@ -31,12 +31,12 @@ export const deletePost = async (postNumber: number, text: string): Promise<Resu.then(http.event("post", "delete"));};-export const addSupport = async (postNumber: number): Promise<Result> => {- return http.post(`/api/v1/posts/${postNumber}/support`).then(http.event("post", "support"));+export const addVote = async (postNumber: number): Promise<Result> => {+ return http.post(`/api/v1/posts/${postNumber}/votes`).then(http.event("post", "vote"));};-export const removeSupport = async (postNumber: number): Promise<Result> => {- return http.delete(`/api/v1/posts/${postNumber}/support`).then(http.event("post", "unsupport"));+export const removeVote = async (postNumber: number): Promise<Result> => {+ return http.delete(`/api/v1/posts/${postNumber}/votes`).then(http.event("post", "unvote"));};export const subscribe = async (postNumber: number): Promise<Result> => {diff --git a/tests/pages/ShowPostPage.ts b/tests/pages/ShowPostPage.tsindex 46b9c0cce..5157cd427 100644--- a/tests/pages/ShowPostPage.ts+++ b/tests/pages/ShowPostPage.ts@@ -14,8 +14,8 @@ export class ShowPostPage extends Page {public Status!: WebComponent;@findBy(".c-segment.l-response .content")public ResponseText!: WebComponent;- @findBy(".c-support-counter button")- public SupportCounter!: WebComponent;+ @findBy(".c-vote-counter button")+ public VoteCounter!: WebComponent;@findBy(".action-col .c-button.respond")public RespondButton!: Button;@findBy(".c-modal-window .c-response-form")diff --git a/tests/pages/components/PostList.ts b/tests/pages/components/PostList.tsindex ed4a99eb0..7690cfc24 100644--- a/tests/pages/components/PostList.ts+++ b/tests/pages/components/PostList.ts@@ -6,7 +6,7 @@ export class PostItem {private Link: WebComponent;constructor(protected tab: BrowserTab, public selector: string) {- this.Vote = new WebComponent(tab, `${this.selector} .c-support-counter button`);+ this.Vote = new WebComponent(tab, `${this.selector} .c-vote-counter button`);this.Link = new WebComponent(tab, `${this.selector} .c-list-item-title`);}diff --git a/tests/scenarios/feedback-loop.ts b/tests/scenarios/feedback-loop.tsindex 69bb9bb5f..bdcde10c2 100644--- a/tests/scenarios/feedback-loop.ts+++ b/tests/scenarios/feedback-loop.ts@@ -59,7 +59,7 @@ it("Tab1: Can submit Posts", async () => {// Assertawait ensure(ctx.tab1.pages.showPost.Title).textIs("Add support to TypeScript");await ensure(ctx.tab1.pages.showPost.Description).textIs("Because the language and community is awesome! :)");- await ensure(ctx.tab1.pages.showPost.SupportCounter).textIs("1");+ await ensure(ctx.tab1.pages.showPost.VoteCounter).textIs("1");});it("Tab1: Can edit title and description", async () => {@@ -69,7 +69,7 @@ it("Tab1: Can edit title and description", async () => {// Assertawait ensure(ctx.tab1.pages.showPost.Title).textIs("Support for TypeScript");await ensure(ctx.tab1.pages.showPost.Description).textIs("Because the language and community is awesome!");- await ensure(ctx.tab1.pages.showPost.SupportCounter).textIs("1");+ await ensure(ctx.tab1.pages.showPost.VoteCounter).textIs("1");});it("Tab2: Can login as another user", async () => {