-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Standup comments 1 #446
Open
GALTdea
wants to merge
41
commits into
main
Choose a base branch
from
standup-comments-1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Standup comments 1 #446
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
666ef94
Add StandupMeetingComment model
GALTdea 8fffecc
Add enum for standup_meeting_comment sections
GALTdea 2abc9b1
WIP: still need to organize views and controllers
GALTdea 1a73ed7
refactor yesterday_work_description to sections controller and added …
GALTdea bc0599f
remove unneded code and files
GALTdea f8748ae
removes unneded code
GALTdea d30f07c
rubocop fixes
GALTdea 36e8431
Style Standup comment section
GALTdea 0cc40e0
Adds user reference to standup meeting comments
GALTdea 1015180
resize comment container
GALTdea 47052d9
Add comment font-awesome icon to link_to
GALTdea a0cafb6
refactor standup_meeting creation to persist standup_meeting to be ab…
GALTdea a6ba1ca
remove unneded actions and add destroy action
GALTdea d275920
Adds a delete comment link
GALTdea 15b42f3
modify routes
GALTdea 82ff3b1
WIP: Adding request spec for standup_meeting_comments destroy action
GALTdea 01e3471
create action request test working
GALTdea 363fb0b
Fix standup_meeting_comment facotory bot
GALTdea eab9d4c
Add standup_meeting_comment_policy
GALTdea 4060e57
Rubocop
GALTdea f9b21ee
Add policy test specs for standup_meeting_comment destroy?
GALTdea fdc424c
.
GALTdea f54b765
Fix delete link style
GALTdea 09bdb6b
Update section index view style
GALTdea ec90999
remove create action
GALTdea 56ca3f5
Add comments spec for comments method)
GALTdea e6f5907
rubocop
GALTdea 03f7438
Add spec for section_content method
GALTdea f178b4f
Complete section_content specs for all sections
GALTdea b6519f1
Add policy to comment links
GALTdea bb8e968
Add StandupMeetingCommentPolicy edit? spec
GALTdea df52161
Re set migratioin
GALTdea 3ab668e
update standup_meeting_comments attribute name to sesction_name
GALTdea fe4d9c5
Update specs to reflect latest migration
GALTdea 4f928a0
Address PR feedback
GALTdea de4903d
update branch
GALTdea 652316e
resolved merging conflicts
GALTdea 86ce397
fixed content_type into an instance variable to fix failed tests in l…
GALTdea 93e6165
fixed bug caused by section_name variable changes
GALTdea dca22a9
Added spec for the allowed_section method
GALTdea 12c8a34
remove uneeded scope
GALTdea File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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,39 @@ | ||
class StandupMeetingCommentsController < ApplicationController | ||
before_action :set_standup_meeting, only: %i[create] | ||
|
||
def edit; end | ||
|
||
def create | ||
@standup_meeting_comment = @standup_meeting.standup_meeting_comments.new(standup_meeting_comment_params) | ||
@standup_meeting_comment.user = current_user | ||
if @standup_meeting_comment.save | ||
redirect_to @standup_meeting_comment, notice: 'Comment was successfully created.' | ||
else | ||
render :new | ||
end | ||
end | ||
|
||
def destroy | ||
@standup_meeting_comment = StandupMeetingComment.find(params[:id]) | ||
authorize @standup_meeting_comment | ||
respond_to do |format| | ||
if @standup_meeting_comment.destroy | ||
format.html do | ||
redirect_back(fallback_location: root_path, notice: 'Comment was successfully deleted.') | ||
end | ||
else | ||
format.html { render :show, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
private | ||
|
||
def set_standup_meeting | ||
@standup_meeting = StandupMeeting.find(params[:standup_meeting_id]) | ||
end | ||
|
||
def standup_meeting_comment_params | ||
params.require(:standup_meeting_comment).permit(:content, :section_name, :standup_meeting_id) | ||
end | ||
end |
This file contains 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,13 @@ | ||
class StandupMeetings::SectionsController < ApplicationController | ||
def index | ||
@standup_meeting = StandupMeeting.find(params[:standup_meeting_id]) | ||
@section = params[:section] | ||
|
||
if @standup_meeting.allowed_section?(@section) | ||
@question = @standup_meeting.send(@section) | ||
else | ||
flash[:alert] = 'Invalid section' | ||
redirect_to standup_meeting_group_standup_meetings_path(@standup_meeting.group) | ||
end | ||
end | ||
end |
This file contains 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
This file contains 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,2 @@ | ||
module StandupMeetingCommentsHelper | ||
end |
This file contains 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 |
---|---|---|
|
@@ -23,6 +23,8 @@ | |
class StandupMeeting < ApplicationRecord | ||
has_noticed_notifications | ||
|
||
has_many :standup_meeting_comments, dependent: :destroy | ||
|
||
belongs_to :standup_meeting_group, inverse_of: :standup_meetings | ||
belongs_to :user | ||
|
||
|
@@ -36,6 +38,8 @@ class StandupMeeting < ApplicationRecord | |
|
||
validates :meeting_date, presence: true | ||
|
||
ALLOWED_SECTIONS = %w[yesterday_work_description today_work_description blockers_description].freeze | ||
|
||
enum status: { | ||
draft: 0, | ||
completed: 1, | ||
|
@@ -44,4 +48,23 @@ class StandupMeeting < ApplicationRecord | |
} | ||
|
||
scope :for_member, ->(user, group) { where(user:, standup_meeting_group: group) } | ||
|
||
def comments(section) | ||
standup_meeting_comments.where(section_name: section) | ||
end | ||
|
||
def section_content(section) | ||
case section | ||
when 'yesterday_work_description' | ||
yesterday_work_description | ||
when 'today_work_description' | ||
today_work_description | ||
when 'blockers_description' | ||
blockers_description | ||
end | ||
end | ||
|
||
def allowed_section?(secion_name) | ||
ALLOWED_SECTIONS.include?(secion_name) | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Awesome 🙌 |
||
end |
This file contains 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,27 @@ | ||
# == Schema Information | ||
# | ||
# Table name: standup_meeting_comments | ||
# | ||
# id :bigint not null, primary key | ||
# section_name :string not null | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# standup_meeting_id :bigint not null | ||
# user_id :bigint not null | ||
# | ||
# Indexes | ||
# | ||
# index_standup_meeting_comments_on_standup_meeting_id (standup_meeting_id) | ||
# index_standup_meeting_comments_on_user_id (user_id) | ||
# | ||
# Foreign Keys | ||
# | ||
# fk_rails_... (standup_meeting_id => standup_meetings.id) | ||
# fk_rails_... (user_id => users.id) | ||
# | ||
class StandupMeetingComment < ApplicationRecord | ||
belongs_to :standup_meeting | ||
belongs_to :user | ||
|
||
has_rich_text :content | ||
end |
This file contains 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
This file contains 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,11 @@ | ||
class StandupMeetingCommentPolicy < ApplicationPolicy | ||
alias_method :standup_meeting_comment, :record | ||
|
||
def destroy? | ||
user == standup_meeting_comment.user | ||
end | ||
|
||
def edit? | ||
user == standup_meeting_comment.user | ||
end | ||
end |
This file contains 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,43 @@ | ||
<h1 class="text-2xl font-bold mb-4 text-center "><%= @section.humanize.titleize %></h1> | ||
<div class="max-w-6xl mx-auto border rounded-lg p-4"> | ||
<h1 class="text-1xl font-bold mb-4"><%= @standup_meeting.section_content(@section) %> </h1> | ||
</div> | ||
|
||
<div class="max-w-6xl mx-auto mt-4"> | ||
<% @standup_meeting.comments(@section).each do |comment| %> | ||
<div class="flex-1 border rounded-lg leading-relaxed mb-3"> | ||
<div class="bg-gray-100 px-3 py-1 rounded-t-lg"> | ||
<strong class="text-sm font-semibold"><%= comment.user.first_name %></strong> <span class="text-xs text-gray-500"><%= time_ago_in_words(comment.created_at) %></span> | ||
</div> | ||
|
||
<div class="mt-2 mx-2"> | ||
<p class="text-sm"> | ||
<%= comment.content %> | ||
</p> | ||
</div> | ||
|
||
<div class="mt-4 flex justify-end m-2 text-xs text-gray-500"> | ||
<% if policy(comment).edit? %> | ||
<div class="text-sm hover:text-blue-600 cursor-pointer mr-2">Edit</div> | ||
<% end %> | ||
<% if policy(comment).destroy? %> | ||
<div class="text-sm hover:text-blue-600 cursor-pointer"> <%= link_to 'Delete', standup_meeting_standup_meeting_comment_path(@standup_meeting, comment), method: :delete, data: { turbo_method: :delete } %></div> | ||
<% end %> | ||
</div> | ||
</div> | ||
<% end %> | ||
|
||
<div class="border-t-4 border-gray-300 mt-4"> | ||
<div>Add a comment</div> | ||
<%= form_with model:[@standup_meeting, StandupMeetingComment.new], html: { class: 'border rounded-lg mt-4 p-2' } do |f| %> | ||
<%= f.hidden_field :section_name, value: @section %> | ||
|
||
<div class="flex flex-col justify-between space-y-2 mb-4"> | ||
<%= f.rich_text_area :content, class:"textarea textarea-bordered" %> | ||
</div> | ||
<div class="form-control"> | ||
<%= f.submit class:"btn btn-primary btn-sm mx-auto"%> | ||
</div> | ||
<% end %> | ||
</div> | ||
</div> |
This file contains 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
10 changes: 10 additions & 0 deletions
10
db/migrate/20231127185636_create_standup_meeting_comments.rb
This file contains 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,10 @@ | ||
class CreateStandupMeetingComments < ActiveRecord::Migration[7.0] | ||
def change | ||
create_table :standup_meeting_comments do |t| | ||
t.string :section_name, null: false | ||
t.references :standup_meeting, null: false, foreign_key: true | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
5 changes: 5 additions & 0 deletions
5
db/migrate/20231201004804_add_user_to_standup_meeting_comments.rb
This file contains 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,5 @@ | ||
class AddUserToStandupMeetingComments < ActiveRecord::Migration[7.0] | ||
def change | ||
add_reference :standup_meeting_comments, :user, null: false, foreign_key: true | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
This file contains 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
This file contains 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,28 @@ | ||
# == Schema Information | ||
# | ||
# Table name: standup_meeting_comments | ||
# | ||
# id :bigint not null, primary key | ||
# section_name :string not null | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# standup_meeting_id :bigint not null | ||
# user_id :bigint not null | ||
# | ||
# Indexes | ||
# | ||
# index_standup_meeting_comments_on_standup_meeting_id (standup_meeting_id) | ||
# index_standup_meeting_comments_on_user_id (user_id) | ||
# | ||
# Foreign Keys | ||
# | ||
# fk_rails_... (standup_meeting_id => standup_meetings.id) | ||
# fk_rails_... (user_id => users.id) | ||
# | ||
FactoryBot.define do | ||
factory :standup_meeting_comment do | ||
section_name { 'MyString' } | ||
standup_meeting | ||
user | ||
end | ||
end |
This file contains 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,15 @@ | ||
require 'rails_helper' | ||
|
||
# Specs in this file have access to a helper object that includes | ||
# the StandupMeetingCommentsHelper. For example: | ||
# | ||
# describe StandupMeetingCommentsHelper do | ||
# describe "string concat" do | ||
# it "concats two strings with spaces" do | ||
# expect(helper.concat_strings("this","that")).to eq("this that") | ||
# end | ||
# end | ||
# end | ||
RSpec.describe StandupMeetingCommentsHelper do | ||
pending "add some examples to (or delete) #{__FILE__}" | ||
end |
This file contains 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,26 @@ | ||
# == Schema Information | ||
# | ||
# Table name: standup_meeting_comments | ||
# | ||
# id :bigint not null, primary key | ||
# section_name :string not null | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# standup_meeting_id :bigint not null | ||
# user_id :bigint not null | ||
# | ||
# Indexes | ||
# | ||
# index_standup_meeting_comments_on_standup_meeting_id (standup_meeting_id) | ||
# index_standup_meeting_comments_on_user_id (user_id) | ||
# | ||
# Foreign Keys | ||
# | ||
# fk_rails_... (standup_meeting_id => standup_meetings.id) | ||
# fk_rails_... (user_id => users.id) | ||
# | ||
require 'rails_helper' | ||
|
||
RSpec.describe StandupMeetingComment do | ||
pending "add some examples to (or delete) #{__FILE__}" | ||
end |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This controller (along with its view) creates a dynamic view corresponding to the appropriate question/section in the standup meeting groups. e.g:
when params:
http://localhost:3000/standup_meetings/597/sections?section=yesterday_work_description