diff --git a/app/assets/javascripts/contestnotifications.js b/app/assets/javascripts/contestnotifications.js new file mode 100644 index 00000000..dee720fa --- /dev/null +++ b/app/assets/javascripts/contestnotifications.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/app/assets/stylesheets/contestnotifications.css b/app/assets/stylesheets/contestnotifications.css new file mode 100644 index 00000000..afad32db --- /dev/null +++ b/app/assets/stylesheets/contestnotifications.css @@ -0,0 +1,4 @@ +/* + Place all the styles related to the matching controller here. + They will automatically be included in application.css. +*/ diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index a25b346c..06e2285c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -264,6 +264,12 @@ class ApplicationController < ActionController::Base render_404 end + def find_contest_by_contest_id + @contest = Contest.find(params[:contest_id]) + rescue ActiveRecord::RecordNotFound + render_404 + end + # Find a project based on params[:project_id] # TODO: some subclasses override this, see about merging their logic def find_optional_project @@ -274,12 +280,26 @@ class ApplicationController < ActionController::Base render_404 end + def find_optional_contest + @contest = Contest.find(params[:contest_id]) unless params[:contest_id].blank? + allowed = User.current.allowed_to?({:controller => params[:controller], :action => params[:action]}, @contest, :global => true) + allowed ? true : deny_access + rescue ActiveRecord::RecordNotFound + render_404 + end + # Finds and sets @project based on @object.project def find_project_from_association render_404 unless @object.present? @project = @object.project end + + def find_contest_from_association + render_404 unless @object.present? + + @contest = @object.contest + end def find_model_object model = self.class.model_object @@ -291,6 +311,16 @@ class ApplicationController < ActionController::Base render_404 end + def find_model_object_contest + model = self.class.model_object + if model + @object = model.find(params[:id]) + self.instance_variable_set('@' + controller_name.singularize, @object) if @object + end + rescue ActiveRecord::RecordNotFound + render_404 + end + def self.model_object(model) self.model_object = model end diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index b2689d0c..5b5578c0 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -19,6 +19,7 @@ class CommentsController < ApplicationController default_search_scope :news model_object News before_filter :find_model_object + before_filter :find_model_object_contest before_filter :find_project_from_association before_filter :authorize @@ -50,4 +51,12 @@ class CommentsController < ApplicationController @comment = nil @news end + + def find_model_object_contest + super + @contestnotification = @object + @comment = nil + @contestnotification + end + end diff --git a/app/controllers/contestnotifications_controller.rb b/app/controllers/contestnotifications_controller.rb new file mode 100644 index 00000000..4ca19e6e --- /dev/null +++ b/app/controllers/contestnotifications_controller.rb @@ -0,0 +1,161 @@ +class ContestnotificationsController < ApplicationController + # GET /contestnotifications + # GET /contestnotifications.json + layout 'base_contest' + default_search_scope :contestnotification + model_object Contestnotification + before_filter :find_model_object_contest, :except => [:new, :create, :index] + before_filter :find_contest_from_association, :except => [:new, :create, :index] + before_filter :find_contest_by_contest_id, :only => [:new, :create] + before_filter :authorize, :except => [:index] + before_filter :find_optional_contest, :only => :index + accept_rss_auth :index + accept_api_auth :index + + def index + # @contestnotifications = Contestnotification.all +# + # respond_to do |format| + # format.html # index.html.erb + # format.json { render json: @contestnotifications } + # end + + ### begin ### + case params[:format] + when 'xml', 'json' + @offset, @limit = api_offset_and_limit + else + @limit = 10 + end + + scope = @contest ? @contest.contestnotification.visible : Contestnotification.visible + + @contestnotification_count = scope.count + @contestnotification_pages = Paginator.new @contestnotification_count, @limit, params['page'] + @offset ||= @contestnotification_pages.offset + @contestnotifications = scope.all(:include => [:author, :contest], + :order => "#{Contestnotification.table_name}.created_on DESC", + :offset => @offset, + :limit => @limit) + + respond_to do |format| + format.html { + @contestnotification = Contestnotification.new # for adding news inline + render :layout => 'base_contest' + } + format.api + format.atom { render_feed(@contestnotifications, :title => (@contest ? @contest.name : Setting.app_title) + ": #{l(:label_contest_notification)}") } + end + ### end ### + end + + # GET /contestnotifications/1 + # GET /contestnotifications/1.json + def show + # @contestnotification = Contestnotification.find(params[:id]) +# + # respond_to do |format| + # format.html # show.html.erb + # format.json { render json: @contestnotification } + # end + @comments = @contestnotification.comments + @comments.reverse! if User.current.wants_comments_in_reverse_order? + render :layout => 'base_contest' + + end + + # GET /contestnotifications/new + # GET /contestnotifications/new.json + def new + # @contestnotification = Contestnotification.new +# + # respond_to do |format| + # format.html # new.html.erb + # format.json { render json: @contestnotification } + # end + @contestnotification = Contestnotification.new(:contest => @contest, :author => User.current) + render :layout => 'base_contest' + end + + # GET /contestnotifications/1/edit + def edit + # @contestnotification = Contestnotification.find(params[:id]) + end + + # POST /contestnotifications + # POST /contestnotifications.json + def create + # @contestnotification = Contestnotification.new(params[:contestnotification]) +# + # respond_to do |format| + # if @contestnotification.save + # format.html { redirect_to @contestnotification, notice: 'Contestnotification was successfully created.' } + # format.json { render json: @contestnotification, status: :created, location: @contestnotification } + # else + # format.html { render action: "new" } + # format.json { render json: @contestnotification.errors, status: :unprocessable_entity } + # end + # end + @contestnotification = Contestnotification.new(:contest => @contest, :author => User.current) + @contestnotification.safe_attributes = params[:contestnotification] + @news.save_attachments(params[:attachments]) + if @contestnotification.save + render_attachment_warning_if_needed(@contestnotification) + flash[:notice] = l(:notice_successful_create) + redirect_to project_news_index_path(@contest) + else + layout_file = 'base_contest' + render :action => 'new', :layout => layout_file + end + end + + # PUT /contestnotifications/1 + # PUT /contestnotifications/1.json + def update + # @contestnotification = Contestnotification.find(params[:id]) +# + # respond_to do |format| + # if @contestnotification.update_attributes(params[:contestnotification]) + # format.html { redirect_to @contestnotification, notice: 'Contestnotification was successfully updated.' } + # format.json { head :no_content } + # else + # format.html { render action: "edit" } + # format.json { render json: @contestnotification.errors, status: :unprocessable_entity } + # end + # end + @contestnotification.safe_attributes = params[:contestnotification] + @contestnotification.save_attachments(params[:attachments]) + if @contestnotification.save + render_attachment_warning_if_needed(@contestnotification) + flash[:notice] = l(:notice_successful_update) + redirect_to contestnotification_path(@contestnotification) + else + render :action => 'edit' + end + end + + # DELETE /contestnotifications/1 + # DELETE /contestnotifications/1.json + def destroy + # @contestnotification = Contestnotification.find(params[:id]) + # @contestnotification.destroy +# + # respond_to do |format| + # format.html { redirect_to contestnotifications_url } + # format.json { head :no_content } + # end + @contestnotification.destroy + redirect_to contest_contestnotification_index_path(@contest) + end + + private + + def find_optional_contest + return true unless params[:contest_id] + @contest = Contest.find(params[:contest_id]) + authorize + rescue ActiveRecord::RecordNotFound + render_404 + end + +end diff --git a/app/controllers/documents_controller.rb b/app/controllers/documents_controller.rb index 51486f25..7e21242c 100644 --- a/app/controllers/documents_controller.rb +++ b/app/controllers/documents_controller.rb @@ -21,6 +21,7 @@ class DocumentsController < ApplicationController model_object Document before_filter :find_project_by_project_id, :only => [:index, :new, :create] before_filter :find_model_object, :except => [:index, :new, :create] + before_filter :find_model_object_contest, :except => [:index, :new, :create] before_filter :find_project_from_association, :except => [:index, :new, :create] before_filter :authorize , :except => [:index]#Added by young diff --git a/app/controllers/issue_categories_controller.rb b/app/controllers/issue_categories_controller.rb index a716653a..f5ba71de 100644 --- a/app/controllers/issue_categories_controller.rb +++ b/app/controllers/issue_categories_controller.rb @@ -19,6 +19,7 @@ class IssueCategoriesController < ApplicationController menu_item :settings model_object IssueCategory before_filter :find_model_object, :except => [:index, :new, :create] + before_filter :find_model_object_contest, :except => [:index, :new, :create] before_filter :find_project_from_association, :except => [:index, :new, :create] before_filter :find_project_by_project_id, :only => [:index, :new, :create] before_filter :authorize @@ -119,4 +120,10 @@ class IssueCategoriesController < ApplicationController super @category = @object end + + def find_model_object_contest + super + @category = @object + end + end diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index d8e583bf..29c37c09 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -17,6 +17,7 @@ class MembersController < ApplicationController model_object Member before_filter :find_model_object, :except => [:index, :create, :autocomplete] + before_filter :find_model_object_contest, :except => [:index, :create, :autocomplete] before_filter :find_project_from_association, :except => [:index, :create, :autocomplete] before_filter :find_project_by_project_id, :only => [:index, :create, :autocomplete] before_filter :authorize diff --git a/app/controllers/versions_controller.rb b/app/controllers/versions_controller.rb index 49e32ba1..72cb5301 100644 --- a/app/controllers/versions_controller.rb +++ b/app/controllers/versions_controller.rb @@ -20,6 +20,7 @@ class VersionsController < ApplicationController menu_item :roadmap model_object Version before_filter :find_model_object, :except => [:index, :new, :create, :close_completed] + before_filter :find_model_object_contest, :except => [:index, :new, :create] before_filter :find_project_from_association, :except => [:index, :new, :create, :close_completed] before_filter :find_project_by_project_id, :only => [:index, :new, :create, :close_completed] before_filter :authorize @@ -154,6 +155,13 @@ class VersionsController < ApplicationController redirect_to settings_project_path(@project, :tab => 'versions') end + def close_completed_contest + if request.put? + @contest.close_completed_versions + end + redirect_to settings_contest_path(@contest, :tab => 'versions') + end + def destroy if @version.fixed_issues.empty? @version.destroy diff --git a/app/helpers/contestnotifications_helper.rb b/app/helpers/contestnotifications_helper.rb new file mode 100644 index 00000000..ab17149d --- /dev/null +++ b/app/helpers/contestnotifications_helper.rb @@ -0,0 +1,2 @@ +module ContestnotificationsHelper +end diff --git a/app/models/contest.rb b/app/models/contest.rb index 9a326865..4234f751 100644 --- a/app/models/contest.rb +++ b/app/models/contest.rb @@ -13,6 +13,7 @@ class Contest < ActiveRecord::Base has_many :join_in_competitions, foreign_key: 'competition_id', :dependent => :destroy has_many :join_in_contests, class_name: 'JoinInCompetition', foreign_key: 'competition_id', :dependent => :destroy has_many :praise_tread, as: :praise_tread_object, dependent: :destroy + has_many :contestnotification, :dependent => :destroy, :include => :author @@ -93,6 +94,17 @@ class Contest < ActiveRecord::Base end end + # Closes open and locked project versions that are completed + def close_completed_versions_contest + Version.transaction do + versions.where(:status => %w(open locked)).all.each do |version| + if version.completed? + version.update_attribute(:status, 'closed') + end + end + end + end + def set_commit(commit) self.update_attribute(:commit, commit) end diff --git a/app/models/contestnotification.rb b/app/models/contestnotification.rb new file mode 100644 index 00000000..b0021c98 --- /dev/null +++ b/app/models/contestnotification.rb @@ -0,0 +1,61 @@ +class Contestnotification < ActiveRecord::Base + attr_accessible :author_id, :comments_count, :contest_id, :description, :summary, :title + + include Redmine::SafeAttributes + belongs_to :contest + belongs_to :author, :class_name => 'User', :foreign_key => 'author_id' + has_many :comments, :as => :commented, :dependent => :delete_all, :order => "created_at" + # fq + has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy + + validates_presence_of :title, :description + validates_length_of :title, :maximum => 60 + validates_length_of :summary, :maximum => 255 + + acts_as_attachable :delete_permission => :manage_contestnotification + acts_as_searchable :columns => ['title', 'summary', "#{table_name}.description"], :include => :contest + acts_as_event :url => Proc.new {|o| {:controller => 'contestnotification', :action => 'show', :id => o.id}} + acts_as_activity_provider :find_options => {:include => [:contest, :author]}, + :author_key => :author_id + acts_as_watchable + + after_create :add_author_as_watcher, :reset_counters! + + after_create :act_as_activity + + + # scope :visible, lambda {|*args| + # includes(:contest).where(Contest.allowed_to_condition(args.shift || User.current, :view_news, *args)) + # } + + safe_attributes 'title', 'summary', 'description' + + def visible?(user=User.current) + !user.nil? && user.allowed_to?(:view_contestnotification, contest) + end + + # Returns true if the news can be commented by user + def commentable?(user=User.current) + user.allowed_to?(:comment_contestnotification, contest) + end + + def recipients + contest.users.select {|user| user.notify_about?(self)}.map(&:mail) + end + + # returns latest news for contests visible by user + def self.latest(user = User.current, count = 5) + visible(user).includes([:author, :contest]).order("#{Contestnotification.table_name}.created_on DESC").limit(count).all + end + + private + + def add_author_as_watcher + Watcher.create(:watchable => self, :user => author) + end + ## fq + def act_as_activity + self.acts << Activity.new(:user_id => self.author_id) + end + +end diff --git a/app/models/user.rb b/app/models/user.rb index cf8e3c0c..c8b02f1a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -109,6 +109,7 @@ class User < Principal # added by bai has_many :join_in_contests, :dependent => :destroy has_many :news, :foreign_key => 'author_id' + has_many :contestnotification, :foreign_key => 'author_id' has_many :comments, :foreign_key => 'author_id' has_many :wiki_contents, :foreign_key => 'author_id' has_many :journals diff --git a/app/views/contestnotifications/_form.html.erb b/app/views/contestnotifications/_form.html.erb new file mode 100644 index 00000000..7fb5b719 --- /dev/null +++ b/app/views/contestnotifications/_form.html.erb @@ -0,0 +1,41 @@ +<%= form_for(@contestnotification) do |f| %> + <% if @contestnotification.errors.any? %> +
+

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

+ + +
+ <% end %> + +
+ <%= f.label :contest_id %>
+ <%= f.number_field :contest_id %> +
+
+ <%= f.label :title %>
+ <%= f.text_field :title %> +
+
+ <%= f.label :summary %>
+ <%= f.text_field :summary %> +
+
+ <%= f.label :description %>
+ <%= f.text_field :description %> +
+
+ <%= f.label :author_id %>
+ <%= f.number_field :author_id %> +
+
+ <%= f.label :comments_count %>
+ <%= f.number_field :comments_count %> +
+
+ <%= f.submit %> +
+<% end %> diff --git a/app/views/contestnotifications/edit.html.erb b/app/views/contestnotifications/edit.html.erb new file mode 100644 index 00000000..1db3cd20 --- /dev/null +++ b/app/views/contestnotifications/edit.html.erb @@ -0,0 +1,6 @@ +

Editing contestnotification

+ +<%= render 'form' %> + +<%= link_to 'Show', @contestnotification %> | +<%= link_to 'Back', contestnotifications_path %> diff --git a/app/views/contestnotifications/index.html.erb b/app/views/contestnotifications/index.html.erb new file mode 100644 index 00000000..2dbfdf89 --- /dev/null +++ b/app/views/contestnotifications/index.html.erb @@ -0,0 +1,133 @@ + + + +<% + btn_tips = l(:label_news_new) + label_tips = l(:label_news) +%> + + + <%= label_tips %> + + +<%= link_to(btn_tips, + new_contest_contestnotification_path(@contest), + :class => 'icon icon-add', + :onclick => 'showAndScrollTo("add-news", "news_title"); return false;') %> + +<% if @contest && User.current.allowed_to?(:manage_news, @contest) %> + +<% end %> +
+ <% if @contestnotifications.empty? %> +

+ <%= l(:label_no_data) %> +

+ <% else %> + <% @contestnotifications.each do |contestnotification| %> + + + + + + +
<%= link_to image_tag(url_to_avatar(contestnotification.author), :class => "avatar"), user_path(contestnotification.author) %> + + + + + + + + + + + + +
+ <%= link_to_user(contestnotification.author) if contestnotification.respond_to?(:author) %><%= l(:label_project_notice) %><%= link_to h(news.title), news_path(news) %> + <%= delete_link contestnotification_path(news) if User.current.allowed_to?(:manage_contestnotification, @contest) %> +
+ <%= textilizable(contestnotification, :description) %>
<%= l :label_update_time %> + : <%= format_time(contestnotification.created_at) %><%= link_to l(:label_project_newother), contestnotification_path(contestnotification) %><%= "(#{l(:label_x_comments, :count => contestnotification.comments_count)})" if contestnotification.comments_count >= 0 %>
+
+ <% end %> + <% end %> +
+ +
+ + + <% other_formats_links do |f| %> + <%= f.link_to 'Atom', :url => {:project_id => @project, :key => User.current.rss_key} %> + <% end %> + + <% content_for :header_tags do %> + <%= auto_discovery_link_tag(:atom, params.merge({:format => 'atom', :page => nil, :key => User.current.rss_key})) %> + <%= stylesheet_link_tag 'scm' %> + <% end %> + + <% html_title(l(:label_news_plural)) -%> +
+ + + + diff --git a/app/views/contestnotifications/new.html.erb b/app/views/contestnotifications/new.html.erb new file mode 100644 index 00000000..f29bf784 --- /dev/null +++ b/app/views/contestnotifications/new.html.erb @@ -0,0 +1,16 @@ + + + + + +<%= labelled_form_for @contestnotification, :url => contest_contestnotification_index_path(@contest), + :html => { :id => 'news-form', :multipart => true } do |f| %> + <%= render :partial => 'news/form', :locals => { :f => f } %> + <%= submit_tag l(:button_create), :class => "whiteButton m3p10 h30" %> + <%= preview_link preview_news_path(:project_id => @project), 'news-form' ,target='preview',{:class => 'whiteButton m3p10'}%> +<% end %> +
diff --git a/app/views/contestnotifications/show.html.erb b/app/views/contestnotifications/show.html.erb new file mode 100644 index 00000000..310f8b57 --- /dev/null +++ b/app/views/contestnotifications/show.html.erb @@ -0,0 +1,35 @@ +

<%= notice %>

+ +

+ Contest: + <%= @contestnotification.contest_id %> +

+ +

+ Title: + <%= @contestnotification.title %> +

+ +

+ Summary: + <%= @contestnotification.summary %> +

+ +

+ Description: + <%= @contestnotification.description %> +

+ +

+ Author: + <%= @contestnotification.author_id %> +

+ +

+ Comments count: + <%= @contestnotification.comments_count %> +

+ + +<%= link_to 'Edit', edit_contestnotification_path(@contestnotification) %> | +<%= link_to 'Back', contestnotifications_path %> diff --git a/config/locales/zh.yml b/config/locales/zh.yml index f86a757c..51337ddc 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1961,6 +1961,8 @@ zh: label_attendingcontestwork_deposit_project: 托管项目 label_attendingcontestwork_sorting_intimation: 您可以重新打分,打分结果以最后一次打分为主! + label_contest_notification: 竞赛通知 + #end # ajax异步验证 diff --git a/config/routes.rb b/config/routes.rb index b2fdd370..ef63888f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -16,6 +16,9 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. RedmineApp::Application.routes.draw do + resources :contestnotifications + + resources :homework_users diff --git a/db/migrate/20140530010015_create_contestnotifications.rb b/db/migrate/20140530010015_create_contestnotifications.rb new file mode 100644 index 00000000..087c2cf8 --- /dev/null +++ b/db/migrate/20140530010015_create_contestnotifications.rb @@ -0,0 +1,14 @@ +class CreateContestnotifications < ActiveRecord::Migration + def change + create_table :contestnotifications do |t| + t.integer :contest_id + t.string :title + t.string :summary + t.string :description + t.integer :author_id + t.integer :comments_count + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 68b9ad65..1123adad 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20140526104509) do +ActiveRecord::Schema.define(:version => 20140530010015) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -210,6 +210,17 @@ ActiveRecord::Schema.define(:version => 20140526104509) do t.string "reward" end + create_table "contestnotifications", :force => true do |t| + t.integer "contest_id" + t.string "title" + t.string "summary" + t.string "description" + t.integer "author_id" + t.integer "comments_count" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "contests", :force => true do |t| t.string "name" t.string "budget", :default => "" diff --git a/lib/redmine.rb b/lib/redmine.rb index 3a3cad61..7b28ac22 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -146,6 +146,12 @@ Redmine::AccessControl.map do |map| map.permission :comment_news, {:comments => :create} end + map.project_module :contestnotification do |map| + map.permission :manage_contestnotification, {:contestnotification => [:new, :create, :edit, :update, :destroy], :comments => [:destroy]}, :require => :member + map.permission :view_contestnotification, {:contestnotification => [:index, :show]}, :public => true, :read => true + map.permission :comment_contestnotification, {:comments => :create} + end + map.project_module :documents do |map| map.permission :add_documents, {:documents => [:new, :create, :add_attachment]}, :require => :loggedin map.permission :edit_documents, {:documents => [:edit, :update, :add_attachment]}, :require => :loggedin @@ -390,6 +396,7 @@ Redmine::Activity.map do |activity| activity.register :issues, :class_name => %w(Issue Journal) activity.register :changesets activity.register :news + activity.register :contestnotification activity.register :documents, :class_name => %w(Document Attachment) activity.register :files, :class_name => 'Attachment' activity.register :wiki_edits, :class_name => 'WikiContent::Version', :default => false @@ -405,6 +412,7 @@ end Redmine::Search.map do |search| search.register :issues search.register :news + search.register :contestnotification search.register :documents search.register :changesets search.register :wiki_pages diff --git a/test/fixtures/contestnotifications.yml b/test/fixtures/contestnotifications.yml new file mode 100644 index 00000000..6409a5f7 --- /dev/null +++ b/test/fixtures/contestnotifications.yml @@ -0,0 +1,17 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html + +one: + contest_id: 1 + title: MyString + summary: MyString + description: MyString + author_id: 1 + comments_count: 1 + +two: + contest_id: 1 + title: MyString + summary: MyString + description: MyString + author_id: 1 + comments_count: 1 diff --git a/test/functional/contestnotifications_controller_test.rb b/test/functional/contestnotifications_controller_test.rb new file mode 100644 index 00000000..948955a8 --- /dev/null +++ b/test/functional/contestnotifications_controller_test.rb @@ -0,0 +1,49 @@ +require 'test_helper' + +class ContestnotificationsControllerTest < ActionController::TestCase + setup do + @contestnotification = contestnotifications(:one) + end + + test "should get index" do + get :index + assert_response :success + assert_not_nil assigns(:contestnotifications) + end + + test "should get new" do + get :new + assert_response :success + end + + test "should create contestnotification" do + assert_difference('Contestnotification.count') do + post :create, contestnotification: { author_id: @contestnotification.author_id, comments_count: @contestnotification.comments_count, contest_id: @contestnotification.contest_id, description: @contestnotification.description, summary: @contestnotification.summary, title: @contestnotification.title } + end + + assert_redirected_to contestnotification_path(assigns(:contestnotification)) + end + + test "should show contestnotification" do + get :show, id: @contestnotification + assert_response :success + end + + test "should get edit" do + get :edit, id: @contestnotification + assert_response :success + end + + test "should update contestnotification" do + put :update, id: @contestnotification, contestnotification: { author_id: @contestnotification.author_id, comments_count: @contestnotification.comments_count, contest_id: @contestnotification.contest_id, description: @contestnotification.description, summary: @contestnotification.summary, title: @contestnotification.title } + assert_redirected_to contestnotification_path(assigns(:contestnotification)) + end + + test "should destroy contestnotification" do + assert_difference('Contestnotification.count', -1) do + delete :destroy, id: @contestnotification + end + + assert_redirected_to contestnotifications_path + end +end diff --git a/test/unit/contestnotification_test.rb b/test/unit/contestnotification_test.rb new file mode 100644 index 00000000..22b8113c --- /dev/null +++ b/test/unit/contestnotification_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class ContestnotificationTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/unit/helpers/contestnotifications_helper_test.rb b/test/unit/helpers/contestnotifications_helper_test.rb new file mode 100644 index 00000000..d79755d8 --- /dev/null +++ b/test/unit/helpers/contestnotifications_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class ContestnotificationsHelperTest < ActionView::TestCase +end