# HG changeset patch # User Nattee Niparnan # Date 2016-12-28 09:07:53 # Node ID 54dff44ae178a3ab5647552d6c4076b529916748 # Parent 3b5645cfc80e153ae59b5e80a2291a3ed7371011 start testing add compiler msg pop up diff --git a/Gemfile b/Gemfile --- a/Gemfile +++ b/Gemfile @@ -13,15 +13,14 @@ # Gems used only for assets and not required # in production environments by default. -group :assets do - gem 'sass-rails' - gem 'coffee-rails' +gem 'sass-rails' +gem 'coffee-rails' # See https://github.com/sstephenson/execjs#readme for more supported runtimes # gem 'therubyracer', :platforms => :ruby - gem 'uglifier' -end +gem 'uglifier' + # gem 'prototype-rails' @@ -77,6 +76,3 @@ gem 'in_place_editing' gem 'verification', :git => 'https://github.com/sikachu/verification.git' -group :test, :development do - gem 'rspec-rails' -end diff --git a/Gemfile.lock b/Gemfile.lock --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,10 +1,10 @@ GIT remote: https://github.com/sikachu/verification.git - revision: e6fe084ce16b7b5a4b1cdfca5374d125fd034a0f + revision: ff31697b940d7b0e2ec65f08764215c96104e76d specs: verification (1.0.3) - actionpack (>= 3.0.0, < 5.0) - activesupport (>= 3.0.0, < 5.0) + actionpack (>= 3.0.0, < 5.1) + activesupport (>= 3.0.0, < 5.1) GEM remote: https://rubygems.org/ @@ -51,8 +51,8 @@ minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) - arel (6.0.3) - autoprefixer-rails (6.5.3.1) + arel (6.0.4) + autoprefixer-rails (6.6.0) execjs best_in_place (3.0.3) actionpack (>= 3.2) @@ -68,9 +68,8 @@ coffee-script (2.4.1) coffee-script-source execjs - coffee-script-source (1.11.1) - concurrent-ruby (1.0.2) - diff-lcs (1.2.5) + coffee-script-source (1.12.2) + concurrent-ruby (1.0.4) dynamic_form (1.1.4) erubis (2.7.0) execjs (2.7.0) @@ -96,13 +95,12 @@ rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) - jquery-tablesorter (1.23.1) + jquery-tablesorter (1.23.3) railties (>= 3.2, < 6) jquery-timepicker-addon-rails (1.4.1) railties (>= 3.1) - jquery-ui-rails (4.0.3) - jquery-rails - railties (>= 3.1.0) + jquery-ui-rails (6.0.1) + railties (>= 3.2.16) json (1.8.3) loofah (2.0.3) nokogiri (>= 1.5.9) @@ -136,9 +134,9 @@ sprockets-rails rails-deprecated_sanitizer (1.0.3) activesupport (>= 4.2.0.alpha) - rails-dom-testing (1.0.7) + rails-dom-testing (1.0.8) activesupport (>= 4.2.0.beta, < 5.0) - nokogiri (~> 1.6.0) + nokogiri (~> 1.6) rails-deprecated_sanitizer (>= 1.0.1) rails-html-sanitizer (1.0.3) loofah (~> 2.0) @@ -152,26 +150,9 @@ rake (12.0.0) rdiscount (2.2.0.1) rouge (2.0.7) - rspec-core (3.5.4) - rspec-support (~> 3.5.0) - rspec-expectations (3.5.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.5.0) - rspec-mocks (3.5.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.5.0) - rspec-rails (3.5.2) - actionpack (>= 3.0) - activesupport (>= 3.0) - railties (>= 3.0) - rspec-core (~> 3.5.0) - rspec-expectations (~> 3.5.0) - rspec-mocks (~> 3.5.0) - rspec-support (~> 3.5.0) - rspec-support (3.5.0) ruby_parser (3.8.3) sexp_processor (~> 4.1) - sass (3.4.22) + sass (3.4.23) sass-rails (5.0.6) railties (>= 4.0.0, < 6) sass (~> 3.1) @@ -181,7 +162,7 @@ select2-rails (4.0.3) thor (~> 0.14) sexp_processor (4.7.0) - sprockets (3.7.0) + sprockets (3.7.1) concurrent-ruby (~> 1.0) rack (> 1, < 3) sprockets-rails (3.2.0) @@ -228,7 +209,6 @@ rails_bootstrap_sortable rdiscount rouge - rspec-rails sass-rails select2-rails sqlite3 diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -12,7 +12,7 @@ // //= require jquery //= require jquery_ujs -//= require jquery.ui.all +//= require jquery-ui //= require bootstrap-sprockets //= require moment //= require bootstrap-sortable @@ -28,9 +28,6 @@ //= require custom //= require jquery.countdown //-------------- addition from local_jquery ----------- -//= require jquery.ui.datepicker -//= require jquery.ui.slider -//= require jquery-ui-timepicker-addon //= require jquery-tablesorter //= require best_in_place //= require best_in_place.jquery-ui diff --git a/app/assets/javascripts/local_jquery.js b/app/assets/javascripts/local_jquery.js --- a/app/assets/javascripts/local_jquery.js +++ b/app/assets/javascripts/local_jquery.js @@ -1,13 +1,3 @@ -//= require jquery -//= require jquery_ujs -//= require jquery.ui.all -//= require jquery.ui.datepicker -//= require jquery.ui.slider -//= require jquery-ui-timepicker-addon -//= require jquery-tablesorter -//= require best_in_place -//= require best_in_place.jquery-ui - $(document).ready(function() { /* Activating Best In Place */ jQuery(".best_in_place").best_in_place(); diff --git a/app/assets/stylesheets/application.css.scss b/app/assets/stylesheets/application.css.scss --- a/app/assets/stylesheets/application.css.scss +++ b/app/assets/stylesheets/application.css.scss @@ -14,11 +14,11 @@ * # *= require_self */ -@import "jquery.ui.all"; -@import "jquery.ui.core"; -@import "jquery.ui.theme"; -@import "jquery.ui.datepicker"; -@import "jquery.ui.slider"; +@import "jquery-ui"; +//@import "jquery.ui.core"; +//@import "jquery.ui.theme"; +//@import "jquery.ui.datepicker"; +//@import "jquery.ui.slider"; @import "jquery-ui-timepicker-addon"; @import "jquery-tablesorter/theme.metro-dark"; @import "jquery.countdown"; diff --git a/app/views/submissions/compiler_msg.js.haml b/app/views/submissions/compiler_msg.js.haml new file mode 100644 --- /dev/null +++ b/app/views/submissions/compiler_msg.js.haml @@ -0,0 +1,3 @@ +:javascript + $("#compiler_msg").html("#{j @submissionhcompiler_msg}") + diff --git a/config/environments/test.rb b/config/environments/test.rb --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -36,4 +36,8 @@ config.active_support.deprecation = :stderr config.eager_load = false + + #test order + config.active_support.test_order = :sorted + end diff --git a/db/seeds.rb b/db/seeds.rb --- a/db/seeds.rb +++ b/db/seeds.rb @@ -53,6 +53,7 @@ :description => 'If the server is in contest mode and this option is true, on the log in of the admin a menu for site selections is shown.' }, + #---------------------------- right -------------------------------- { :key => 'right.user_hall_of_fame', :value_type => 'boolean', @@ -74,6 +75,20 @@ :description => 'If true, any user can view submissions of every one.' }, + { + :key => 'right.bypass_agreement', + :value_type => 'boolean', + :default_value => 'true', + :description => 'When false, a user must accept usage agreement before login' + }, + + { + :key => 'right.heartbeat_response', + :value_type => 'string', + :default_value => 'OK', + :description => 'Heart beat response text' + }, + # If Configuration['system.online_registration'] is true, the # system allows online registration, and will use these # information for sending confirmation emails. diff --git a/spec/config_spec_helper.rb b/spec/config_spec_helper.rb deleted file mode 100644 --- a/spec/config_spec_helper.rb +++ /dev/null @@ -1,38 +0,0 @@ - -module ConfigSpecHelperMethods - - def find_or_create_and_set_config(key, type, value) - c = Configuration.find_by_key(key) - c ||= Configuration.new(:key => key, - :value_type => type) - c.value = value - c.save! - end - - def enable_multicontest - find_or_create_and_set_config(Configuration::MULTICONTESTS_KEY, - 'boolean','true') - end - - def disable_multicontest - find_or_create_and_set_config(Configuration::MULTICONTESTS_KEY, - 'boolean','false') - end - - def set_indv_contest_mode - find_or_create_and_set_config(Configuration::SYSTEM_MODE_CONF_KEY, - 'string','indv-contest') - end - - def set_standard_mode - find_or_create_and_set_config(Configuration::SYSTEM_MODE_CONF_KEY, - 'string','standard') - end - - def set_contest_time_limit(limit) - find_or_create_and_set_config(Configuration::CONTEST_TIME_LIMIT_KEY, - 'string',limit) - # clear old value - Configuration.contest_time_str = nil - end -end diff --git a/spec/controllers/main_controller_spec.rb b/spec/controllers/main_controller_spec.rb deleted file mode 100644 --- a/spec/controllers/main_controller_spec.rb +++ /dev/null @@ -1,193 +0,0 @@ -require 'delorean' - -require File.dirname(__FILE__) + '/../spec_helper' -require File.dirname(__FILE__) + '/../config_spec_helper' - -describe MainController, "when a user comes to list page" do - - it "should redirect user to login page when unlogged-in user try to access main/list" do - get 'list' - response.should redirect_to(:action => 'login') - end - -end - -describe MainController, "when a logged in user comes to list page, with multicontests off" do - integrate_views - - include ConfigSpecHelperMethods - - fixtures :users - fixtures :problems - fixtures :contests - - before(:each) do - disable_multicontest - end - - it "should list available problems" do - john = users(:john) - get "list", {}, {:user_id => john.id} - - response.should render_template 'main/list' - response.should have_text(/add/) - response.should have_text(/easy_problem/) - response.should have_text(/hard_problem/) - end - -end - -describe MainController, "when a logged in user comes to list page, with multicontests on" do - integrate_views - - include ConfigSpecHelperMethods - - fixtures :users - fixtures :problems - fixtures :contests - - before(:each) do - enable_multicontest - end - - it "should list only available public problems to users with no contest assigned" do - john = users(:john) - get "list", {}, {:user_id => john.id} - - response.should render_template('main/list') - response.should have_text(/add/) - response.should_not have_text(/easy_problem/) - response.should_not have_text(/hard_problem/) - end - - it "should list available problems on a specific contest" do - james = users(:james) - get "list", {}, {:user_id => james.id} - - response.should render_template('main/list') - response.should have_text(/add/) - response.should have_text(/easy_problem/) - response.should_not have_text(/hard_problem/) - end - - it "should shows available problems by contests" do - james = users(:james) - get "list", {}, {:user_id => james.id} - - response.should render_template('main/list') - response.should have_text(Regexp.new('Contest A.*easy_problem', Regexp::MULTILINE)) - end - - it "should shows available problems by contests; problems belonging to more the one contest should appear many times" do - jack = users(:jack) - get "list", {}, {:user_id => jack.id} - - response.should render_template('main/list') - response.should have_text(Regexp.new('Contest A.*easy_problem.*Contest B.*easy_problem', Regexp::MULTILINE)) - response.should have_text(Regexp.new('Contest B.*hard_problem', Regexp::MULTILINE)) - end -end - -describe MainController, "when a user loads sources and compiler messages" do - - before(:each) do - @problem = mock(Problem, :name => 'test', :output_only => false) - @language = mock(Language, :name => 'cpp', :ext => 'cpp') - @submission = mock(Submission, - :id => 1, - :user_id => 1, - :problem => @problem, - :language => @language, - :source => 'sample source', - :compiler_message => 'none') - - @user = mock(User, :id => 1, :login => 'john') - @user.should_receive(:update_start_time).at_most(:once) - - @another_user = mock(User, :id => 2, :login => 'mary') - @another_user.should_receive(:update_start_time).at_most(:once) - - User.should_receive(:find). - with(1).any_number_of_times. - and_return(@user) - User.should_receive(:find). - with(2).any_number_of_times. - and_return(@another_user) - Submission.should_receive(:find). - any_number_of_times.with(@submission.id.to_s). - and_return(@submission) - end - - it "should let user sees her own source" do - @submission.should_receive(:download_filename).and_return("foo.c") - get 'source', {:id => @submission.id}, {:user_id => 1} - response.should be_success - end - - it "should let user sees her own compiler message" do - get 'compiler_msg', {:id => @submission.id}, {:user_id => 1} - response.should be_success - end - - it "should not let user sees other user's source" do - get 'source', {:id => @submission.id}, {:user_id => 2} - flash[:notice].should =~ /[Ee]rror/ - response.should redirect_to(:action => 'list') - end - - it "should not let user sees other user's compiler message" do - get 'compiler_msg', {:id => @submission.id}, {:user_id => 2} - flash[:notice].should =~ /[Ee]rror/ - response.should redirect_to(:action => 'list') - end - -end - - -describe MainController, "during individual contest mode" do - - integrate_views - - include ConfigSpecHelperMethods - - fixtures :users - fixtures :problems - fixtures :contests - - before(:each) do - set_contest_time_limit('3:00') # 3 hours - set_indv_contest_mode - end - - it "should allow newly login user to see problem list" do - john = users(:john) - get "list", {}, {:user_id => john.id} - - response.should render_template 'main/list' - response.should have_text(/add/) - response.should have_text(/easy_problem/) - response.should have_text(/hard_problem/) - end - - it "should not show 'contest over' sign before the contest ends" do - john = users(:john) - get "list", {}, {:user_id => john.id} - - Delorean.time_travel_to(179.minutes.since) do - get "list", {}, {:user_id => john.id} - response.should_not have_text(/OVER/) - end - end - - it "should show 'contest over' sign after the contest ends" do - john = users(:john) - get "list", {}, {:user_id => john.id} - - Delorean.time_travel_to(181.minutes.since) do - get "list", {}, {:user_id => john.id} - response.should have_text(/OVER/) - end - end - -end - diff --git a/spec/controllers/sources_controller_spec.rb b/spec/controllers/sources_controller_spec.rb deleted file mode 100644 --- a/spec/controllers/sources_controller_spec.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'spec_helper' - -describe SourcesController do - - describe "GET 'direct_edit'" do - it "returns http success" do - get 'direct_edit' - response.should be_success - end - end - -end diff --git a/spec/controllers/submissions_controller_spec.rb b/spec/controllers/submissions_controller_spec.rb deleted file mode 100644 --- a/spec/controllers/submissions_controller_spec.rb +++ /dev/null @@ -1,160 +0,0 @@ -require 'spec_helper' - -# This spec was generated by rspec-rails when you ran the scaffold generator. -# It demonstrates how one might use RSpec to specify the controller code that -# was generated by Rails when you ran the scaffold generator. -# -# It assumes that the implementation code is generated by the rails scaffold -# generator. If you are using any extension libraries to generate different -# controller code, this generated spec may or may not pass. -# -# It only uses APIs available in rails and/or rspec-rails. There are a number -# of tools you can use to make these specs even more expressive, but we're -# sticking to rails and rspec-rails APIs to keep things simple and stable. -# -# Compared to earlier versions of this generator, there is very limited use of -# stubs and message expectations in this spec. Stubs are only used when there -# is no simpler way to get a handle on the object needed for the example. -# Message expectations are only used when there is no simpler way to specify -# that an instance is receiving a specific message. - -describe SubmissionsController do - - # This should return the minimal set of attributes required to create a valid - # Submission. As you add validations to Submission, be sure to - # adjust the attributes here as well. - let(:valid_attributes) { { } } - - # This should return the minimal set of values that should be in the session - # in order to pass any filters (e.g. authentication) defined in - # SubmissionsController. Be sure to keep this updated too. - let(:valid_session) { {} } - - describe "GET index" do - it "assigns all submissions as @submissions" do - submission = Submission.create! valid_attributes - get :index, {}, valid_session - assigns(:submissions).should eq([submission]) - end - end - - describe "GET show" do - it "assigns the requested submission as @submission" do - submission = Submission.create! valid_attributes - get :show, {:id => submission.to_param}, valid_session - assigns(:submission).should eq(submission) - end - end - - describe "GET new" do - it "assigns a new submission as @submission" do - get :new, {}, valid_session - assigns(:submission).should be_a_new(Submission) - end - end - - describe "GET edit" do - it "assigns the requested submission as @submission" do - submission = Submission.create! valid_attributes - get :edit, {:id => submission.to_param}, valid_session - assigns(:submission).should eq(submission) - end - end - - describe "POST create" do - describe "with valid params" do - it "creates a new Submission" do - expect { - post :create, {:submission => valid_attributes}, valid_session - }.to change(Submission, :count).by(1) - end - - it "assigns a newly created submission as @submission" do - post :create, {:submission => valid_attributes}, valid_session - assigns(:submission).should be_a(Submission) - assigns(:submission).should be_persisted - end - - it "redirects to the created submission" do - post :create, {:submission => valid_attributes}, valid_session - response.should redirect_to(Submission.last) - end - end - - describe "with invalid params" do - it "assigns a newly created but unsaved submission as @submission" do - # Trigger the behavior that occurs when invalid params are submitted - Submission.any_instance.stub(:save).and_return(false) - post :create, {:submission => { }}, valid_session - assigns(:submission).should be_a_new(Submission) - end - - it "re-renders the 'new' template" do - # Trigger the behavior that occurs when invalid params are submitted - Submission.any_instance.stub(:save).and_return(false) - post :create, {:submission => { }}, valid_session - response.should render_template("new") - end - end - end - - describe "PUT update" do - describe "with valid params" do - it "updates the requested submission" do - submission = Submission.create! valid_attributes - # Assuming there are no other submissions in the database, this - # specifies that the Submission created on the previous line - # receives the :update_attributes message with whatever params are - # submitted in the request. - Submission.any_instance.should_receive(:update_attributes).with({ "these" => "params" }) - put :update, {:id => submission.to_param, :submission => { "these" => "params" }}, valid_session - end - - it "assigns the requested submission as @submission" do - submission = Submission.create! valid_attributes - put :update, {:id => submission.to_param, :submission => valid_attributes}, valid_session - assigns(:submission).should eq(submission) - end - - it "redirects to the submission" do - submission = Submission.create! valid_attributes - put :update, {:id => submission.to_param, :submission => valid_attributes}, valid_session - response.should redirect_to(submission) - end - end - - describe "with invalid params" do - it "assigns the submission as @submission" do - submission = Submission.create! valid_attributes - # Trigger the behavior that occurs when invalid params are submitted - Submission.any_instance.stub(:save).and_return(false) - put :update, {:id => submission.to_param, :submission => { }}, valid_session - assigns(:submission).should eq(submission) - end - - it "re-renders the 'edit' template" do - submission = Submission.create! valid_attributes - # Trigger the behavior that occurs when invalid params are submitted - Submission.any_instance.stub(:save).and_return(false) - put :update, {:id => submission.to_param, :submission => { }}, valid_session - response.should render_template("edit") - end - end - end - - describe "DELETE destroy" do - it "destroys the requested submission" do - submission = Submission.create! valid_attributes - expect { - delete :destroy, {:id => submission.to_param}, valid_session - }.to change(Submission, :count).by(-1) - end - - it "redirects to the submissions list" do - submission = Submission.create! valid_attributes - delete :destroy, {:id => submission.to_param}, valid_session - response.should redirect_to(submissions_url) - end - end - -end diff --git a/spec/controllers/test_controller_spec.rb b/spec/controllers/test_controller_spec.rb deleted file mode 100644 --- a/spec/controllers/test_controller_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ - -require File.dirname(__FILE__) + '/../spec_helper' - -describe TestController do - - before(:each) do - @john = mock(User, :id => "1", :login => 'john') - @john_result = mock(TestRequest, :id => "1", :user_id => @john.id) - @mary_result = mock(TestRequest, :id => "2", :user_id => @john.id + '1') - User.should_receive(:find).at_least(:once).with(@john.id).and_return(@john) - end - - it "should let user see her testing result" do - TestRequest.should_receive(:find).with(@john_result.id). - and_return(@john_result) - get 'result', {:id => @john_result.id}, {:user_id => @john.id} - response.should be_success - end - - it "should not let user see other's testing result" do - TestRequest.should_receive(:find).with(@mary_result.id). - and_return(@mary_result) - get 'result', {:id => @mary_result.id}, {:user_id => @john.id} - response.should redirect_to(:action => 'index') - end - -end - diff --git a/spec/controllers/user_admin_controller_spec.rb b/spec/controllers/user_admin_controller_spec.rb deleted file mode 100644 --- a/spec/controllers/user_admin_controller_spec.rb +++ /dev/null @@ -1,73 +0,0 @@ -require 'delorean' - -require File.dirname(__FILE__) + '/../spec_helper' -require File.dirname(__FILE__) + '/../config_spec_helper' - -describe UserAdminController, "when manage contest" do - - include ConfigSpecHelperMethods - - fixtures :users - fixtures :problems - fixtures :contests - fixtures :roles - - def change_users_contest_to(user_login_list, contest, reset_timer=false) - post_data = { - :contest => {:id => contest.id}, - :operation => 'assign', - :login_list => user_login_list - } - post_data[:reset_timer] = true if reset_timer - post 'manage_contest', post_data, {:user_id => @admin_user.id} - end - - before(:each) do - @admin_user = users(:mary) - @contest_b = contests(:contest_b) - @james = users(:james) - @jack = users(:jack) - - set_contest_time_limit('3:00') - set_indv_contest_mode - end - - it "should allow admin to see contest management page" do - get 'contest_management', {}, {:user_id => @admin_user.id} - - response.should render_template 'user_admin/contest_management' - end - - it "should change users' contest" do - change_users_contest_to("james\njack", @contest_b) - response.should redirect_to :action => 'contest_management' - - @james.contests(true).should include @contest_b - @jack.contests(true).should_not include @contest_a - end - - it "should reset users' timer when their contests change" do - @james.update_start_time - - Delorean.time_travel_to(190.minutes.since) do - @james.contest_finished?.should be_true - - change_users_contest_to("james", @contest_b, true) - - @james.contest_finished?.should be_false - end - end - - it "should set forced_logout flag for users when their contests change" do - @james.update_start_time - - Delorean.time_travel_to(190.minutes.since) do - @james.contest_finished?.should be_true - - change_users_contest_to("james", @contest_b, true) - - @james.contest_stat(true).forced_logout.should be_true - end - end - -end diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb deleted file mode 100644 --- a/spec/controllers/users_controller_spec.rb +++ /dev/null @@ -1,100 +0,0 @@ - -require File.dirname(__FILE__) + '/../spec_helper' - -describe UsersController, "when a new user registers" do - - before(:each) do - # create john - - @john_info = {:login => 'john', - :full_name => 'John John', - :email => 'john@space.com'} - @john = User.new(@john_info) - - @john_activation_key = "123456" - - @john.should_receive(:activation_key). - any_number_of_times. - and_return(@john_activation_key) - - Configuration.new(:key => 'system.online_registration', - :value_type => 'boolean', - :value => 'true').save - - get :new - response.should render_template('users/new') - end - - it "should show the new form again when user information is invalid" do - User.should_receive(:new).with(any_args()).and_return(@john) - @john.should_receive(:activated=).with(false) - @john.should_receive(:valid?).and_return(false) - @john.should_not_receive(:save) - - post :register, :login => @john_info[:login], - :full_name => @john_info[:full_name], - :email => @john_info[:email] - - response.should render_template('users/new') - end - - it "should create unactivated user and send e-mail with activation key" do - User.should_receive(:new).with(any_args()).and_return(@john) - @john.should_receive(:activated=).with(false) - @john.should_receive(:valid?).and_return(true) - @john.should_receive(:save).and_return(true) - - smtp_mock = mock("smtp") - smtp_mock.should_receive(:send_message) do |msg,fr,to| - to.should == [@john_info[:email]] - msg.index(@john_activation_key).should_not be_nil - end - - Net::SMTP.should_receive(:start). - with(any_args()). - and_yield(smtp_mock) - - post :register, :login => @john_info[:login], - :full_name => @john_info[:full_name], - :email => @john_info[:email] - - response.should render_template('users/new_splash') - end - - it "should create unactivated user and return error page when e-mail sending error" do - User.should_receive(:new).with(any_args()).and_return(@john) - @john.should_receive(:activated=).with(false) - @john.should_receive(:valid?).and_return(true) - @john.should_receive(:save).and_return(true) - - smtp_mock = mock("smtp") - smtp_mock.should_receive(:send_message). - and_throw(:error) - - Net::SMTP.should_receive(:start). - with(any_args()). - and_yield(smtp_mock) - - post :register, :login => @john_info[:login], - :full_name => @john_info[:full_name], - :email => @john_info[:email] - - response.should render_template('users/email_error') - end - - it "should activate user with valid activation key" do - login = @john_info[:login] - User.should_receive(:find_by_login). - with(login). - and_return(@john) - User.should_not_receive(:find_by_email) - @john.should_receive(:valid?).and_return(true) - @john.should_receive(:activated=).with(true) - @john.should_receive(:save).and_return(true) - - get :confirm, :login => login, :activation => @john_activation_key - - response.should render_template('users/confirm') - end - -end diff --git a/spec/helpers/sources_helper_spec.rb b/spec/helpers/sources_helper_spec.rb deleted file mode 100644 --- a/spec/helpers/sources_helper_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'spec_helper' - -# Specs in this file have access to a helper object that includes -# the SourcesHelper. For example: -# -# describe SourcesHelper 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 -describe SourcesHelper do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/helpers/submissions_helper_spec.rb b/spec/helpers/submissions_helper_spec.rb deleted file mode 100644 --- a/spec/helpers/submissions_helper_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'spec_helper' - -# Specs in this file have access to a helper object that includes -# the SubmissionsHelper. For example: -# -# describe SubmissionsHelper 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 -describe SubmissionsHelper do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/integration/contest_managements_spec.rb b/spec/integration/contest_managements_spec.rb deleted file mode 100644 --- a/spec/integration/contest_managements_spec.rb +++ /dev/null @@ -1,136 +0,0 @@ -require 'spec_helper' -require 'config_spec_helper' -require 'delorean' - -describe "ContestManagements" do - include ConfigSpecHelperMethods - - fixtures :users - fixtures :problems - fixtures :contests - fixtures :roles - - before(:each) do - @admin_user = users(:mary) - @contest_b = contests(:contest_b) - @james = users(:james) - @jack = users(:jack) - - set_contest_time_limit('3:00') - set_indv_contest_mode - enable_multicontest - end - - it "should reset users' timer when their contests change" do - session = open_session - session.extend(MainSessionMethods) - - james_login_and_get_main_list(session) - session.response.should_not have_text(/OVER/) - - Delorean.time_travel_to(190.minutes.since) do - session.get_main_list - session.response.should have_text(/OVER/) - - session.get '/' # logout - session.get '/main/list' # clearly log out - session.response.should_not render_template 'main/list' - - admin_change_users_contest_to("james", @contest_b, true) - - james_login_and_get_main_list(session) - session.response.should_not have_text(/OVER/) - end - end - - it "should force users to log out when their contests change" do - session = open_session - session.extend(MainSessionMethods) - - james_login_and_get_main_list(session) - session.response.should_not have_text(/OVER/) - - Delorean.time_travel_to(190.minutes.since) do - session.get_main_list - session.response.should have_text(/OVER/) - - admin_change_users_contest_to("james", @contest_b, true) - - session.get '/main/list' - session.response.should_not render_template 'main/list' - session.should be_redirect - - Delorean.time_travel_to(200.minutes.since) do - james_login_and_get_main_list(session) - session.response.should_not have_text(/OVER/) - end - end - end - - it "should maintain admin logged-in sessions even when their contests change" do - session = open_session - session.extend(MainSessionMethods) - - session.login('mary', 'goodbye') - session.get_main_list - session.response.should_not have_text(/OVER/) - - Delorean.time_travel_to(190.minutes.since) do - session.get_main_list - session.response.should have_text(/OVER/) - - admin_change_users_contest_to("mary", @contest_b, true) - - session.get '/main/list' - session.response.should render_template 'main/list' - end - end - - private - - module MainSessionMethods - def login(login_name, password) - post '/login/login', :login => login_name, :password => password - assert_redirected_to '/main/list' - end - - def get_main_list - get '/main/list' - assert_template 'main/list' - end - - def get_main_list_and_assert_logout - get '/main/list' - assert_redirected_to '/main' - end - end - - module ContestManagementSessionMethods - def change_users_contest_to(user_login_list, contest, reset_timer=false) - post_data = { - :contest => {:id => contest.id}, - :operation => 'assign', - :login_list => user_login_list - } - post_data[:reset_timer] = true if reset_timer - post '/user_admin/manage_contest', post_data - end - end - - def admin_change_users_contest_to(user_list, contest, reset_timer) - admin_session = open_session - admin_session.extend(MainSessionMethods) - admin_session.extend(ContestManagementSessionMethods) - - admin_session.login('mary','goodbye') - admin_session.get '/main/list' - admin_session.change_users_contest_to(user_list, contest, reset_timer) - end - - def james_login_and_get_main_list(session) - session.login('james', 'morning') - session.get_main_list - end - -end - diff --git a/spec/models/configuration_spec.rb b/spec/models/configuration_spec.rb deleted file mode 100644 --- a/spec/models/configuration_spec.rb +++ /dev/null @@ -1,95 +0,0 @@ - -require File.dirname(__FILE__) + '/../spec_helper' - -describe Configuration, "when using cache" do - - before(:each) do - Configuration.cache = true - @int_config = mock(Configuration, - :id => 1, - :key => 'mode', - :value_type => 'integer', - :value => '30') - - @string_config = mock(Configuration, - :id => 2, - :key => 'title', - :value_type => 'string', - :value => 'Hello') - - @boolean_config = mock(Configuration, - :id => 3, - :key => 'single_user_mode', - :value_type => 'boolean', - :value => 'true') - end - - after(:each) do - Configuration.cache = false - end - - it "should retrieve int config" do - Configuration.should_receive(:find).once.with(:all). - and_return([@int_config, @string_config, @boolean_config]) - - Configuration.clear - val = Configuration.get('mode') - val.should == 30 - end - - it "should retrieve boolean config" do - Configuration.should_receive(:find).once.with(:all). - and_return([@int_config, @string_config, @boolean_config]) - - Configuration.clear - val = Configuration.get('single_user_mode') - val.should == true - end - - it "should retrieve string config" do - Configuration.should_receive(:find).once.with(:all). - and_return([@int_config, @string_config, @boolean_config]) - - Configuration.clear - val = Configuration.get('title') - val.should == "Hello" - end - - it "should retrieve config with []" do - Configuration.should_receive(:find).once.with(:all). - and_return([@int_config, @string_config, @boolean_config]) - - Configuration.clear - val = Configuration['title'] - val.should == "Hello" - end - - it "should read config table once" do - Configuration.should_receive(:find).once.with(:all). - and_return([@int_config, @string_config, @boolean_config]) - - Configuration.clear - val = Configuration.get('title') - val.should == "Hello" - val = Configuration.get('single_user_mode') - val.should == true - val = Configuration.get('mode') - val.should == 30 - end - - it "should be able to reload config" do - Configuration.should_receive(:find).twice.with(:all). - and_return([@int_config, @string_config, @boolean_config], - [mock(Configuration, - :key => 'title', :value_type => 'string', - :value => 'Goodbye')]) - - Configuration.clear - val = Configuration.get('title') - val.should == "Hello" - Configuration.reload - val = Configuration.get('title') - val.should == "Goodbye" - end - -end diff --git a/spec/models/login_spec.rb b/spec/models/login_spec.rb deleted file mode 100644 --- a/spec/models/login_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe Login do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/models/site_spec.rb b/spec/models/site_spec.rb deleted file mode 100644 --- a/spec/models/site_spec.rb +++ /dev/null @@ -1,48 +0,0 @@ - -require File.dirname(__FILE__) + '/../spec_helper' - -describe Site do - - before(:each) do - start_time = Time.local(2008,5,10,9,00).gmtime - @site = Site.new({:name => 'Test site', - :started => true, - :start_time => start_time }) - @site.stub!(:start_time). - any_number_of_times. - and_return(start_time) - @site.stub!(:started).any_number_of_times.and_return(true) - end - - it "should report that the contest is not finished when the contest time limit is not set" do - Configuration.should_receive(:[]).with('contest.time_limit'). - and_return('unlimit') - @site.finished?.should == false - end - - it "should report that the contest is finished when the contest is over" do - Configuration.should_receive(:[]).with('contest.time_limit'). - and_return('5:00') - Time.stub!(:now). - and_return(Time.local(2008,5,10,14,01).gmtime) - @site.finished?.should == true end - - it "should report if the contest is finished correctly, when the contest is over, and the contest time contains some minutes" do - Configuration.should_receive(:[]).twice.with('contest.time_limit'). - and_return('5:15') - Time.stub!(:now). - and_return(Time.local(2008,5,10,14,14)) - @site.finished?.should == false - Time.stub!(:now). - and_return(Time.local(2008,5,10,14,16)) - @site.finished?.should == true - end - - it "should report that the contest is not finished, when the time is exactly at the finish time" do - Configuration.should_receive(:[]).with('contest.time_limit'). - and_return('5:00') - Time.stub!(:now).and_return(Time.local(2008,5,10,14,00)) - @site.finished?.should == false - end - -end diff --git a/spec/models/submission_spec.rb b/spec/models/submission_spec.rb deleted file mode 100644 --- a/spec/models/submission_spec.rb +++ /dev/null @@ -1,37 +0,0 @@ - -require File.dirname(__FILE__) + '/../spec_helper' - -describe Submission, "when verifying user submission" do - - before(:each) do - @submission = Submission.new - @submission.source = < 'cpp', :ext => 'cpp') - Language.should_receive(:find_by_name).with('C++').and_return(langcpp) - Submission.find_language_in_source(@submission.source).should == langcpp - end - - it "should find problem in source, when there is any" do - problem = stub(Problem, :name => 'testproblem') - Problem.should_receive(:find_by_name).with('testproblem').and_return(problem) - Submission.find_problem_in_source(@submission.source).should == problem - end - - it "should return nil when it cannot find problem in source" do - Submission.find_problem_in_source(< @user, - :problem => nil, - :submission => @submission, - :input_file_name => "somefile") - test_request.save.should == false - test_request.errors['problem'].should_not be_nil - end - - it "should validates that problem is available" do - @problem.should_receive(:available).and_return(false) - test_request = TestRequest.new(:user => @user, - :problem => @problem, - :submission => @submission, - :input_file_name => "somefile") - test_request.save.should == false - end - - it "should validates valid submission" do - @problem.should_receive(:available).and_return(true) - test_request = TestRequest.new(:user_id => @user.id, - :problem => @problem, - :submission => nil, - :input_file_name => "somefile") - test_request.save.should == false - end - -end diff --git a/spec/models/testcases_spec.rb b/spec/models/testcases_spec.rb deleted file mode 100644 --- a/spec/models/testcases_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe Testcases do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb deleted file mode 100644 --- a/spec/models/user_spec.rb +++ /dev/null @@ -1,163 +0,0 @@ -require File.dirname(__FILE__) + '/../spec_helper' -require File.dirname(__FILE__) + '/../config_spec_helper' - -describe User do - - before(:each) do - @password = "hello" - @salt = "123" - @john = stub_model(User, :salt => @salt, - :hashed_password => User.encrypt(@password,@salt)) - end - - it "should be authenticated if activated" do - @john.should_receive(:activated).and_return(true) - @john.authenticated?(@password).should == true - end - - it "should not be authenticated if inactivated" do - @john.should_receive(:activated).and_return(false) - @john.authenticated?(@password).should == false - end - - it "should not be authenticated if incorrect password is provided" do - @john.should_receive(:activated).and_return(true) - @john.should_receive(:hashed_password).and_return("byebye") - @john.authenticated?(@password).should == false - end - -end - -describe User, "during registration" do - - class User - public :encrypt_new_password - end - - before(:each) do - @john = User.new(:login => 'john', :password => 'hello') - @john.encrypt_new_password - end - - it "should produce and accept activation key" do - activation_key = @john.activation_key - - @john.verify_activation_key(activation_key).should == true - end - - it "should not accept invalid activation key" do - @john.verify_activation_key("12345").should == false - end -end - -describe User, "when re-register with the same e-mail" do - - before(:each) do - @mary_email = 'mary@in.th' - - @time_first_register = Time.local(2008,5,10,9,00).gmtime - - @mary_first = mock_model(User, - :login => 'mary1', - :password => 'hello', - :email => @mary_email, - :created_at => @time_first_register) - @mary_second = User.new(:login => 'mary2', - :password => 'hello', - :email => @mary_email) - User.stub!(:find_by_email). - with(@mary_email, {:order => "created_at DESC"}). - and_return(@mary_first) - end - - class User - public :enough_time_interval_between_same_email_registrations - end - - it "should not be allowed if the time interval is less than 5 mins" do - time_now = @time_first_register + 4.minutes - Time.stub!(:now).and_return(time_now) - - @mary_second.enough_time_interval_between_same_email_registrations - @mary_second.errors.length.should_not be_zero - end - - it "should be allowed if the time interval is more than 5 mins" do - time_now = @time_first_register + 6.minutes - Time.stub!(:now).and_return(time_now) - - @mary_second.enough_time_interval_between_same_email_registrations - @mary_second.errors.length.should be_zero - end - -end - -describe User, "as a class" do - - it "should be able to generate random password" do - password1 = User.random_password - password2 = User.random_password - - password1.should_not == password2 - end - -end - -describe User, "when requesting problem description," do - - include ConfigSpecHelperMethods - - fixtures :users - fixtures :problems - - before(:each) do - @james = users(:james) - @john = users(:john) - @jack = users(:jack) - @add = problems(:one) - @easy = problems(:easy) - @hard = problems(:hard) - end - - it "should check if a problem is in user's contests" do - @james.problem_in_user_contests?(@easy).should be_true - @james.problem_in_user_contests?(@hard).should be_false - - @john.problem_in_user_contests?(@easy).should be_false - @john.problem_in_user_contests?(@hard).should be_false - end - - it "should be able to view problem in user's contests, when multicontests is on" do - enable_multicontest - @james.can_view_problem?(@easy).should be_true - @jack.can_view_problem?(@easy).should be_true - @jack.can_view_problem?(@hard).should be_true - end - - it "should not be able to view problem not in user's contests, when multicontests is on" do - enable_multicontest - @james.can_view_problem?(@hard).should be_false - end - - it "with no assigned contest should not be able to view problem in contests when multicontests is on" do - enable_multicontest - @john.can_view_problem?(@add).should be_true - @john.can_view_problem?(@easy).should be_false - @john.can_view_problem?(@hard).should be_false - end - - it "should be able to view all available problems, when multicontests is off" do - disable_multicontest - @john.can_view_problem?(@easy).should be_true - @john.can_view_problem?(@hard).should be_true - @james.can_view_problem?(@easy).should be_true - @james.can_view_problem?(@hard).should be_true - end - - it "should be able to view public problems, when multicontests is on" do - enable_multicontest - @john.can_view_problem?(@add).should be_true - @james.can_view_problem?(@add).should be_true - end - -end diff --git a/spec/rcov.opts b/spec/rcov.opts deleted file mode 100644 --- a/spec/rcov.opts +++ /dev/null @@ -1,2 +0,0 @@ ---exclude "spec/*,gems/*" ---rails \ No newline at end of file diff --git a/spec/requests/submissions_spec.rb b/spec/requests/submissions_spec.rb deleted file mode 100644 --- a/spec/requests/submissions_spec.rb +++ /dev/null @@ -1,11 +0,0 @@ -require 'spec_helper' - -describe "Submissions" do - describe "GET /submissions" do - it "works! (now write some real specs)" do - # Run the generator again with the --webrat flag if you want to use webrat methods/matchers - get submissions_path - response.status.should be(200) - end - end -end diff --git a/spec/routing/submissions_routing_spec.rb b/spec/routing/submissions_routing_spec.rb deleted file mode 100644 --- a/spec/routing/submissions_routing_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -require "spec_helper" - -describe SubmissionsController do - describe "routing" do - - it "routes to #index" do - get("/submissions").should route_to("submissions#index") - end - - it "routes to #new" do - get("/submissions/new").should route_to("submissions#new") - end - - it "routes to #show" do - get("/submissions/1").should route_to("submissions#show", :id => "1") - end - - it "routes to #edit" do - get("/submissions/1/edit").should route_to("submissions#edit", :id => "1") - end - - it "routes to #create" do - post("/submissions").should route_to("submissions#create") - end - - it "routes to #update" do - put("/submissions/1").should route_to("submissions#update", :id => "1") - end - - it "routes to #destroy" do - delete("/submissions/1").should route_to("submissions#destroy", :id => "1") - end - - end -end diff --git a/spec/spec.opts b/spec/spec.opts deleted file mode 100644 --- a/spec/spec.opts +++ /dev/null @@ -1,4 +0,0 @@ ---colour ---format progress ---loadby mtime ---reverse diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb deleted file mode 100644 --- a/spec/spec_helper.rb +++ /dev/null @@ -1,38 +0,0 @@ -# This file is copied to spec/ when you run 'rails generate rspec:install' -ENV["RAILS_ENV"] ||= 'test' -require File.expand_path("../../config/environment", __FILE__) -require 'rspec/rails' -require 'rspec/autorun' - -# Requires supporting ruby files with custom matchers and macros, etc, -# in spec/support/ and its subdirectories. -Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} - -RSpec.configure do |config| - # ## Mock Framework - # - # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line: - # - # config.mock_with :mocha - # config.mock_with :flexmock - # config.mock_with :rr - - # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures - config.fixture_path = "#{::Rails.root}/spec/fixtures" - - # If you're not using ActiveRecord, or you'd prefer not to run each of your - # examples within a transaction, remove the following line or assign false - # instead of true. - config.use_transactional_fixtures = true - - # If true, the base class of anonymous controllers will be inferred - # automatically. This will be the default behavior in future versions of - # rspec-rails. - config.infer_base_class_for_anonymous_controllers = false - - # Run specs in random order to surface order dependencies. If you find an - # order dependency and want to debug it, you can fix the order by providing - # the seed, which is printed after each run. - # --seed 1234 - config.order = "random" -end diff --git a/spec/views/sources/direct_edit.html.haml_spec.rb b/spec/views/sources/direct_edit.html.haml_spec.rb deleted file mode 100644 --- a/spec/views/sources/direct_edit.html.haml_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe "sources/direct_edit.html.haml" do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/views/submissions/edit.html.haml_spec.rb b/spec/views/submissions/edit.html.haml_spec.rb deleted file mode 100644 --- a/spec/views/submissions/edit.html.haml_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'spec_helper' - -describe "submissions/edit" do - before(:each) do - @submission = assign(:submission, stub_model(Submission)) - end - - it "renders the edit submission form" do - render - - # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form[action=?][method=?]", submission_path(@submission), "post" do - end - end -end diff --git a/spec/views/submissions/index.html.haml_spec.rb b/spec/views/submissions/index.html.haml_spec.rb deleted file mode 100644 --- a/spec/views/submissions/index.html.haml_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'spec_helper' - -describe "submissions/index" do - before(:each) do - assign(:submissions, [ - stub_model(Submission), - stub_model(Submission) - ]) - end - - it "renders a list of submissions" do - render - # Run the generator again with the --webrat flag if you want to use webrat matchers - end -end diff --git a/spec/views/submissions/new.html.haml_spec.rb b/spec/views/submissions/new.html.haml_spec.rb deleted file mode 100644 --- a/spec/views/submissions/new.html.haml_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'spec_helper' - -describe "submissions/new" do - before(:each) do - assign(:submission, stub_model(Submission).as_new_record) - end - - it "renders new submission form" do - render - - # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form[action=?][method=?]", submissions_path, "post" do - end - end -end diff --git a/spec/views/submissions/show.html.haml_spec.rb b/spec/views/submissions/show.html.haml_spec.rb deleted file mode 100644 --- a/spec/views/submissions/show.html.haml_spec.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'spec_helper' - -describe "submissions/show" do - before(:each) do - @submission = assign(:submission, stub_model(Submission)) - end - - it "renders attributes in

" do - render - # Run the generator again with the --webrat flag if you want to use webrat matchers - end -end diff --git a/test/fixtures/configurations.yml b/test/fixtures/configurations.yml deleted file mode 100644 --- a/test/fixtures/configurations.yml +++ /dev/null @@ -1,7 +0,0 @@ -# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html - -# one: -# column: value -# -# two: -# column: value diff --git a/test/integration/login_test.rb b/test/integration/login_test.rb new file mode 100644 --- /dev/null +++ b/test/integration/login_test.rb @@ -0,0 +1,13 @@ +require 'test_helper' + +class LoginTest < ActionDispatch::IntegrationTest + # test "the truth" do + # assert true + # end + + test "login with valid information" do + get root_path + assert_response :success + + end +end diff --git a/test/performance/browsing_test.rb b/test/performance/browsing_test.rb deleted file mode 100644 --- a/test/performance/browsing_test.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'test_helper' -require 'rails/performance_test_help' - -class BrowsingTest < ActionDispatch::PerformanceTest - # Refer to the documentation for all available options - # self.profile_options = { :runs => 5, :metrics => [:wall_time, :memory] - # :output => 'tmp/performance', :formats => [:flat] } - - def test_homepage - get '/' - end -end diff --git a/test/unit/.gitkeep b/test/unit/.gitkeep deleted file mode 100644 diff --git a/test/unit/announcement_test.rb b/test/unit/announcement_test.rb deleted file mode 100644 --- a/test/unit/announcement_test.rb +++ /dev/null @@ -1,8 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' - -class AnnouncementTest < ActiveSupport::TestCase - # Replace this with your real tests. - def test_truth - assert true - end -end diff --git a/test/unit/configuration_test.rb b/test/unit/configuration_test.rb deleted file mode 100644 --- a/test/unit/configuration_test.rb +++ /dev/null @@ -1,8 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' - -class ConfigurationTest < ActiveSupport::TestCase - # Replace this with your real tests. - def test_truth - assert true - end -end diff --git a/test/unit/contest_test.rb b/test/unit/contest_test.rb deleted file mode 100644 --- a/test/unit/contest_test.rb +++ /dev/null @@ -1,8 +0,0 @@ -require 'test_helper' - -class ContestTest < ActiveSupport::TestCase - # Replace this with your real tests. - test "the truth" do - assert true - end -end diff --git a/test/unit/country_test.rb b/test/unit/country_test.rb deleted file mode 100644 --- a/test/unit/country_test.rb +++ /dev/null @@ -1,8 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' - -class CountryTest < ActiveSupport::TestCase - # Replace this with your real tests. - def test_truth - assert true - end -end diff --git a/test/unit/description_test.rb b/test/unit/description_test.rb deleted file mode 100644 --- a/test/unit/description_test.rb +++ /dev/null @@ -1,8 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' - -class DescriptionTest < ActiveSupport::TestCase - # Replace this with your real tests. - def test_truth - assert true - end -end diff --git a/test/unit/grader_process_test.rb b/test/unit/grader_process_test.rb deleted file mode 100644 --- a/test/unit/grader_process_test.rb +++ /dev/null @@ -1,8 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' - -class GraderProcessTest < ActiveSupport::TestCase - # Replace this with your real tests. - def test_truth - assert true - end -end diff --git a/test/unit/helpers/contest_management_helper_test.rb b/test/unit/helpers/contest_management_helper_test.rb deleted file mode 100644 --- a/test/unit/helpers/contest_management_helper_test.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'test_helper' - -class ContestManagementHelperTest < ActionView::TestCase -end diff --git a/test/unit/helpers/contests_helper_test.rb b/test/unit/helpers/contests_helper_test.rb deleted file mode 100644 --- a/test/unit/helpers/contests_helper_test.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'test_helper' - -class ContestsHelperTest < ActionView::TestCase -end diff --git a/test/unit/language_test.rb b/test/unit/language_test.rb deleted file mode 100644 --- a/test/unit/language_test.rb +++ /dev/null @@ -1,10 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' - -class LanguageTest < Test::Unit::TestCase - fixtures :languages - - # Replace this with your real tests. - def test_truth - assert true - end -end diff --git a/test/unit/message_test.rb b/test/unit/message_test.rb deleted file mode 100644 --- a/test/unit/message_test.rb +++ /dev/null @@ -1,8 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' - -class MessageTest < ActiveSupport::TestCase - # Replace this with your real tests. - def test_truth - assert true - end -end diff --git a/test/unit/problem_test.rb b/test/unit/problem_test.rb deleted file mode 100644 --- a/test/unit/problem_test.rb +++ /dev/null @@ -1,10 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' - -class ProblemTest < Test::Unit::TestCase - fixtures :problems - - # Replace this with your real tests. - def test_truth - assert true - end -end diff --git a/test/unit/right_test.rb b/test/unit/right_test.rb deleted file mode 100644 --- a/test/unit/right_test.rb +++ /dev/null @@ -1,10 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' - -class RightTest < Test::Unit::TestCase - fixtures :rights - - # Replace this with your real tests. - def test_truth - assert true - end -end diff --git a/test/unit/role_test.rb b/test/unit/role_test.rb deleted file mode 100644 --- a/test/unit/role_test.rb +++ /dev/null @@ -1,10 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' - -class RoleTest < Test::Unit::TestCase - fixtures :roles - - # Replace this with your real tests. - def test_truth - assert true - end -end diff --git a/test/unit/site_test.rb b/test/unit/site_test.rb deleted file mode 100644 --- a/test/unit/site_test.rb +++ /dev/null @@ -1,8 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' - -class SiteTest < ActiveSupport::TestCase - # Replace this with your real tests. - def test_truth - assert true - end -end diff --git a/test/unit/submission_test.rb b/test/unit/submission_test.rb deleted file mode 100644 --- a/test/unit/submission_test.rb +++ /dev/null @@ -1,10 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' - -class SubmissionTest < Test::Unit::TestCase - fixtures :submissions - - # Replace this with your real tests. - def test_truth - assert true - end -end diff --git a/test/unit/task_test.rb b/test/unit/task_test.rb deleted file mode 100644 --- a/test/unit/task_test.rb +++ /dev/null @@ -1,41 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' - -class TaskTest < Test::Unit::TestCase - fixtures :tasks - - self.use_transactional_fixtures = false - - def test_get_inqueue_simple - task1 = Task.get_inqueue_and_change_status(Task::STATUS_GRADING) - - assert_equal task1.id, 3, "should get the earliest task" - assert_equal task1.status, Task::STATUS_GRADING, "status changes" - - task2 = Task.get_inqueue_and_change_status(Task::STATUS_GRADING) - - assert_equal task2.id, 4, "should get the next task" - assert_equal task2.status, Task::STATUS_GRADING, "status changes" - end - - def generate_tasks(n) - n.times do |i| - Task.create(:submission_id => i, - :status => Task::STATUS_INQUEUE, - :create_at => Time.now + i.minutes) - end - end - - # use the process version in /test/concurrent instead - def UNUSED_test_get_inqueue_concurrent - ActiveRecord::Base.allow_concurrency = true - - task1 = Task.get_inqueue_and_change_status(Task::STATUS_GRADING) - - assert_equal task1.id, 3, "should get the earliest task" - assert_equal task1.status, Task::STATUS_GRADING, "status changes" - - ActiveRecord::Base.verify_active_connections! - end - -end - diff --git a/test/unit/test_pair_test.rb b/test/unit/test_pair_test.rb deleted file mode 100644 --- a/test/unit/test_pair_test.rb +++ /dev/null @@ -1,8 +0,0 @@ -require 'test_helper' - -class TestPairTest < ActiveSupport::TestCase - # Replace this with your real tests. - test "the truth" do - assert true - end -end diff --git a/test/unit/test_request_test.rb b/test/unit/test_request_test.rb deleted file mode 100644 --- a/test/unit/test_request_test.rb +++ /dev/null @@ -1,8 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' - -class TestRequestTest < ActiveSupport::TestCase - # Replace this with your real tests. - def test_truth - assert true - end -end diff --git a/test/unit/user_contest_stat_test.rb b/test/unit/user_contest_stat_test.rb deleted file mode 100644 --- a/test/unit/user_contest_stat_test.rb +++ /dev/null @@ -1,8 +0,0 @@ -require 'test_helper' - -class UserContestStatTest < ActiveSupport::TestCase - # Replace this with your real tests. - test "the truth" do - assert true - end -end diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb deleted file mode 100644 --- a/test/unit/user_test.rb +++ /dev/null @@ -1,10 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' - -class UserTest < Test::Unit::TestCase - fixtures :users - - # Replace this with your real tests. - def test_truth - assert true - end -end