diff --git a/README.md b/README.md index 35dc92e..11b60bb 100644 --- a/README.md +++ b/README.md @@ -152,5 +152,3 @@ heroku run rails db:seed * Sai Nithin * Vinayaka Hegde * [Legacy Code](https://github.com/tamu-edu-students/csce606-ELRC-Synergistic-Leadership-Theory) - - diff --git a/rails_root/app/controllers/admins_controller.rb b/rails_root/app/controllers/admins_controller.rb index 1551c9c..83e0bb5 100644 --- a/rails_root/app/controllers/admins_controller.rb +++ b/rails_root/app/controllers/admins_controller.rb @@ -1,6 +1,4 @@ -# frozen_string_literal: true - -# admins_controller.rb +#admins_controller.rb class AdminsController < ApplicationController def index @survey_responses = SurveyResponse.get_all_responses(page: params[:page], per_page: 20) diff --git a/rails_root/app/helpers/admins_helper.rb b/rails_root/app/helpers/admins_helper.rb index 8955410..d4f7b34 100644 --- a/rails_root/app/helpers/admins_helper.rb +++ b/rails_root/app/helpers/admins_helper.rb @@ -1,5 +1,2 @@ -# frozen_string_literal: true - -# helper method for the admin controller module AdminsHelper end diff --git a/rails_root/app/models/survey_response.rb b/rails_root/app/models/survey_response.rb index 9415290..f1e61ef 100644 --- a/rails_root/app/models/survey_response.rb +++ b/rails_root/app/models/survey_response.rb @@ -16,10 +16,10 @@ class SurveyResponse < ApplicationRecord belongs_to :profile, class_name: 'SurveyProfile' - has_many :invitations, - foreign_key: :parent_response_id, - class_name: 'Invitation', - dependent: :destroy + has_many :invitations, + foreign_key: :parent_response_id, + class_name: 'Invitation', + dependent: :destroy def self.create_from_params(user_id, params) # FIXME: When we look up things and fail, we should use more descriptive exceptions instead of ActiveRecord::RecordNotFound diff --git a/rails_root/app/views/admins/index.html.erb b/rails_root/app/views/admins/index.html.erb index a332500..d2db529 100644 --- a/rails_root/app/views/admins/index.html.erb +++ b/rails_root/app/views/admins/index.html.erb @@ -8,26 +8,22 @@
- - - - - - - + + + + + + <% if @survey_responses.present? %> <% @survey_responses.each do |response| %> - - - - - - - + + + + + + <% end %> <% end %> diff --git a/rails_root/app/views/layouts/_header.html.erb b/rails_root/app/views/layouts/_header.html.erb index 83c614a..c4cbf95 100644 --- a/rails_root/app/views/layouts/_header.html.erb +++ b/rails_root/app/views/layouts/_header.html.erb @@ -23,10 +23,6 @@ - - diff --git a/rails_root/config/routes.rb b/rails_root/config/routes.rb index bac42dc..32d6ccb 100644 --- a/rails_root/config/routes.rb +++ b/rails_root/config/routes.rb @@ -8,9 +8,7 @@ get 'home/index' get 'about', to: 'about#index' - get '/admin', to: 'admins#index', as: 'admin_dashboard' - #get 'survey_responses/:id', to: 'survey_responses#show', as: 'survey_response' - + get '/admin', to: 'admins#index' # get 'survey', to: 'survey_responses#new', as: 'survey' # get 'survey/page/:page', to: 'survey_responses#survey', as: 'survey_page' diff --git a/rails_root/features/admin_management.feature b/rails_root/features/admin_management.feature deleted file mode 100644 index f1e6a72..0000000 --- a/rails_root/features/admin_management.feature +++ /dev/null @@ -1,12 +0,0 @@ -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 diff --git a/rails_root/features/step_definitions/admin_management_steps.rb b/rails_root/features/step_definitions/admin_management_steps.rb deleted file mode 100644 index b187b95..0000000 --- a/rails_root/features/step_definitions/admin_management_steps.rb +++ /dev/null @@ -1,29 +0,0 @@ -# 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 diff --git a/rails_root/spec/helpers/admins_helper_spec.rb b/rails_root/spec/helpers/admins_helper_spec.rb index e99f449..67e4a8d 100644 --- a/rails_root/spec/helpers/admins_helper_spec.rb +++ b/rails_root/spec/helpers/admins_helper_spec.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - require 'rails_helper' # Specs in this file have access to a helper object that includes diff --git a/rails_root/spec/requests/admin_dashboard_spec.rb b/rails_root/spec/requests/admin_dashboard_spec.rb deleted file mode 100644 index d4d8124..0000000 --- a/rails_root/spec/requests/admin_dashboard_spec.rb +++ /dev/null @@ -1,32 +0,0 @@ -# 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 diff --git a/rails_root/spec/requests/admins_spec.rb b/rails_root/spec/requests/admins_spec.rb index a7c195d..355fdd0 100644 --- a/rails_root/spec/requests/admins_spec.rb +++ b/rails_root/spec/requests/admins_spec.rb @@ -1,12 +1,11 @@ -# 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 diff --git a/rails_root/spec/views/admins/index.html.erb_spec.rb b/rails_root/spec/views/admins/index.html.erb_spec.rb index 5aa5e8f..094b2f0 100644 --- a/rails_root/spec/views/admins/index.html.erb_spec.rb +++ b/rails_root/spec/views/admins/index.html.erb_spec.rb @@ -1,7 +1,5 @@ -# 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
IDProfileShare CodeCreated AtView Survey
IDProfileShare CodeCreated At
<%= response.id %><%= response.profile.user_id %><%= response.share_code %><%= response.created_at.strftime('%Y-%m-%d %H:%M:%S') %> - <%= link_to 'View Survey', survey_response_path(response) %> -
<%= response.id %><%= response.profile.user_id %><%= response.share_code %><%= response.created_at.strftime('%Y-%m-%d %H:%M:%S') %>