diff --git a/.project b/.project index fa0fd95..e3474de 100644 --- a/.project +++ b/.project @@ -12,6 +12,7 @@ + com.aptana.projects.webnature org.radrails.rails.core.railsnature com.aptana.ruby.core.rubynature diff --git a/Gemfile b/Gemfile index 5f791cc..2658b93 100644 --- a/Gemfile +++ b/Gemfile @@ -24,7 +24,7 @@ gem 'jbuilder', '~> 2.0' gem 'sdoc', '~> 0.4.0', group: :doc # Use ActiveModel has_secure_password -# gem 'bcrypt', '~> 3.1.7' +gem 'bcrypt', '~> 3.1.7' # Use unicorn as the app server # gem 'unicorn' diff --git a/Gemfile.lock b/Gemfile.lock index b6c0f91..cbac2c6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -28,6 +28,7 @@ GEM thread_safe (~> 0.1) tzinfo (~> 1.1) arel (5.0.1.20140414130214) + bcrypt (3.1.9-x86-mingw32) builder (3.2.2) coffee-rails (4.0.1) coffee-script (>= 2.2.0) @@ -109,6 +110,7 @@ PLATFORMS x86-mingw32 DEPENDENCIES + bcrypt (~> 3.1.7) coffee-rails (~> 4.0.0) jbuilder (~> 2.0) jquery-rails diff --git a/app/assets/javascripts/answers.js.coffee b/app/assets/javascripts/answers.js.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/answers.js.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/javascripts/hackers.js.coffee b/app/assets/javascripts/hackers.js.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/hackers.js.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/javascripts/logout.js.coffee b/app/assets/javascripts/logout.js.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/logout.js.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/javascripts/sessions.js.coffee b/app/assets/javascripts/sessions.js.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/sessions.js.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/answers.css.scss b/app/assets/stylesheets/answers.css.scss new file mode 100644 index 0000000..24dc3ae --- /dev/null +++ b/app/assets/stylesheets/answers.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Answers controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/hackers.css.scss b/app/assets/stylesheets/hackers.css.scss new file mode 100644 index 0000000..3a13f75 --- /dev/null +++ b/app/assets/stylesheets/hackers.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Hackers controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/logout.css.scss b/app/assets/stylesheets/logout.css.scss new file mode 100644 index 0000000..56a0eae --- /dev/null +++ b/app/assets/stylesheets/logout.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the logout controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/questions.css.scss b/app/assets/stylesheets/questions.css.scss index a7cd45c..2d19a1f 100644 --- a/app/assets/stylesheets/questions.css.scss +++ b/app/assets/stylesheets/questions.css.scss @@ -1,3 +1,13 @@ // Place all the styles related to the Questions controller here. // They will automatically be included in application.css. // You can use Sass (SCSS) here: http://sass-lang.com/ + +// Shifting
 login to the top right of the page
+
+.usernameTB {
+    float: right;
+    text-align: right;
+}
+
+
+
diff --git a/app/assets/stylesheets/sessions.css.scss b/app/assets/stylesheets/sessions.css.scss
new file mode 100644
index 0000000..ccb1ed2
--- /dev/null
+++ b/app/assets/stylesheets/sessions.css.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the Sessions 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/answers_controller.rb b/app/controllers/answers_controller.rb
new file mode 100644
index 0000000..0195833
--- /dev/null
+++ b/app/controllers/answers_controller.rb
@@ -0,0 +1,103 @@
+class AnswersController < ApplicationController
+  before_action :set_answer, only: [:show, :edit, :update, :destroy]
+  before_action :list
+  # GET /answers
+  # GET /answers.json
+  def index
+    @answers = Answer.all
+  end
+  
+  def list
+    @responses = Response.all
+  end
+
+  # GET /answers/1
+  # GET /answers/1.json
+  def show
+  end
+
+  # GET /answers/new
+  def new
+    @answer = Answer.new
+  end
+
+  # GET /answers/1/edit
+  def edit
+  end
+	
+  # POST /answers
+  # POST /answers.json
+  def create
+    @answer = Answer.new(answer_params)
+	@answer.creator_id = session[:id]
+    respond_to do |format|
+      if @answer.save
+        format.html { redirect_to @answer, notice: 'Answer was successfully created.' }
+        format.json { render :show, status: :created, location: @answer }
+      else
+        format.html { render :new }
+        format.json { render json: @answer.errors, status: :unprocessable_entity }
+      end
+    end
+
+  end
+
+  # PATCH/PUT /answers/1
+  # PATCH/PUT /answers/1.json
+  def update
+    respond_to do |format|
+      if @answer.update(answer_params)
+        format.html { redirect_to @answer, notice: 'Answer was successfully updated.' }
+        format.json { render :show, status: :ok, location: @answer }
+      else
+        format.html { render :edit }
+        format.json { render json: @answer.errors, status: :unprocessable_entity }
+      end
+    end
+  end
+
+  # DELETE /answers/1
+  # DELETE /answers/1.json
+  def destroy
+    @answer.destroy
+    respond_to do |format|
+      format.html { redirect_to answers_url, notice: 'Answer was successfully destroyed.' }
+      format.json { head :no_content }
+    end
+  end
+  	# POST /answers
+  # POST /answers.json
+
+  def correct
+    @answer = Answer.find(params[:id])
+	  if @answer.response_score == 0
+      p "fuuuuuuuuuuuuuuuuuucccccccccccccckkkkkkkkkkkkkkkk"
+		@answer.response_score = 1
+		@question = Question.find(@answer.q_response_id)
+		@question.toggle!(:answered)
+		@user = User.find(@answer.creator_id)
+		@user.increment!(:score)
+    
+		@user.save
+		@answer.save
+		@question.save
+		end
+	redirect_to(:back)
+end
+  private
+    # Use callbacks to share common setup or constraints between actions.
+    def set_answer
+      @answer = Answer.find(params[:id])
+    end
+
+    # Never trust parameters from the scary internet, only allow the white list through.
+    def answer_params
+      params.require(:answer).permit(:answer_id, :q_response_id, :creator_id, :response_score, :content, :timestamp)
+    end
+    
+    def answer
+      @answer.response_score=0
+    end
+	
+
+end
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index d83690e..ada5c82 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -2,4 +2,20 @@ class ApplicationController < ActionController::Base
   # Prevent CSRF attacks by raising an exception.
   # For APIs, you may want to use :null_session instead.
   protect_from_forgery with: :exception
+  
+  def current_user  
+    @current_user ||= User.find(session[:user_id]) if session[:user_id]  
+  end  
+  
+  helper_method :current_user
+  
+  before_filter :require_login
+
+private
+
+  def require_login
+    unless session[:id]
+      redirect_to new_session_path
+    end
+  end
 end
diff --git a/app/controllers/hackers_controller.rb b/app/controllers/hackers_controller.rb
new file mode 100644
index 0000000..a9dfef5
--- /dev/null
+++ b/app/controllers/hackers_controller.rb
@@ -0,0 +1,74 @@
+class HackersController < ApplicationController
+  before_action :set_hacker, only: [:show, :edit, :update, :destroy]
+
+  # GET /hackers
+  # GET /hackers.json
+  def index
+    @hackers = Hacker.all
+  end
+
+  # GET /hackers/1
+  # GET /hackers/1.json
+  def show
+  end
+
+  # GET /hackers/new
+  def new
+    @hacker = Hacker.new
+  end
+
+  # GET /hackers/1/edit
+  def edit
+  end
+
+  # POST /hackers
+  # POST /hackers.json
+  def create
+    @hacker = Hacker.new(hacker_params)
+
+    respond_to do |format|
+      if @hacker.save
+        format.html { redirect_to @hacker, notice: 'Hacker was successfully created.' }
+        format.json { render :show, status: :created, location: @hacker }
+      else
+        format.html { render :new }
+        format.json { render json: @hacker.errors, status: :unprocessable_entity }
+      end
+    end
+  end
+
+  # PATCH/PUT /hackers/1
+  # PATCH/PUT /hackers/1.json
+  def update
+    respond_to do |format|
+      if @hacker.update(hacker_params)
+        format.html { redirect_to @hacker, notice: 'Hacker was successfully updated.' }
+        format.json { render :show, status: :ok, location: @hacker }
+      else
+        format.html { render :edit }
+        format.json { render json: @hacker.errors, status: :unprocessable_entity }
+      end
+    end
+  end
+
+  # DELETE /hackers/1
+  # DELETE /hackers/1.json
+  def destroy
+    @hacker.destroy
+    respond_to do |format|
+      format.html { redirect_to hackers_url, notice: 'Hacker was successfully destroyed.' }
+      format.json { head :no_content }
+    end
+  end
+
+  private
+    # Use callbacks to share common setup or constraints between actions.
+    def set_hacker
+      @hacker = Hacker.find(params[:id])
+    end
+
+    # Never trust parameters from the scary internet, only allow the white list through.
+    def hacker_params
+      params.require(:hacker).permit(:username, :password, :first_name, :last_name, :score, :type)
+    end
+end
diff --git a/app/controllers/logout_controller.rb b/app/controllers/logout_controller.rb
new file mode 100644
index 0000000..48b416c
--- /dev/null
+++ b/app/controllers/logout_controller.rb
@@ -0,0 +1,25 @@
+class LogoutController < ApplicationController
+    def new
+    @session = Session.new
+    end
+  
+  
+  skip_before_filter :require_login
+  
+    def create  
+      user = User.find_by_username(params[:username]) 
+      if user && user.authenticate(params[:password])  
+        session[:id] = user.id  
+        reset_session
+        redirect_to root_url, :notice => "Logged in!"  
+      else  
+        flash.now.alert = "Invalid email or password"  
+        render "new"  
+      end  
+    end   
+  
+  def destroy  
+    session.delete(:id) 
+    redirect_to root_url, :notice => "Logged out!"  
+  end 
+end
diff --git a/app/controllers/questions_controller.rb b/app/controllers/questions_controller.rb
index 3e9d951..579c299 100644
--- a/app/controllers/questions_controller.rb
+++ b/app/controllers/questions_controller.rb
@@ -1,15 +1,17 @@
 class QuestionsController < ApplicationController
   before_action :set_question, only: [:show, :edit, :update, :destroy]
-
+	
   # GET /questions
   # GET /questions.json
   def index
     @questions = Question.all
+	
   end
 
   # GET /questions/1
   # GET /questions/1.json
   def show
+  @answers =  Answer.where( q_response_id: @question.id)
   end
 
   # GET /questions/new
@@ -20,6 +22,15 @@ def new
   # GET /questions/1/edit
   def edit
   end
+  
+  # POST /questions
+  # POST /questions.json
+  def answer
+    @question = Question.find(params[:id])
+	  @question.toggle!(:answered) 
+	  @question.save()
+  redirect_to(:back)
+	  end
 
   # POST /questions
   # POST /questions.json
@@ -61,7 +72,6 @@ def destroy
     end
   end
 
-  private
     # Use callbacks to share common setup or constraints between actions.
     def set_question
       @question = Question.find(params[:id])
@@ -71,4 +81,5 @@ def set_question
     def question_params
       params.require(:question).permit(:question_id, :creator_id, :title, :content, :category, :answered, :closing_comment, :timestamp)
     end
+    
 end
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb
new file mode 100644
index 0000000..471d06d
--- /dev/null
+++ b/app/controllers/sessions_controller.rb
@@ -0,0 +1,25 @@
+class SessionsController < ApplicationController  
+  def new  
+  end  
+    def new
+    @session = Session.new
+    end
+  
+  skip_before_filter :require_login
+  
+    def create  
+      user = User.find_by_username(params[:username]) 
+      if user && user.authenticate(params[:password])  
+        session[:id] = user.id  
+        redirect_to root_url, :notice => "Logged in!"  
+      else  
+        flash.now.alert = "Invalid email or password"  
+        render "new"  
+      end  
+    end   
+  
+  def destroy  
+    session.delete(:id) 
+    redirect_to root_url, :notice => "Logged out!"  
+  end  
+end 
\ No newline at end of file
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 8441ffe..8eea749 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -4,9 +4,11 @@ class UsersController < ApplicationController
   # GET /users
   # GET /users.json
   def index
-    @users = User.all
+    @users = User.all.order(score: :desc)
   end
 
+  skip_before_filter :require_login
+
   # GET /users/1
   # GET /users/1.json
   def show
@@ -15,6 +17,8 @@ def show
   # GET /users/new
   def new
     @user = User.new
+	
+ 
   end
 
   # GET /users/1/edit
@@ -25,7 +29,7 @@ def edit
   # POST /users.json
   def create
     @user = User.new(user_params)
-
+    @user.score=0
     respond_to do |format|
       if @user.save
         format.html { redirect_to @user, notice: 'User was successfully created.' }
@@ -61,7 +65,7 @@ def destroy
     end
   end
 
-  private
+
     # Use callbacks to share common setup or constraints between actions.
     def set_user
       @user = User.find(params[:id])
diff --git a/app/helpers/answers_helper.rb b/app/helpers/answers_helper.rb
new file mode 100644
index 0000000..2bbb30d
--- /dev/null
+++ b/app/helpers/answers_helper.rb
@@ -0,0 +1,9 @@
+module AnswersHelper
+  def list
+  @responses = Response.all
+  end
+    def answer_question(answer)
+    return ""
+   end
+   
+end
diff --git a/app/helpers/hackers_helper.rb b/app/helpers/hackers_helper.rb
new file mode 100644
index 0000000..885a3da
--- /dev/null
+++ b/app/helpers/hackers_helper.rb
@@ -0,0 +1,2 @@
+module HackersHelper
+end
diff --git a/app/helpers/logout_helper.rb b/app/helpers/logout_helper.rb
new file mode 100644
index 0000000..b1bf445
--- /dev/null
+++ b/app/helpers/logout_helper.rb
@@ -0,0 +1,2 @@
+module LogoutHelper
+end
diff --git a/app/helpers/questions_helper.rb b/app/helpers/questions_helper.rb
index 2eaab4a..4379775 100644
--- a/app/helpers/questions_helper.rb
+++ b/app/helpers/questions_helper.rb
@@ -1,2 +1,11 @@
 module QuestionsHelper
+   def answer_question(question)
+    if(question.answered==false)
+    question.answered=true
+    elsif
+    question.answered=false
+    end
+    question.save
+    return ""
+   end
 end
diff --git a/app/helpers/sessions_helper.rb b/app/helpers/sessions_helper.rb
new file mode 100644
index 0000000..17b74f1
--- /dev/null
+++ b/app/helpers/sessions_helper.rb
@@ -0,0 +1,5 @@
+module SessionsHelper
+   def destroy_session
+    session.destroy
+   end
+end
diff --git a/app/models/answer.rb b/app/models/answer.rb
new file mode 100644
index 0000000..e534e3c
--- /dev/null
+++ b/app/models/answer.rb
@@ -0,0 +1,3 @@
+class Answer < ActiveRecord::Base
+belongs_to :question
+end
diff --git a/app/models/hacker.rb b/app/models/hacker.rb
new file mode 100644
index 0000000..1238654
--- /dev/null
+++ b/app/models/hacker.rb
@@ -0,0 +1,3 @@
+class Hacker < ActiveRecord::Base 
+  validates_presence_of :password, :on => :create 
+end
diff --git a/app/models/question.rb b/app/models/question.rb
index cf6dc41..f7c7ebd 100644
--- a/app/models/question.rb
+++ b/app/models/question.rb
@@ -1,3 +1,8 @@
 class Question < ActiveRecord::Base
-
+has_many :answers
+has_many :responses
+  validates_uniqueness_of :content 
+  validates_uniqueness_of :title
+  validates_presence_of :content
+  validates_presence_of :title
 end
diff --git a/app/models/response.rb b/app/models/response.rb
index 28aea65..565b618 100644
--- a/app/models/response.rb
+++ b/app/models/response.rb
@@ -1,2 +1,3 @@
 class Response < ActiveRecord::Base
+  belongs_to :questions
 end
diff --git a/app/models/session.rb b/app/models/session.rb
new file mode 100644
index 0000000..54fee45
--- /dev/null
+++ b/app/models/session.rb
@@ -0,0 +1,2 @@
+class Session < ActiveRecord::Base
+end
diff --git a/app/models/user.rb b/app/models/user.rb
index 4a57cf0..fc7f635 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -1,2 +1,9 @@
 class User < ActiveRecord::Base
+  has_secure_password
+  has_many :responses
+  has_many :questions
+  has_many :answers
+  has_many :messages
+  validates_uniqueness_of :username
+  validates_presence_of :password
 end
diff --git a/app/views/answers/_form.html.erb b/app/views/answers/_form.html.erb
new file mode 100644
index 0000000..5c91a0a
--- /dev/null
+++ b/app/views/answers/_form.html.erb
@@ -0,0 +1,25 @@
+<%= form_for(@answer) do |f| %>
+  <% if @answer.errors.any? %>
+    
+

<%= pluralize(@answer.errors.count, "error") %> prohibited this answer from being saved:

+ + +
+ <% end %> + +
+ <%= f.label :content %>
+ <%= f.text_area :content, size: '50x10' %> +
+
+ <%= f.submit %> +
+ <%=f.hidden_field :creator_id, :value => session[:id] %> + <%=f.hidden_field :response_score, :value => 0 %> + <%=f.hidden_field :timestamp, :value => DateTime.now %> + <%=f.hidden_field :q_response_id, :value => params[:question_id] %> +<% end %> diff --git a/app/views/answers/edit.html.erb b/app/views/answers/edit.html.erb new file mode 100644 index 0000000..92f7d3f --- /dev/null +++ b/app/views/answers/edit.html.erb @@ -0,0 +1,6 @@ +

Editing answer

+ +<%= render 'form' %> + +<%= link_to 'Show', @answer %> | +<%= link_to 'Back', answers_path %> diff --git a/app/views/answers/index.html.erb b/app/views/answers/index.html.erb new file mode 100644 index 0000000..2fc3fda --- /dev/null +++ b/app/views/answers/index.html.erb @@ -0,0 +1,45 @@ + +<%= link_to 'log out', logout_path %> + +

+ +

Listing answers

+ + + + + + + + + + + + + + + + <% @answers.each do |answer| %> + + + + + + + + + + + + + <% if session[:id] == Question.find(answer.q_response_id).creator_id %> + + <% end %> + + <% end %> + +
AnswerQ responseCreatorResponse scoreContentTimestamp
<%= answer.id %><%= answer.q_response_id %><%= answer.creator_id %><%= answer.response_score %><%= answer.content %><%= answer.timestamp %><%= link_to 'Show', answer %><%= link_to 'Edit', edit_answer_path(answer) %><%= link_to 'Destroy', answer, method: :delete, data: { confirm: 'Are you sure?' } %><%= link_to 'Respond', new_response_path(:question_id => answer.q_response_id, :response_id => answer.id) %><%= link_to 'Correct', correct_answer_path(answer)%>
+ +
+ +<%= link_to 'New Answer', new_answer_path %> diff --git a/app/views/answers/index.json.jbuilder b/app/views/answers/index.json.jbuilder new file mode 100644 index 0000000..8403297 --- /dev/null +++ b/app/views/answers/index.json.jbuilder @@ -0,0 +1,4 @@ +json.array!(@answers) do |answer| + json.extract! answer, :id, :answer_id, :q_response_id, :creator_id, :response_score, :content, :timestamp + json.url answer_url(answer, format: :json) +end diff --git a/app/views/answers/new.html.erb b/app/views/answers/new.html.erb new file mode 100644 index 0000000..20757c4 --- /dev/null +++ b/app/views/answers/new.html.erb @@ -0,0 +1,5 @@ +

New answer

+ +<%= render 'form' %> + +<%= link_to 'Back', answers_path %> diff --git a/app/views/answers/show.html.erb b/app/views/answers/show.html.erb new file mode 100644 index 0000000..1749256 --- /dev/null +++ b/app/views/answers/show.html.erb @@ -0,0 +1,29 @@ + + +

+ Comments: +

+ +<% @responses.order('timestamp').reverse_order().take(3).each do |response| %> + + + + + + +
+ + + + + + + + + +

<%=response.content%>

+ +
+<% end %> + + diff --git a/app/views/answers/show.json.jbuilder b/app/views/answers/show.json.jbuilder new file mode 100644 index 0000000..0d70158 --- /dev/null +++ b/app/views/answers/show.json.jbuilder @@ -0,0 +1 @@ +json.extract! @answer, :id, :answer_id, :q_response_id, :creator_id, :response_score, :content, :timestamp, :created_at, :updated_at diff --git a/app/views/hackers/_form.html.erb b/app/views/hackers/_form.html.erb new file mode 100644 index 0000000..c2e3969 --- /dev/null +++ b/app/views/hackers/_form.html.erb @@ -0,0 +1,45 @@ +<%= form_for(@hacker) do |f| %> + <% if @hacker.errors.any? %> +
+

<%= pluralize(@hacker.errors.count, "error") %> prohibited this hacker from being saved:

+ + +
+ <% end %> + +
+ <%= f.label :username %>
+ <%= f.text_field :username %> +
+
+ <%= f.label :password %>
+ <%= f.text_field :password %> +
+
+ <%= f.label :password_confirmation %> + <%= f.password_field :password_confirmation %> +
+
+ <%= f.label :first_name %>
+ <%= f.text_field :first_name %> +
+
+ <%= f.label :last_name %>
+ <%= f.text_field :last_name %> +
+
+ <%= f.label :score %>
+ <%= f.number_field :score %> +
+
+ <%= f.label :type %>
+ <%= f.number_field :type %> +
+
+ <%= f.submit %> +
+<% end %> diff --git a/app/views/hackers/edit.html.erb b/app/views/hackers/edit.html.erb new file mode 100644 index 0000000..b585a65 --- /dev/null +++ b/app/views/hackers/edit.html.erb @@ -0,0 +1,6 @@ +

Editing hacker

+ +<%= render 'form' %> + +<%= link_to 'Show', @hacker %> | +<%= link_to 'Back', hackers_path %> diff --git a/app/views/hackers/index.html.erb b/app/views/hackers/index.html.erb new file mode 100644 index 0000000..7f7918b --- /dev/null +++ b/app/views/hackers/index.html.erb @@ -0,0 +1,37 @@ +

Listing hackers

+ + + + + + + + + + + + + + + + + <% @hackers.each do |hacker| %> + + + + + + + + + + + + + <% end %> + +
idUsernamePasswordFirst nameLast nameScoreType
<%= hacker.id %><%= hacker.username %><%= hacker.password %><%= hacker.first_name %><%= hacker.last_name %><%= hacker.score %><%= hacker.type %><%= link_to 'Show', hacker %><%= link_to 'Edit', edit_hacker_path(hacker) %><%= link_to 'Destroy', hacker, method: :delete, data: { confirm: 'Are you sure?' } %>
+ +
+ +<%= link_to 'New Hacker', new_hacker_path %> diff --git a/app/views/hackers/index.json.jbuilder b/app/views/hackers/index.json.jbuilder new file mode 100644 index 0000000..e13c550 --- /dev/null +++ b/app/views/hackers/index.json.jbuilder @@ -0,0 +1,4 @@ +json.array!(@hackers) do |hacker| + json.extract! hacker, :id, :username, :password, :first_name, :last_name, :score, :type + json.url hacker_url(hacker, format: :json) +end diff --git a/app/views/hackers/login.html.erb b/app/views/hackers/login.html.erb new file mode 100644 index 0000000..37f4f79 --- /dev/null +++ b/app/views/hackers/login.html.erb @@ -0,0 +1,30 @@ +

login

+ +<%= form_for(@hacker) do |f| %> + <% if @hacker.errors.any? %> +
+

<%= pluralize(@hacker.errors.count, "error") %> prohibited this hacker from being saved:

+ + +
+ <% end %> + +
+ <%= f.label :username %>
+ <%= f.text_field :username %> +
+
+ <%= f.label :password %>
+ <%= f.text_field :password %> +
+
+ <%= f.submit %> +
+<% end %> + + +<%= link_to 'Back', hackers_path %> diff --git a/app/views/hackers/new.html.erb b/app/views/hackers/new.html.erb new file mode 100644 index 0000000..e141b1f --- /dev/null +++ b/app/views/hackers/new.html.erb @@ -0,0 +1,5 @@ +

New hacker

+ +<%= render 'form' %> + +<%= link_to 'Back', hackers_path %> diff --git a/app/views/hackers/show.html.erb b/app/views/hackers/show.html.erb new file mode 100644 index 0000000..32e9748 --- /dev/null +++ b/app/views/hackers/show.html.erb @@ -0,0 +1,34 @@ +

<%= notice %>

+ +

+ Username: + <%= @hacker.username %> +

+ +

+ Password: + <%= @hacker.password %> +

+ +

+ First name: + <%= @hacker.first_name %> +

+ +

+ Last name: + <%= @hacker.last_name %> +

+ +

+ Score: + <%= @hacker.score %> +

+ +

+ Type: + <%= @hacker.type %> +

+ +<%= link_to 'Edit', edit_hacker_path(@hacker) %> | +<%= link_to 'Back', hackers_path %> diff --git a/app/views/hackers/show.json.jbuilder b/app/views/hackers/show.json.jbuilder new file mode 100644 index 0000000..b71b64b --- /dev/null +++ b/app/views/hackers/show.json.jbuilder @@ -0,0 +1 @@ +json.extract! @hacker, :id, :username, :password, :first_name, :last_name, :score, :type, :created_at, :updated_at diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index 24e379e..5480d7f 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -1,46 +1,70 @@ - - - - + - - + - question - - + - + - - - - +<%= link_to 'log in', new_session_path %> +<%= link_to 'log out', logout_path %> - -
-
-

question

-
- +<%= link_to 'New Question', new_question_path %> + + +<% @questions.each do |question| %> + + + + + + + +
<%= question.creator_id %>  
+ + + + + +
Question +

<%=question.content%>

+<% end %> + + + + + + + + +
Username  
+ + + + + +
Question +

Questions?Question?Question?

+ + + + + + + + + +
Username  
+ + + + + + + +
Question +

Questions?Question?Question?

+ + -
- -
- - -
- diff --git a/app/views/questions/_form.html.erb b/app/views/questions/_form.html.erb index 78637d1..897e056 100644 --- a/app/views/questions/_form.html.erb +++ b/app/views/questions/_form.html.erb @@ -16,8 +16,8 @@ category: <%= f.select :category, options_for_select(%w[1 2 3 4 5]) %>
content : <%= f.text_area(:content, size: '50x10') %>
-<%=f.hidden_field :question_id, :value => 123 %> -<%=f.hidden_field :creator_id, :value => 100 %> + +<%=f.hidden_field :creator_id, :value => session[:id] %> <%=f.hidden_field :answered, :value => false %> <%=f.hidden_field :timestamp, :value => DateTime.now %> diff --git a/app/views/questions/index.html.erb b/app/views/questions/index.html.erb index 9f35791..2a7de62 100644 --- a/app/views/questions/index.html.erb +++ b/app/views/questions/index.html.erb @@ -1,3 +1,4 @@ + @@ -6,7 +7,17 @@ - + - + +<%= link_to 'log out', logout_path %> +<%= link_to 'New User', new_user_path %> +<%= link_to 'Scores', users_path %> +

+

Listing questions

@@ -65,11 +81,16 @@ + + + <% @questions.each do |question| %> - - + + + + @@ -79,17 +100,239 @@ - + + <% end %> + +
<%= question.question_id %><%= question.creator_id %><%= question.id %><%= question.creator_id %><%= question.title %> <%= question.content %> <%= question.category %><%= link_to 'Show', question %> <%= link_to 'Edit', edit_question_path(question) %> <%= link_to 'Destroy', question, method: :delete, data: { confirm: 'Are you sure?' } %><%= link_to 'Respond', new_response_path(:question_id => question.question_id) %><%= link_to 'Respond', new_answer_path(:question_id => question.id) %><%= link_to 'Answer', answer_question_path(question)%>

+ <%= link_to 'New Question', new_question_path %> + +

Category 1

+ +<% @questions.where("category = '1'").order('timestamp').reverse_order().each do |question| %> + + + + + + + +
<%= link_to question.title, question %>  
+ + + + + + + + + + + + + + + + +

<%=question.content%>

+ <%= question.answered %>
+ <% if session[:id] != question.creator_id %> + + <%= link_to 'Respond', new_answer_path(:question_id => question.id) %><%end%> +
+<% end %> + + +
+

Category 2

+<% @questions.where("category = '2'").order('timestamp').reverse_order().each do |question| %> + + + + + + + +
<%= link_to question.title, question %>  
+ + + + + + + + + + + + + + + + + +

<%=question.content%>

+ <%= question.answered %>
+ <% if session[:id] != question.creator_id %> + <%= link_to 'Respond', new_answer_path(:question_id => question.id) %> <%end%><%= " "%> +
+<% end %> + +
+

Category 3

+<% @questions.where("category = '3'").order('timestamp').reverse_order().each do |question| %> + + + + + + + +
<%= link_to question.title, question %>  
+ + + + + + + + + + + + + + + + + +

<%=question.content%>

+ <%= question.answered %>
+ <% if session[:id] != question.creator_id %> + <%= link_to 'Respond', new_answer_path(:question_id => question.id) %><%end%><%= " "%> +
+<% end %> + +
+

Category 4

+<% @questions.where("category = '4'").order('timestamp').reverse_order().each do |question| %> + + + + + + + +
<%= link_to question.title, question %>  
+ + + + + + + + + + + + <% if session[:id] != question.creator_id %> + + + + <%end%> +

<%=question.content%>

+

<%=question.answered%>

+ + + + <%= link_to 'Respond', new_answer_path(:question_id => question.id) %> +
+<% end %> + +
+

Category 5

+<% @questions.where("category = '5'").order('timestamp').reverse_order().each do |question| %> + + + + + + + +
<%= link_to question.title, question %>  
+ + + + + + + + + + + + + + + <% if session[:id] != question.creator_id %> + + + + <%end%> +

<%=question.content%>

+
+ <%= question.answered %>
+ + <%= link_to 'Respond', new_answer_path(:question_id => question.id) %> +
+<% end %> + + + + + \ No newline at end of file diff --git a/app/views/questions/show.html.erb b/app/views/questions/show.html.erb index 83e8be3..860edc9 100644 --- a/app/views/questions/show.html.erb +++ b/app/views/questions/show.html.erb @@ -1,8 +1,8 @@ -

<%= notice %>

+ + +

+ + <%= @question.title %> +

- Content: + Question: <%= @question.content %>

-

+

+ Answers: +

+ + <% @answers.where("q_response_id = '" + @question.id.to_s + "'").each do |answer| %> + + + +
+ + + + + + + + + + + + + + + + + + + + + +

<%=answer.content%>

<%= link_to 'Respond', new_response_path(:question_id => answer.q_response_id, :response_id => answer.id) %><%= " "%><%= link_to "Show All Comments", answer %>
<%= link_to 'Correct', correct_answer_path(answer)%>
+
+
+<% end %> +<% if session[:id] != @question.creator_id %> + + <%= link_to 'Answer', new_answer_path(:question_id => @question.id) %><%end%> +
+<%= link_to 'Back', questions_path %> + diff --git a/app/views/responses/_form.html.erb b/app/views/responses/_form.html.erb index db3030a..be38eaf 100644 --- a/app/views/responses/_form.html.erb +++ b/app/views/responses/_form.html.erb @@ -18,8 +18,7 @@
<%= f.submit %>
- <%=f.hidden_field :response_id, :value => 456 %> - <%=f.hidden_field :creator_id, :value => 123 %> + <%=f.hidden_field :creator_id, :value => session[:id] %> <%=f.hidden_field :response_score, :value => 0 %> <%=f.hidden_field :timestamp, :value => DateTime.now %> <%=f.hidden_field :q_response_id, :value => params[:question_id] %> diff --git a/app/views/responses/index.html.erb b/app/views/responses/index.html.erb index 278ef14..d48e184 100644 --- a/app/views/responses/index.html.erb +++ b/app/views/responses/index.html.erb @@ -1,3 +1,7 @@ + +<%= link_to 'log out', logout_path %> + +

Listing responses

@@ -15,9 +19,9 @@ - <% @responses.each do |response| %> + <% @responses.order('timestamp').reverse_order().take(3).each do |response| %> - + @@ -27,7 +31,6 @@ - <% end %> diff --git a/app/views/sessions/_form.html.erb b/app/views/sessions/_form.html.erb new file mode 100644 index 0000000..ad76797 --- /dev/null +++ b/app/views/sessions/_form.html.erb @@ -0,0 +1,17 @@ +<%= form_for(@session) do |f| %> + <% if @session.errors.any? %> +
+

<%= pluralize(@session.errors.count, "error") %> prohibited this session from being saved:

+ + +
+ <% end %> + +
+ <%= f.submit %> +
+<% end %> diff --git a/app/views/sessions/edit.html.erb b/app/views/sessions/edit.html.erb new file mode 100644 index 0000000..bbd8407 --- /dev/null +++ b/app/views/sessions/edit.html.erb @@ -0,0 +1,6 @@ +

Editing session

+ +<%= render 'form' %> + +<%= link_to 'Show', @session %> | +<%= link_to 'Back', sessions_path %> diff --git a/app/views/sessions/index.html.erb b/app/views/sessions/index.html.erb new file mode 100644 index 0000000..637c079 --- /dev/null +++ b/app/views/sessions/index.html.erb @@ -0,0 +1,5 @@ +

Listing sessions

+ +
+ +<%= link_to 'New Session', new_session_path %> diff --git a/app/views/sessions/index.json.jbuilder b/app/views/sessions/index.json.jbuilder new file mode 100644 index 0000000..8d865db --- /dev/null +++ b/app/views/sessions/index.json.jbuilder @@ -0,0 +1,4 @@ +json.array!(@sessions) do |session| + json.extract! session, :id + json.url session_url(session, format: :json) +end diff --git a/app/views/sessions/new.html.erb b/app/views/sessions/new.html.erb new file mode 100644 index 0000000..e17629b --- /dev/null +++ b/app/views/sessions/new.html.erb @@ -0,0 +1,17 @@ + + +

Log in

+ +<%= form_tag sessions_path do %> +
+ <%= label_tag :username %> + <%= text_field_tag :username, params[:username] %> +
+
+ <%= label_tag :password %> + <%= password_field_tag :password %> +
+
<%= submit_tag "Log in" %>
+<% end %> +<%= link_to 'New User', new_user_path %> + diff --git a/app/views/sessions/show.html.erb b/app/views/sessions/show.html.erb new file mode 100644 index 0000000..5e8ceb0 --- /dev/null +++ b/app/views/sessions/show.html.erb @@ -0,0 +1,4 @@ +

<%= notice %>

+ +<%= link_to 'Edit', edit_session_path(@session) %> | +<%= link_to 'Back', sessions_path %> diff --git a/app/views/sessions/show.json.jbuilder b/app/views/sessions/show.json.jbuilder new file mode 100644 index 0000000..8cfb72c --- /dev/null +++ b/app/views/sessions/show.json.jbuilder @@ -0,0 +1 @@ +json.extract! @session, :id, :created_at, :updated_at diff --git a/app/views/users/_form.html.erb b/app/views/users/_form.html.erb index 9c57c90..4b1ac14 100644 --- a/app/views/users/_form.html.erb +++ b/app/views/users/_form.html.erb @@ -11,10 +11,6 @@ <% end %> -
- <%= f.label :user_id %>
- <%= f.number_field :user_id %> -
<%= f.label :username %>
<%= f.text_field :username %> @@ -22,7 +18,7 @@
<%= f.label :password %>
<%= f.text_field :password %> -
+
<%= f.label :first_name %>
<%= f.text_field :first_name %> @@ -31,14 +27,6 @@ <%= f.label :last_name %>
<%= f.text_field :last_name %>
-
- <%= f.label :score %>
- <%= f.number_field :score %> -
-
- <%= f.label :type %>
- <%= f.number_field :type %> -
<%= f.submit %>
diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index 9337a7d..a505219 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -1,3 +1,6 @@ + + +

Listing users

<%= response.response_id %><%= response.id %> <%= response.q_response_id %> <%= response.r_response_id %> <%= response.creator_id %><%= link_to 'Show', response %> <%= link_to 'Edit', edit_response_path(response) %> <%= link_to 'Destroy', response, method: :delete, data: { confirm: 'Are you sure?' } %><%= link_to 'Respond', new_response_path(:question_id => response.q_response_id, :response_id => response.response_id) %>
@@ -17,7 +20,7 @@ <% @users.each do |user| %> - + @@ -35,3 +38,24 @@
<%= link_to 'New User', new_user_path %> + +
<%= user.user_id %><%= user.id %> <%= user.username %> <%= user.password %> <%= user.first_name %>
+ + + + + + + + + + + <% @users.each do |user| %> + + + + + + <% end %> + +
UserUsernameScore
<%= user.id %><%= user.username %><%= user.score %>
\ No newline at end of file diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb index efc0404..17c898d 100644 --- a/app/views/users/new.html.erb +++ b/app/views/users/new.html.erb @@ -2,4 +2,4 @@ <%= render 'form' %> -<%= link_to 'Back', users_path %> +<%= link_to 'Back', sessions_path %> diff --git a/config/routes.rb b/config/routes.rb index 7ee7ed2..0d597df 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,14 +1,32 @@ Rails.application.routes.draw do + resources :sessions do + end + + controller :logout do + get 'logout' => :destroy + end + + resources :hackers + + resources :answers do + get 'correct', :on => :member + resources :responses + end + root 'questions#index' resources :responses - resources :questions + resources :questions do + get 'answer', :on => :member + resources :answers + end resources :messages resources :users - + resources :hackers + # The priority is based upon order of creation: first created -> highest priority. # See how all your routes lay out with "rake routes". diff --git a/db/migrate/20141013185823_create_questions.rb b/db/migrate/20141013185823_create_questions.rb index b24e487..2dcb237 100644 --- a/db/migrate/20141013185823_create_questions.rb +++ b/db/migrate/20141013185823_create_questions.rb @@ -1,6 +1,8 @@ class CreateQuestions < ActiveRecord::Migration def change + create_table :questions do |t| + t.integer :question_id t.integer :creator_id t.string :title @@ -13,4 +15,6 @@ def change t.timestamps end end + + end diff --git a/db/migrate/20141020220453_create_answers.rb b/db/migrate/20141020220453_create_answers.rb new file mode 100644 index 0000000..0186710 --- /dev/null +++ b/db/migrate/20141020220453_create_answers.rb @@ -0,0 +1,15 @@ +class CreateAnswers < ActiveRecord::Migration + def change + create_table :answers do |t| + t.belongs_to :question + t.integer :answer_id + t.integer :q_response_id + t.integer :creator_id + t.integer :response_score + t.text :content + t.datetime :timestamp + + t.timestamps + end + end +end diff --git a/db/migrate/20141020233116_create_hackers.rb b/db/migrate/20141020233116_create_hackers.rb new file mode 100644 index 0000000..4cd367a --- /dev/null +++ b/db/migrate/20141020233116_create_hackers.rb @@ -0,0 +1,14 @@ +class CreateHackers < ActiveRecord::Migration + def change + create_table :hackers do |t| + t.string :username + t.string :password + t.string :first_name + t.string :last_name + t.integer :score + t.integer :type + + t.timestamps + end + end +end diff --git a/db/migrate/20141129223728_create_sessions.rb b/db/migrate/20141129223728_create_sessions.rb new file mode 100644 index 0000000..96e28b9 --- /dev/null +++ b/db/migrate/20141129223728_create_sessions.rb @@ -0,0 +1,8 @@ +class CreateSessions < ActiveRecord::Migration + def change + create_table :sessions do |t| + + t.timestamps + end + end +end diff --git a/db/migrate/20141130112227_add_password_digest_to_users.rb b/db/migrate/20141130112227_add_password_digest_to_users.rb new file mode 100644 index 0000000..7ad1f62 --- /dev/null +++ b/db/migrate/20141130112227_add_password_digest_to_users.rb @@ -0,0 +1,5 @@ +class AddPasswordDigestToUsers < ActiveRecord::Migration + def change + add_column :users, :password_digest, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index ee1820c..53b4013 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,29 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20141013235253) do +ActiveRecord::Schema.define(version: 20141130112227) do + + create_table "answers", force: true do |t| + t.integer "answer_id" + t.integer "q_response_id" + t.integer "creator_id" + t.integer "response_score" + t.text "content" + t.datetime "timestamp" + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "hackers", force: true do |t| + t.string "username" + t.string "password" + t.string "first_name" + t.string "last_name" + t.integer "score" + t.integer "type" + t.datetime "created_at" + t.datetime "updated_at" + end create_table "messages", force: true do |t| t.integer "message_id" @@ -62,6 +84,11 @@ t.datetime "updated_at" end + create_table "sessions", force: true do |t| + t.datetime "created_at" + t.datetime "updated_at" + end + create_table "users", force: true do |t| t.integer "user_id" t.string "username" @@ -72,6 +99,7 @@ t.integer "type" t.datetime "created_at" t.datetime "updated_at" + t.string "password_digest" end end diff --git a/test/controllers/answers_controller_test.rb b/test/controllers/answers_controller_test.rb new file mode 100644 index 0000000..7d9381c --- /dev/null +++ b/test/controllers/answers_controller_test.rb @@ -0,0 +1,49 @@ +require 'test_helper' + +class AnswersControllerTest < ActionController::TestCase + setup do + @answer = answers(:one) + end + + test "should get index" do + get :index + assert_response :success + assert_not_nil assigns(:answers) + end + + test "should get new" do + get :new + assert_response :success + end + + test "should create answer" do + assert_difference('Answer.count') do + post :create, answer: { answer_id: @answer.answer_id, content: @answer.content, creator_id: @answer.creator_id, q_response_id: @answer.q_response_id, response_score: @answer.response_score, timestamp: @answer.timestamp } + end + + assert_redirected_to answer_path(assigns(:answer)) + end + + test "should show answer" do + get :show, id: @answer + assert_response :success + end + + test "should get edit" do + get :edit, id: @answer + assert_response :success + end + + test "should update answer" do + patch :update, id: @answer, answer: { answer_id: @answer.answer_id, content: @answer.content, creator_id: @answer.creator_id, q_response_id: @answer.q_response_id, response_score: @answer.response_score, timestamp: @answer.timestamp } + assert_redirected_to answer_path(assigns(:answer)) + end + + test "should destroy answer" do + assert_difference('Answer.count', -1) do + delete :destroy, id: @answer + end + + assert_redirected_to answers_path + end +end diff --git a/test/controllers/hackers_controller_test.rb b/test/controllers/hackers_controller_test.rb new file mode 100644 index 0000000..ec8926b --- /dev/null +++ b/test/controllers/hackers_controller_test.rb @@ -0,0 +1,49 @@ +require 'test_helper' + +class HackersControllerTest < ActionController::TestCase + setup do + @hacker = hackers(:one) + end + + test "should get index" do + get :index + assert_response :success + assert_not_nil assigns(:hackers) + end + + test "should get new" do + get :new + assert_response :success + end + + test "should create hacker" do + assert_difference('Hacker.count') do + post :create, hacker: { first_name: @hacker.first_name, last_name: @hacker.last_name, password: @hacker.password, score: @hacker.score, type: @hacker.type, username: @hacker.username } + end + + assert_redirected_to hacker_path(assigns(:hacker)) + end + + test "should show hacker" do + get :show, id: @hacker + assert_response :success + end + + test "should get edit" do + get :edit, id: @hacker + assert_response :success + end + + test "should update hacker" do + patch :update, id: @hacker, hacker: { first_name: @hacker.first_name, last_name: @hacker.last_name, password: @hacker.password, score: @hacker.score, type: @hacker.type, username: @hacker.username } + assert_redirected_to hacker_path(assigns(:hacker)) + end + + test "should destroy hacker" do + assert_difference('Hacker.count', -1) do + delete :destroy, id: @hacker + end + + assert_redirected_to hackers_path + end +end diff --git a/test/controllers/logout_controller_test.rb b/test/controllers/logout_controller_test.rb new file mode 100644 index 0000000..5857074 --- /dev/null +++ b/test/controllers/logout_controller_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class LogoutControllerTest < ActionController::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/controllers/sessions_controller_test.rb b/test/controllers/sessions_controller_test.rb new file mode 100644 index 0000000..6074b20 --- /dev/null +++ b/test/controllers/sessions_controller_test.rb @@ -0,0 +1,49 @@ +require 'test_helper' + +class SessionsControllerTest < ActionController::TestCase + setup do + @session = sessions(:one) + end + + test "should get index" do + get :index + assert_response :success + assert_not_nil assigns(:sessions) + end + + test "should get new" do + get :new + assert_response :success + end + + test "should create session" do + assert_difference('Session.count') do + post :create, session: { } + end + + assert_redirected_to session_path(assigns(:session)) + end + + test "should show session" do + get :show, id: @session + assert_response :success + end + + test "should get edit" do + get :edit, id: @session + assert_response :success + end + + test "should update session" do + patch :update, id: @session, session: { } + assert_redirected_to session_path(assigns(:session)) + end + + test "should destroy session" do + assert_difference('Session.count', -1) do + delete :destroy, id: @session + end + + assert_redirected_to sessions_path + end +end diff --git a/test/fixtures/answers.yml b/test/fixtures/answers.yml new file mode 100644 index 0000000..dabb2ee --- /dev/null +++ b/test/fixtures/answers.yml @@ -0,0 +1,17 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + answer_id: 1 + q_response_id: 1 + creator_id: 1 + response_score: 1 + content: MyText + timestamp: 2014-10-20 17:04:53 + +two: + answer_id: 1 + q_response_id: 1 + creator_id: 1 + response_score: 1 + content: MyText + timestamp: 2014-10-20 17:04:53 diff --git a/test/fixtures/hackers.yml b/test/fixtures/hackers.yml new file mode 100644 index 0000000..67c2a75 --- /dev/null +++ b/test/fixtures/hackers.yml @@ -0,0 +1,17 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + username: MyString + password: MyString + first_name: MyString + last_name: MyString + score: 1 + type: 1 + +two: + username: MyString + password: MyString + first_name: MyString + last_name: MyString + score: 1 + type: 1 diff --git a/test/fixtures/sessions.yml b/test/fixtures/sessions.yml new file mode 100644 index 0000000..937a0c0 --- /dev/null +++ b/test/fixtures/sessions.yml @@ -0,0 +1,11 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +# This model initially had no columns defined. If you add columns to the +# model remove the '{}' from the fixture names and add the columns immediately +# below each fixture, per the syntax in the comments below +# +one: {} +# column: value +# +two: {} +# column: value diff --git a/test/helpers/answers_helper_test.rb b/test/helpers/answers_helper_test.rb new file mode 100644 index 0000000..a044015 --- /dev/null +++ b/test/helpers/answers_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class AnswersHelperTest < ActionView::TestCase +end diff --git a/test/helpers/hackers_helper_test.rb b/test/helpers/hackers_helper_test.rb new file mode 100644 index 0000000..5389edc --- /dev/null +++ b/test/helpers/hackers_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class HackersHelperTest < ActionView::TestCase +end diff --git a/test/helpers/logout_helper_test.rb b/test/helpers/logout_helper_test.rb new file mode 100644 index 0000000..ae65bd2 --- /dev/null +++ b/test/helpers/logout_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class LogoutHelperTest < ActionView::TestCase +end diff --git a/test/helpers/sessions_helper_test.rb b/test/helpers/sessions_helper_test.rb new file mode 100644 index 0000000..7d44e09 --- /dev/null +++ b/test/helpers/sessions_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class SessionsHelperTest < ActionView::TestCase +end diff --git a/test/models/answer_test.rb b/test/models/answer_test.rb new file mode 100644 index 0000000..c0af5c3 --- /dev/null +++ b/test/models/answer_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class AnswerTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/models/hacker_test.rb b/test/models/hacker_test.rb new file mode 100644 index 0000000..f7006d8 --- /dev/null +++ b/test/models/hacker_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class HackerTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/models/session_test.rb b/test/models/session_test.rb new file mode 100644 index 0000000..2d1bc1b --- /dev/null +++ b/test/models/session_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class SessionTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end