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

E2476 student_team_controller.rb file created #136

Open
wants to merge 34 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
7bc5fdf
E2476 student_team_controller.rb file created
moreharsh Nov 16, 2024
58b1086
E2476 basic methods of a controller are defined
moreharsh Nov 16, 2024
31f4165
E2476 show method updated to give the json response back
moreharsh Nov 16, 2024
e89b112
Modified existing student_teams_controller
anmolkoul11 Nov 18, 2024
137813a
Merge pull request #3 from moreharsh/akoul_init
moreharsh Nov 19, 2024
108e44e
Changed the studentteamscontroller class name as per the RESTAPI format
moreharsh Nov 19, 2024
1f994ed
Added private functions to access teams and students data
moreharsh Nov 19, 2024
741a5da
Updated he show function to display team details and not student details
moreharsh Nov 19, 2024
8b3b1db
Added the index method to retrieve Student Teams data using query par…
moreharsh Nov 19, 2024
0a37882
Modified the update method so appropriate response is returned back t…
moreharsh Nov 19, 2024
763d871
resolves #14: cleaning up notify_team_creation_success
akarsh16reddy Nov 27, 2024
80d73b6
resolves #15: moving remove_team_user from student teams controller t…
akarsh16reddy Nov 27, 2024
e44c2a1
resolves #16: adding ParameterMissing callback
akarsh16reddy Nov 28, 2024
3792fc3
Rearranged and cleaned the code
moreharsh Nov 30, 2024
c9e0c72
remove participant method updated
moreharsh Nov 30, 2024
d71b378
Implementing assignment_team, team & correcting all REST API endpoints
akarsh16reddy Dec 1, 2024
957a31d
updated & tested create method, adding db seeds
akarsh16reddy Dec 2, 2024
86b8aa5
all API endpoints work, corrected destroy method & cleanup
akarsh16reddy Dec 2, 2024
5c9ae7d
adding member routes
akarsh16reddy Dec 2, 2024
cff5b3e
update student team controller
anmolkoul11 Dec 2, 2024
7d5b8cd
minor controller refactoring and code cleanup
anmolkoul11 Dec 2, 2024
2481aa2
API endpoint optimizations
anmolkoul11 Dec 2, 2024
7704a3d
Merge pull request #18 from moreharsh/akoul_ref
anmolkoul11 Dec 2, 2024
9d99777
added helper class for private methods
anmolkoul11 Dec 2, 2024
e3d5d22
Adding swagger tests for all REST methods
akarsh16reddy Dec 3, 2024
c6b05c8
adding remove participant REST endpoint
akarsh16reddy Dec 3, 2024
7d3a719
Added validation to check for empty strings for update method
moreharsh Dec 3, 2024
6d20fbe
Made code consitent, remove unwanted calls
moreharsh Dec 3, 2024
3619270
updating student team controller spec and auto team generate changes
anmolkoul11 Dec 3, 2024
9a8fdae
Merge pull request #26 from moreharsh/akoul_2
anmolkoul11 Dec 3, 2024
c1d4d21
covering more scenarios in create & update with minor bug fixes
anmolkoul11 Dec 3, 2024
62e05ef
added tests for remove_participant & fixed buggy exceptions
anmolkoul11 Dec 4, 2024
8dae732
adding add_participant & better responses
akarsh16reddy Dec 4, 2024
71e7597
add participant to swagger
akarsh16reddy Dec 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
covering more scenarios in create & update with minor bug fixes
anmolkoul11 committed Dec 3, 2024
commit c1d4d218f309355a3a8f0129095fd2933cd0aff6
2 changes: 1 addition & 1 deletion app/helpers/student_teams_helper.rb
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ def generate_team_name
end

def user_not_found
render json: { error: "User with id #{params[:id]} not found" }, status: :not_found
render json: { error: "User id #{params[:id]} not found" }, status: :not_found
end

def parameter_missing(exception)
80 changes: 69 additions & 11 deletions spec/requests/api/v1/student_teams_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -17,7 +17,6 @@
}
end
run_test!
expect(response.status).to eq(200)
end
end

@@ -155,6 +154,17 @@
expect(response.body).to include('error')
end
end

response(404, 'not_found') do
let(:team) do
post '/api/v1/student_teams', params: { team: { name: 'ABCD10' }, student_id: 0 }, as: :json
end
run_test! do
expect(response.status).to eq(404)
expect(response.body).to include('not found')
end
end

end

patch('Update a Student Team') do
@@ -175,6 +185,7 @@
}
}

# Scenario 1: Team name updated successfully
response(200, 'successful') do
after do |example|
example.metadata[:response][:content] = {
@@ -183,9 +194,52 @@
}
}
end
run_test!
expect(response.status).to eq(200)
run_test! do
expect(response.status).to eq(200)
end
end

# Scenario 2: Invalid team updation (empty name)
response(422, 'unprocessable entity') do
let(:student_team_request) do
{ team: {name: ""}, team_id: 2}
end
after do |example|
example.metadata[:response][:content] = {
'application/json' => {
example: JSON.parse(response.body, symbolize_names: true)
}
}
end
run_test! do
expect(response.status).to eq(422)
expect(response.body).to include('Team name should not be empty')
end
end
# Scenario 3: Team Name already present
response(422, 'unprocessable entity') do
let(:existing_team) { create(:team, name: 'ABCD10', team_id: 3) }

let(:team) do
post '/api/v1/student_teams', params: { team: { name: 'ABCD10' }, team_id: 2 }, as: :json
end

run_test! do
expect(response.status).to eq(422)
expect(response.body).to include('"error":"That team name is already in use."')
end
end
#Scenario 4 : Invalid Team ID
response(404, 'not_found') do
let(:team) do
post '/api/v1/student_teams', params: { team: { name: 'ABCD10' }, team_id: 0 }, as: :json
end
run_test! do
expect(response.status).to eq(404)
expect(response.body).to include('not found')
end
end

end
end
path '/api/v1/student_teams/{id}' do
@@ -204,15 +258,17 @@
}
}
end
run_test!
expect(response.status).to eq(200)
run_test! do
expect(response.status).to eq(200)
end
end

# Get request on /api/v1/student_teams/{id} returns the response 404 not found - when correct id passed is not present in the database
response(404, 'not_found') do
let(:id) { 'invalid' }
run_test!
expect(response.status).to eq(404)
run_test! do
expect(response.status).to eq(404)
end
end
end

@@ -230,15 +286,17 @@
}
}
end
run_test!
expect(response.status).to eq(204)
run_test! do
expect(response.status).to eq(204)
end
end

# delete request on /api/v1/student_teams/{id} returns 404 not found response, when id is not present in the database
response(404, 'not found') do
let(:id) { 0 }
run_test!
expect(response.status).to eq(204)
run_test! do
expect(response.status).to eq(404)
end
end
end
end