Skip to content

Test/global actions#7955

Open
akarki2005 wants to merge 6 commits into
MarkUsProject:masterfrom
akarki2005:test/global-actions
Open

Test/global actions#7955
akarki2005 wants to merge 6 commits into
MarkUsProject:masterfrom
akarki2005:test/global-actions

Conversation

@akarki2005
Copy link
Copy Markdown

Proposed Changes

This PR adds missing test coverage for three private helper methods called through GroupsController#global_actions:

  1. check_for_groupings: raises when no groupings are selected
  2. add_members: raises when 2+ groupings are selected, no students are selected, or group_max would be exceeded
  3. add_member: sets :inviter status when grouping is empty, raises when student is already grouped, raises when student cannot be invited (different course), and sets @warning_grace_day when student has insufficient grace credits

Type of Change

(Write an X or a brief description next to the type or types that best describe your changes.)

Type Applies?
🚨 Breaking change (fix or feature that would cause existing functionality to change)
New feature (non-breaking change that adds functionality)
🐛 Bug fix (non-breaking change that fixes an issue)
🎨 User interface change (change to user interface; provide screenshots)
♻️ Refactoring (internal change to codebase, without changing functionality)
🚦 Test update (change that only adds or modifies tests) X
📦 Dependency update (change that updates a dependency)
🔧 Internal (change that only affects developers or continuous integration)

Checklist

(Complete each of the following items for your pull request. Indicate that you have completed an item by changing the [ ] into a [x] in the raw text, or by clicking on the checkbox in the rendered description on GitHub.)

Before opening your pull request:

  • I have performed a self-review of my changes.
    • Check that all changed files included in this pull request are intentional changes.
    • Check that all changes are relevant to the purpose of this pull request, as described above.
  • I have added tests for my changes, if applicable.
    • This is required for all bug fixes and new features.
  • If this is my first contribution, I have added myself to the list of contributors.

After opening your pull request:

  • I have updated the project Changelog (this is required for all changes).
  • I have verified that the pre-commit.ci checks have passed.
  • I have verified that the CI tests have passed.
  • I have reviewed the test coverage changes reported by Coveralls.
  • I have requested a review from a project maintainer.

Copy link
Copy Markdown
Collaborator

@david-yz-liu david-yz-liu left a comment

Choose a reason for hiding this comment

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

@akarki2005 in addition to the inline comments I left, I see that the pre-commit bot made some updates to your branch. This indicates that you haven't set up the pre-commit hooks properly in your local repository, so please make sure to do so before making another commit.

describe '#check_for_groupings' do
let(:grouping) { create(:grouping_with_inviter) }

it 'should return a bad request when no grouping is selected.' do
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This test is good, but should be grouped with the other validate_grouping test. #check_for_groupings is a helper method, so this test is really checking the behaviour of the main controller method (global_actions), and the tests there are subdivided into the different action types.

assignment_id: grouping.assignment.id,
groupings: [],
global_actions: 'valid' }
expect(response).to have_http_status(:bad_request)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is good, but also check the contents of the flash error message (look at how other tests do this).

This applies to the other tests you've added below.

end
end

describe '#add_member' do
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Similarly to my above comment, you don't need to add a new describe block; it's okay to just add these test cases to the existing block

groupings: [grouping],
students: [student1.id],
global_actions: 'assign' }
expect(assigns(:warning_grace_day)).to be_present
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This one is interesting. I looked into this and the @warning_grace_day instance variable isn't actually used anywhere.

Please modify the actual controller code to instead flash a warning message, and then make sure to test this in the UI. The point is that this warning message should appear to the instructor when this situation happens (but the student can still be assigned---verify this in the test case too).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants