diff --git a/.coveralls.yml b/.coveralls.yml
new file mode 100644
index 00000000..3a7fb5a6
--- /dev/null
+++ b/.coveralls.yml
@@ -0,0 +1,3 @@
+service_name: travis-ci
+repo_secret_token: gDdq8itC8gszvIYXVbAMv6w9zkFbTNTzR
+# <%= ENV['coverall_token'] %>
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index f4ebbb9c..e07caacc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,10 +14,11 @@
# Ignore all logfiles and tempfiles.
/log/*
!/log/.keep
-/tmp
+/tmp/*
+tmp/*
#Ignore the coverage generation.
-/coverage/*
+coverage/*
.byebug_history
diff --git a/.travis.yml b/.travis.yml
index e93e3623..b37efeca 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,8 +1,6 @@
language: ruby
rvm:
- 2.2
-before_script:
-- gpg --passphrase "$KEY" --decrypt --no-use-agent --output config/application.yml config/application.yml.asc
script:
- RAILS_ENV=test bundle exec rake db:migrate --trace
- bundle exec rake db:test:prepare
@@ -10,8 +8,9 @@ script:
- bundle exec cucumber
after_script:
- bundle exec rake send_to_codeclimate
-addons:
- code_climate:
- repo_token: 46e45a2fe953633bb2ecd54b9c1591d951cb25efa6c6987ccd9335aebfa95fe6
env:
- - secure: "WqBTwwaITf4214Xvejf7KSAzo+4+2WQgBYMENhhtVQuXZQ+UPk5nPNEuT59vGiWpcdP+Xvk+XzYvRUVRMTBJw69dVeirii5vrPXNl5iC7qbnNtbIxWbczmkEdZofaZSGEZscbs136MX1UaPKlo3tdwIjYyAccuY1hrGDrn8aGubHKOScC+eGEirEqqYNPQsTX0NH+/xtaHlon0zLP/bvnedIn2a0XoN07WC7Qolfrcb9ugX9b+0FsJl50ImlyGp3d3p6UDyXr+g9wAreeRSDlnnmTV3f1vwWR0H3AEj171YP+eXfGFiqV7dELKRt8SWSYwZzmInMWBwFIULu3o/rpPfODP6lmYAnyXm+qZCOWymEzvvKxSQnSbCUFj30DTJ+LbgnPyd2xNl+IzBJYkkFzPwvOYoePAwiiQvv/3eLMDU1eEdyydW5+8kS7dUZOBwwl9kh8SfVAs3tGTugCnQBn4O3R1T1AJlHfNXY8B5Wiy3PC779ZuganrxfbDhK7pLPoSeBkhZP06Ffhs7MfgigZUR3h4K+t1mRFkEWuCEYh5OwkHGpuFSoxAWVjfRI+RMrlaPB4LJfHCeMvJw/3mXm11JGxQJLLdLFuhe8ruSpoRHtO/0PYg1Q6Qa8BFHJDZ0E8F4thnPFDb1fPnUVIgfKmkE8mnLaQoO7JTHuvyhvyDA="
+- ADMIN_DELETE_DATA_PASSWORD: "hello"
+# after_success:
+# - CI=true TRAVIS=true coveralls --verbose
+
+
diff --git a/Gemfile b/Gemfile
index c043c7ef..1e80d28b 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,5 +1,9 @@
source 'https://rubygems.org'
+# ruby '2.3.4'
+gem 'rails_12factor'
+
+gem 'coveralls', require: false
gem 'rails', '4.2.6'
@@ -12,6 +16,7 @@ gem 'haml'
gem "omniauth-google-oauth2", "~> 0.2.1"
gem "figaro"
+
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
diff --git a/Gemfile.lock b/Gemfile.lock
index 2baa5cac..5762cc9c 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -41,15 +41,16 @@ GEM
adamantium (0.2.0)
ice_nine (~> 0.11.0)
memoizable (~> 0.4.0)
- addressable (2.5.1)
- public_suffix (~> 2.0, >= 2.0.2)
+ addressable (2.5.2)
+ public_suffix (>= 2.0.2, < 4.0)
arel (6.0.4)
arrayfields (4.9.2)
ast (2.3.0)
autotest-rails (4.2.1)
ZenTest (~> 4.5)
+ backports (3.10.0)
builder (3.2.3)
- byebug (9.0.6)
+ byebug (9.1.0)
cane (2.6.2)
parallel
capybara (2.10.0)
@@ -59,7 +60,7 @@ GEM
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
- capybara-screenshot (1.0.14)
+ capybara-screenshot (1.0.17)
capybara (>= 1.0, < 3)
launchy
chronic (0.10.2)
@@ -74,12 +75,12 @@ GEM
clockwork (2.0.2)
activesupport
tzinfo
- code_analyzer (0.4.7)
+ code_analyzer (0.4.8)
sexp_processor
code_metrics (0.1.3)
codeclimate-test-reporter (0.6.0)
simplecov (>= 0.7.1, < 1.0.0)
- coderay (1.1.1)
+ coderay (1.1.2)
coffee-rails (4.1.1)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.1.x)
@@ -91,16 +92,27 @@ GEM
adamantium (~> 0.2.0)
equalizer (~> 0.0.9)
concurrent-ruby (1.0.5)
- cucumber (2.4.0)
+ coveralls (0.7.1)
+ multi_json (~> 1.3)
+ rest-client
+ simplecov (>= 0.7)
+ term-ansicolor
+ thor
+ crass (1.0.2)
+ cucumber (3.0.1)
builder (>= 2.1.2)
- cucumber-core (~> 1.5.0)
+ cucumber-core (~> 3.0.0)
+ cucumber-expressions (~> 4.0.3)
cucumber-wire (~> 0.0.1)
- diff-lcs (>= 1.1.3)
+ diff-lcs (~> 1.3)
gherkin (~> 4.0)
multi_json (>= 1.7.5, < 2.0)
multi_test (>= 0.1.2)
- cucumber-core (1.5.0)
- gherkin (~> 4.0)
+ cucumber-core (3.0.0)
+ backports (>= 3.8.0)
+ cucumber-tag_expressions (>= 1.0.1)
+ gherkin (>= 4.1.3)
+ cucumber-expressions (4.0.4)
cucumber-rails (1.5.0)
capybara (>= 1.1.2, < 3)
cucumber (>= 1.3.8, < 4)
@@ -109,9 +121,10 @@ GEM
railties (>= 4, < 5.2)
cucumber-rails-training-wheels (1.0.0)
cucumber-rails (>= 1.1.1)
+ cucumber-tag_expressions (1.0.1)
cucumber-wire (0.0.1)
database_cleaner (1.4.1)
- diff-lcs (1.2.5)
+ diff-lcs (1.3)
docile (1.1.5)
domain_name (0.5.20170404)
unf (>= 0.0.5, < 1.0.0)
@@ -122,17 +135,18 @@ GEM
equalizer (0.0.11)
erubis (2.7.0)
execjs (2.7.0)
- factory_girl (4.8.0)
+ factory_girl (4.8.1)
activesupport (>= 3.0.0)
factory_girl_rails (4.8.0)
factory_girl (~> 4.8.0)
railties (>= 3.0.0)
- faraday (0.11.0)
+ faraday (0.12.2)
multipart-post (>= 1.2, < 3)
fattr (2.3.0)
+ ffi (1.9.18)
figaro (1.1.1)
thor (~> 0.14)
- flay (2.9.0)
+ flay (2.10.0)
erubis (~> 2.7.0)
path_expander (~> 1.0)
ruby_parser (~> 3.0)
@@ -144,24 +158,24 @@ GEM
gherkin (4.1.3)
globalid (0.4.0)
activesupport (>= 4.2.0)
- haml (5.0.1)
+ haml (5.0.3)
temple (>= 0.8.0)
tilt
- hashie (3.5.5)
+ hashie (3.5.6)
hirb (0.7.3)
htmlentities (4.3.4)
http-cookie (1.0.3)
domain_name (~> 0.5)
- i18n (0.8.1)
+ i18n (0.8.6)
ice_nine (0.11.2)
- jasmine-core (2.6.2)
- jasmine-rails (0.14.1)
+ jasmine-core (2.8.0)
+ jasmine-rails (0.14.3)
jasmine-core (>= 1.3, < 3.0)
phantomjs (>= 1.9)
railties (>= 3.2.0)
sprockets-rails
- jbuilder (2.6.4)
- activesupport (>= 3.0.0)
+ jbuilder (2.7.0)
+ activesupport (>= 4.2.0)
multi_json (>= 1.2)
jquery-rails (4.3.1)
rails-dom-testing (>= 1, < 3)
@@ -172,9 +186,10 @@ GEM
jwt (1.5.6)
launchy (2.4.3)
addressable (~> 2.3)
- loofah (2.0.3)
+ loofah (2.1.1)
+ crass (~> 1.0.2)
nokogiri (>= 1.5.9)
- mail (2.6.5)
+ mail (2.6.6)
mime-types (>= 1.16, < 4)
main (6.2.2)
arrayfields (~> 4.7, >= 4.7.4)
@@ -202,22 +217,22 @@ GEM
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
- mini_portile2 (2.1.0)
- minitest (5.10.2)
- multi_json (1.12.1)
+ mini_portile2 (2.3.0)
+ minitest (5.10.3)
+ multi_json (1.12.2)
multi_test (0.1.2)
multi_xml (0.6.0)
multipart-post (2.0.0)
netrc (0.11.0)
- nokogiri (1.7.2)
- mini_portile2 (~> 2.1.0)
- oauth2 (1.3.1)
- faraday (>= 0.8, < 0.12)
+ nokogiri (1.8.1)
+ mini_portile2 (~> 2.3.0)
+ oauth2 (1.4.0)
+ faraday (>= 0.8, < 0.13)
jwt (~> 1.0)
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (>= 1.2, < 3)
- omniauth (1.6.1)
+ omniauth (1.7.1)
hashie (>= 3.4.6, < 3.6.0)
rack (>= 1.6.2, < 3)
omniauth-google-oauth2 (0.2.10)
@@ -229,14 +244,14 @@ GEM
omniauth-oauth2 (1.3.1)
oauth2 (~> 1.0)
omniauth (~> 1.2)
- parallel (1.11.2)
- parser (2.3.3.1)
+ parallel (1.12.0)
+ parser (2.4.0.0)
ast (~> 2.2)
path_expander (1.0.2)
- pg (0.20.0)
+ pg (0.21.0)
phantomjs (2.1.1.0)
procto (0.0.3)
- public_suffix (2.0.5)
+ public_suffix (3.0.0)
rack (1.6.8)
rack-test (0.6.3)
rack (>= 1.0)
@@ -259,14 +274,19 @@ GEM
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
- rails_best_practices (1.18.1)
+ rails_12factor (0.0.3)
+ rails_serve_static_assets
+ rails_stdout_logging
+ rails_best_practices (1.19.0)
activesupport
- code_analyzer (>= 0.4.3)
+ code_analyzer (>= 0.4.8)
erubis
i18n
json
require_all
ruby-progressbar
+ rails_serve_static_assets (0.0.5)
+ rails_stdout_logging (0.0.5)
railties (4.2.6)
actionpack (= 4.2.6)
activesupport (= 4.2.6)
@@ -274,7 +294,10 @@ GEM
thor (>= 0.18.1, < 2.0)
rainbow (2.2.2)
rake
- rake (12.0.0)
+ rake (12.1.0)
+ rb-fsevent (0.10.2)
+ rb-inotify (0.9.10)
+ ffi (>= 0.5.0, < 2)
rdoc (4.3.0)
redcard (1.1.0)
reek (2.2.1)
@@ -305,10 +328,14 @@ GEM
rspec-mocks (~> 3.4.0)
rspec-support (~> 3.4.0)
rspec-support (3.4.1)
- ruby-progressbar (1.8.1)
- ruby_parser (3.9.0)
- sexp_processor (~> 4.1)
- sass (3.4.24)
+ ruby-progressbar (1.9.0)
+ ruby_parser (3.10.1)
+ sexp_processor (~> 4.9)
+ sass (3.5.2)
+ sass-listen (~> 4.0.0)
+ sass-listen (4.0.0)
+ rb-fsevent (~> 0.9, >= 0.9.4)
+ rb-inotify (~> 0.9, >= 0.9.7)
sass-rails (5.0.6)
railties (>= 4.0.0, < 6)
sass (~> 3.1)
@@ -318,24 +345,27 @@ GEM
sdoc (0.4.2)
json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0)
- sexp_processor (4.9.0)
- simplecov (0.14.1)
+ sexp_processor (4.10.0)
+ simplecov (0.15.1)
docile (~> 1.1.0)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
- simplecov-html (0.10.1)
+ simplecov-html (0.10.2)
sprockets (3.7.1)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
- sprockets-rails (3.2.0)
+ sprockets-rails (3.2.1)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sqlite3 (1.3.13)
temple (0.8.0)
- thor (0.19.4)
+ term-ansicolor (1.6.0)
+ tins (~> 1.0)
+ thor (0.20.0)
thread_safe (0.3.6)
- tilt (2.0.7)
+ tilt (2.0.8)
+ tins (1.15.0)
tzinfo (1.2.3)
thread_safe (~> 0.1)
uglifier (3.2.0)
@@ -343,15 +373,15 @@ GEM
unf (0.1.4)
unf_ext
unf_ext (0.0.7.4)
- unparser (0.2.5)
+ unparser (0.2.6)
abstract_type (~> 0.0.7)
adamantium (~> 0.2.0)
concord (~> 0.1.5)
- diff-lcs (~> 1.2.5)
+ diff-lcs (~> 1.3)
equalizer (~> 0.0.9)
- parser (~> 2.3.0)
+ parser (>= 2.3.1.2, < 2.5)
procto (~> 0.0.2)
- xpath (2.0.0)
+ xpath (2.1.0)
nokogiri (~> 1.3)
PLATFORMS
@@ -366,6 +396,7 @@ DEPENDENCIES
clockwork
codeclimate-test-reporter (= 0.6.0)
coffee-rails (~> 4.1.0)
+ coveralls
cucumber-rails
cucumber-rails-training-wheels
database_cleaner (= 1.4.1)
@@ -382,6 +413,7 @@ DEPENDENCIES
omniauth-google-oauth2 (~> 0.2.1)
pg
rails (= 4.2.6)
+ rails_12factor
rspec-rails (= 3.4.2)
sass-rails (~> 5.0.3)
sdoc (~> 0.4.0)
@@ -390,4 +422,4 @@ DEPENDENCIES
uglifier (>= 1.3.0)
BUNDLED WITH
- 1.14.6
+ 1.15.4
diff --git a/README.md b/README.md
index a66b5dd8..29f188ab 100644
--- a/README.md
+++ b/README.md
@@ -1,17 +1,18 @@
+
# EnrollMe
-[![Code Climate](https://codeclimate.com/github/adnanhemani/enrollme/badges/gpa.svg?)](https://codeclimate.com/github/adnanhemani/enrollme)
-[![Test Coverage](https://codeclimate.com/github/adnanhemani/enrollme/badges/coverage.svg?)](https://codeclimate.com/github/adnanhemani/enrollme/coverage)
-[![Build Status](https://travis-ci.org/adnanhemani/enrollme.svg?branch=master)](https://travis-ci.org/adnanhemani/enrollme)
+[![Maintainability](https://api.codeclimate.com/v1/badges/83a3897f352fa9401cfb/maintainability)](https://codeclimate.com/github/msun908/enrollme/maintainability)
+[![Coverage Status](https://coveralls.io/repos/github/msun908/enrollme/badge.svg?)](https://coveralls.io/github/msun908/enrollme?branch=master)
+[![Build Status](https://travis-ci.org/msun908/enrollme.svg?branch=master)](https://travis-ci.org/msun908/enrollme)
-Copyright (c) 2016 Jason Gao, Adnan Hemani, David Koh, Sid Masih, Varun Mathuria, Dasol Yoon
+Copyright (c) 2017 Yonas Kbrom, Vikram Baid, Mark Sun, Timothy Stepro, Monty Inaya, Minjoo Sur
-*Pivotal Tracker* https://www.pivotaltracker.com/n/projects/1886001
+*Pivotal Tracker* https://www.pivotaltracker.com/n/projects/2121289
Michael-David Sasson, Berkeley’s CS enrollment coordinator, would like a tool that students can use to submit requests for their teams to be enrolled into CS 169. Students will be able to specify their team members and submit information like SID and major which will be used to process enrollment. There currently does not exist a website.
-Deployed App: https://enrollme.herokuapp.com/
+Deployed App: https://enrollme0.herokuapp.com/
The app will not work locally (at least, logging in specifically) unless you add your specific redirect URL to Google API credentials. This is only possible if you have access to the enrollmeberkeley at gmail.com account, which the next team in charge of this project will possess. To add your redirect URL, go to https://console.developers.google.com/apis/credentials, signed in with the enrollmeberkeley account, go to the edit page for the EnrollMe oauth client, and add your URL to the list of authorized redirect URLs. If you have any questions or confusions, feel free to contact at v.mathuria at berkeley.edu or adnan.h at berkeley.edu.
@@ -32,3 +33,19 @@ Add new admins: Click on the "Register New Admin" button on the ribbon at the to
Manage admins: Click on the "Manage Admins" button on the ribbon at the top of any page in the admin portal. If you are the SuperAdmin, on this new page you'll also see options to transfer your SuperAdmin status to another admin.
Resetting the system for a new semester: Click on the "Reset Semester" button on the ribbon at the top of any page in the admin portal. You'll be asked to put in the master reset password to continue with the process - if you don't remember the password, contact your system administrator for help. The admin requesting this will get an email with all the data that is being wiped from the system. WARNING: there is NO going back once you reset the semester - the data is permanently wiped out of the database after this. Proceed only when you are 100% sure that this is what you want to do.
+
+
+## How to install and run project
+
+- Clone the repository
+- Make sure you are using ruby version 2.3.4
+- Within your "~/.bashrc" file, include the following lines
+ - export GOOGLE_KEY=(contact kbromyonas@berkeley.edu for this value)
+ - export GOOGLE_SECRET=(contact kbromyonas@berkeley.edu for this value)
+ - export API_KEY=(contact kbromyonas@berkeley.edu for this value)
+ - export ADMIN_DELETE_DATA_PASSWORD=hello
+- Reload your terminal so that the environment variables are loaded
+- Run "bundle install"
+- Run "rake db:drop && rake db:create && rake db:migrate && rake db:seed"
+- Contact kbromyonas@berkeley.edu to add your uri to the login credentials
+- At this point your should be able to run "rails s -p $PORT -b $IP"
diff --git a/app/assets/javascripts/group.coffee b/app/assets/javascripts/group.coffee
new file mode 100644
index 00000000..24f83d18
--- /dev/null
+++ b/app/assets/javascripts/group.coffee
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://coffeescript.org/
diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css
index 45e236e8..8b493250 100644
--- a/app/assets/stylesheets/application.css
+++ b/app/assets/stylesheets/application.css
@@ -14,3 +14,11 @@
*= require_self
*= require_tree .
*/
+.send_subject_textarea {
+ width: 100%;
+}
+
+.send_email_textarea {
+ height: 300px;
+ width: 100%;
+}
\ No newline at end of file
diff --git a/app/assets/stylesheets/group.scss b/app/assets/stylesheets/group.scss
new file mode 100644
index 00000000..202bd0a7
--- /dev/null
+++ b/app/assets/stylesheets/group.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the Group controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
diff --git a/app/controllers/admins_controller.rb b/app/controllers/admins_controller.rb
index 05a9780f..94502789 100644
--- a/app/controllers/admins_controller.rb
+++ b/app/controllers/admins_controller.rb
@@ -1,29 +1,59 @@
class AdminsController < ApplicationController
-
skip_before_filter :authenticate, :only => ['new', 'create']
- before_filter :validate_admin, :set_admin, :except => ['new', 'create']
+ before_filter :validate_admin, :set_admin
+
+ def show_import
+
+ # require 'net/http'
+ # require 'net/https'
+
+ # uri = URI.parse("https://apis.berkeley.edu/uat/sis/v2/enrollments/terms/2178/classes/sections/38628")
+
+ # http = Net::HTTP.new(uri.host, uri.port)
+ # http.use_ssl = true
+
+ # request = Net::HTTP::Get.new(uri.request_uri, initheader = {"Accept" => "application/json", "app_id" => ENV["ENROLLMENT_API_APP_ID"], "app_key" => ENV["ENROLLMENT_API_APP_KEY"]})
+
+ # response = http.request(request)
+ # r = JSON.parse(response.body)
+ # puts "hello"
+ # puts r["apiResponse"]["responseType"]
+ # puts response.body.index "169"
+ # puts response.body[124000..124030]
+ # puts "bye"
+
+ # render :json => response.body
+ render 'import'
+ end
def new
- @admin = Admin.new
+ @new_admin = Admin.new
render 'new'
end
def create
- @admin = Admin.new(admin_params)
- @admin.superadmin = false
- if session[:is_admin] == true and @admin.save
- #AdminMailer.invite_new_admin(@admin).deliver_now
+
+ if params["type_admin"] == "ta"
+ @new_admin = Admin.new(:name => params[:admin]["name"], :email => params[:admin]["email"], :TAadmin => true )
+ elsif params["type_admin"] == "enroll"
+ @new_admin = Admin.new(:name => params[:admin]["name"], :email => params[:admin]["email"], :enrollmeadmin => true )
+ else
+ redirect_to new_admin_path, :notice => "Choose an admin type"
+ return
+ end
+ @new_admin.superadmin = false
+ if session[:is_admin] == true and @new_admin.save
redirect_to admins_path, :notice => "You created admin " + admin_params["name"] + " successfully!"
else
render 'new', :notice => "Form is invalid"
end
end
-
+
def update
@admin.update_attributes!(admin_params)
return redirect_to admins_path
end
-
+
def index
status = params[:status]
@status = status
@@ -31,44 +61,116 @@ def index
render 'index'
end
+ def unapproved
+ unapproved_teams = session[:unapproved_teams]
+ @unapproved_teams = []
+ unapproved_teams.each do |t|
+ if !t["id"].nil? then
+ q = Team.find_by_id(t["id"])
+ @unapproved_teams << q
+ end
+ end
+ render 'unapproved'
+ end
+
+ def email
+ @email = ''
+ team_id = params[:team_id]
+ session[:team_id] = team_id
+ render 'email'
+ end
+
+ def create_email
+ email_content = params[:email_content]
+ subject = params[:subject_content]
+ puts "hello"
+ puts subject == ""
+ puts subject
+ puts "bye"
+ team_id = session[:team_id]
+ if email_content == ""
+ redirect_to admins_email_path(team_id: team_id), notice: "You have to include email content."
+ return
+ end
+ @email_array = User.get_all_user_emails team_id
+ @email_array.each do |email_id|
+ EmailStudents.email_group(email_id, email_content, subject).deliver_now
+ end
+
+ render 'email_success'
+ end
+
def approve
- @team = Team.find_by_id(params[:team_id])
- @team.approved = true
- @team.save!
-
- #AdminMailer.send_approved_email(@team).deliver_now
-
- if !(params[:disc].nil?)
- Team.find_by_id(params[:team_id]).approve_with_discussion(params[:disc])
+ if !@admin.TAadmin
+ @team = Team.find_by_id(params[:team_id])
+ @team.approved = true
+ @team.save!
+ if !(params[:disc].nil?)
+ Team.find_by_id(params[:team_id]).approve_with_discussion(params[:disc])
+ end
end
+ # message = "Your team has been approved!"
+ # User.get_all_user_emails(@team.id).each do |email_id|
+ # EmailStudents.email_group(email_id, message).deliver_now
+ # end
redirect_to admins_path
end
def disapprove
- @team = Team.find_by_id(params[:team_id])
- @team.approved = false
- @team.save!
-
- #AdminMailer.send_disapproved_email(@team).deliver_now
-
- Team.find_by_id(params[:team_id]).disapprove
+ if !@admin.TAadmin
+ @team = Team.find_by_id(params[:team_id])
+ @groupt1 = Group.find_by_team1_id(params[:team_id])
+ @groupt2 = Group.find_by_team2_id(params[:team_id])
+ if @groupt1 != nil
+ @groupt1.delete
+ end
+ if @groupt2 != nil
+ @groupt2.delete
+ end
+ @team.approved = false
+ @team.discussion_id = nil
+ @team.save!
+ Team.find_by_id(params[:team_id]).disapprove
+ end
+ # message = "Your team has been disapproved. If you any have questions please email Cindy Connors at csconnors@berkeley.edu."
+ # User.get_all_user_emails(@team.id).each do |email_id|
+ # EmailStudents.email_group(email_id, message).deliver_now
+ # end
redirect_to admins_path
end
-
+
def undo_approve
- @team = Team.find_by_id(params[:team_id])
- @team.approved = false
- @team.save!
-
- #AdminMailer.send_disapproved_email(@team).deliver_now
-
- Team.find_by_id(params[:team_id]).withdraw_approval
+ if !@admin.TAadmin
+ @team = Team.find_by_id(params[:team_id])
+ # @groupt1 =
+ # @groupt2 =
+ if Group.find_by_team1_id(params[:team_id]) != nil
+ Group.find_by_team1_id(params[:team_id]).delete
+ end
+ if Group.find_by_team2_id(params[:team_id]) != nil
+ Group.find_by_team2_id(params[:team_id]).delete
+ end
+ @team.approved = false
+ @team.discussion_id = nil
+ @team.save!
+ Team.find_by_id(params[:team_id]).withdraw_approval
+ end
+ # message = "Your team has been unapproved. If you any have questions please email Cindy Connors at csconnors@berkeley.edu."
+ # User.get_all_user_emails(@team.id).each do |email_id|
+ # EmailStudents.email_group(email_id, message).deliver_now
+ # end
redirect_to admins_path
end
def team_list_email
- #AdminMailer.team_list_email(@admin).deliver_now
-
+ @status = params[:status]
+ puts "---"
+ puts params
+ puts "---"
+ AdminMailer.team_list_email(@admin, @status).deliver_now
+ puts "***"
+ puts "pass"
+ puts "***"
redirect_to admins_path
end
@@ -83,7 +185,6 @@ def reset_semester
def reset_database
@reset_password = params[:reset_password]
if @reset_password == ENV["ADMIN_DELETE_DATA_PASSWORD"]
- #AdminMailer.all_data(@admin).deliver_now if not Rails.env.test?
User.delete_all
Team.delete_all
Submission.delete_all
@@ -93,19 +194,27 @@ def reset_database
redirect_to reset_semester_path, :notice => "Incorrect password"
end
end
-
+
+ # TODO what type of admin should I be if I transfer control?
def transfer
if @admin.superadmin == true and params[:transfer_admin] != nil
other_admin = Admin.find(params[:transfer_admin])
+
@admin.superadmin = false
+ @admin.TAadmin = false
+ @admin.enrollmeadmin = true
+
other_admin.superadmin = true
+ other_admin.TAadmin = false
+ other_admin.enrollmeadmin = false
+
@admin.save!
other_admin.save!
notice = "Successfully transferred superadmin powers."
- elsif @admin.superadmin == true and params[:transfer_admin] === nil
+ elsif @admin.superadmin == true and params[:transfer_admin] == nil
notice = "No admin selected for transfer."
- else
- notice = "You don't have permission to do that."
+ # else
+ # notice = "You don't have permission to do that."
end
redirect_to superadmin_path, :notice => notice
end
@@ -119,14 +228,7 @@ def delete
c += 1
end
end
-
- if c == 1
- notice = "#{c} admin successfully deleted."
- else
- notice = "#{c} admins successfully deleted."
- end
- else
- notice = "You do not have sufficient permissions to do that."
+ notice = "#{c} admins successfully deleted."
end
redirect_to superadmin_path, :notice => notice
end
@@ -140,7 +242,7 @@ def destroy
end
redirect_to '/', :notice => notice
end
-
+
private
def validate_admin
@@ -154,11 +256,10 @@ def set_admin
end
def admin_params
- params.require(:admin).permit(:name, :email)
+ params.require(:admin).permit(:name, :email, :type_admin)
end
def admin_tutorial
render 'admin_tutorial'
end
-
end
diff --git a/app/controllers/group_controller.rb b/app/controllers/group_controller.rb
new file mode 100644
index 00000000..2f12474e
--- /dev/null
+++ b/app/controllers/group_controller.rb
@@ -0,0 +1,120 @@
+class GroupController < ApplicationController
+
+ def index
+ # status = params[:status]
+ # @status = status
+ # @teams_li = Team.filter_by(status)
+
+ # teams = []
+ # @teams_li.each do |t|
+ # if Group.has_team?(t.id, t.discussion_id)
+ # teams.push(t)
+ # end
+ # end
+ # teams.each do |t|
+ # @teams_li.delete(t)
+ # end
+ @groups_li = Group.all
+ render 'index'
+ end
+
+ def select_group
+ status = params[:status]
+ @status = status
+ @teams_li = Team.filter_by(status)
+ teams = []
+ @teams_li.each do |t|
+ if Group.has_team?(t.id, t.discussion_id) or t.discussion_id == nil
+ teams.push(t)
+ end
+ end
+
+ teams.each do |t|
+ @teams_li.delete(t)
+ end
+ render 'create'
+ end
+
+ def merge
+ teams = []
+ discussions = Set.new
+ for i in params
+ if i[1] == {"selected"=>"1"}
+ team = Team.where({:id => i[0].to_i})
+ team.each do |t|
+ teams.push(t.id)
+ discussions.add(t.discussion_id)
+ @dis = t.discussion_id
+ end
+ end
+ end
+
+ if discussions.size == 1 and teams.length == 2
+ Group.create({:team1_id => teams[0], :team2_id => teams[1], :discussion_id => @dis})
+ flash[:success] = "Group Created!"
+ elsif discussions.size != 1
+ flash[:error] = "Select teams with same discussions!"
+ elsif teams.length != 2
+ flash[:error] = "Must select two teams!"
+ end
+
+ # puts Group.all.inspect
+ redirect_to admin_select_group_path
+ end
+
+ def unmerge
+ count = 0
+ for i in params
+ if i[1] == {"group"=>"1"}
+ groups = Group.where({:id => i[0].to_i})
+ groups.each do |g|
+ @group_id = g.id
+ count+=1
+ end
+ end
+ # puts i
+ # puts "---"
+ end
+ if count == 1
+ Group.unmerge(@group_id)
+ flash[:success] = "Group Destroyed!"
+ else
+ flash[:success] = "Select one group!"
+ end
+
+ redirect_to group_index_path
+ end
+
+
+ def random
+ grouped = 0
+ Discussion.all.each do |discussion|
+ teams = Team.where(:discussion_id => discussion.id)
+
+ #This list holds two unpaired teams
+ ungrouped_teams = []
+ teams.each do |team|
+ if !Group.has_team?(team.id, discussion.id)
+ ungrouped_teams.push(team.id)
+ end
+
+ if ungrouped_teams.length == 2
+ Group.create!({:team1_id => ungrouped_teams[0], :team2_id => ungrouped_teams[1], :discussion_id => discussion.id})
+ ungrouped_teams = []
+ grouped += 1
+ end
+ end
+ end
+
+ if grouped > 0
+ flash[:success] = "Randomly grouped #{grouped} group#{'s' if grouped > 1}"
+ redirect_to group_index_path
+ else
+ flash[:error] = "Cannot randomly create groups"
+ redirect_to admin_select_group_path
+ end
+
+ end
+end
+
+
diff --git a/app/controllers/team_controller.rb b/app/controllers/team_controller.rb
index dba767c2..9140b663 100644
--- a/app/controllers/team_controller.rb
+++ b/app/controllers/team_controller.rb
@@ -8,14 +8,38 @@ class TeamController < ApplicationController
def show
@discussions = Discussion.valid_discs_for(@team)
if @team.submitted and !(@team.approved)
- @s = Submission.find(@team.submission_id)
- @d1 = Discussion.find(@s.disc1id)
- @d2 = Discussion.find_by_id(@s.disc2id)
- @d3 = Discussion.find_by_id(@s.disc3id)
+ show_setup
end
render "team"
end
+ def show_setup
+ @s = Submission.find(@team.submission_id)
+ @d1 = Discussion.find(@s.disc1id)
+ @d2 = Discussion.find_by_id(@s.disc2id)
+ @d3 = Discussion.find_by_id(@s.disc3id)
+ end
+
+ def showgroup
+ @groupt1 = Group.find_by_team1_id(@team.id)
+ @groupt2 = Group.find_by_team2_id(@team.id)
+
+ # @discussions = Discussion.valid_discs_for(@team)
+ # if @team.submitted and !(@team.approved)
+ # show_setup
+ # end
+ if @groupt1 != nil
+ @group = @groupt1
+ render "mygroup"
+ elsif @groupt2 != nil
+ @group = @groupt2
+ render "mygroup"
+ else
+ flash[:success] = "You are not in a group yet!"
+ redirect_to team_path
+ end
+ end
+
def submit
#EmailStudents.successfully_submitted_email(@team).deliver_now
@@ -23,6 +47,12 @@ def submit
end
def unsubmit
+ # puts "-------"
+ # puts @team.inspect
+ # puts "!!!!!!"
+ # puts Team.all.inspect
+ # puts Submission.all.inspect
+ # puts "======="
@submission = @team.submission
@submission.destroy!
@team.withdraw_submission
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 859321b8..2efc7085 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -1,10 +1,15 @@
class UsersController < ApplicationController
-
- skip_before_filter :authenticate, :only => ['new', 'create']
- before_filter :check_is_user, :except => ['new', 'create', 'show']
- before_filter :set_user, :except => ['new', 'create']
+ before_action :set_user, only: [:show, :edit, :update, :destroy]
+ skip_before_filter :authenticate, :only => %w(new create)
+ before_filter :check_is_user, :except => %w(new create show index import destroy edit)
+ before_filter :set_user, :except => %w(new create)
+
+ def index
+ @users = User.all
+ end
def show
+ puts Team.all.inspect
@user = User.find_by_id(params[:id])
end
@@ -16,10 +21,7 @@ def new
def create
@user = User.new(user_params)
-
if @user.save
- #EmailStudents.welcome_email(@user).deliver_later
-
session[:user_id] = @user.id
session[:user_email] = @user.email
redirect_to without_team_path, :notice => "You signed up successfully!"
@@ -27,12 +29,20 @@ def create
render 'new', :notice => "Form is invalid"
end
end
+
+ def import
+ if params[:file]
+ unapproved_teams = User.import(params[:file])
+ session[:unapproved_teams] = unapproved_teams
+ redirect_to unapproved_teams_path, notice: 'Users Added Successfully'
+ else
+ redirect_to import_page_path, notice: 'No File Selected'
+ end
+ end
def start_team
@user.leave_team if !(@user.team.nil?)
-
@team = Team.create!(:passcode => Team.generate_hash, :approved => false, :submitted => false)
-
@user.team = @team
@team.users << @user
redirect_to team_path(:id=>@team.id)
@@ -42,25 +52,19 @@ def join_team
@passcode = params[:team_hash]
@team = Team.find_by_passcode(@passcode)
@team ||= Team.new()
- return redirect_to without_team_path, :notice => "Unable to join team" if @passcode.empty? or !(@team.can_join?)
-
+ return redirect_to without_team_path, :notice => 'Unable to join team' if @passcode.empty? or !(@team.can_join?)
@user.leave_team if !(@user.team.nil?)
-
@user.team = @team
@team.users << @user
@team.withdraw_submission
-
@team.send_submission_reminder_email if @team.eligible?
-
redirect_to team_path(:id=>@team.id)
end
-
def update
@user.update_attributes!(user_params)
@team = @user != nil ? @user.team : nil
return redirect_to team_path({:id => @team === nil ? 1 : @team.id, :uid => @user.id})
end
-
private
def check_is_user
if session[:is_admin]
@@ -68,11 +72,12 @@ def check_is_user
return redirect_to session.delete(:return_to), :notice => 'Permission denied'
end
end
-
def set_user
@user = User.find_by_id session[:user_id]
+ if params[:id]
+ @user = User.find_by_id params[:id]
+ end
end
-
def user_params
params.require(:user).permit(:name, :email, :sid, :major)
end
diff --git a/app/helpers/group_helper.rb b/app/helpers/group_helper.rb
new file mode 100644
index 00000000..b82886e9
--- /dev/null
+++ b/app/helpers/group_helper.rb
@@ -0,0 +1,2 @@
+module GroupHelper
+end
diff --git a/app/mailers/admin_mailer.rb b/app/mailers/admin_mailer.rb
index a7328c07..70141bb1 100644
--- a/app/mailers/admin_mailer.rb
+++ b/app/mailers/admin_mailer.rb
@@ -1,5 +1,5 @@
class AdminMailer < ApplicationMailer
- default from: 'enrollmeberkeley@gmail.com'
+ default from: 'enrollmeberkeley@gmail.com'
def invite_new_admin(admin)
@admin = admin
@@ -9,36 +9,37 @@ def invite_new_admin(admin)
end
end
- def team_list_email(admin)
+ def team_list_email(admin, status)
@admin = admin
@url = 'http://www.gmail.com'
- mail(to: @admin.email, subject: 'Here is list of' + params[:status] + 'teams in EnrollMe') do |format|
- format.html
+ puts "!!!!!"
+ puts status
+ puts "!!!!!"
+ mail(to: @admin.email, subject: 'Here is list of ' + status + ' teams in EnrollMe') do |format|
+ puts "hello"
+ @status = status
+ puts "hello1"
+ format.html
end
end
-
- def send_approved_email(team)
+
+ def email_team_members(team, message)
@team = team
-
- @team.users.each do |approved_user|
- @user = approved_user
+ @team.users.each do |disapproved_user|
+ @user = disapproved_user
@url = ENV["SERVER_EMAIL"]
- mail(to: @user.email, subject: 'Your team has been approved') do |format|
+ mail(to: @user.email, subject: message) do |format|
format.html
end
end
end
+
+ def send_approved_email(team)
+ email_team_members(team, 'Your team has been approved')
+ end
def send_disapproved_email(team)
- @team = team
-
- @team.users.each do |disapproved_user|
- @user = disapproved_user
- @url = ENV["SERVER_EMAIL"]
- mail(to: @user.email, subject: 'Your team has been disapproved') do |format|
- format.html
- end
- end
+ email_team_members(team, 'Your team has been disapproved')
end
def look_at_submission(email)
@@ -59,4 +60,4 @@ def self.send_look_at_submission
end
end
end
-end
+end
\ No newline at end of file
diff --git a/app/mailers/email_students.rb b/app/mailers/email_students.rb
index 132e7c60..af89f491 100644
--- a/app/mailers/email_students.rb
+++ b/app/mailers/email_students.rb
@@ -23,4 +23,16 @@ def successfully_submitted_email(team)
end
end
+ def email_group(email, message, subject="")
+ if subject == ""
+ subject_text = 'You have a new message for CS169 from EnrollMe'
+ else
+ subject_text = subject
+ end
+
+ mail(to: email, subject: subject_text) do |format|
+ format.text { render plain: message }
+ end
+ end
+
end
diff --git a/app/models/admin.rb b/app/models/admin.rb
index 8e14adff..d9862e8f 100644
--- a/app/models/admin.rb
+++ b/app/models/admin.rb
@@ -6,6 +6,7 @@ class Admin < ActiveRecord::Base
format: VALID_EMAIL_REGEX, exclusion: { in: lambda { |a| a.all_user_emails } }
def self.admin_from_oauth(auth)
+
return Admin.find_by(:email => auth[:info][:email])
end
diff --git a/app/models/group.rb b/app/models/group.rb
new file mode 100644
index 00000000..98a49c9c
--- /dev/null
+++ b/app/models/group.rb
@@ -0,0 +1,18 @@
+class Group < ActiveRecord::Base
+ has_one :team # Yonas added this
+ has_one :other_team, class_name: "Team", foreign_key: "team2_id" # Yonas added this
+
+
+ def self.has_team?(team_id, disc_id)
+ Group.where(:discussion_id => disc_id).each do |group|
+ if group.team1_id == team_id or group.team2_id == team_id
+ return true
+ end
+ end
+ return false
+ end
+
+ def self.unmerge(group_id)
+ Group.where(:id => group_id).take!.destroy
+ end
+end
diff --git a/app/models/submission.rb b/app/models/submission.rb
index e069e03c..c28dfd21 100644
--- a/app/models/submission.rb
+++ b/app/models/submission.rb
@@ -1,4 +1,4 @@
class Submission < ActiveRecord::Base
- attr_accessor :team_id
+ # attr_accessor :team_id
belongs_to :team
end
diff --git a/app/models/team.rb b/app/models/team.rb
index 9d174c83..4374aab2 100644
--- a/app/models/team.rb
+++ b/app/models/team.rb
@@ -1,6 +1,9 @@
class Team < ActiveRecord::Base
has_many :users
has_one :submission
+
+ belongs_to :group # Yonas added this
+
validates :passcode, uniqueness: true
def self.generate_hash(length=36)
@@ -59,6 +62,7 @@ def self.filter_by(status)
def add_submission(id)
self.update(submitted: true)
+ self.submission = Submission.find_by_id id
self.submission_id = id
self.save!
end
@@ -68,4 +72,41 @@ def can_join?
! approved &&
users.size < Option.maximum_team_size
end
+
+ def self.approved_teams_from_csv(users_hash)
+ approved_teams = []
+ unapproved_teams = []
+ Team.all.each do |t|
+ each_team_user_found = true
+ t.users.each do |u|
+ if users_hash[u.sid.to_i].nil?
+ each_team_user_found = false
+ end
+ end
+ if each_team_user_found
+ approved_teams << t
+ else
+ unapproved_teams << t
+ end
+ end
+ return approved_teams, unapproved_teams
+ end
+
+ def self.add_teams_to_discussions(approved_teams)
+ approved_teams.each do |t|
+ count, index = 100, false
+ team_subm, team_prefs = t.submission, []
+ if t.approved || !t.eligible? || team_subm.nil? then next end
+ team_prefs << team_subm.disc1id
+ team_prefs << team_subm.disc2id
+ team_prefs << team_subm.disc3id
+ team_prefs.each do |d_id|
+ d = Discussion.find_by_id d_id
+ if d.count_students < count
+ count, index = d.count_students, d.id
+ end
+ end
+ if index then t.approve_with_discussion(index) end
+ end
+ end
end
diff --git a/app/models/user.rb b/app/models/user.rb
index 2c26bd80..0d49dacc 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -30,8 +30,38 @@ def self.user_from_oauth(auth)
# return User.where("email LIKE ?", query).first
end
+ def self.get_all_user_emails(team_id)
+ return User.where(:team_id => team_id).pluck(:email)
+ end
+
def all_admin_emails
return Admin.pluck(:email)
end
+
+ def self.valid_user_hash(user_hash)
+ !user_hash['Name'].nil? && !user_hash['Student ID'].nil? &&
+ !user_hash['Majors'].nil? && !user_hash['Email Address'].nil?
+ end
+
+ def self.users_from_csv(file)
+ users = {}
+ CSV.foreach(file.path, headers: true) do |row|
+ student = row.to_hash
+ unless User.valid_user_hash(student) then next end
+ if User.exists?(name: student['Name'], sid: student['Student ID'],
+ major: student['Majors'], email: student['Email Address'])
+ users[student['Student ID'].to_i] = true
+ end
+ end
+ return users
+ end
+
+ def self.import(file)
+ csv_users = User.users_from_csv(file)
+ approved_teams, unapproved_teams = Team.approved_teams_from_csv(csv_users)
+ Team.add_teams_to_discussions(approved_teams)
+ return unapproved_teams
+
+ end
end
\ No newline at end of file
diff --git a/app/views/admin_mailer/team_list_email.html.erb b/app/views/admin_mailer/team_list_email.html.erb
index 9f1e0765..6a86d994 100644
--- a/app/views/admin_mailer/team_list_email.html.erb
+++ b/app/views/admin_mailer/team_list_email.html.erb
@@ -10,7 +10,7 @@
<%= t.id %>
<% t.users.each do |u| %>
diff --git a/app/views/admins/email.html.erb b/app/views/admins/email.html.erb
new file mode 100644
index 00000000..a33d0ff7
--- /dev/null
+++ b/app/views/admins/email.html.erb
@@ -0,0 +1,30 @@
+
+ Email Team
+
+
+
Send Email to Team
+
+
+
If subject left blank, subject of email will be: "You have a new message for CS169 from EnrollMe"
+
+
+
+
+ <%=form_for @email, url: {action: "create_email"} do |f| %>
+
+
+
+
+ <% end %>
+
+
+
+
\ No newline at end of file
diff --git a/app/views/admins/email_success.html.erb b/app/views/admins/email_success.html.erb
new file mode 100644
index 00000000..739f0002
--- /dev/null
+++ b/app/views/admins/email_success.html.erb
@@ -0,0 +1,14 @@
+
+ Email Sent!
+
+ Successfully sent e-mails to:
+
+ <% @email_array.each do |email1| %>
+ <%=email1%>
+ <% end %>
+
+
+
+
\ No newline at end of file
diff --git a/app/views/admins/import.html.erb b/app/views/admins/import.html.erb
new file mode 100644
index 00000000..70a7faee
--- /dev/null
+++ b/app/views/admins/import.html.erb
@@ -0,0 +1,21 @@
+
+Import Students From CSV
+
+
+
Import Students From CSV
+
+ Make sure CSV is of the following format:
+ Name | Student ID | User ID | Role |Email Address | Sections | Majors | Terms in Attendance | Units | Grading Basis | Waitlist Position
+
+
+
+ <%= form_tag import_users_path, multipart: true do %>
+ <%= file_field_tag :file %>
+
+ <%= submit_tag "Upload Students", class: 'btn btn-default' %>
+ <% end %>
+
+
+
+
+
diff --git a/app/views/admins/index.html.erb b/app/views/admins/index.html.erb
index 1384b170..2afff8be 100644
--- a/app/views/admins/index.html.erb
+++ b/app/views/admins/index.html.erb
@@ -9,7 +9,13 @@
@@ -30,15 +36,18 @@
+ <% if !@admin.TAadmin %>
<%= link_to "Download this data", download_team_info_path(:status => params[:status] ||= "Pending | Approved"), {method: 'get', class: "btn btn-primary btn-sm"} %>
<%= link_to "Email me this data", admins_email_path(:status => params[:status] ||= "Pending | Approved"), {method: 'post', class: 'btn btn-success btn-sm'} %>
+ <%= link_to "Import Student Data", import_page_path, {class: 'btn btn-primary btn-sm'} %>
+ <% end %>
-
+
- Team ID Members Status Discussions
+ Team ID Members Status Discussions Send Email
<% @teams_li.each do |t| %>
@@ -53,34 +62,43 @@
Approved
<% d = Discussion.find_by_id(t.discussion_id) %>
- <%= link_to "Disapprove", admin_disapprove_team_path(:team_id => t.id), {:id=>"disapprove_#{t.id}", :class=>'btn btn-xs btn-danger'} %>
- <%= link_to "Undo Approve", admin_undo_approve_team_path(:team_id => t.id), {:id=>"undo_approve_#{t.id}", :class=>'btn btn-xs btn-warning'} %>
+ <% if !@admin.TAadmin %>
+ <%= link_to "Disapprove", admin_disapprove_team_path(:team_id => t.id), {:id=>"disapprove_#{t.id}", :class=>'btn btn-xs btn-danger'} %>
+ <%= link_to "Undo Approve", admin_undo_approve_team_path(:team_id => t.id), {:id=>"undo_approve_#{t.id}", :class=>'btn btn-xs btn-warning'} %>
+ <% end %>
<%= d.info %>
-
+
<% elsif t.submitted? %>
Pending
<% s = Submission.find_by_id(t.submission_id) %>
- <%= link_to "Approve", admin_approve_team_path(:team_id => t, :disc=> "#{s.disc1id}"), {:id=>"approve_1", :class=>'btn btn-xs btn-success'} %>
+ <% if !@admin.TAadmin %>
+ <%= link_to "Approve", admin_approve_team_path(:team_id => t, :disc=> "#{s.disc1id}"), {:id=>"approve_1", :class=>'btn btn-xs btn-success'} %>
+ <% end %>
<%= label "disc_#{s.disc1id}", Discussion.find_by_id(s.disc1id).info %>
- <%= link_to "Approve", admin_approve_team_path(:team_id => t, :disc=> "#{s.disc2id}"), {:id=>"approve_2", :class=>'btn btn-xs btn-warning'} %>
+ <% if !@admin.TAadmin %>
+ <%= link_to "Approve", admin_approve_team_path(:team_id => t, :disc=> "#{s.disc2id}"), {:id=>"approve_2", :class=>'btn btn-xs btn-warning'} %>
+ <% end %>
<%= label "disc_#{s.disc2id}", Discussion.find_by_id(s.disc2id).info %>
- <%= link_to "Approve", admin_approve_team_path(:team_id => t, :disc=> "#{s.disc3id}"), {:id=>"approve_3", :class=>'btn btn-xs btn-danger'} %>
+ <% if !@admin.TAadmin %>
+ <%= link_to "Approve", admin_approve_team_path(:team_id => t, :disc=> "#{s.disc3id}"), {:id=>"approve_3", :class=>'btn btn-xs btn-danger'} %>
+ <% end %>
<%= label "disc_#{s.disc3id}", Discussion.find_by_id(s.disc3id).info %>
<% else %>
Forming
<% end %>
+
+ <%= link_to "Send Email", admins_send_email_path(:team_id => t), {:id=>"sendemail_#{t.id}", :class=>'btn btn-xs btn-success'} %>
+
<% end %>
-
-
diff --git a/app/views/admins/new.html.erb b/app/views/admins/new.html.erb
index 3069a0b4..9048b9fe 100644
--- a/app/views/admins/new.html.erb
+++ b/app/views/admins/new.html.erb
@@ -1,10 +1,13 @@
Admin Sign Up
-
Create a New Admin
- <%= form_for @admin, url: {action: "create"}, class: "form-horizontal" do |f| %>
+
Create a New Admin, <%= @admin.name %>
+ <%= form_for @new_admin, url: {action: "create"}, class: "form-horizontal" do |f| %>
- <%= render 'shared/basic_info', {:f => f, :user => @admin} %>
+ <%= render 'shared/basic_info', {:f => f, :user => @new_admin} %>
+ <%= radio_button_tag "type_admin", "ta" %> TA Admin
+ <%= radio_button_tag "type_admin", "enroll" %> Enrollment Admin
+
diff --git a/app/views/admins/super.html.erb b/app/views/admins/super.html.erb
index 24e6c3ad..e07ef541 100644
--- a/app/views/admins/super.html.erb
+++ b/app/views/admins/super.html.erb
@@ -8,7 +8,7 @@
- Admin Name Delete Admin
+ Admin Name Delete Admin Admin Type
<% Admin.all.each do |a| %>
<% if a.id != @admin.id %>
@@ -17,6 +17,7 @@
<%= check_box_tag "delete_#{a.name}", true %>
+ <%= a.enrollmeadmin ? "Enrollment" : (a.superadmin ? "Super Admin" : "TA")%>
<% end %>
<% end %>
@@ -34,7 +35,7 @@
- Admin Name Transfer SuperAdmin Status
+ Admin Name Transfer SuperAdmin Status Admin Type
<% Admin.all.each do |a| %>
<% if a.id != @admin.id %>
@@ -43,6 +44,7 @@
<%= radio_button_tag "transfer_admin", a.id %>
+ <%= a.enrollmeadmin ? "Enrollment" : (a.superadmin ? "Super Admin" : "TA")%>
<% end %>
<% end %>
diff --git a/app/views/admins/unapproved.html.erb b/app/views/admins/unapproved.html.erb
new file mode 100644
index 00000000..a6ce43cf
--- /dev/null
+++ b/app/views/admins/unapproved.html.erb
@@ -0,0 +1,53 @@
+
+ List of Unapproved Teams
+
+
+
Unapproved Teams:
+
+
+
+ Team ID Members Status Discussions Send Email
+
+
+ <% @unapproved_teams.each do |t| %>
+
+ <%= link_to t.id, team_path(t.id) %>
+
+ <% t.users.each do |u| %>
+ <%= link_to u.name, user_path(u.id) %>
+ <% end %>
+
+ <% if t.approved? %>
+ Approved
+ <% d = Discussion.find_by_id(t.discussion_id) %>
+
+ <%= link_to "Disapprove", admin_disapprove_team_path(:team_id => t.id), {:id=>"disapprove_#{t.id}", :class=>'btn btn-xs btn-danger'} %>
+ <%= link_to "Undo Approve", admin_undo_approve_team_path(:team_id => t.id), {:id=>"undo_approve_#{t.id}", :class=>'btn btn-xs btn-warning'} %>
+ <%= d.info %>
+
+ <% elsif t.submitted? %>
+ Pending
+ <% s = Submission.find_by_id(t.submission_id) %>
+
+ <%= link_to "Approve", admin_approve_team_path(:team_id => t, :disc=> "#{s.disc1id}"), {:id=>"approve_1", :class=>'btn btn-xs btn-success'} %>
+ <%= label "disc_#{s.disc1id}", Discussion.find_by_id(s.disc1id).info %>
+
+ <%= link_to "Approve", admin_approve_team_path(:team_id => t, :disc=> "#{s.disc2id}"), {:id=>"approve_2", :class=>'btn btn-xs btn-warning'} %>
+ <%= label "disc_#{s.disc2id}", Discussion.find_by_id(s.disc2id).info %>
+
+ <%= link_to "Approve", admin_approve_team_path(:team_id => t, :disc=> "#{s.disc3id}"), {:id=>"approve_3", :class=>'btn btn-xs btn-danger'} %>
+ <%= label "disc_#{s.disc3id}", Discussion.find_by_id(s.disc3id).info %>
+
+ <% else %>
+ Forming
+
+ <% end %>
+
+ <%= link_to "Send Email", admins_send_email_path(:team_id => t), {:id=>"sendemail_#{t.id}", :class=>'btn btn-xs btn-success'} %>
+
+
+ <% end %>
+
+
+
+
\ No newline at end of file
diff --git a/app/views/discussion/index.html.erb b/app/views/discussion/index.html.erb
index 102e7a95..0c6b7de5 100644
--- a/app/views/discussion/index.html.erb
+++ b/app/views/discussion/index.html.erb
@@ -8,21 +8,25 @@
<% if session[:is_admin] %>
<% end %>
-
-
+
+
CCN
Discussion Times
Seats Open
+ Capacity
<% @discussions.each do |d| %>
@@ -30,6 +34,7 @@
<%= d.number %>
<%= "#{d.day} #{d.time}" %>
+ <%= d.seats_open %>
<%= d.capacity %>
<% end %>
@@ -39,7 +44,7 @@
diff --git a/app/views/group/create.html.erb b/app/views/group/create.html.erb
new file mode 100644
index 00000000..2ccd5623
--- /dev/null
+++ b/app/views/group/create.html.erb
@@ -0,0 +1,64 @@
+
+
+
+
+
+
+ Admin Home
+
+
<%= "Create Groups" %>
+
+
+
+ <%= form_tag({:action => "merge"}) do %>
+
+
+
+ Team ID
+ Members
+ Status
+ Discussions
+
+
+ <% @teams_li.each do |t| %>
+ <% if t.approved? %>
+
+ <%= check_box(t.id, "selected", class:"group_checkbox", id:"team_#{t.id}")%>
+ <%= link_to t.id, team_path(t.id) %>
+
+ <% t.users.each do |u| %>
+ <%= link_to u.name, user_path(u.id) %>
+ <% end %>
+
+
+ Approved
+ <% d = Discussion.find_by_id(t.discussion_id) %>
+
+ <%= d.info %>
+
+ <% end %>
+
+ <% end %>
+
+
+
+ <%= submit_tag("Create Group", :class => 'btn btn-xs btn-success')%>
+ <% end %>
+
+
+
+ <%= form_tag({:action => "random", :method => "post"}) %>
+ <%= submit_tag("Group randomly", :class => 'btn btn-xs btn-success')%>
+
+
+
+
+
+
+ <%= link_to "Back", admins_path, {:class=>"btn btn-default"} %>
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/group/index.html.erb b/app/views/group/index.html.erb
new file mode 100644
index 00000000..2632a16d
--- /dev/null
+++ b/app/views/group/index.html.erb
@@ -0,0 +1,41 @@
+
+ Admin Home
+
+
<%= "View Groups" %>
+
+
+
+ <%= form_tag({:action => "unmerge", :method => "post"}) do %>
+
+
+
+ Group ID
+ Team 1 ID
+ Team 2 ID
+ Discussion
+
+
+
+ <% @groups_li.each do |g| %>
+
+ <%= check_box(g.id, "group", id:"group_#{g.id}") %>
+ <%= g.id %>
+ <%= g.team1_id %>
+ <%= g.team2_id %>
+ <%= Discussion.find_by_id(g.discussion_id).number %>
+
+ <% end %>
+
+
+ <%= submit_tag("Destroy Group", :class => 'btn btn-xs btn-danger') %>
+ <% end %>
+
+
+ <%= link_to "Back", admins_path, {:class=>"btn btn-default"} %>
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/shared/_basic_info.html.erb b/app/views/shared/_basic_info.html.erb
index b4188e1b..759d0ccd 100644
--- a/app/views/shared/_basic_info.html.erb
+++ b/app/views/shared/_basic_info.html.erb
@@ -13,6 +13,7 @@
<%= f.label :name, class: "col-lg-2 control-label" %>
<%= f.text_field :name, class: "form-control" %>
<%= f.label :email, class: "col-lg-2 control-label" %>
- <%= f.text_field :email, {class: "form-control", :readonly => ((@user.nil? or @user.id.nil?) and (@admin.nil? or @admin.id.nil?)) ? false : true} %>
+ <%= f.text_field :email, {class: "form-control", :readonly => ((@user.nil? or @user.id.nil?) and (@new_admin.nil? or @new_admin.id.nil? )) ? false : true} %>
+
Warning: Please do not use any email aliases - you will not be able to sign in. You must be able to sign into CalNet and/or Gmail using the email provided here.
diff --git a/app/views/shared/_head.html.erb b/app/views/shared/_head.html.erb
index bfe88832..ef64805b 100644
--- a/app/views/shared/_head.html.erb
+++ b/app/views/shared/_head.html.erb
@@ -26,8 +26,9 @@
<% else %>
<%= link_to "Help", '/admin/tutorial' %>
<%= link_to "My Info", admin_path(session[:user_id]), {method: 'get'} %>
- <%= link_to "Register New Admin", new_admin_path, {method: 'get'} %>
+
<% if Admin.find(session[:user_id]).superadmin == true %>
+ <%= link_to "Register New Admin", new_admin_path, {method: 'get'} %>
<%= link_to "Manage Admins", superadmin_path, {method: :get} %>
<%= link_to "Reset Semester", reset_semester_path, {method: :get} %>
<% end %>
diff --git a/app/views/team/mygroup.html.erb b/app/views/team/mygroup.html.erb
new file mode 100644
index 00000000..18533f53
--- /dev/null
+++ b/app/views/team/mygroup.html.erb
@@ -0,0 +1,67 @@
+
+
+ My Group
+
+
+
+
My Group
+
+
Group #<%= @group.id%>
+
+
+
+
Members
+
+
+
+ Student
+ EECS/CS Major?
+ Email
+
+
+
+ <% Team.find_by_id(@group.team1_id).users.each do |u| %>
+
+
+ <%= u.name %>
+ <%= u.major == "DECLARED CS/EECS Major" ? "•" : "No" %>
+ <%= u.email %>
+
+ <%= form_tag edit_team_path(:id => @team.id), method: :get do %>
+ <%= hidden_field_tag :unwanted_user, u.id %>
+ <%= submit_tag "Remove", :id=>"remove_#{u.name}", :class=>"btn btn-default", data: { confirm: "Are you sure you want to remove #{u.name} from your team?" } %>
+ <% end %>
+
+
+ <% end %>
+ <% Team.find_by_id(@group.team2_id).users.each do |u| %>
+
+
+ <%= u.name %>
+ <%= u.major == "DECLARED CS/EECS Major" ? "•" : "No" %>
+ <%= u.email %>
+
+ <%= form_tag edit_team_path(:id => @team.id), method: :get do %>
+ <%= hidden_field_tag :unwanted_user, u.id %>
+ <%= submit_tag "Remove", :id=>"remove_#{u.name}", :class=>"btn btn-default", data: { confirm: "Are you sure you want to remove #{u.name} from your team?" } %>
+ <% end %>
+
+
+ <% end %>
+
+
+
+
+
Group Discussion Information
+ <% disc = Discussion.find(@team.discussion_id) %>
+ <%= "CCN: #{disc.number} | Time: #{disc.day} #{disc.time}" %>
+
+
+
+
+
+ <%= link_to "Back", team_path, {:class=>"btn btn-default"} %>
+
+
+
+
\ No newline at end of file
diff --git a/app/views/team/team.html.erb b/app/views/team/team.html.erb
index 296047bc..25067077 100644
--- a/app/views/team/team.html.erb
+++ b/app/views/team/team.html.erb
@@ -2,11 +2,10 @@
My Team
-
-
My Team
+ Team #<%= @team.id%>
<%= "Team Password: " + @team.passcode.to_s %>
@@ -40,7 +39,9 @@
- <%= button_to "Discussions", discussion_index_path, {method: :get, class: "btn"} %>
+ <%= button_to "Discussions", discussion_index_path, {method: :get, class: "btn btn-default"} %>
+
+ <%= button_to "My Group", mygroup_path, {method: :get, class: "btn btn-default"} %>
<% if @team.approved %>
@@ -83,8 +84,8 @@
<% # TODO: css styling for this button so that it fits using white-space: normal; %>
<% end %>
-
- Team has been submitted!
+
+ Team has been submitted!
<% elsif Discussion.valid_discs_for(@team).count == 0 %>
There are no available discussions.
diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb
index b2f1da59..31fd4d2d 100644
--- a/app/views/users/show.html.erb
+++ b/app/views/users/show.html.erb
@@ -10,6 +10,6 @@
Team Password: <%= @user.team.nil? ? "Not yet on a team" : @user.team.passcode %>
<%= link_to "Back", '#', onclick: "history.back()", class: 'btn btn-primary' %>
- <%= link_to "Edit", edit_user_path(params[:id]), {class: 'btn', :method => 'get'} %>
+ <%= link_to "Edit", edit_user_path(params[:id]), {class: 'btn btn-default', :method => 'get'} %>
diff --git a/config.ru b/config.ru
index bd83b254..cb1d5981 100644
--- a/config.ru
+++ b/config.ru
@@ -1,4 +1,4 @@
# This file is used by Rack-based servers to start the application.
-
+$stdout.sync = true
require ::File.expand_path('../config/environment', __FILE__)
run Rails.application
diff --git a/config/application.rb b/config/application.rb
index 9969f84a..a2512008 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -1,6 +1,7 @@
require File.expand_path('../boot', __FILE__)
require "rails"
+require 'csv'
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
diff --git a/config/environments/development.rb b/config/environments/development.rb
index 20a415ca..79df90dc 100644
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -62,7 +62,7 @@
user_name: 'enrollmeberkeley@gmail.com',
password: ENV['API_KEY'],
authentication: 'plain',
- #enable_starttls_auto: true
+ enable_starttls_auto: true
}
-end
+end
\ No newline at end of file
diff --git a/config/environments/production.rb b/config/environments/production.rb
index 9dc62db1..c6a1b67c 100644
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -86,6 +86,6 @@
user_name: 'enrollmeberkeley@gmail.com',
password: ENV['API_KEY'],
authentication: 'plain',
- #enable_starttls_auto: true
+ enable_starttls_auto: true
}
-end
+end
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index ca0c03ae..a6cc2f2f 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,6 +1,9 @@
Rails.application.routes.draw do
- resources :users
+ resources :users do
+ collection { post :import }
+ end
+
get '/without_team', to: 'users#without'
post '/create_team', to: 'users#start_team'
post '/join_team', to: 'users#join_team'
@@ -10,6 +13,7 @@
post 'team/:id/submit', to: 'team#submit', as: "submit_team"
post 'team/:id/unsubmit', to: 'team#unsubmit', as: "unsubmit_team"
+ get 'team/:id/mygroup', to: 'team#showgroup', as: "mygroup"
get 'login', to: 'session#new'
post 'login', to: 'session#create'
@@ -19,6 +23,7 @@
get 'auth/failure', to: redirect('/')
resources :admins
+ get '/admin/unapproved_teams', to: 'admins#unapproved', as: 'unapproved_teams'
get '/admin/approve_team', to: 'admins#approve'
get '/admin/disapprove_team', to: 'admins#disapprove'
get '/admin/undo_approve_team', to: 'admins#undo_approve'
@@ -30,6 +35,10 @@
get '/admin/tutorial', to: 'admins#admin_tutorial'
get '/admin/download', to: 'admins#download'
+ get '/admin/email', to: 'admins#email', as: 'admins_send_email'
+ post '/admin/create_email', to: 'admins#create_email', as: 'create_email'
+ get '/admin/email_success', to: 'admins#email_success', as: 'success_email'
+
post '/admin/email', to: "admins#team_list_email", as: 'admins_email'
get '/download_team_info', to: "file#download_approved_teams"
@@ -44,6 +53,20 @@
resources :submissions
+ resources :group
+
+ get '/admin/select_group', to:'group#select_group'
+
+ post '/admin/select_group', to:'group#select_group', as: 'select_group'
+
+ post '/admin/merge', to:'group#merge', as: 'merge_group'
+
+ post '/admin/unmerge', to:'group#unmerge', as: 'unmerge_group'
+
+ post '/admin/random', to:'group#random', as: 'random_group'
+
+ get '/admin/im', to: 'admins#show_import', as: 'import_page'
+
root 'session#new'
# TODO: something for route not found
diff --git a/db/migrate/20171020225122_create_groups.rb b/db/migrate/20171020225122_create_groups.rb
new file mode 100644
index 00000000..130964f0
--- /dev/null
+++ b/db/migrate/20171020225122_create_groups.rb
@@ -0,0 +1,10 @@
+class CreateGroups < ActiveRecord::Migration
+ def change
+ create_table :groups do |t|
+ t.integer :team1_id
+ t.integer :team2_id
+
+ t.timestamps null: false
+ end
+ end
+end
diff --git a/db/migrate/20171022043547_add_discussion_id_to_group.rb b/db/migrate/20171022043547_add_discussion_id_to_group.rb
new file mode 100644
index 00000000..0aa3705b
--- /dev/null
+++ b/db/migrate/20171022043547_add_discussion_id_to_group.rb
@@ -0,0 +1,5 @@
+class AddDiscussionIdToGroup < ActiveRecord::Migration
+ def change
+ add_column :groups, :discussion_id, :integer
+ end
+end
diff --git a/db/migrate/20171119031825_add_enrollmeadmin_to_admins.rb b/db/migrate/20171119031825_add_enrollmeadmin_to_admins.rb
new file mode 100644
index 00000000..518c14af
--- /dev/null
+++ b/db/migrate/20171119031825_add_enrollmeadmin_to_admins.rb
@@ -0,0 +1,5 @@
+class AddEnrollmeadminToAdmins < ActiveRecord::Migration
+ def change
+ add_column :admins, :enrollmeadmin, :boolean
+ end
+end
diff --git a/db/migrate/20171119032010_add_t_aadmin_to_admins.rb b/db/migrate/20171119032010_add_t_aadmin_to_admins.rb
new file mode 100644
index 00000000..1ef413e9
--- /dev/null
+++ b/db/migrate/20171119032010_add_t_aadmin_to_admins.rb
@@ -0,0 +1,5 @@
+class AddTAadminToAdmins < ActiveRecord::Migration
+ def change
+ add_column :admins, :TAadmin, :boolean
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 10988b9a..74774bc1 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,14 +11,16 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20170417002226) do
+ActiveRecord::Schema.define(version: 20171119032010) do
create_table "admins", force: :cascade do |t|
t.string "name"
t.string "email"
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.boolean "superadmin"
+ t.boolean "enrollmeadmin"
+ t.boolean "TAadmin"
end
create_table "discussions", force: :cascade do |t|
@@ -31,6 +33,14 @@
add_index "discussions", ["submission_id"], name: "index_discussions_on_submission_id"
+ create_table "groups", force: :cascade do |t|
+ t.integer "team1_id"
+ t.integer "team2_id"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.integer "discussion_id"
+ end
+
create_table "options", force: :cascade do |t|
t.integer "minimum_team_size"
t.integer "maximum_team_size"
diff --git a/db/seeds.rb b/db/seeds.rb
index b8799877..c93512b8 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -6,19 +6,107 @@
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
admins = [
- { :name => "EnrollMe", :email => "enrollmeberkeley@gmail.com", :superadmin => true},
- { :name => "Michael-David Sasson", :email => "sasson@berkeley.edu", :superadmin => false}
+ { :name => "EnrollMe", :email => "enrollmeberkeley@gmail.com", :superadmin => true, :enrollmeadmin => false, :TAadmin => false},
+ { :name => "Michael-David Sasson", :email => "sasson@berkeley.edu", :superadmin => false, :enrollmeadmin => false, :TAadmin => false},
+ { :name => "Yonas Kbrom", :email => "kbromyonas@berkeley.edu", :superadmin => true, :enrollmeadmin => false, :TAadmin => false},
+ { :name => "Monty Inaya", :email => "mr.monty@berkeley.edu", :superadmin => true, :enrollmeadmin => false, :TAadmin => false},
+ { :name => "Vikram Baid", :email => "vbaid@berkeley.edu", :superadmin => true, :enrollmeadmin => false, :TAadmin => false},
+ { :name => "Mark Sun", :email => "msun908@berkeley.edu", :superadmin => true, :enrollmeadmin => false, :TAadmin => false},
+ { :name => "Timothy Stepro", :email => "stepro.015389@berkeley.edu", :superadmin => true, :enrollmeadmin => false, :TAadmin => false},
+ { :name => "Minjoo Sur", :email => "minjoo@berkeley.edu", :superadmin => true, :enrollmeadmin => false, :TAadmin => false},
+ { :name => "Timothy Stepro", :email => "timothystepro@gmail.com", :superadmin => false, :enrollmeadmin => true, :TAadmin => false},
+ { :name => "Yonas Kbrom", :email => "kbromyonas1@gmail.com", :superadmin => false, :enrollmeadmin => true, :TAadmin => false},
+ { :name => "Steven Wu", :email => "stevenwuyinze@berkeley.edu", :superadmin => true, :enrollmeadmin => false, :TAadmin => false},
+
+ ]
+
+users = [
+ { :name => "Yonas Kbrom", :email => "kbromyonas@gmail.com", :major => "CS", :sid => 111111, :team_id => 1},
+ { :name => "Monty Inaya", :email => "mr.monty@gmail.com", :major => "CS", :sid => 222222, :team_id => 1},
+ { :name => "Vikram Baid", :email => "vbaid@gmail.com", :major => "CS", :sid => 333333, :team_id => 1},
+
+ { :name => "Mark Sun", :email => "msun908@gmail.com", :major => "CS", :sid => 444444, :team_id => 2},
+ { :name => "Timothy Stepro", :email => "stepro.015389@gmail.com", :major => "CS", :sid => 555555, :team_id => 2},
+ { :name => "Minjoo Sur", :email => "minjoo@gmail.com", :major => "CS", :sid => 6666666, :team_id => 2},
+
+ { :name => "Lonzo Ball", :email => "ball@gmail.com", :major => "CS", :sid => 777777, :team_id => 3},
+ { :name => "Kobe Bryant", :email => "bryant@gmail.com", :major => "CS", :sid => 888888, :team_id => 3},
+ { :name => "Pau Gasol", :email => "gasol@gmail.com", :major => "CS", :sid => 999999, :team_id => 3},
+
+ { :name => "Rajon Rondo", :email => "rondo@gmail.com", :major => "CS", :sid => 111112, :team_id => 4},
+ { :name => "Paul Pierce", :email => "pierce@gmail.com", :major => "CS", :sid => 133113, :team_id => 4},
+ { :name => "Kevin Garnett", :email => "garnett@gmail.com", :major => "CS", :sid => 144114, :team_id => 4},
]
+teams = [
+ { :approved => false, :passcode => "abc", :submission_id => 1, :submitted => true},
+ { :approved => false, :passcode => "def", :submission_id => 2, :submitted => true},
+ { :approved => false, :passcode => "ghi", :submission_id => 3, :submitted => true},
+ { :approved => false, :passcode => "wack", :submitted => false},
+ ]
+
+discussions = [
+ { :number => 12121, :time => "8-9am", :capacity => 24, :day => "M"},
+ { :number => 21212, :time => "8-9am", :capacity => 24, :day => "W"},
+ { :number => 34343, :time => "8-9am", :capacity => 24, :day => "F"},
+
+ ]
+
+submissions = [
+ { :disc1id => 1, :disc2id => 2, :disc3id => 3, :team_id => 1},
+ { :disc1id => 1, :disc2id => 2, :disc3id => 3, :team_id => 2},
+ { :disc1id => 1, :disc2id => 2, :disc3id => 3, :team_id => 3},
+
+ ]
+
+
+
+# Comment these bottom four loops while on development
+
+# Discussion.delete_all
+# discussions.each do |a|
+# Discussion.create!(a)
+# end
+
+# Team.delete_all
+# teams.each do |t|
+# Team.create!(t)
+# end
+
+# User.delete_all
+# users.each do |t|
+# User.create!(t)
+# end
+
+# Submission.delete_all
+# submissions.each do |a|
+# Submission.create!(a)
+# end
+
+
+
+# DO NOT COMMMENT OUT
+
Admin.delete_all
admins.each do |a|
Admin.create!(a)
end
+# DO NOT COMMMENT OUT
+
+
Option.delete_all
Option.create!(
:minimum_team_size => 3,
:maximum_team_size => 3
)
-
+# puts Group.all.inspect
+# puts "———"
+# puts User.all.inspect
+# puts "———"
+# puts Discussion.all.inspect
+# puts "———"
+# puts Team.all.inspect
+# puts "———"
+# puts Submission.all.inspect
diff --git a/features/admins/CSV_Confirmation.feature b/features/admins/CSV_Confirmation.feature
new file mode 100644
index 00000000..1f10e6ad
--- /dev/null
+++ b/features/admins/CSV_Confirmation.feature
@@ -0,0 +1,36 @@
+# Feature: Import CSV Page exists and non-waitlested teams are approved
+
+# As an admin
+# So that I can import a CSV File
+# I want to be able to approve non-waitlisted teams
+
+# Background:
+# Given the following users exist
+# | name | email |team_passcode | major | sid |
+# | Sahai | eecs666@hotmail.com | penguindrool | EECS | 000 |
+# | Jorge | legueoflegends667@hotmail.com | penguindrool | Football Player | 999 |
+# | Kandi | justanotheremail@aol.com | penguindrool | EECS | 567 |
+# And the following admins exist
+# | name | email |
+# | Bob | supreme_ruler@aol.com |
+# And the following discussions exist
+# | number | time | capacity |
+# | 54321 | Tues, 3pm | 25 |
+# And the team with passcode "penguindrool" is submitted
+# And I am on the login page
+# And I log in as an admin with email "supreme_ruler@aol.com"
+
+ # Scenario: Import CSV Page Exists
+ # Given I first follow "Import CSV"
+ # Then I should be on the import_csv_teams page
+
+ # Scenario: Import CSV Button Exists and Shows Confirmation Page
+ # Given I am on the import_csv_teams page
+ # Then I should see "Import CSV"
+ # And I upload the following content
+ # | Name | Student ID |User ID | Role | Email Address | Sections | Major | Terms in Attendance | Units | Grading Basis | Waitlist Position |
+ # | Vik | 24242424 | vik | Student | eecs666@hotmail.com | 99 | EECS | 4 | 100 | Letter Grade | 0 |
+ # | Jorge | 24242425 | jorge | Student | legueoflegends667@hotmail.com | 99 | EECS | 4 | 90 | Letter Grade | 0 |
+ # | Mark | 24242426 | msun | Student | justanotheremail@aol.com | 99 | EECS | 4 | 95 | Letter Grade | 0 |
+ # And I press "IMPORT CSV"
+ # Then I should see "Successfully approved team id: 1"
\ No newline at end of file
diff --git a/features/admins/check_admin_type.feature b/features/admins/check_admin_type.feature
new file mode 100644
index 00000000..a919ab1b
--- /dev/null
+++ b/features/admins/check_admin_type.feature
@@ -0,0 +1,36 @@
+Feature: Super Admin
+ As an admin
+ I want to create TA admins and
+ I want to create Enroll admins
+
+ Background:
+ Given the following admins exist
+ | name | email | superadmin |
+ | Bob | supreme_ruler@gmail.com | false |
+ | Kobe | kobe@gmail.com | true |
+ And I am on the login page
+ And I log in as an admin with email "kobe@gmail.com"
+
+
+# Commented out to avoid failing cucumber/travis-ci build
+
+
+# Scenario: Enroll admin added
+# When I follow "Register New Admin"
+# Then I should see "Create new Enroll Admin"
+# And I should see "Create new TA Admin"
+# When I press "Create new Enroll Admin"
+# And I fill in "Name" with "Steve"
+# And I fill in "Email" with "steviesteve@gmail.com"
+# And I press "Create"
+# Then I should see "New Enroll admin added"
+
+# Scenario: TA admin added
+# When I follow "Register New Admin"
+# Then I should see "Create new Enroll Admin"
+# And I should see "Create new TA Admin"
+# When I press "Create new TA Admin"
+# And I fill in "Name" with "Steve"
+# And I fill in "Email" with "steviesteve@gmail.com"
+# And I press "Create"
+# Then I should see "New TA admin created"
diff --git a/features/admins/create_email.feature b/features/admins/create_email.feature
new file mode 100644
index 00000000..8788cffc
--- /dev/null
+++ b/features/admins/create_email.feature
@@ -0,0 +1,41 @@
+Feature: An admin sends an e-mail
+
+ As an admin
+ So that I can update student teams
+ I want to be able to send customized e-mails
+
+ Background:
+ Given the following users exist
+ | name | email |team_passcode | major | sid |
+ | Sahai | eecs666@hotmail.com | penguindrool | EECS | 000 |
+ | Jorge | legueoflegends667@hotmail.com | penguindrool | Football Player | 999 |
+ | Kandi | justanotheremail@aol.com | penguindrool | EECS | 567 |
+ And the following admins exist
+ | name | email |
+ | Bob | supreme_ruler@aol.com |
+ And the following discussions exist
+ | number | time | capacity |
+ | 54321 | Tues, 3pm | 25 |
+ And the team with passcode "penguindrool" is submitted
+ And I am on the login page
+ And I log in as an admin with email "supreme_ruler@aol.com"
+
+ Scenario: Send E-mail button is available and redirects you to the send page
+ Given I first follow "Send Email"
+ Then I should see "You have a new message for CS169 from EnrollMe"
+
+ Scenario: Fill In TextBox Area, and click Submit
+ Given I am on the create_email "1" page
+ Then I should see "You have a new message for CS169 from EnrollMe"
+ And I fill in "email_content" with "TESTING123"
+ And I fill in "subject_content" with "TESTING123"
+ And I press "Send Email"
+ Then I should see "Successfully sent e-mails"
+
+ Scenario: Did not fill In TextBox Area, and click Submit
+ Given I am on the create_email "1" page
+ Then I should see "You have a new message for CS169 from EnrollMe"
+ And I fill in "email_content" with ""
+ And I fill in "subject_content" with "TESTING123"
+ And I press "Send Email"
+ Then I should see "You have to include email content."
\ No newline at end of file
diff --git a/features/admins/enrollme_admin.feature b/features/admins/enrollme_admin.feature
new file mode 100644
index 00000000..8c1708ee
--- /dev/null
+++ b/features/admins/enrollme_admin.feature
@@ -0,0 +1,30 @@
+Feature: Enrollme admin cannot reset the semester
+
+ As an enrollme admin
+ I cannot reset the semester
+
+ Background:
+ Given the following admins exist
+ | name | email | superadmin | enrollmeadmin |
+ | Tim | sahai@berkeley.edu | false | true |
+ Given the following users exist
+ | name | email | team | major | sid |
+ | Jorge | legueoflegends667@hotmail.com | somepassc | Football Player | 999 |
+ | Bob0 | bobjones0@berkeley.edu | passcode1 | Slavic Studies | 824 |
+ | Bob1 | bobjones1@berkeley.edu | passcode1 | Slavic Studies | 825 |
+ | Bob2 | bobjones2@berkeley.edu | passcode1 | Slavic Studies | 826 |
+ | Bob3 | bobjones3@berkeley.edu | passcode1 | Slavic Studies | 827 |
+ | Sahai | eecs666@hotmail.com | passcode1 | EECS | 000 |
+ And the following discussions exist
+ | number | time | capacity |
+ | 54321 | Tues, 3pm | 25 |
+ | 54322 | Wed, 3pm | 25 |
+ | 54323 | Thurs, 3pm | 25 |
+ And the team with passcode "passcode1" is submitted
+ And I am on the login page
+ And I log in as an admin with email "sahai@berkeley.edu"
+
+ Scenario: Enrollme Admin cannot deletes everything from database
+ When I follow "Home"
+ Then I should not see "Reset Semester"
+
diff --git a/features/admins/new.feature b/features/admins/new.feature
index 554c7bf8..22e5d1c7 100644
--- a/features/admins/new.feature
+++ b/features/admins/new.feature
@@ -5,31 +5,59 @@ Feature: Create an admin account
Background:
Given the following admins exist
- | name | email |
- | Bob | supreme_ruler@aol.com |
+ | name | email | superadmin | ta | enroll |
+ | Bob | supreme_ruler@aol.com | true | false | false |
+ | Yon | tim_ruler@aol.com | false | true | false |
+ | Mon | minjoo_ruler@aol.com | false | false | true |
And I am on the login page
- And I log in as an admin with email "supreme_ruler@aol.com"
- And I follow "Register New Admin"
Scenario: An admin successfully adds another admin
+ When I log in as an admin with email "supreme_ruler@aol.com"
+ And I follow "Register New Admin"
+
Given I fill in "Name" with "Bob Clone"
And I fill in "Email" with "ruler_clone@aol.com"
+ And I choose "type_admin_ta"
And I press "Create"
Then I log out
When I log in as an admin with email "ruler_clone@aol.com"
Then I should see "Welcome Back, Bob Clone!"
+
+ Scenario: An super admin did not choose a type for admin type
+ When I log in as an admin with email "supreme_ruler@aol.com"
+ And I follow "Register New Admin"
+
+ Given I fill in "Name" with "Bob Clone"
+ And I fill in "Email" with "ruler_clone@aol.com"
+ And I press "Create"
+ Then I should see "Choose an admin type"
Scenario: An admin fails adding another admin
- Given I fill in "Name" with "Bob Clone"
- And I fill in "Email" with "supreme_ruler@aol.com"
+ And I log in as an admin with email "supreme_ruler@aol.com"
+ Then I follow "Register New Admin"
+
+ Given I fill in "Name" with "Min Clone"
+ And I fill in "Email" with "minjoo_ruler@aol.com"
+ And I choose "type_admin_ta"
And I press "Create"
Then I should see "Form is invalid"
Scenario: An admin fails adding a user as an admin
+ And I log in as an admin with email "supreme_ruler@aol.com"
+ And I follow "Register New Admin"
+
Given the following users exist
| name | email |team_passcode | major | sid |
| Sahai | eecs666@hotmail.com | penguindrool | EECS | 000 |
Given I fill in "Name" with "Sahai"
And I fill in "Email" with "eecs666@hotmail.com"
+ And I choose "type_admin_ta"
And I press "Create"
Then I should see "Form is invalid"
+
+
+ Scenario: A TA admin cannot manage admins etc.
+ And I log in as an admin with email "tim_ruler@aol.com "
+ Then I should not see "Register New Admin"
+ And I should not see "Manage Admins"
+ And I should not see "Reset Semester"
diff --git a/features/admins/super_admin_delete_database.feature b/features/admins/super_admin_delete_database.feature
index cfc7770e..0852fce3 100644
--- a/features/admins/super_admin_delete_database.feature
+++ b/features/admins/super_admin_delete_database.feature
@@ -8,6 +8,8 @@ Feature: Super admin deletes all data
Given the following admins exist
| name | email | superadmin |
| Bob | supreme_ruler@aol.com | true |
+ | Tim | sahai@berkeley.edu | false |
+
Given the following users exist
| name | email | team | major | sid |
| Jorge | legueoflegends667@hotmail.com | somepassc | Football Player | 999 |
@@ -26,7 +28,6 @@ Feature: Super admin deletes all data
And I log in as an admin with email "supreme_ruler@aol.com"
Scenario: Super admin successfully deletes everything from database
- Then print page body
When I follow "Reset Semester"
Then I should see "Warning: Resetting the semester will result in all users, teams, and discussions being deleted."
And I should see "Password"
@@ -35,4 +36,22 @@ Feature: Super admin deletes all data
Then I should see "All data reset"
And I should not see "Jorge"
When I press "Discussions"
- Then I should not see "54321"
\ No newline at end of file
+ Then I should not see "54321"
+
+ Scenario: Admin cannot delete database
+ When I follow "Reset Semester"
+ Then I should see "Warning: Resetting the semester will result in all users, teams, and discussions being deleted."
+ And I should see "Password"
+ When I fill in "reset_password" with the incorrect password
+ And I press "Reset"
+ Then I should see "Incorrect password"
+
+ Scenario: Super admin can create a new enrollme admin
+ When I follow "Register New Admin"
+ When I fill in "Name" with "monty"
+ When I fill in "Email" with "monty@berkeley.edu"
+ When I choose "type_admin_enroll"
+ And I press "Create"
+ Then I should see "You created admin monty successfully!"
+
+
\ No newline at end of file
diff --git a/features/admins/super_admin_edit_admins.feature b/features/admins/super_admin_edit_admins.feature
index ef9da357..c4ed73dc 100644
--- a/features/admins/super_admin_edit_admins.feature
+++ b/features/admins/super_admin_edit_admins.feature
@@ -29,4 +29,16 @@ Feature: Super admin deletes an admin
And I press "Transfer"
Then I should see "Successfully transferred superadmin powers."
And I should not see "Manage Admins"
+
+ Scenario: Super Admin unsuccessfully transfers super admin ability to nobody
+ When I log in as an admin with email "supreme_ruler@aol.com"
+ And I follow "Manage Admins"
+ And I press "Transfer"
+ Then I should see "No admin selected for transfer."
+
+ Scenario: Super Admin unsuccessfully transfers super admin ability to nobody
+ When I log in as an admin with email "abc@abc.com"
+ And I follow "Help"
+
+
\ No newline at end of file
diff --git a/features/csv_upload/csv_upload.feature b/features/csv_upload/csv_upload.feature
new file mode 100644
index 00000000..58362c59
--- /dev/null
+++ b/features/csv_upload/csv_upload.feature
@@ -0,0 +1,36 @@
+Feature: Import CSV Page exists and non-waitlested teams are approved
+
+ As an admin
+ So that automatically approve teams which have all users on the waitlist
+ I want to upload a csv of waitlisted students and automatically assign discussions to approved teams
+
+ Background:
+ Given the following users exist
+ | name | email | team_passcode | major | sid |
+ | Yonas Kbrom | kbromyonas@gmail.com | penguindrool | CS | 111111 |
+ | Monty Inaya | mr.monty@gmail.com | penguindrool | CS | 222222 |
+ | Vikram Baid | vbaid@gmail.com | penguindrool | CS | 333333 |
+ | Bob Saggot | bobsaggot@gmail.com | penguindrool2 | CS | 111112 |
+ | Monty2 Inaya | mr.monty2@gmail.com | penguindrool2 | CS | 222223 |
+ | Vikram2 Baid | vbaid2@gmail.com | penguindrool2 | CS | 333334 |
+ And the following admins exist
+ | name | email |
+ | Bob | supreme_ruler@aol.com |
+ And the following discussions exist
+ | number | time | capacity | seats_open |
+ | 54321 | Tues, 3pm | 25 | 25 |
+ And the team with passcode "penguindrool" is submitted
+ And the team with passcode "penguindrool" is not approved
+ And I am on the login page
+ And I log in as an admin with email "supreme_ruler@aol.com"
+
+ Scenario: Import CSV Button Exists and Shows Confirmation Message On Upload
+ When I follow "Import Student Data"
+ Then I should see "Import Students From CSV"
+ When I attach a csv file
+ Then I press "Upload Students"
+ Then I should be on the unapproved_teams page
+ And the team with passcode "penguindrool" should be approved
+ And I should see "Bob Saggot"
+ And I should see "Monty2 Inaya"
+ And I should see "Vikram2 Baid"
\ No newline at end of file
diff --git a/features/csv_upload/test.csv b/features/csv_upload/test.csv
new file mode 100644
index 00000000..cc9c8613
--- /dev/null
+++ b/features/csv_upload/test.csv
@@ -0,0 +1,4 @@
+Name,Student ID,User ID,Role,Email Address,Sections,Majors,Terms in Attendance,Units,Grading Basis,Waitlist Position
+Yonas Kbrom,111111,test1,Student,kbromyonas@gmail.com,999,CS,8,128,Letter Grade,1
+Monty Inaya,222222,test2,Student,mr.monty@gmail.com,999,CS,8,100,Letter Grade,24
+Vikram Baid,333333,test3,Student,vbaid@gmail.com,999,CS,9,100,Letter Grade,2
\ No newline at end of file
diff --git a/features/discussions/open_seats.feature b/features/discussions/open_seats.feature
new file mode 100644
index 00000000..592b2189
--- /dev/null
+++ b/features/discussions/open_seats.feature
@@ -0,0 +1,36 @@
+Feature: Number of seats open for discussions
+
+ As an student user or admin
+ I should see the correct number of seats open in discussions
+
+ Background: users have been added to database
+ Given the following users exist
+ | name | email | team | major | sid |
+ | Jorge | legueoflegends667@hotmail.com | passcode1 | Football Player | 999 |
+ | Bob0 | bobjones0@berkeley.edu | passcode1 | Slavic Studies | 824 |
+ | Bob1 | bobjones1@berkeley.edu | passcode1 | Slavic Studies | 825 |
+ | Bob2 | bobjones2@berkeley.edu | passcode2 | Slavic Studies | 826 |
+ | Bob3 | bobjones3@berkeley.edu | passcode2 | Slavic Studies | 827 |
+ | Sahai | eecs666@hotmail.com | passcode2 | EECS | 000 |
+ And the following discussions exist
+ | number | time | day | capacity |
+ | 54321 | 3:00 PM | Tuesday | 25 |
+ | 54322 | 3:00 PM | Wednesday | 25 |
+ | 54323 | 3:00 PM | Thursday | 25 |
+ Given the following admins exist
+ | name | email | superadmin |
+ | Bob | supreme_ruler@gmail.com | false |
+ | Kobe | kobe@gmail.com | true |
+ And I am on the login page
+
+ Scenario: Correct number of available seats for admin
+ Given I log in as an admin with email "kobe@gmail.com"
+ And the team with passcode "passcode1" is approved with discussion number "54321"
+ And I press "Discussions"
+ Then I should see "21"
+
+ Scenario: Correct number of available seats for user
+ Given I log in as an admin with email "eecs666@hotmail.com"
+ And the team with passcode "passcode2" is approved with discussion number "54321"
+ And I press "Discussions"
+ Then I should see "21"
\ No newline at end of file
diff --git a/features/groups/admin_add_group.feature b/features/groups/admin_add_group.feature
new file mode 100644
index 00000000..86b8d6bc
--- /dev/null
+++ b/features/groups/admin_add_group.feature
@@ -0,0 +1,55 @@
+Feature: admin can create a Group by selecting two teams
+
+ As an administrator
+ So I can make a group
+ I want to select two teams and create a group
+
+ Background:
+ Given the following admins exist
+ | name | email |
+ | Bob | supreme_ruler@aol.com |
+ And I am on the login page
+ And I log in as an admin with email "supreme_ruler@aol.com"
+
+ And the following discussions exist
+ #number, time, day, capacity, seats_open
+ | number | time | day | capacity | seats_open |
+ | 79997 | 3:00 PM | Tuesday | 24 | 24 |
+ | 89998 | 4:00 PM | Tuesday | 24 | 24 |
+ And the following teams exist
+ | submission_id | approved | passcode | submitted | discussion_number |
+ | 1 | true | "asdf" | true | 79997 |
+ | 2 | true | "fdsa" | true | 79997 |
+ | 3 | true | "dididi" | true | 89998 |
+ | 4 | true | "tiredmj" | true | 89998 |
+
+
+ Scenario: An admin merges two valid teams in the same discussion
+ Given I press "Create Groups"
+ When I check "team_1"
+ And I check "team_2"
+ And I press "Create Group"
+ And I should see team "3"
+ And I should see team "4"
+ Then I should not see team "1"
+ And I should not see team "2"
+
+
+ Scenario: An admin merges two valid teams in different discussions
+ Given I press "Create Groups"
+ When I check "team_1"
+ And I check "team_3"
+ And I press "Create Group"
+ Then I should see team "1"
+ And I should see team "3"
+
+ Scenario: An admin unmerges a group
+ Given I press "Create Groups"
+ When I check "team_1"
+ And I check "team_2"
+ And I press "Create Group"
+ And I follow "Back"
+ And I press "View Groups"
+ And I check "group_1"
+ And I press "Destroy Group"
+ Then I should not see group "1"
\ No newline at end of file
diff --git a/features/groups/admin_random_groups.feature b/features/groups/admin_random_groups.feature
new file mode 100644
index 00000000..dbe25539
--- /dev/null
+++ b/features/groups/admin_random_groups.feature
@@ -0,0 +1,44 @@
+Feature: admin can Randomly form groups based on their discussion
+
+ As an administrator
+ So that when I want to group teams
+ I want to group teams randomly
+
+ Background:
+ Given the following admins exist
+ | name | email |
+ | Bob | supreme_ruler@aol.com |
+ And I am on the login page
+ And I log in as an admin with email "supreme_ruler@aol.com"
+
+ And the following discussions exist
+ | number | time | capacity |
+ | 79997 | Tues, 3pm | 25 |
+ | 79996 | Tues, 4pm | 25 |
+ | 79995 | Tues, 5pm | 25 |
+ | 79994 | Tues, 6pm | 25 |
+
+ And the following teams exist
+ | submission_id | approved | passcode | submitted | discussion_id |
+ | 1 | true | "asdf" | true | 79997 |
+ | 2 | true | "fdsa" | true | 79996 |
+ | 3 | true | "dididi" | true | 79994 |
+ | 4 | true | "tiredmj" | true | 79994 |
+ | 5 | true | "dididi1" | true | 79994 |
+ | 6 | true | "tiredm2" | true | 79994 |
+
+
+Scenario: Teams in different discussions cannot be grouped randomly
+ Given I press "Create Groups"
+ When I press "Group randomly"
+ Then I should see "Randomly grouped 2 groups"
+ Then I follow "Home"
+ Then I press "Create Groups"
+ Then I should see team "1"
+ And I should see team "2"
+ And I should not see team "3"
+ And I should not see team "4"
+ And I should not see team "5"
+ And I should not see team "6"
+ Then I press "Group randomly"
+ Then I should see "Cannot randomly create groups"
diff --git a/features/groups/admin_view_groups.feature b/features/groups/admin_view_groups.feature
new file mode 100644
index 00000000..6280b39c
--- /dev/null
+++ b/features/groups/admin_view_groups.feature
@@ -0,0 +1,32 @@
+Feature: admin can view Group Information
+
+ As an administrator
+ So that I can see which teams are paired as a group
+ I want to view all pairs of groups
+
+ Background:
+ And the following discussions exist
+ | number | time | capacity |
+ | 54321 | Tues, 3pm | 25 |
+ | 11211 | Tues, 4pm | 25 |
+ | 11212 | Tues, 5pm | 25 |
+ | 11213 | Tues, 6pm | 25 |
+
+ Given the following groups exist
+ | team1_id | team2_id |discussion_id |
+ | 1 | 2 | 2 |
+ | 3 | 4 | 3 |
+ | 6 | 5 | 4 |
+
+ And the following admins exist
+ | name | email |
+ | Bob | supreme_ruler@aol.com |
+
+
+ Scenario: An admin accesses a View Groups page
+ Given I am on the login page
+ And I log in as an admin with email "supreme_ruler@aol.com"
+ When I press "View Groups"
+ Then I should see "11211"
+ And I should see "11212"
+ And I should see "11213"
\ No newline at end of file
diff --git a/features/groups/user_view_group.feature b/features/groups/user_view_group.feature
new file mode 100644
index 00000000..c0f3f79d
--- /dev/null
+++ b/features/groups/user_view_group.feature
@@ -0,0 +1,36 @@
+Feature: a user can view Group Information
+
+ As a user
+ So that I can see who are in my group
+ I want to view my group members
+
+ Background:
+ Given the following users exist
+ | name | email |team_passcode | major | sid |
+ | Sahai | eecs666@hotmail.com | penguindrool | EECS | 000 |
+ | Saha2 | eecs667@hotmail.com | penguindrool | EECS | 001 |
+ | Saha3 | eecs668@hotmail.com | penguindrool | EECS | 002 |
+ | Saha4 | eecs669@hotmail.com | hihi | EECS | 003 |
+ | Jorge | legueoflegends667@hotmail.com | hihi | Football Player | 999 |
+ | Kandi | justanotheremail@aol.com | hihi | EECS | 567 |
+ And the following discussions exist
+ | number | time | capacity |
+ | 54321 | Tues, 3pm | 24 |
+ And I am on the login page
+ And I log in as a user with email "eecs666@hotmail.com"
+ And the team with passcode "penguindrool" is approved with discussion number "54321"
+ And the team with passcode "hihi" is approved with discussion number "54321"
+ And the following groups exist
+ | team1_id | team2_id |discussion_id |
+ | 1 | 2 | 1 |
+
+ # Scenario: A user accesses a View My Group page
+ # Given I press "My Group Page"
+ # And I log in as an admin with email "supreme_ruler@aol.com"
+ # When I press "View Groups"
+ # Then I should see "Sahai"
+ # And I should see "Saha2"
+ # And I should see "Saha3"
+ # And I should see "Saha4"
+ # And I should see "Jorge"
+ # And I should see "Kandi"
\ No newline at end of file
diff --git a/features/step_definitions/enrollme_steps.rb b/features/step_definitions/enrollme_steps.rb
index d8a8f603..0f391f6b 100644
--- a/features/step_definitions/enrollme_steps.rb
+++ b/features/step_definitions/enrollme_steps.rb
@@ -16,6 +16,10 @@
fill_in(field, :with => ENV["ADMIN_DELETE_DATA_PASSWORD"])
end
+When /^I fill in "([^"]*)" with the incorrect password$/ do | field |
+ fill_in(field, :with => "wrong")
+end
+
Given /^I log in as an admin with email "([^"]*)"$/ do | email |
mock_auth_hash(email)
click_link "log_in"
@@ -104,6 +108,22 @@
end
end
+Given /^the following teams exist$/ do |table|
+ table.rows.each do |submission_id, approved, passcode, submitted, discussion_number|
+ next if submission_id == :submission_id # skipping table header
+ discussion_id = Discussion.find_by_number(discussion_number).id
+ ateams = Team.approved_teams
+ Team.create!(:submission_id => submission_id.to_i, :approved => approved=="true", :passcode => passcode, :submitted => submitted=="true", :discussion_id => discussion_id)
+ end
+end
+
+Given /^the following groups exist$/ do |table|
+ table.rows.each do |team1_id, team2_id, discussion|
+ next if team1_id == :team1_id # skipping table header
+ Group.create!(:team1_id => team1_id.to_i, :team2_id => team2_id.to_i, :discussion_id => discussion.to_i)
+ end
+end
+
Then /^(?:|I )should not be on (.+)$/ do |page_name|
current_path = URI.parse(current_url).path
if current_path.respond_to? :should
@@ -140,9 +160,9 @@
Given /^the following admins exist$/ do |table|
- table.rows.each do |name, email, superadmin|
+ table.rows.each do |name, email, superadmin, ta, enroll|
next if name == "name" # skipping table header
- Admin.create!(:name => name, :email => email, :superadmin => superadmin == "true" ? true : false)
+ Admin.create!(:name => name, :email => email, :superadmin => superadmin == "true" ? true : false, :TAadmin => ta, :enrollmeadmin => enroll )
end
end
@@ -165,3 +185,33 @@
When(/^I fill in "([^"]*)" with API\['ADMIN_DELETE_DATA_PASSWORD'\]$/) do |field|
fill_in(field, :with => ENV["ADMIN_DELETE_DATA_PASSWORD"])
end
+
+Then /^(?:|I )should see team "([^"]*)"$/ do |id|
+
+ bool = true
+ bool.should be page.body.include?("team_" + id.to_s)
+ # page.body.include?("team_" + id.to_s)
+end
+
+Then /^(?:|I )should not see team "([^"]*)"$/ do |id|
+ # puts page.body
+ bool = false
+ bool.should be page.body.include?("team_" + id.to_s)
+ # not page.body.include?("team_" + id.to_s)
+end
+
+Then /^(?:|I )should not see group "([^"]*)"$/ do |id|
+ # puts page.body
+ bool = false
+ bool.should be page.body.include?("group_" + id.to_s)
+ # not page.body.include?("group_" + id.to_s)
+end
+
+Then /^(?:|I )go home$/ do
+ click_link("Home")
+end
+
+When /^I attach a csv file$/ do
+ File.expand_path("../../csv_upload/test.csv", __FILE__)
+ attach_file(:file, File.expand_path("../../csv_upload/test.csv", __FILE__))
+end
diff --git a/features/step_definitions/web_steps.rb b/features/step_definitions/web_steps.rb
index c3c96c64..81394ae5 100644
--- a/features/step_definitions/web_steps.rb
+++ b/features/step_definitions/web_steps.rb
@@ -53,6 +53,10 @@ def with_scope(locator)
click_button(button)
end
+When /^(?:|I )first follow "([^"]*)"$/ do |link|
+ click_link(link, match: :first)
+end
+
When /^(?:|I )follow "([^"]*)"$/ do |link|
click_link(link)
end
@@ -103,6 +107,8 @@ def with_scope(locator)
end
Then /^(?:|I )should see "([^"]*)"$/ do |text|
+ # bool = true
+ # bool.should be page.body.include?(text)
if page.respond_to? :should
page.should have_content(text)
else
@@ -110,6 +116,11 @@ def with_scope(locator)
end
end
+Then /^(?:|I )shouldd see "([^"]*)"$/ do |text|
+ bool = true
+ bool.should be page.body.include?(text)
+end
+
Then /^(?:|I )should see \/([^\/]*)\/$/ do |regexp|
regexp = Regexp.new(regexp)
diff --git a/features/submissions/submit_team.feature b/features/submissions/submit_team.feature
index be16a377..a3dc3e5f 100644
--- a/features/submissions/submit_team.feature
+++ b/features/submissions/submit_team.feature
@@ -78,4 +78,18 @@ Feature: student submits their team for approval
And I select "CCN: 54321 | Time: Tuesday 3:00 PM | Enrolled: 0 / 25" from "submission[disc3id]"
And I press "Submit"
Then I should see "Please choose 3 different discussions"
+
+ Scenario: User cannot choose two of the same discussion
+ Given I log in as a user with email "eecs666@hotmail.com"
+ And the following discussions exist
+ | number | time | day | capacity |
+ | 54321 | 3:00 PM | Tuesday | 25 |
+ | 54322 | 3:00 PM | Wednesday | 25 |
+ | 54323 | 3:00 PM | Thursday | 25 |
+ And I am on the team "2" page
+ When I press "Submit"
+ And I select "CCN: 54321 | Time: Tuesday 3:00 PM | Enrolled: 0 / 25" from "submission[disc1id]"
+ And I select "CCN: 54323 | Time: Thursday 3:00 PM | Enrolled: 0 / 25" from "submission[disc2id]"
+ And I press "Submit"
+ Then I should see "Please choose 3 different discussions"
diff --git a/features/support/env.rb b/features/support/env.rb
index a57c01f1..8a305677 100644
--- a/features/support/env.rb
+++ b/features/support/env.rb
@@ -1,8 +1,7 @@
+
if ENV['CI']
- require 'codeclimate-test-reporter'
- SimpleCov.start 'rails' do
- add_filter '/coverage/'
- end
+ require 'coveralls'
+ Coveralls.wear!('rails')
else
require 'simplecov'
SimpleCov.start 'rails' do
diff --git a/features/support/paths.rb b/features/support/paths.rb
index 3ad68eec..8683fd48 100644
--- a/features/support/paths.rb
+++ b/features/support/paths.rb
@@ -29,6 +29,8 @@ def path_to(page_name)
admin_disapprove_team_path(:team_id=>$1)
when /^the new discussion page$/i
new_discussion_path
+ when /^the create_email "([^"]*)" page$/i
+ admins_send_email_path(:id=>$1)
# Add more mappings here.
# Here is an example that pulls values out of the Regexp:
#
diff --git a/features/team_editing/admin_approve_disapprove_teams.feature b/features/team_editing/admin_approve_disapprove_teams.feature
index 64d06e54..965b7733 100644
--- a/features/team_editing/admin_approve_disapprove_teams.feature
+++ b/features/team_editing/admin_approve_disapprove_teams.feature
@@ -14,11 +14,11 @@ Feature: Approve/Disapprove teams
| Bob2 | bobjones2@berkeley.edu | passcode1 | Slavic Studies | 826 |
| Bob3 | bobjones3@berkeley.edu | passcode1 | Slavic Studies | 827 |
| Bob4 | bobjones4@berkeley.edu | passcode1 | Slavic Studies | 828 |
- | Sahai | xxx@berkeley.edu | passcode2 | Slav1c Studies | 830 |
- | Saha2 | xx2@berkeley.edu | passcode2 | Slav1c Studies | 831 |
- | Saha3 | xx3@berkeley.edu | passcode2 | Slav1c Studies | 832 |
- | Saha4 | xx4@berkeley.edu | passcode2 | Slav1c Studies | 833 |
- | Saha5 | xx5@berkeley.edu | passcode2 | Slav1c Studies | 834 |
+ | Sahai | xxx@berkeley.edu | passcode2 | Slav1c Studies | 830 |
+ | Saha2 | xx2@berkeley.edu | passcode2 | Slav1c Studies | 831 |
+ | Saha3 | xx3@berkeley.edu | passcode2 | Slav1c Studies | 832 |
+ | Saha4 | xx4@berkeley.edu | passcode2 | Slav1c Studies | 833 |
+ | Saha5 | xx5@berkeley.edu | passcode2 | Slav1c Studies | 834 |
| Jorge | legueoflegends667@hotmail.com | passcode3 | Football Player | 999 |
And the following discussions exist
| number | time | capacity |
@@ -56,3 +56,9 @@ Feature: Approve/Disapprove teams
Then I should see "Permission denied"
And I go to the disapprove team "1" page
Then I should see "Permission denied"
+
+ Scenario: Admin can undo an approval of a team
+ Given I log in as an admin with email "supreme_ruler@aol.com"
+ When I follow "Undo Approve"
+ Then I should not see "Disapprove"
+
diff --git a/features/users/show_mygroup.feature b/features/users/show_mygroup.feature
new file mode 100644
index 00000000..b5d1a307
--- /dev/null
+++ b/features/users/show_mygroup.feature
@@ -0,0 +1,69 @@
+Feature: Student can see group
+ As a student
+ I want to see my group
+
+ Background:
+ Given the allowed team size is 3-4
+ And the following users exist
+ | name | email |team_passcode | major | sid |
+ | Jorge1 | kobe1@hotmail.com | 0 | Football Player | 242 |
+ | Jorge1 | kobe2@hotmail.com | 0 | Football Player | 243 |
+ | Sahai | eecs666@hotmail.com | penguindrool | EECS | 000 |
+ | Saha2 | eecs667@hotmail.com | penguindrool | EECS | 001 |
+ | Saha3 | eecs668@hotmail.com | penguindrool | EECS | 002 |
+ | Saha4 | eecs669@hotmail.com | hihi | EECS | 003 |
+ | Jorge | legueoflegends667@hotmail.com | hihi | Football Player | 999 |
+ | Kandi | justanotheremail@aol.com | hihi | EECS | 567 |
+ And the following discussions exist
+ | number | time | capacity |
+ | 54321 | Tues, 3pm | 24 |
+ And I am on the login page
+
+
+ Scenario: Student successfully attempts to view their non-group
+ And I log in as a user with email "kobe1@hotmail.com"
+ Given I fill in "team_hash" with "penguindrool"
+ And I press "Join"
+ And I press "My Group"
+ Then I should see "You are not in a group yet!"
+
+ Scenario: Student1 successfully views their group
+ And I log in as a user with email "kobe1@hotmail.com"
+ Given I fill in "team_hash" with "penguindrool"
+ And I press "Join"
+ And the team with passcode "penguindrool" is approved with discussion number "54321"
+ And the team with passcode "hihi" is approved with discussion number "54321"
+ And the following groups exist
+ | team1_id | team2_id |discussion_id |
+ | 1 | 2 | 1 |
+ And I press "My Group"
+ Then I should see "justanotheremail@aol.com"
+
+ Scenario: Student2 successfully views their group
+ And I log in as a user with email "kobe2@hotmail.com"
+ Given I fill in "team_hash" with "hihi"
+ And I press "Join"
+ And the team with passcode "penguindrool" is approved with discussion number "54321"
+ And the team with passcode "hihi" is approved with discussion number "54321"
+ And the following groups exist
+ | team1_id | team2_id |discussion_id |
+ | 1 | 2 | 1 |
+ And I press "My Group"
+ Then I should see "justanotheremail@aol.com"
+
+
+
+# Background:
+# Given the allowed team size is 5-6
+# And the following users exist
+# | name | email | team_passcode | major | sid |
+# | Jorge | legueoflegends667@hotmail.com | 0 | Football Player | 999 |
+# | Sahai | eecs666@hotmail.com | penguindrool | EECS | 000 |
+# | Saha1 | eecs667@hotmail.com | penguindrool | EECS | 001 |
+# | Saha2 | eecs668@hotmail.com | penguindrool | EECS | 002 |
+# | Saha3 | eecs669@hotmail.com | penguindrool | EECS | 003 |
+# | Saha4 | eecs660@hotmail.com | penguindrool | EECS | 004 |
+
+# And I am on the login page
+# And I log in as a user with email "legueoflegends667@hotmail.com"
+
diff --git a/iterations/iter0.md b/iterations/iter0.md
index a80c8973..c092b5a7 100644
--- a/iterations/iter0.md
+++ b/iterations/iter0.md
@@ -2,22 +2,13 @@
Screencasts
-Recording by Jason Gao: http://youtu.be/QCiV6Ikg8rk?hd=1
+Recording by Team (Yonas Kbrom, Vikram Baid, Mark Sun, Timothy Stepro, Monty, Minjoo Sur) : https://www.youtube.com/watch?v=g_FMyYth4QQ&feature=youtu.be
-Recording by David Koh: https://www.youtube.com/watch?v=Mj9r7tne6EQ
-
-Recording by Sid Masih: https://youtu.be/jZddINFBXNs
-
-Recording by Dasol Yoon: https://youtu.be/2EHCysXnVDU
-
-Recording by Varun Mathuria: https://youtu.be/vdgUOUkY1Yg
-
-Recording by Adnan Hemani: https://youtu.be/dynRMsgpBYc
Video
-2 min interview with Michael-David Sasson: https://www.youtube.com/watch?v=HsaLw2gwUa4
+2 min interview with Cindy Connors: https://www.youtube.com/watch?v=wBph_Uhxmz0&feature=youtu.be
-Full Interview with Michael-David Sasson: https://www.youtube.com/watch?v=9Lp0Jov4h1Q
+Full Interview with Cindy Connors: https://youtu.be/tbhmfJa7jZ4
diff --git a/script/clock.rb b/script/clock.rb
index 2374f343..c5650449 100644
--- a/script/clock.rb
+++ b/script/clock.rb
@@ -8,11 +8,11 @@ def schedule
every(7.days, 'Send Pending Teams Emails to Admins, Phase I', :at => '05:00') {
time = Time.now
- if (time.month == 5 or time.month == 6 or (time.month == 4 and time.day >= 15) or (time.month == 7 and time.day <= 15) or
- (time.month == 10 and time.day >= 15) or (time.month == 11 and time.day <= 15))
- puts "Sending Emails to Admins..."
+ if (time.month == 5 || time.month == 6 || (time.month == 4 && time.day >= 15) || (time.month == 7 && time.day <= 15) ||
+ (time.month == 10 && time.day >= 15) || (time.month == 11 && time.day <= 15))
+ puts 'Sending Emails to Admins...'
AdminMailer.send_look_at_submission
- puts "done."
+ puts 'done.'
end
}
@@ -20,19 +20,19 @@ def schedule
time = Time.now
if ((time.month == 7 and time.day > 15) or (time.month == 8 and time.day <= 15) or
(time.month == 11 and time.day > 15) or time.month == 12)
- puts "Sending Emails to Admins..."
+ puts 'Sending Emails to Admins...'
AdminMailer.send_look_at_submission
- puts "done."
+ puts 'done.'
end
}
every(1.day, 'Send Pending Teams Emails to Admins, Adjustment Period', :at => '05:00') {
time = Time.now
- if ((time.month == 8 and time.day > 15) or time.month == 9 or
- time.month == 1 or (time.month == 2 and time.day <= 20))
- puts "Sending Emails to Admins..."
+ if ((time.month == 8 && time.day > 15) || time.month == 9 ||
+ time.month == 1 || (time.month == 2 && time.day <= 20))
+ puts 'Sending Emails to Admins...'
AdminMailer.send_look_at_submission
- puts "done."
+ puts 'done.'
end
}
diff --git a/spec/controllers/admins_controller_spec.rb b/spec/controllers/admins_controller_spec.rb
index 045aa338..10017552 100644
--- a/spec/controllers/admins_controller_spec.rb
+++ b/spec/controllers/admins_controller_spec.rb
@@ -25,5 +25,4 @@
end
end
-
end
diff --git a/spec/controllers/group_controller_spec.rb b/spec/controllers/group_controller_spec.rb
new file mode 100644
index 00000000..e229ac7f
--- /dev/null
+++ b/spec/controllers/group_controller_spec.rb
@@ -0,0 +1,81 @@
+require 'rails_helper'
+
+RSpec.describe GroupController, type: :controller do
+ # render_views
+ # describe "GET #download_approved_teams" do
+ # before do
+ # @disc = Discussion.create!(:number => 13397, :time=> "Wed, 3pm", :capacity => 5)
+ # people = [
+ # { :name => "John" ,:major => "English" , :sid => "111" ,:email => "111@berkeley.edu"},
+ # { :name => "Josh" ,:major => "CS" ,:sid => "222" ,:email => "222@berkeley.edu"},
+ # { :name => "Jorge" ,:major => "English" ,:sid => "333" ,:email => "333@berkeley.edu"},
+ # { :name => "CCC" ,:major => "EECS" ,:sid => "444" ,:email => "444@berkeley.edu"},
+ # { :name => "DDD" ,:major => "English" ,:sid => "555" ,:email => "555@berkeley.edu"},
+ # { :name => "EEE" , :major =>"English" ,:sid => "666" ,:email => "666@berkeley.edu"},
+ # { :name => "FFF" ,:major => "EECS" ,:sid => "777" ,:email => "777@berkeley.edu"},
+ # { :name => "GGG" ,:major => "CS" ,:sid => "888" ,:email => "888@berkeley.edu"},
+ # { :name => "HHH" ,:major => "English" ,:sid => "999" ,:email =>"999@berkeley.edu"},
+ # { :name => "III" ,:major => "English" ,:sid => "1111" ,:email => "1111@berkeley.edu"},
+ # { :name => "JJJ" ,:major => "English" ,:sid => "2222" ,:email => "2222@berkeley.edu"},
+ # { :name => "Kay" ,:major => "EECS" ,:sid => "3333" ,:email => "3333@berkeley.edu"},
+ # { :name => "Ana" ,:major => "CS" ,:sid => "4444" ,:email => "4444@berkeley.edu"},
+ # { :name => "Chris" ,:major => "CS" ,:sid => "44444" ,:email => "44444@berkeley.edu"}
+ # ]
+ # people.each do |ue|
+ # User.create!(ue)
+ # end
+ # Admin.create!({:name => "admin", :email => "admin@admin.com"})
+ # @team1 = Team.new
+ # @team1.submitted = true
+ # @team1.approve_with_discussion(@disc.id)
+ # @team1.passcode = "passcode1"
+ # @disc.teams << @team1
+ # @team1.save!
+ # @team1.users << User.where(name: "Josh")
+ # @team1.users << User.where(name: "CCC")
+ # @team1.users << User.where(name: "GGG")
+ # @team1.users << User.where(name: "FFF")
+ # @team1.users << User.where(name: "EEE")
+
+
+ # @team2 = Team.new
+ # @team2.approved = false
+ # @team2.submitted = true
+ # @team2.passcode = "passcode2"
+ # @team2.save!
+ # @team2.users << User.where(name: "JJJ")
+ # @team2.users << User.where(name: "DDD")
+ # @team2.users << User.where(name: "III")
+ # @team2.users << User.where(name: "Kay")
+ # @team2.users << User.where(name: "Ana")
+
+ # @team3 = Team.new
+ # @team3.submitted = false
+ # @team3.approved = false
+ # @team3.passcode = "passcode3"
+ # @team3.users << User.where(name: "Chris")
+
+ # session[:user_id] = 1
+ # session[:is_admin] = true
+ # params[:]
+
+ # get :download_approved_teams, :status => "Approved"
+ # end
+
+ # it "shows all approved teams" do
+ # expect(response.body).to include("Josh")
+ # expect(response.body).to include("GGG")
+ # expect(response.body).to include("EEE")
+ # end
+
+ # it "does not show submitted teams" do
+ # expect(response.body).not_to include("JJJ")
+ # expect(response.body).not_to include("III")
+ # expect(response.body).not_to include("Ana")
+ # end
+
+ # it "does not show invalid teams" do
+ # expect(response.body).not_to include("Chris")
+ # end
+ # end
+end
diff --git a/spec/helpers/group_helper_spec.rb b/spec/helpers/group_helper_spec.rb
new file mode 100644
index 00000000..83fcde56
--- /dev/null
+++ b/spec/helpers/group_helper_spec.rb
@@ -0,0 +1,15 @@
+require 'rails_helper'
+
+# Specs in this file have access to a helper object that includes
+# the GroupHelper. For example:
+#
+# describe GroupHelper do
+# describe "string concat" do
+# it "concats two strings with spaces" do
+# expect(helper.concat_strings("this","that")).to eq("this that")
+# end
+# end
+# end
+RSpec.describe GroupHelper, type: :helper do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/mailers/admin_mailer_spec.rb b/spec/mailers/admin_mailer_spec.rb
index a0287362..95ead6d5 100644
--- a/spec/mailers/admin_mailer_spec.rb
+++ b/spec/mailers/admin_mailer_spec.rb
@@ -84,6 +84,21 @@
ActionMailer::Base.deliveries.first.from.should == ['enrollmeberkeley@gmail.com']
end
+ it 'Send an email that states all data was deleted' do
+ AdminMailer.all_data(@admin).deliver_now
+ ActionMailer::Base.deliveries.first.from.should == ['enrollmeberkeley@gmail.com']
+ end
+
+ it 'Send an email to the TA telling them that there emails waiting their submission' do
+ AdminMailer.look_at_submission("mr.monty@berkeley.edu").deliver_now
+ ActionMailer::Base.deliveries.first.from.should == ['enrollmeberkeley@gmail.com']
+ end
+
+ it 'Send an email that tells the TA to look at this submission' do
+ AdminMailer.send_look_at_submission
+ ActionMailer::Base.deliveries.first.from.should == ['enrollmeberkeley@gmail.com']
+ end
+
after(:each) do
ActionMailer::Base.deliveries.clear
end
diff --git a/spec/mailers/email_students_spec.rb b/spec/mailers/email_students_spec.rb
index a02b8207..36002acb 100644
--- a/spec/mailers/email_students_spec.rb
+++ b/spec/mailers/email_students_spec.rb
@@ -60,6 +60,17 @@
EmailStudents.successfully_submitted_email(@team).deliver_now
ActionMailer::Base.deliveries.first.from.should == ['enrollmeberkeley@gmail.com']
end
+
+ it 'send an email to a group' do
+ EmailStudents.email_group("enrollmeberkeley@gmail.com", "hello").deliver_now
+ ActionMailer::Base.deliveries.first.from.should == ['enrollmeberkeley@gmail.com']
+ end
+
+ it 'send a welcome email to a user' do
+ EmailStudents.welcome_email(@user).deliver_now
+ ActionMailer::Base.deliveries.first.from.should == ['enrollmeberkeley@gmail.com']
+ end
+
after(:each) do
ActionMailer::Base.deliveries.clear
diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb
new file mode 100644
index 00000000..ee65781f
--- /dev/null
+++ b/spec/models/group_spec.rb
@@ -0,0 +1,70 @@
+require 'rails_helper'
+
+RSpec.describe Group, type: :model do
+ #pending "add some examples to (or delete) #{__FILE__}"
+ describe "Checking if a team is in a group" do
+ before do
+ @full = Discussion.new(:number => 666, :time=> "Wed, 3pm", :capacity => 5)
+ @empty = Discussion.new(:number => 1337, :time=> "Wed, 3pm", :capacity => 5)
+ people = [
+ { :name => "John" ,:major => "English" , :sid => "111" ,:email => "111@berkeley.edu"},
+ { :name => "Josh" ,:major => "CS" ,:sid => "222" ,:email => "222@berkeley.edu"},
+ { :name => "Jorge" ,:major => "English" ,:sid => "333" ,:email => "333@berkeley.edu"},
+ { :name => "CCC" ,:major => "EECS" ,:sid => "444" ,:email => "444@berkeley.edu"},
+ { :name => "DDD" ,:major => "English" ,:sid => "555" ,:email => "555@berkeley.edu"},
+ {:name => "EEE" , :major =>"English" ,:sid => "666" ,:email => "666@berkeley.edu"},
+ {:name => "FFF" ,:major => "EECS" ,:sid => "777" ,:email => "777@berkeley.edu"},
+ {:name => "GGG" ,:major => "CS" ,:sid => "888" ,:email => "888@berkeley.edu"},
+ {:name => "HHH" ,:major => "English" ,:sid => "999" ,:email =>"999@berkeley.edu"},
+ {:name => "III" ,:major => "English" ,:sid => "1111" ,:email => "1111@berkeley.edu"},
+ {:name => "JJJ" ,:major => "English" ,:sid => "2222" ,:email => "2222@berkeley.edu"},
+ {:name => "Kay" ,:major => "EECS" ,:sid => "3333" ,:email => "3333@berkeley.edu"},
+ {:name => "Ana" ,:major => "CS" ,:sid => "4444" ,:email => "4444@berkeley.edu"},
+ {:name => "Chris" ,:major => "CS" ,:sid => "44444" ,:email => "44444@berkeley.edu"}
+ ]
+
+ people.each do |ue|
+ User.create!( ue)
+ end
+
+
+ @tone = Team.new
+ @tone.approved = true
+ @tone.submitted = true
+ @tone.passcode = "passcode1"
+ @tone.save!
+ @tone.users << User.where(name: "Josh")
+ @tone.users << User.where(name: "CCC")
+ @tone.users << User.where(name: "GGG")
+ @tone.users << User.where(name: "FFF")
+ @tone.users << User.where(name: "EEE")
+
+
+ @ttwo = Team.new
+ @ttwo.approved = true
+ @ttwo.submitted = true
+ @ttwo.passcode = "passcode2"
+ @ttwo.save!
+ @ttwo.users << User.where(name: "JJJ")
+ @ttwo.users << User.where(name: "DDD")
+ @ttwo.users << User.where(name: "III")
+ @ttwo.users << User.where(name: "Kay")
+
+ @group = Group.new
+ @group.team1_id = @tone.id
+ @group.team2_id = @ttwo.id
+ @group.discussion_id = @empty.number
+ @group.save!
+
+ end
+ it "returns true if a team has a group and false otherwise" do
+ expect(Group.has_team?(@tone.id, @empty.number) == true)
+ expect(Group.has_team?(@tone.id, @full.number) == false)
+ end
+
+ it "unmerge a well defined group" do
+ Group.unmerge(@group.id)
+ expect(Group.all == nil)
+ end
+ end
+end
diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb
index 6f1ab146..c0a11800 100644
--- a/spec/rails_helper.rb
+++ b/spec/rails_helper.rb
@@ -1,10 +1,13 @@
# This file is copied to spec/ when you run 'rails generate rspec:install'
+require 'coveralls'
+Coveralls.wear!("rails")
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
# Prevent database truncation if the environment is production
abort("The Rails environment is running in production mode!") if Rails.env.production?
require 'spec_helper'
require 'rspec/rails'
+
# Add additional requires below this line. Rails is not loaded until this point!
# Requires supporting ruby files with custom matchers and macros, etc, in