123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224 |
- require "#{File.dirname(__FILE__)}/spec_helper"
- include SpecHelper
- describe "routes" do
- describe 'basic auth' do
- it "ohne auth" do
- get '/info'
- last_response.status.must_equal 401
- end
- it "falsche auth" do
- authorize 'oh', 'ah'
- get '/info'
- last_response.status.must_equal 401
- end
- it "korrekte auth" do
- authorize 'test', 'test'
- get '/info'
- last_response.status.must_equal 200
- end
- end
- describe "Views ok" do
- it "gibt home-view 200 zurück" do
- get '/'
- last_response.status.must_equal 200
- end
- end
- end
- describe "verlauf schüler" do
- before do
- Lehrer.create(:id => 1, :name => "Müller")
- Lehrer.create(:id => 2, :name => "Maier")
- Lehrer.create(:id => 3, :name => "Walter")
- end
- describe "schüler besucht seite zur aktiven Wahl" do
- before do
- Schueler.create(:hashid => "a", :vorname => "A", :klasse => "A1")
- Schueler.create(:hashid => "b", :vorname => "B", :klasse => "B1")
- end
- it "schüler gibt code auf startseite ein und wird umgeleitet" do
- Time.stub :now, Time.parse("Sep 21, 2016, 17:00") do
- post "/hashid", params={:hashid => "a"}
- follow_redirect!
- last_response.body.must_include "Hallo A,"
- end
- end
- it "schüler stellt sich auf als schuko" do
- Time.stub :now, Time.parse("Sep 21, 2016, 17:00") do
- post "/wahl", params={:hashid => "a",:schuko => "on"}
- a = Schueler["a"]
- a.schuko.must_equal true
- a.sprecher.must_be_nil
- end
- end
- it "schüler stellt sich auf als sprecher" do
- Time.stub :now, Time.parse("Sep 21, 2016, 17:00") do
- post "/wahl", params={:hashid => "a",:sprecher => "on"}
- a = Schueler["a"]
- a.sprecher.must_equal true
- a.schuko.must_be_nil
- end
- end
- it "schüler stellt sich auf als sprecher und ändert Daten" do
- Time.stub :now, Time.parse("Sep 21, 2016, 17:00") do
- post "/wahl", params={:hashid => "a",:sprecher => "on"}
- post "/wahl", params={:hashid => "a",:sprecher => "", :schuko => "on", :email => "xyz"}
- a = Schueler["a"]
- a.sprecher.must_be_nil
- a.schuko.must_equal true
- a.email.must_equal "xyz"
- end
- end
- it "schüler stellt sich auf als sprecher und schuko" do
- Time.stub :now, Time.parse("Sep 21, 2016, 17:00") do
- post "/wahl", params={:hashid => "a", :sprecher => "on", :schuko => "on"}
- a = Schueler["a"]
- a.schuko.must_equal true
- a.sprecher.must_equal true
- end
- end
- it "schüler stellt sich auf als schuko und gibt Infos" do
- Time.stub :now, Time.parse("Sep 21, 2016, 17:00") do
- post "/wahl", params={:hashid => "a",:schuko => "on", :nachname => "AA7", :info => "Bin hier"}
- get "/a"
- last_response.body.must_include "AA7"
- last_response.body.must_include "Bin hier"
- end
- end
- end
- describe "schüler besucht seite zur passiven Wahl" do
- before do
- Schueler.create(:hashid => "a", :vorname => "A", :klasse => "A1", :schuko => true, :sprecher => true)
- Schueler.create(:hashid => "b", :vorname => "B", :klasse => "B1", :schuko => true, :sprecher => true)
- Schueler.create(:hashid => "c", :schuko => true)
- %w(d e f g h i j k l).each do |s|
- Schueler.create(:hashid => s, :sprecher => true)
- end
- end
- it "schüler gibt code auf startseite ein und wird umgeleitet" do
- Time.stub :now, Time.parse("Oct 1, 2016, 17:00") do
- post "/hashid", params={:hashid => "a"}
- follow_redirect!
- last_response.body.must_include "Hallo A,"
- end
- end
- it "schüler will sich als schuko aufstellen nach wahlbeginn" do
- Time.stub :now, Time.parse("Oct 1, 2016, 17:00") do
- post "/wahl", params={:hashid => "d",:schuko => "on"}
- a = Schueler["d"]
- a.sprecher.must_equal true
- a.schuko.must_be_nil
- follow_redirect!
- last_response.body.must_include "Wahl hat bereits begonnen"
- end
- end
- it "schüler wählt jeweils zwei" do
- Time.stub :now, Time.parse("Oct 1, 2016, 17:00") do
- post "/a", params={:sprecher => ["a", "b"], :schuko => ["a", "b"], :lehrer => [1,2]}
- a = Schueler["a"]
- a.gewaehlt.must_equal true
- Sprecher.count.must_equal 2
- Schuko.count.must_equal 2
- Verbindungslehrer.count.must_equal 2
- end
- end
- it "schüler wählt jeweils zwei und versucht es nochmal" do
- Time.stub :now, Time.parse("Oct 1, 2016, 17:00") do
- post "/a", params={:sprecher => ["a", "b"], :schuko => ["a", "b"], :lehrer => [1,2]}
- post "/a", params={:sprecher => ["d"]}
- a = Schueler["a"]
- a.gewaehlt.must_equal true
- Sprecher.count.must_equal 2
- Schuko.count.must_equal 2
- Verbindungslehrer.count.must_equal 2
- end
- end
- it "schüler wählt drei sprecher statt zwei" do
- Time.stub :now, Time.parse("Oct 1, 2016, 17:00") do
- post "/a", params={:sprecher => ["a", "b", "d"]}
- a = Schueler["a"]
- a.gewaehlt.must_be_nil
- Sprecher.count.must_equal 0
- end
- end
- it "schüler wählt neun schuko statt acht" do
- Time.stub :now, Time.parse("Oct 1, 2016, 17:00") do
- post "/a", params={:schuko => %w(d e f g h i j k l)}
- a = Schueler["a"]
- a.gewaehlt.must_be_nil
- Schuko.count.must_equal 0
- end
- end
- it "schüler wählt drei lehrer statt zwei" do
- Time.stub :now, Time.parse("Oct 1, 2016, 17:00") do
- post "/a", params={:lehrer => [1,2,3]}
- a = Schueler["a"]
- a.gewaehlt.must_be_nil
- Verbindungslehrer.count.must_equal 0
- end
- end
- it "schüler wählt nichtaufgestellten schuko" do
- Time.stub :now, Time.parse("Oct 1, 2016, 17:00") do
- post "/a", params={:schuko => %w(d)}
- a = Schueler["a"]
- a.gewaehlt.must_be_nil
- Schuko.count.must_equal 0
- end
- end
- end
- describe "schüler besucht seite nach der wahl" do
- before do
- Schueler.create(:hashid => "a", :vorname => "A", :klasse => "A1", :schuko => true, :sprecher => true)
- Schueler.create(:hashid => "b", :vorname => "B", :klasse => "B1", :schuko => true, :sprecher => true)
- Schueler.create(:hashid => "c", :schuko => true)
- Schueler.create(:hashid => "d")
- end
- it "schüler gibt code auf startseite ein und wird umgeleitet" do
- Time.stub :now, Time.parse("Oct 3, 2016, 19:00") do
- post "/hashid", params={:hashid => "a"}
- follow_redirect!
- last_response.body.must_include "Hallo A,"
- end
- end
- it "schüler will sich als schuko aufstellen nach wahlbeginn" do
- Time.stub :now, Time.parse("Oct 3, 2016, 19:00") do
- post "/wahl", params={:hashid => "d",:schuko => "on"}
- a = Schueler["d"]
- a.sprecher.must_be_nil
- a.schuko.must_be_nil
- end
- end
- it "schüler wählt jeweils zwei und kann es nicht mehr" do
- Time.stub :now, Time.parse("Oct 3, 2016, 19:00") do
- post "/a", params={:sprecher => ["a", "b"], :schuko => ["a", "b"], :lehrer => [1,2]}
- a = Schueler["a"]
- a.gewaehlt.must_be_nil
- Sprecher.count.must_equal 0
- Schuko.count.must_equal 0
- Verbindungslehrer.count.must_equal 0
- end
- end
- end
- end
|