Skip to content
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

feat: added NewAssignmentNotification - to all groupmembers #3312

Merged
merged 22 commits into from
Dec 16, 2022

Conversation

VaibhavUpreti
Copy link
Member

Fixes #3294

Describe the changes you have made in this PR -

  • added notifications to group members on new Assignment creation

Screenshots of the changes (If any) -

Screenshot 2022-10-10 at 7 44 42 PM

Note: Please check Allow edits from maintainers. if you would like us to assist in the PR.

@coveralls
Copy link

coveralls commented Oct 10, 2022

Coverage Status

Coverage increased (+0.07%) to 82.109% when pulling 0af622b on VaibhavUpreti:NewAssignmentNotification into d27a74b on CircuitVerse:master.

app/models/assignment.rb Outdated Show resolved Hide resolved
app/models/assignment.rb Outdated Show resolved Hide resolved
app/models/assignment.rb Outdated Show resolved Hide resolved
app/models/assignment.rb Outdated Show resolved Hide resolved
app/notifications/new_assignment_notification.rb Outdated Show resolved Hide resolved
app/notifications/new_assignment_notification.rb Outdated Show resolved Hide resolved
app/notifications/new_assignment_notification.rb Outdated Show resolved Hide resolved
app/notifications/new_assignment_notification.rb Outdated Show resolved Hide resolved
app/notifications/new_assignment_notification.rb Outdated Show resolved Hide resolved
@VaibhavUpreti
Copy link
Member Author

@vedant-jain03 kindly review.

app/models/assignment.rb Outdated Show resolved Hide resolved
app/notifications/new_assignment_notification.rb Outdated Show resolved Hide resolved
app/notifications/new_assignment_notification.rb Outdated Show resolved Hide resolved
app/models/assignment.rb Outdated Show resolved Hide resolved
Copy link
Member

@vedant-jain03 vedant-jain03 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @VaibhavUpreti , here are my reviews!
Kindly go through and let me know if you have any doubt!

cc @tachyons

app/models/assignment.rb Outdated Show resolved Hide resolved
app/models/assignment.rb Outdated Show resolved Hide resolved
db/schema.rb Outdated Show resolved Hide resolved
app/controllers/users/noticed_notifications_controller.rb Outdated Show resolved Hide resolved
config/locales/views/users/en.yml Outdated Show resolved Hide resolved
app/notifications/new_assignment_notification.rb Outdated Show resolved Hide resolved
config/locales/views/users/hi.yml Outdated Show resolved Hide resolved
app/notifications/new_assignment_notification.rb Outdated Show resolved Hide resolved
@VaibhavUpreti

This comment was marked as resolved.

app/models/assignment.rb Outdated Show resolved Hide resolved
app/models/assignment.rb Outdated Show resolved Hide resolved
@vedant-jain03
Copy link
Member

@VaibhavUpreti could you please add spec testcases for this notifications!

Also test if the assignment got deleted, the associated notification are destroying or not!
That is the edge case, we need to see!

I think has_noticed_notifications do this thing but just in case kindly test this in your end!

app/models/assignment.rb Outdated Show resolved Hide resolved
@VaibhavUpreti
Copy link
Member Author

@VaibhavUpreti could you please add spec testcases for this notifications!

Also test if the assignment got deleted, the associated notification are destroying or not! That is the edge case, we need to see!

I think has_noticed_notifications do this thing but just in case kindly test this in your end!

Yeah Sure! I will write the required specs for these... And nothing seems to be broken after deleting the assignments ... The notifications are also getting cleaned up.

@VaibhavUpreti
Copy link
Member Author

@vedant-jain03 I have written the tests ... can u please check .. also I had sent u dm on slack regarding testing controller

spec/controllers/noticed_notifications_controller_spec.rb Outdated Show resolved Hide resolved
spec/models/assignment_spec.rb Outdated Show resolved Hide resolved
@vedant-jain03
Copy link
Member

@VaibhavUpreti
you need to write the test for this in #create in assignment_controller_spec.rb.

Here

Try adding under the context when primary mentor is logged in, try this:

      it "sends notifications to group members" do
        sign_in @primary_mentor
        post group_assignments_path(@group), params: { assignment:
          { description: "group assignment", name: "Test Name" } }
        expect(@member.noticed_notifications.count).to eq(1)
      end

@VaibhavUpreti
Copy link
Member Author

VaibhavUpreti commented Oct 22, 2022

@vedant-jain03 I think this one is good to merge now.

Copy link
Member

@vedant-jain03 vedant-jain03 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VaibhavUpreti Great work, thanks!

cc @tachyons, we can merge this!

@VaibhavUpreti
Copy link
Member Author

@vedant-jain03 , @tachyons ... Anything else needed with this patch? or are we good to merge this

app/controllers/users/noticed_notifications_controller.rb Outdated Show resolved Hide resolved
app/models/assignment.rb Outdated Show resolved Hide resolved
app/models/assignment.rb Outdated Show resolved Hide resolved
@vedant-jain03 vedant-jain03 added the notifications the issues and PR for this will under notification context label Nov 3, 2022
@codeclimate
Copy link

codeclimate bot commented Nov 7, 2022

An error occurred when fetching issues.

View more on Code Climate.

@VaibhavUpreti
Copy link
Member Author

@tachyons @vedant-jain03 I haven't used the function "notification_type" as I think routing is part of ActionController and not present in custom classes. So the current code handles routing in the controller itself and "notify" function works for now.

Is there any way we can use "redirect_to" method in our service class ... is so then we can keep this function else remove this.

@VaibhavUpreti
Copy link
Member Author

@tachyons made the controller "skinny" ... moved all the logic to the service class. Kindly review.

@vedant-jain03 vedant-jain03 added this to Ready for Review in Main Platform Improvement Nov 16, 2022
project = notification.params[:project]
redirect_to user_project_path(project.author, project)
answer = NotifyUser.new(params).call
return redirect_to group_assignment_path(answer.first_param, answer.second) if answer.type == "new_assignment"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Why introduce a new type in service when we can already compare with schema type.
  2. Stick to if-else block as we have some other notification coming up which may have a different path other than project or group.
    Else LGTM @tachyons WDYT?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tachyons tachyons merged commit a92acd5 into CircuitVerse:master Dec 16, 2022
@vedant-jain03 vedant-jain03 moved this from Need / Ready for Review to Completed(Merged) in Main Platform Improvement Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
notifications the issues and PR for this will under notification context
Projects
Main Platform Improvement
Completed(Merged)
Development

Successfully merging this pull request may close these issues.

feat: notify group members for the new assignment in the group
4 participants