-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Revert "Admin management display page""
- Loading branch information
1 parent
7a95457
commit 22819ef
Showing
13 changed files
with
119 additions
and
24 deletions.
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
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 |
---|---|---|
@@ -1,2 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
# helper method for the admin controller | ||
module AdminsHelper | ||
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
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
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,12 @@ | ||
Feature: Admin Dashboard Access | ||
I want to see the Admin Dashboard link | ||
So that I can access administrative functions | ||
|
||
Background: | ||
Given I am on the homepage | ||
And I try to login | ||
|
||
Scenario: Principal sees "Admin Dashboard" link and clicks it | ||
Then I should see "Admin Dashboard" in the header | ||
When I click on "Admin Dashboard" | ||
Then I should be on the Admin Dashboard page |
29 changes: 29 additions & 0 deletions
29
rails_root/features/step_definitions/admin_management_steps.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,29 @@ | ||
# frozen_string_literal: true | ||
|
||
# Step definition for navigating to the homepage | ||
Given('I am on the homepage') do | ||
visit root_path | ||
expect(page).to have_current_path(root_path) # Ensure the user is on the homepage | ||
end | ||
|
||
Given('I have logged in as a {string}') do |role| | ||
# Create a user with the specified role (principal, teacher, superintendent) | ||
@user = FactoryBot.create(:survey_profile, role:) | ||
allow_any_instance_of(ApplicationController).to receive(:current_user_id).and_return(@user.user_id) | ||
end | ||
|
||
Then('I should see {string} in the header') do |link_text| | ||
# Check that the Admin Dashboard link is present | ||
expect(page).to have_link(link_text) | ||
end | ||
|
||
When('I click on {string}') do |link_text| | ||
# Click the Admin Dashboard link | ||
click_link(link_text) | ||
end | ||
|
||
Then('I should be on the Admin Dashboard page') do | ||
# Verify that the user is redirected to the Admin Dashboard page | ||
expect(current_path).to eq(admin_dashboard_path) | ||
expect(page).to have_content('Admin Dashboard') | ||
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,32 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe 'Admin Dashboard Access', type: :request do | ||
# Create a user with the principal role (you can change this to other roles if needed) | ||
let(:user) { FactoryBot.create(:survey_profile, role: 'Teacher') } | ||
|
||
before do | ||
allow_any_instance_of(SurveyResponsesController).to receive(:current_user_id).and_return(user.user_id) | ||
end | ||
|
||
describe 'GET / (Homepage)' do | ||
it 'displays the Admin Dashboard link in the header' do | ||
# Visit the homepage | ||
get root_path | ||
|
||
expect(response).to have_http_status(:ok) | ||
expect(response.body).to include('Admin Dashboard') | ||
end | ||
end | ||
|
||
describe 'GET /admin_dashboard' do | ||
it 'redirects to the Admin Dashboard page when clicked' do | ||
# Visit the Admin Dashboard page | ||
get admin_dashboard_path | ||
|
||
expect(response).to have_http_status(:ok) | ||
expect(response.body).to include('Admin Dashboard') | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe "Admins", type: :request do | ||
describe "GET /index" do | ||
it "returns http success" do | ||
get "/admins/index" | ||
RSpec.describe 'Admins', type: :request do | ||
describe 'GET /index' do | ||
it 'returns http success' do | ||
get '/admins/index' | ||
expect(response).to have_http_status(:success) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe "admins/index.html.erb", type: :view do | ||
RSpec.describe 'admins/index.html.erb', type: :view do | ||
pending "add some examples to (or delete) #{__FILE__}" | ||
end |