From ce6746f7a9317fed56cec1979e3adb95bf3fd5a4 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Mon, 26 Dec 2011 19:48:57 +0400 Subject: [PATCH 01/12] [refs #54] Add subscribes and notifications --- app/controllers/subscribes_controller.rb | 31 +++++++++++++++ app/helpers/subscribes_helper.rb | 2 + app/mailers/user_mailer.rb | 26 ++++++++++++- app/models/comment.rb | 16 ++++++++ app/models/issue.rb | 39 +++++++++++++++++++ app/models/relation.rb | 1 + app/models/subscribe.rb | 4 ++ app/views/issues/show.html.haml | 8 ++++ .../issue_assign_notification.haml | 7 ++++ .../user_mailer/new_comment_notification.haml | 7 ++++ .../user_mailer/new_issue_notification.haml | 7 ++++ config/locales/ru.yml | 9 +++++ config/routes.rb | 3 ++ .../20111226141947_create_subscribes.rb | 14 +++++++ db/schema.rb | 21 ++++++---- .../controllers/subscribes_controller_spec.rb | 5 +++ spec/factories/subscribes.rb | 6 +++ spec/helpers/subscribes_helper_spec.rb | 15 +++++++ spec/models/subscribe_spec.rb | 5 +++ 19 files changed, 218 insertions(+), 8 deletions(-) create mode 100644 app/controllers/subscribes_controller.rb create mode 100644 app/helpers/subscribes_helper.rb create mode 100644 app/models/subscribe.rb create mode 100644 app/views/user_mailer/issue_assign_notification.haml create mode 100644 app/views/user_mailer/new_comment_notification.haml create mode 100644 app/views/user_mailer/new_issue_notification.haml create mode 100644 db/migrate/20111226141947_create_subscribes.rb create mode 100644 spec/controllers/subscribes_controller_spec.rb create mode 100644 spec/factories/subscribes.rb create mode 100644 spec/helpers/subscribes_helper_spec.rb create mode 100644 spec/models/subscribe_spec.rb diff --git a/app/controllers/subscribes_controller.rb b/app/controllers/subscribes_controller.rb new file mode 100644 index 000000000..4bb51be46 --- /dev/null +++ b/app/controllers/subscribes_controller.rb @@ -0,0 +1,31 @@ +class SubscribesController < ApplicationController + def create + @subscribe = @subscribeable.subscribes.build(:user_id => current_user.id) + if @subscribe.save + flash[:notice] = I18n.t("flash.subscribe.saved") + redirect_to :back + else + flash[:error] = I18n.t("flash.subscribe.saved_error") + redirect_to :back + end + end + + def destroy + @subscribe = Subscribe.find(params[:id]) + @subscribe.destroy + + flash[:notice] = t("flash.subscribe.destroyed") + redirect_to :back + end + + private + + def find_subscribeable + params.each do |name, value| + if name =~ /(.+)_id$/ + return $1.classify.constantize.find(value) + end + end + nil + end +end diff --git a/app/helpers/subscribes_helper.rb b/app/helpers/subscribes_helper.rb new file mode 100644 index 000000000..dc1b490ec --- /dev/null +++ b/app/helpers/subscribes_helper.rb @@ -0,0 +1,2 @@ +module SubscribesHelper +end diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index 3137b0dff..2c43482e1 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -5,7 +5,31 @@ class UserMailer < ActionMailer::Base def new_user_notification(user) @user = user - mail(:to => user.email, :subject => "Регистрация на проекте «#{APP_CONFIG['project_name']}»") do |format| + mail(:to => user.email, :subject => I18n.t("notifications.subjects.new_user_notification", :project_name => APP_CONFIG['project_name'])) do |format| + format.html + end + end + + def new_comment_notification(comment, user) + @user = user + @comment = comment + mail(:to => user.email, :subject => I18n.t("notifications.subjects.new_comment_notification")) do |format| + format.html + end + end + + def new_issue_notification(issue, user) + @user = user + @issue = issue + mail(:to => user.email, :subject => I18n.t("notifications.subjects.new_issue_notification")) do |format| + format.html + end + end + + def issue_assign_notification(issue, user) + @user = user + @issue = issue + mail(:to => user.email, :subject => I18n.t("notifications.subjects.issue_assign_notification")) do |format| format.html end end diff --git a/app/models/comment.rb b/app/models/comment.rb index 4c15a8b66..36e14c412 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -3,4 +3,20 @@ class Comment < ActiveRecord::Base belongs_to :user validates :body, :user_id, :commentable_id, :commentable_type, :presence => true + + after_create :deliver_new_comment_notification + + protected + + def deliver_new_comment_notification + #UserMailer.new_comment_notification(self, self.commentable.user).deliver + #UserMailer.new_comment_notification(self, self.commentable.project.owner).deliver + recipients = self.commentable.project.relations.by_role('admin').where(:object_type => 'User').map { |rel| rel.read_attribute(:object_id) } + recipients = recipients | [self.commentable.user_id] + recipients = recipients | [self.commentable.project.owner_id] if self.commentable.project.owner_type == 'User' + recipients.each do |recipient_id| + recipient = User.find(recipient_id) + UserMailer.new_comment_notification(self, recipient).deliver + end + end end diff --git a/app/models/issue.rb b/app/models/issue.rb index ad6f57468..586175b89 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -5,12 +5,17 @@ class Issue < ActiveRecord::Base belongs_to :user has_many :comments, :as => :commentable + has_many :subscribes, :as => :subscribeable validates :title, :body, :project_id, :user_id, :presence => true #attr_readonly :serial_id after_create :set_serial_id + after_create :subscribe_users + after_create :deliver_new_issue_notification + after_create :deliver_issue_assign_notification + after_update :deliver_issue_assign_notification protected @@ -18,4 +23,38 @@ class Issue < ActiveRecord::Base self.serial_id = self.project.issues.count self.save! end + + def deliver_new_issue_notification + #UserMailer.new_issue_notification(self, self.project.owner).deliver + #self.project.relations.by_role('admin').each do |rel| + # admin = User.find(rel.object_id) + # UserMailer.new_issue_notification(self, admin).deliver + #end + + recipients = collect_recipient_ids + recipients.each do |recipient_id| + recipient = User.find(recipient_id) + UserMailer.new_issue_notification(self, recipient).deliver + end + end + + def deliver_issue_assign_notification + UserMailer.issue_assign_notification(self, self.user).deliver if self.user_id_was != self.user_id + end + + def subscribe_users + recipients = collect_recipient_ids + recipients.each do |recipient_id| + ss = self.subscribes.build(:user_id => recipient_id) + ss.save! + end + end + + def collect_recipient_ids + recipients = self.project.relations.by_role('admin').where(:object_type => 'User').map { |rel| rel.read_attribute(:object_id) } + recipients = recipients | [self.user_id] + recipients = recipients | [self.project.owner_id] if self.project.owner_type == 'User' + recipients + end + end diff --git a/app/models/relation.rb b/app/models/relation.rb index 822687dca..a08ddf6a9 100644 --- a/app/models/relation.rb +++ b/app/models/relation.rb @@ -10,6 +10,7 @@ class Relation < ActiveRecord::Base scope :by_object, lambda {|obj| {:conditions => ['object_id = ? AND object_type = ?', obj.id, obj.class.to_s]}} scope :by_target, lambda {|tar| {:conditions => ['target_id = ? AND target_type = ?', tar.id, tar.class.to_s]}} + scope :by_role, lambda {|role| {:conditions => ['role = ?', role]}} def self.create_with_role(object, target, role) r = new diff --git a/app/models/subscribe.rb b/app/models/subscribe.rb new file mode 100644 index 000000000..0c3a52698 --- /dev/null +++ b/app/models/subscribe.rb @@ -0,0 +1,4 @@ +class Subscribe < ActiveRecord::Base + belongs_to :subscribeable, :polymorphic => true + belongs_to :user +end diff --git a/app/views/issues/show.html.haml b/app/views/issues/show.html.haml index 51c080e4a..69c2be747 100644 --- a/app/views/issues/show.html.haml +++ b/app/views/issues/show.html.haml @@ -20,6 +20,14 @@ = t('activerecord.attributes.issue.status') \: = @issue.status + %p + %b + = t('layout.issues.subscribe') + \: + - if @issue.subscribes.exists? :user_id => current_user.id + = link_to t('layout.issues.unsubscribe_btn'), unsubscribe_issue(@issue), :method => :post + - else + = link_to t('layout.issues.subscribe_btn'), subscribe_issue(@issue), :method => :delete %a{ :name => "comments" } .block diff --git a/app/views/user_mailer/issue_assign_notification.haml b/app/views/user_mailer/issue_assign_notification.haml new file mode 100644 index 000000000..72e99e7df --- /dev/null +++ b/app/views/user_mailer/issue_assign_notification.haml @@ -0,0 +1,7 @@ +%p== Здравствуйте, #{@user.name}. + + +%p Вам была назначена задача #{ link_to @issue.title, show_issue_path(@issue.project, @issue.serial_id) } + + +%p== Команда поддержки «ROSA Build System» diff --git a/app/views/user_mailer/new_comment_notification.haml b/app/views/user_mailer/new_comment_notification.haml new file mode 100644 index 000000000..0e57ff415 --- /dev/null +++ b/app/views/user_mailer/new_comment_notification.haml @@ -0,0 +1,7 @@ +%p== Здравствуйте, #{@user.name}. + + +%p К задаче #{ link_to @comment.commentable.title, show_issue_path(@comment.commentable.project, @comment.commentable.serial_id) } был добавлен новый комментарий. + + +%p== Команда поддержки «ROSA Build System» diff --git a/app/views/user_mailer/new_issue_notification.haml b/app/views/user_mailer/new_issue_notification.haml new file mode 100644 index 000000000..e98f32f45 --- /dev/null +++ b/app/views/user_mailer/new_issue_notification.haml @@ -0,0 +1,7 @@ +%p== Здравствуйте, #{@user.name}. + + +%p К проекту #{ link_to @issue.project.name, project_path(@issue.project) } была добавлена задача #{ link_to @issue.title, show_issue_path(@issue.project, @issue.serial_id) } + + +%p== Команда поддержки «ROSA Build System» diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 97eea839c..563ffdea7 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -106,6 +106,9 @@ ru: open: Открытые closed: Закрытые any: Все + subscribe: Подписка на уведомления + subscribe_btn: Подписаться + unsubscribe_btn: Отписаться comments: confirm_delete: Вы уверены, что хотите удалить комментарий? @@ -653,3 +656,9 @@ ru: distro: Дистрибутив platform: Архитектура counter: Закачки + notifications: + subjects: + new_comment_notification: Новый комментарий к Вашей задаче + new_issue_notification: Новая задача добавлена к проекту + new_user_notification: Регистрация на проекте «%{ project_name }» + issue_assign_notification: Вам назначили задачу diff --git a/config/routes.rb b/config/routes.rb index 4a0227e63..e71991c55 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -78,6 +78,9 @@ Rosa::Application.routes.draw do resources :categories, :only => [:index, :show] end + match "issues/:issue_id/subscribe" => 'subscribes#create', :as => :subscribe_issue, :via => :post + match "issues/:issue_id/unsubscribe" => 'subscribes#destroy', :as => :unsubscribe_issue, :via => :delete + match "projects/:project_id/issues/:serial_id" => 'issues#show', :serial_id => /\d+/, :as => :show_issue, :via => :get match "projects/:project_id/issues/:serial_id/edit" => 'issues#edit', :serial_id => /\d+/, :as => :edit_issue, :via => :get resources :projects do diff --git a/db/migrate/20111226141947_create_subscribes.rb b/db/migrate/20111226141947_create_subscribes.rb new file mode 100644 index 000000000..631e09f09 --- /dev/null +++ b/db/migrate/20111226141947_create_subscribes.rb @@ -0,0 +1,14 @@ +class CreateSubscribes < ActiveRecord::Migration + def self.up + create_table :subscribes do |t| + t.integer :subscribeable_id + t.string :subscribeable_type + t.integer :user_id + t.timestamps + end + end + + def self.down + drop_table :subscribes + end +end diff --git a/db/schema.rb b/db/schema.rb index 55f94564c..1aece65f1 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20111221194422) do +ActiveRecord::Schema.define(:version => 20111226141947) do create_table "arches", :force => true do |t| t.string "name", :null => false @@ -245,7 +245,6 @@ ActiveRecord::Schema.define(:version => 20111221194422) do t.string "object_type" t.integer "target_id" t.string "target_type" - t.integer "role_id" t.datetime "created_at" t.datetime "updated_at" t.string "role" @@ -272,18 +271,26 @@ ActiveRecord::Schema.define(:version => 20111221194422) do add_index "rpms", ["project_id", "arch_id"], :name => "index_rpms_on_project_id_and_arch_id" add_index "rpms", ["project_id"], :name => "index_rpms_on_project_id" + create_table "subscribes", :force => true do |t| + t.integer "subscribeable_id" + t.string "subscribeable_type" + t.integer "user_id" + t.datetime "created_at" + t.datetime "updated_at" + end + create_table "users", :force => true do |t| t.string "name" - t.string "email", :default => "", :null => false - t.string "encrypted_password", :limit => 128, :default => "", :null => false + t.string "email", :default => "", :null => false + t.string "encrypted_password", :limit => 128, :default => "", :null => false + t.string "password_salt", :default => "", :null => false t.string "reset_password_token" - t.datetime "reset_password_sent_at" + t.string "remember_token" t.datetime "remember_created_at" t.datetime "created_at" t.datetime "updated_at" - t.string "uname" t.text "ssh_key" - t.integer "role_id" + t.string "uname" t.string "role" end diff --git a/spec/controllers/subscribes_controller_spec.rb b/spec/controllers/subscribes_controller_spec.rb new file mode 100644 index 000000000..e1c466cb3 --- /dev/null +++ b/spec/controllers/subscribes_controller_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe SubscribesController do + +end diff --git a/spec/factories/subscribes.rb b/spec/factories/subscribes.rb new file mode 100644 index 000000000..f0644816f --- /dev/null +++ b/spec/factories/subscribes.rb @@ -0,0 +1,6 @@ +# Read about factories at http://github.com/thoughtbot/factory_girl + +FactoryGirl.define do + factory :subscribe do + end +end \ No newline at end of file diff --git a/spec/helpers/subscribes_helper_spec.rb b/spec/helpers/subscribes_helper_spec.rb new file mode 100644 index 000000000..c72869cf9 --- /dev/null +++ b/spec/helpers/subscribes_helper_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +# Specs in this file have access to a helper object that includes +# the SubscribesHelper. For example: +# +# describe SubscribesHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# helper.concat_strings("this","that").should == "this that" +# end +# end +# end +describe SubscribesHelper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/subscribe_spec.rb b/spec/models/subscribe_spec.rb new file mode 100644 index 000000000..0df4fbb42 --- /dev/null +++ b/spec/models/subscribe_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe Subscribe do + pending "add some examples to (or delete) #{__FILE__}" +end From 8face9208ed4c4dcc8b87fe8dc501f3e7da2ac93 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Tue, 27 Dec 2011 16:35:31 +0400 Subject: [PATCH 02/12] [refs #54] Add fixes and locales to subscribes --- app/controllers/subscribes_controller.rb | 16 +++++++++++----- app/views/issues/show.html.haml | 4 ++-- config/locales/ru.yml | 4 ++++ 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/app/controllers/subscribes_controller.rb b/app/controllers/subscribes_controller.rb index 4bb51be46..98efb5ccb 100644 --- a/app/controllers/subscribes_controller.rb +++ b/app/controllers/subscribes_controller.rb @@ -1,4 +1,8 @@ class SubscribesController < ApplicationController + before_filter :authenticate_user! + before_filter :set_instances + before_filter :set_subscribeable + def create @subscribe = @subscribeable.subscribes.build(:user_id => current_user.id) if @subscribe.save @@ -11,8 +15,7 @@ class SubscribesController < ApplicationController end def destroy - @subscribe = Subscribe.find(params[:id]) - @subscribe.destroy + @subscribeable.subscribes.where(:user_id => current_user.id)[0].destroy flash[:notice] = t("flash.subscribe.destroyed") redirect_to :back @@ -20,12 +23,15 @@ class SubscribesController < ApplicationController private - def find_subscribeable + def set_instances params.each do |name, value| if name =~ /(.+)_id$/ - return $1.classify.constantize.find(value) + instance_variable_set "@"+$1, $1.classify.constantize.find(value) end end - nil + end + + def set_subscribeable + @subscribeable = @issue if @issue end end diff --git a/app/views/issues/show.html.haml b/app/views/issues/show.html.haml index 69c2be747..943ea1a0a 100644 --- a/app/views/issues/show.html.haml +++ b/app/views/issues/show.html.haml @@ -25,9 +25,9 @@ = t('layout.issues.subscribe') \: - if @issue.subscribes.exists? :user_id => current_user.id - = link_to t('layout.issues.unsubscribe_btn'), unsubscribe_issue(@issue), :method => :post + = link_to t('layout.issues.unsubscribe_btn'), unsubscribe_issue_path(@issue), :method => :delete - else - = link_to t('layout.issues.subscribe_btn'), subscribe_issue(@issue), :method => :delete + = link_to t('layout.issues.subscribe_btn'), subscribe_issue_path(@issue), :method => :post§ %a{ :name => "comments" } .block diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 563ffdea7..20dd0c45d 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -352,6 +352,10 @@ ru: project_version_not_found: версия не найден flash: + subscribe: + saved: Вы подписаны на оповещения для этой задачи + destroyed: Подписка на оповещения для этой задачи убрана + exception_message: У Вас нет доступа к этой странице! downloads: From d3ba83135ee10393b26ed816bac0d3dd271e3cf1 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Tue, 27 Dec 2011 17:18:25 +0400 Subject: [PATCH 03/12] [refs #54] Add some locales and interface fixes for issues --- app/views/comments/_form.html.haml | 2 +- app/views/issues/_form.html.haml | 9 +++++---- app/views/issues/_list.html.haml | 3 +++ config/locales/ru.yml | 4 +++- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/views/comments/_form.html.haml b/app/views/comments/_form.html.haml index ccca4cc1d..2b046013d 100644 --- a/app/views/comments/_form.html.haml +++ b/app/views/comments/_form.html.haml @@ -1,5 +1,5 @@ .group - = f.label :body, :class => :label + = f.label :body, t("activerecord.attributes.comment.body"), :class => :label = f.text_area :body, :class => 'text_field', :cols => 80 .group.navform.wat-cf diff --git a/app/views/issues/_form.html.haml b/app/views/issues/_form.html.haml index bb1bc72ed..985ff7913 100644 --- a/app/views/issues/_form.html.haml +++ b/app/views/issues/_form.html.haml @@ -8,12 +8,13 @@ = f.label :body, :class => :label = f.text_area :body, :class => 'text_field', :cols => 80 -.group - = f.label :status, :class => :label - = f.select :status, Issue::STATUSES, :class => 'text_field' +- unless @issue.new_record? + .group + = f.label :status, :class => :label + = f.select :status, Issue::STATUSES, :class => 'text_field' .group - = label_tag "", t("layout.issues.user_id"), :class => :label + = label_tag "", t("activerecord.attributes.issue.user_id"), :class => :label = autocomplete_field_tag 'user_id', @user_uname, autocomplete_user_uname_platforms_path, :id_element => '#user_id_field' = hidden_field_tag 'user_id', @user_id, :id => 'user_id_field' diff --git a/app/views/issues/_list.html.haml b/app/views/issues/_list.html.haml index dfb083664..41ec58acc 100644 --- a/app/views/issues/_list.html.haml +++ b/app/views/issues/_list.html.haml @@ -1,12 +1,15 @@ %table.table %tr %th.first= t("activerecord.attributes.issue.title") + %th.first= t("activerecord.attributes.issue.user") %th.first= t("activerecord.attributes.issue.status") %th.last   - @issues.each do |issue| %tr{:class => cycle("odd", "even")} %td = link_to issue.title, show_issue_path(@project, issue.serial_id) + %td + = link_to issue.user.uname, user_path(issue.user) %td = issue.status %td.last diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 20dd0c45d..242514ab5 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -101,6 +101,7 @@ ru: new: Новая задача list_header: Список confirm_delete: Вы уверены, что хотите удалить эту задачу? + edit_header: Редактирование задачи new_header: Новая задача statuses: open: Открытые @@ -497,7 +498,8 @@ ru: issue: title: Заголовок body: Содержание - user: Назначено + user: Назначена + user_id: Назначена project: Проект status: Статус From b48ffecc2807346b99c120b295dbfa16c9d18934 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Tue, 27 Dec 2011 17:52:48 +0400 Subject: [PATCH 04/12] [refs #54] Add new styles to comments list to issue page --- app/views/issues/show.html.haml | 21 ++++++++------------- app/views/layouts/_stylesheets.html.haml | 2 +- public/stylesheets/patches.css | 4 ++++ 3 files changed, 13 insertions(+), 14 deletions(-) create mode 100644 public/stylesheets/patches.css diff --git a/app/views/issues/show.html.haml b/app/views/issues/show.html.haml index 943ea1a0a..8b52735a2 100644 --- a/app/views/issues/show.html.haml +++ b/app/views/issues/show.html.haml @@ -30,25 +30,20 @@ = link_to t('layout.issues.subscribe_btn'), subscribe_issue_path(@issue), :method => :post§ %a{ :name => "comments" } -.block - .secondary-navigation - %ul.wat-cf +.block#block-lists .content %h2.title = t("layout.issues.comments_header") .inner - %table.table - %tr - %th.first= t("activerecord.attributes.user.uname") - %th.first= t("activerecord.attributes.comment.body") - %th.last   + %ul.list - @issue.comments.each do |comment| - %tr{:class => cycle("odd", "even")} - %td - = comment.user.uname - %td + %li + .left + = link_to comment.user.uname, user_path(comment.user.uname) + .item = comment.body - %td.last + %br + %br = link_to t("layout.edit"), edit_project_issue_comment_path(@project, @issue, comment) if can? :update, comment = link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), project_issue_comment_path(@project, @issue, comment), :method => "delete", :class => "button", :confirm => t("layout.comments.confirm_delete") if can? :delete, comment diff --git a/app/views/layouts/_stylesheets.html.haml b/app/views/layouts/_stylesheets.html.haml index b2e58f3b8..e8c95cca9 100644 --- a/app/views/layouts/_stylesheets.html.haml +++ b/app/views/layouts/_stylesheets.html.haml @@ -1,6 +1,6 @@ -#= include_stylesheets :application = stylesheet_link_tag "web-app-theme/base.css", "web-app-theme/themes/default/style.css", "web-app-theme/override.css", "git/style.css" -= stylesheet_link_tag "jquery-ui-1.8.16.custom.css" += stylesheet_link_tag "jquery-ui-1.8.16.custom.css", "patches.css" = yield :stylesheets diff --git a/public/stylesheets/patches.css b/public/stylesheets/patches.css new file mode 100644 index 000000000..d6a3f9473 --- /dev/null +++ b/public/stylesheets/patches.css @@ -0,0 +1,4 @@ +ul.list li .item { + margin-left: 180px; +} + From ecbfed930054d232008fee4317f7f551f0d77686 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Tue, 27 Dec 2011 21:49:08 +0400 Subject: [PATCH 05/12] [refs #54] Fix user_id validation into issues --- app/controllers/issues_controller.rb | 2 +- app/models/issue.rb | 8 ++++++-- app/views/issues/_list.html.haml | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index a6a4cb734..031ca5ff4 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -27,7 +27,7 @@ class IssuesController < ApplicationController @issue = Issue.new(params[:issue]) @issue.user_id = @user_id @issue.project_id = @project.id - if @issue.save! + if @issue.save flash[:notice] = I18n.t("flash.issue.saved") redirect_to project_issues_path(@project) else diff --git a/app/models/issue.rb b/app/models/issue.rb index 586175b89..78b41a8b0 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -7,7 +7,7 @@ class Issue < ActiveRecord::Base has_many :comments, :as => :commentable has_many :subscribes, :as => :subscribeable - validates :title, :body, :project_id, :user_id, :presence => true + validates :title, :body, :project_id, :presence => true #attr_readonly :serial_id @@ -17,6 +17,10 @@ class Issue < ActiveRecord::Base after_create :deliver_issue_assign_notification after_update :deliver_issue_assign_notification + def assign_uname + user.uname if user + end + protected def set_serial_id @@ -52,7 +56,7 @@ class Issue < ActiveRecord::Base def collect_recipient_ids recipients = self.project.relations.by_role('admin').where(:object_type => 'User').map { |rel| rel.read_attribute(:object_id) } - recipients = recipients | [self.user_id] + recipients = recipients | [self.user_id] if self.user_id recipients = recipients | [self.project.owner_id] if self.project.owner_type == 'User' recipients end diff --git a/app/views/issues/_list.html.haml b/app/views/issues/_list.html.haml index 41ec58acc..7415a221e 100644 --- a/app/views/issues/_list.html.haml +++ b/app/views/issues/_list.html.haml @@ -9,7 +9,7 @@ %td = link_to issue.title, show_issue_path(@project, issue.serial_id) %td - = link_to issue.user.uname, user_path(issue.user) + = link_to issue.user.uname, user_path(issue.user) if issue.user %td = issue.status %td.last From 1c263c6e0a4978655e6f956adf7d8a18022e66d5 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Wed, 28 Dec 2011 14:47:54 +0400 Subject: [PATCH 06/12] [refs #54] Notification DJ support. Routes fixes. --- app/controllers/subscribes_controller.rb | 2 ++ app/models/issue.rb | 5 +++-- app/views/issues/show.html.haml | 4 ++-- app/views/user_mailer/issue_assign_notification.haml | 2 +- app/views/user_mailer/new_comment_notification.haml | 2 +- app/views/user_mailer/new_issue_notification.haml | 2 +- config/routes.rb | 4 ++-- 7 files changed, 12 insertions(+), 9 deletions(-) diff --git a/app/controllers/subscribes_controller.rb b/app/controllers/subscribes_controller.rb index 98efb5ccb..d075950f0 100644 --- a/app/controllers/subscribes_controller.rb +++ b/app/controllers/subscribes_controller.rb @@ -23,6 +23,7 @@ class SubscribesController < ApplicationController private + # Sets instances for parent resources (@issue, etc.) def set_instances params.each do |name, value| if name =~ /(.+)_id$/ @@ -31,6 +32,7 @@ class SubscribesController < ApplicationController end end + # Sets current parent resource by setted instance def set_subscribeable @subscribeable = @issue if @issue end diff --git a/app/models/issue.rb b/app/models/issue.rb index 48e9092d5..34401d4be 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -42,12 +42,13 @@ class Issue < ActiveRecord::Base recipients = collect_recipient_ids recipients.each do |recipient_id| recipient = User.find(recipient_id) - UserMailer.new_issue_notification(self, recipient).deliver + UserMailer.delay.new_issue_notification(self, recipient)#.deliver end end def deliver_issue_assign_notification - UserMailer.issue_assign_notification(self, self.user).deliver if self.user_id_was != self.user_id + #UserMailer.delay.issue_assign_notification(self, self.user).deliver if self.user_id_was != self.user_id + UserMailer.delay.issue_assign_notification(self, self.user) if self.user_id_was != self.user_id end def subscribe_users diff --git a/app/views/issues/show.html.haml b/app/views/issues/show.html.haml index 847afd8b9..202d891f4 100644 --- a/app/views/issues/show.html.haml +++ b/app/views/issues/show.html.haml @@ -25,9 +25,9 @@ = t('layout.issues.subscribe') \: - if @issue.subscribes.exists? :user_id => current_user.id - = link_to t('layout.issues.unsubscribe_btn'), unsubscribe_issue_path(@issue), :method => :delete + = link_to t('layout.issues.unsubscribe_btn'), unsubscribe_issue_path(@issue.id), :method => :delete - else - = link_to t('layout.issues.subscribe_btn'), subscribe_issue_path(@issue), :method => :post§ + = link_to t('layout.issues.subscribe_btn'), subscribe_issue_path(@issue.id), :method => :post§ %a{ :name => "comments" } .block#block-lists diff --git a/app/views/user_mailer/issue_assign_notification.haml b/app/views/user_mailer/issue_assign_notification.haml index 72e99e7df..a6615d3eb 100644 --- a/app/views/user_mailer/issue_assign_notification.haml +++ b/app/views/user_mailer/issue_assign_notification.haml @@ -1,7 +1,7 @@ %p== Здравствуйте, #{@user.name}. -%p Вам была назначена задача #{ link_to @issue.title, show_issue_path(@issue.project, @issue.serial_id) } +%p Вам была назначена задача #{ link_to @issue.title, [@issue.project, @issue] } %p== Команда поддержки «ROSA Build System» diff --git a/app/views/user_mailer/new_comment_notification.haml b/app/views/user_mailer/new_comment_notification.haml index 0e57ff415..88692f64e 100644 --- a/app/views/user_mailer/new_comment_notification.haml +++ b/app/views/user_mailer/new_comment_notification.haml @@ -1,7 +1,7 @@ %p== Здравствуйте, #{@user.name}. -%p К задаче #{ link_to @comment.commentable.title, show_issue_path(@comment.commentable.project, @comment.commentable.serial_id) } был добавлен новый комментарий. +%p К задаче #{ link_to @comment.commentable.title, [@comment.commentable.project, @comment.commentable] } был добавлен новый комментарий. %p== Команда поддержки «ROSA Build System» diff --git a/app/views/user_mailer/new_issue_notification.haml b/app/views/user_mailer/new_issue_notification.haml index e98f32f45..3a2604cfb 100644 --- a/app/views/user_mailer/new_issue_notification.haml +++ b/app/views/user_mailer/new_issue_notification.haml @@ -1,7 +1,7 @@ %p== Здравствуйте, #{@user.name}. -%p К проекту #{ link_to @issue.project.name, project_path(@issue.project) } была добавлена задача #{ link_to @issue.title, show_issue_path(@issue.project, @issue.serial_id) } +%p К проекту #{ link_to @issue.project.name, project_path(@issue.project) } была добавлена задача #{ link_to @issue.title, [@issue.project, @issue] } %p== Команда поддержки «ROSA Build System» diff --git a/config/routes.rb b/config/routes.rb index d076405a2..db44731a0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -78,8 +78,8 @@ Rosa::Application.routes.draw do resources :categories, :only => [:index, :show] end - #match "issues/:issue_id/subscribe" => 'subscribes#create', :as => :subscribe_issue, :via => :post - #match "issues/:issue_id/unsubscribe" => 'subscribes#destroy', :as => :unsubscribe_issue, :via => :delete + match "issues/:issue_id/subscribe" => 'subscribes#create', :as => :subscribe_issue, :via => :post + match "issues/:issue_id/unsubscribe" => 'subscribes#destroy', :as => :unsubscribe_issue, :via => :delete #match "projects/:project_id/issues/:serial_id" => 'issues#show', :serial_id => /\d+/, :as => :show_issue, :via => :get #match "projects/:project_id/issues/:serial_id/edit" => 'issues#edit', :serial_id => /\d+/, :as => :edit_issue, :via => :get From fa8656d1f53d5d96048fc5c6ede82784356ca7e0 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Wed, 28 Dec 2011 17:54:45 +0400 Subject: [PATCH 07/12] [refs #54] Refactor subscires routes and authorize --- app/controllers/subscribes_controller.rb | 36 ++++++++++++++---------- app/models/ability.rb | 8 ++++++ app/views/issues/show.html.haml | 4 +-- config/routes.rb | 5 ++-- 4 files changed, 34 insertions(+), 19 deletions(-) diff --git a/app/controllers/subscribes_controller.rb b/app/controllers/subscribes_controller.rb index d075950f0..e08d48db9 100644 --- a/app/controllers/subscribes_controller.rb +++ b/app/controllers/subscribes_controller.rb @@ -1,10 +1,15 @@ class SubscribesController < ApplicationController before_filter :authenticate_user! - before_filter :set_instances - before_filter :set_subscribeable + #before_filter :set_instances + #before_filter :set_subscribeable + + load_and_authorize_resource :project + load_and_authorize_resource :issue, :through => :project, :find_by => :serial_id + load_and_authorize_resource :subscribe, :through => :issue, :find_by => :user_id def create - @subscribe = @subscribeable.subscribes.build(:user_id => current_user.id) + #@subscribe = @subscribeable.subscribes.build(:user_id => current_user.id) + @subscribe = @issue.subscribes.build(:user_id => current_user.id) if @subscribe.save flash[:notice] = I18n.t("flash.subscribe.saved") redirect_to :back @@ -15,25 +20,26 @@ class SubscribesController < ApplicationController end def destroy - @subscribeable.subscribes.where(:user_id => current_user.id)[0].destroy + #@subscribeable.subscribes.where(:user_id => current_user.id)[0].destroy + @subscribe.destroy flash[:notice] = t("flash.subscribe.destroyed") redirect_to :back end - private + #private # Sets instances for parent resources (@issue, etc.) - def set_instances - params.each do |name, value| - if name =~ /(.+)_id$/ - instance_variable_set "@"+$1, $1.classify.constantize.find(value) - end - end - end + #def set_instances + # params.each do |name, value| + # if name =~ /(.+)_id$/ + # instance_variable_set "@"+$1, $1.classify.constantize.find(value) + # end + # end + #end # Sets current parent resource by setted instance - def set_subscribeable - @subscribeable = @issue if @issue - end + #def set_subscribeable + # @subscribeable = @issue if @issue + #end end diff --git a/app/models/ability.rb b/app/models/ability.rb index 9a601f37e..ebff5da1b 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -90,6 +90,14 @@ class Ability can(:create, Comment) {|comment| can? :read, comment.commentable.project} can(:update, Comment) {|comment| can? :update, comment.user_id == user.id or local_admin?(comment.commentable.project)} cannot :manage, Comment, :commentable => {:project => {:has_issues => false}} # switch off issues + + can :create, Subscribe do |subscribe| + !subscribe.subscribeable.subscribes.exists?(:user_id => user.id) + end + can :destroy, Subscribe do |subscribe| + subscribe.subscribeable.subscribes.exists?(:user_id => user.id) && user.id == subscribe.user_id + end + #can [:create, :delete], Subscribe end end diff --git a/app/views/issues/show.html.haml b/app/views/issues/show.html.haml index 202d891f4..3c0bf000f 100644 --- a/app/views/issues/show.html.haml +++ b/app/views/issues/show.html.haml @@ -25,9 +25,9 @@ = t('layout.issues.subscribe') \: - if @issue.subscribes.exists? :user_id => current_user.id - = link_to t('layout.issues.unsubscribe_btn'), unsubscribe_issue_path(@issue.id), :method => :delete + = link_to t('layout.issues.unsubscribe_btn'), project_issue_subscribe_path(@project, @issue, current_user.id), :method => :delete - else - = link_to t('layout.issues.subscribe_btn'), subscribe_issue_path(@issue.id), :method => :post§ + = link_to t('layout.issues.subscribe_btn'), project_issue_subscribes_path(@project, @issue), :method => :post§ %a{ :name => "comments" } .block#block-lists diff --git a/config/routes.rb b/config/routes.rb index db44731a0..c6b729fd7 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -78,8 +78,8 @@ Rosa::Application.routes.draw do resources :categories, :only => [:index, :show] end - match "issues/:issue_id/subscribe" => 'subscribes#create', :as => :subscribe_issue, :via => :post - match "issues/:issue_id/unsubscribe" => 'subscribes#destroy', :as => :unsubscribe_issue, :via => :delete + #match "issues/:issue_id/subscribe" => 'subscribes#create', :as => :subscribe_issue, :via => :post + #match "issues/:issue_id/unsubscribe" => 'subscribes#destroy', :as => :unsubscribe_issue, :via => :delete #match "projects/:project_id/issues/:serial_id" => 'issues#show', :serial_id => /\d+/, :as => :show_issue, :via => :get #match "projects/:project_id/issues/:serial_id/edit" => 'issues#edit', :serial_id => /\d+/, :as => :edit_issue, :via => :get @@ -87,6 +87,7 @@ Rosa::Application.routes.draw do resources :projects do resources :issues do resources :comments, :only => [:edit, :create, :update, :destroy] + resources :subscribes, :only => [:create, :destroy] end resource :repo, :controller => "git/repositories", :only => [:show] resources :build_lists, :only => [:index, :new, :create] From 49ec1ebe984f6b1fbbc017abb5c76ef7d556e544 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Wed, 28 Dec 2011 18:24:24 +0400 Subject: [PATCH 08/12] [refs #54] Remove unused comments --- app/controllers/subscribes_controller.rb | 20 -------------------- app/views/issues/show.html.haml | 2 +- 2 files changed, 1 insertion(+), 21 deletions(-) diff --git a/app/controllers/subscribes_controller.rb b/app/controllers/subscribes_controller.rb index e08d48db9..e9ff43abf 100644 --- a/app/controllers/subscribes_controller.rb +++ b/app/controllers/subscribes_controller.rb @@ -1,14 +1,11 @@ class SubscribesController < ApplicationController before_filter :authenticate_user! - #before_filter :set_instances - #before_filter :set_subscribeable load_and_authorize_resource :project load_and_authorize_resource :issue, :through => :project, :find_by => :serial_id load_and_authorize_resource :subscribe, :through => :issue, :find_by => :user_id def create - #@subscribe = @subscribeable.subscribes.build(:user_id => current_user.id) @subscribe = @issue.subscribes.build(:user_id => current_user.id) if @subscribe.save flash[:notice] = I18n.t("flash.subscribe.saved") @@ -20,26 +17,9 @@ class SubscribesController < ApplicationController end def destroy - #@subscribeable.subscribes.where(:user_id => current_user.id)[0].destroy @subscribe.destroy flash[:notice] = t("flash.subscribe.destroyed") redirect_to :back end - - #private - - # Sets instances for parent resources (@issue, etc.) - #def set_instances - # params.each do |name, value| - # if name =~ /(.+)_id$/ - # instance_variable_set "@"+$1, $1.classify.constantize.find(value) - # end - # end - #end - - # Sets current parent resource by setted instance - #def set_subscribeable - # @subscribeable = @issue if @issue - #end end diff --git a/app/views/issues/show.html.haml b/app/views/issues/show.html.haml index 3c0bf000f..073de4c2a 100644 --- a/app/views/issues/show.html.haml +++ b/app/views/issues/show.html.haml @@ -27,7 +27,7 @@ - if @issue.subscribes.exists? :user_id => current_user.id = link_to t('layout.issues.unsubscribe_btn'), project_issue_subscribe_path(@project, @issue, current_user.id), :method => :delete - else - = link_to t('layout.issues.subscribe_btn'), project_issue_subscribes_path(@project, @issue), :method => :post§ + = link_to t('layout.issues.subscribe_btn'), project_issue_subscribes_path(@project, @issue), :method => :post %a{ :name => "comments" } .block#block-lists From 635e2b7977bc3e28fa68661c6ad0119dd3ad1f88 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Thu, 29 Dec 2011 15:16:54 +0400 Subject: [PATCH 09/12] [refs #54] Add comments specs and factory. Remove unused code. Add one delay and fix some links. --- app/models/ability.rb | 17 +-- app/models/comment.rb | 4 +- app/models/issue.rb | 7 - app/views/issues/show.html.haml | 6 +- db/schema.rb | 11 +- spec/controllers/comments_controller_spec.rb | 145 ++++++++++++++++++- spec/controllers/issues_controller_spec.rb | 2 - spec/factories/comments.rb | 11 +- spec/factories/issues.rb | 1 + 9 files changed, 168 insertions(+), 36 deletions(-) diff --git a/app/models/ability.rb b/app/models/ability.rb index ebff5da1b..a0bd61c8d 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -88,16 +88,8 @@ class Ability cannot :manage, Issue, :project => {:has_issues => false} # switch off issues can(:create, Comment) {|comment| can? :read, comment.commentable.project} - can(:update, Comment) {|comment| can? :update, comment.user_id == user.id or local_admin?(comment.commentable.project)} + can(:update, Comment) {|comment| comment.user_id == user.id or local_admin?(comment.commentable.project)} cannot :manage, Comment, :commentable => {:project => {:has_issues => false}} # switch off issues - - can :create, Subscribe do |subscribe| - !subscribe.subscribeable.subscribes.exists?(:user_id => user.id) - end - can :destroy, Subscribe do |subscribe| - subscribe.subscribeable.subscribes.exists?(:user_id => user.id) && user.id == subscribe.user_id - end - #can [:create, :delete], Subscribe end end @@ -106,6 +98,13 @@ class Ability cannot :destroy, Repository, :platform => {:platform_type => 'personal'} cannot :fork, Project, :owner_id => user.id, :owner_type => user.class.to_s cannot :destroy, Issue + + can :create, Subscribe do |subscribe| + !subscribe.subscribeable.subscribes.exists?(:user_id => user.id) + end + can :destroy, Subscribe do |subscribe| + subscribe.subscribeable.subscribes.exists?(:user_id => user.id) && user.id == subscribe.user_id + end end # TODO group_ids ?? diff --git a/app/models/comment.rb b/app/models/comment.rb index 36e14c412..439fd0733 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -9,14 +9,12 @@ class Comment < ActiveRecord::Base protected def deliver_new_comment_notification - #UserMailer.new_comment_notification(self, self.commentable.user).deliver - #UserMailer.new_comment_notification(self, self.commentable.project.owner).deliver recipients = self.commentable.project.relations.by_role('admin').where(:object_type => 'User').map { |rel| rel.read_attribute(:object_id) } recipients = recipients | [self.commentable.user_id] recipients = recipients | [self.commentable.project.owner_id] if self.commentable.project.owner_type == 'User' recipients.each do |recipient_id| recipient = User.find(recipient_id) - UserMailer.new_comment_notification(self, recipient).deliver + UserMailer.delay.new_comment_notification(self, recipient) end end end diff --git a/app/models/issue.rb b/app/models/issue.rb index 34401d4be..9ae96f439 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -33,12 +33,6 @@ class Issue < ActiveRecord::Base end def deliver_new_issue_notification - #UserMailer.new_issue_notification(self, self.project.owner).deliver - #self.project.relations.by_role('admin').each do |rel| - # admin = User.find(rel.object_id) - # UserMailer.new_issue_notification(self, admin).deliver - #end - recipients = collect_recipient_ids recipients.each do |recipient_id| recipient = User.find(recipient_id) @@ -47,7 +41,6 @@ class Issue < ActiveRecord::Base end def deliver_issue_assign_notification - #UserMailer.delay.issue_assign_notification(self, self.user).deliver if self.user_id_was != self.user_id UserMailer.delay.issue_assign_notification(self, self.user) if self.user_id_was != self.user_id end diff --git a/app/views/issues/show.html.haml b/app/views/issues/show.html.haml index 073de4c2a..49b229b5c 100644 --- a/app/views/issues/show.html.haml +++ b/app/views/issues/show.html.haml @@ -30,7 +30,7 @@ = link_to t('layout.issues.subscribe_btn'), project_issue_subscribes_path(@project, @issue), :method => :post %a{ :name => "comments" } -.block#block-lists +.block#block-list .content %h2.title = t("layout.issues.comments_header") @@ -44,8 +44,8 @@ = comment.body %br %br - = link_to t("layout.edit"), edit_project_issue_comment_path(@project, @issue, comment) if can? :update, comment - = link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), project_issue_comment_path(@project, @issue, comment), :method => "delete", :class => "button", :confirm => t("layout.comments.confirm_delete") if can? :delete, comment + = link_to t("layout.edit"), edit_project_issue_comment_path(@project, @issue.id, comment) if can? :update, comment + = link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), project_issue_comment_path(@project, @issue.id, comment), :method => "delete", :class => "button", :confirm => t("layout.comments.confirm_delete") if can? :delete, comment .block .content diff --git a/db/schema.rb b/db/schema.rb index 1aece65f1..37cc1d3a6 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -245,6 +245,7 @@ ActiveRecord::Schema.define(:version => 20111226141947) do t.string "object_type" t.integer "target_id" t.string "target_type" + t.integer "role_id" t.datetime "created_at" t.datetime "updated_at" t.string "role" @@ -281,16 +282,16 @@ ActiveRecord::Schema.define(:version => 20111226141947) do create_table "users", :force => true do |t| t.string "name" - t.string "email", :default => "", :null => false - t.string "encrypted_password", :limit => 128, :default => "", :null => false - t.string "password_salt", :default => "", :null => false + t.string "email", :default => "", :null => false + t.string "encrypted_password", :limit => 128, :default => "", :null => false t.string "reset_password_token" - t.string "remember_token" + t.datetime "reset_password_sent_at" t.datetime "remember_created_at" t.datetime "created_at" t.datetime "updated_at" - t.text "ssh_key" t.string "uname" + t.text "ssh_key" + t.integer "role_id" t.string "role" end diff --git a/spec/controllers/comments_controller_spec.rb b/spec/controllers/comments_controller_spec.rb index 562bf1aff..8e9af23eb 100644 --- a/spec/controllers/comments_controller_spec.rb +++ b/spec/controllers/comments_controller_spec.rb @@ -1,5 +1,148 @@ require 'spec_helper' -describe CommentsController do +shared_examples_for 'user with create comment rights' do + it 'should be able to perform create action' do + post :create, @create_params + response.should redirect_to(project_issue_path(@project, @issue)) + end + it 'should create issue object into db' do + lambda{ post :create, @create_params }.should change{ Comment.count }.by(1) + end +end + +shared_examples_for 'user with update own comment rights' do + it 'should be able to perform update action' do + put :update, {:id => @own_comment.id}.merge(@update_params) + response.should redirect_to([@project, @issue]) + end + + it 'should update issue title' do + put :update, {:id => @own_comment.id}.merge(@update_params) + @own_comment.reload.body.should == 'updated' + end +end + +shared_examples_for 'user with update stranger comment rights' do + it 'should be able to perform update action' do + put :update, {:id => @comment.id}.merge(@update_params) + response.should redirect_to([@project, @issue]) + end + + it 'should update issue title' do + put :update, {:id => @comment.id}.merge(@update_params) + @comment.reload.body.should == 'updated' + end +end + +shared_examples_for 'user without update stranger comment rights' do + it 'should not be able to perform update action' do + put :update, {:id => @comment.id}.merge(@update_params) + response.should redirect_to(forbidden_path) + end + + it 'should not update issue title' do + put :update, {:id => @comment.id}.merge(@update_params) + @comment.reload.body.should_not == 'updated' + end +end + +shared_examples_for 'user without destroy comment rights' do + it 'should not be able to perform destroy action' do + delete :destroy, :id => @comment.id, :issue_id => @issue.id, :project_id => @project.id + response.should redirect_to(forbidden_path) + end + + it 'should not reduce comments count' do + lambda{ delete :destroy, :id => @comment.id, :issue_id => @issue.id, :project_id => @project.id }.should change{ Issue.count }.by(0) + end +end + +#shared_examples_for 'user with destroy rights' do +# it 'should be able to perform destroy action' do +# delete :destroy, :id => @comment.id, :issue_id => @issue.id, :project_id => @project.id +# response.should redirect_to([@project, @issue]) +# end +# +# it 'should reduce comments count' do +# lambda{ delete :destroy, :id => @comment.id, :issue_id => @issue.id, :project_id => @project.id }.should change{ Comment.count }.by(-1) +# end +#end + +describe CommentsController do + before(:each) do + stub_rsync_methods + + @project = Factory(:project) + @issue = Factory(:issue, :project_id => @project.id) + @comment = Factory(:comment, :commentable => @issue) + + @create_params = {:comment => {:body => 'I am a comment!'}, :project_id => @project.id, :issue_id => @issue.id} + @update_params = {:comment => {:body => 'updated'}, :project_id => @project.id, :issue_id => @issue.id} + + any_instance_of(Project, :versions => ['v1.0', 'v2.0']) + + @request.env['HTTP_REFERER'] = project_issue_path(@project, @issue) + end + + context 'for project admin user' do + before(:each) do + @user = Factory(:user) + set_session_for(@user) + @project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin') + + @own_comment = Factory(:comment, :commentable => @issue, :user => @user) + end + + it_should_behave_like 'user with create comment rights' + it_should_behave_like 'user with update stranger comment rights' + it_should_behave_like 'user with update own comment rights' + it_should_behave_like 'user without destroy comment rights' + end + + context 'for project owner user' do + before(:each) do + @user = Factory(:user) + set_session_for(@user) + @project.update_attribute(:owner, @user) + @project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin') + + @own_comment = Factory(:comment, :commentable => @issue, :user => @user) + end + + it_should_behave_like 'user with create comment rights' + it_should_behave_like 'user with update stranger comment rights' + it_should_behave_like 'user with update own comment rights' + it_should_behave_like 'user without destroy comment rights' + end + + context 'for project reader user' do + before(:each) do + @user = Factory(:user) + set_session_for(@user) + @project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'reader') + + @own_comment = Factory(:comment, :commentable => @issue, :user => @user) + end + + it_should_behave_like 'user with create comment rights' + it_should_behave_like 'user without update stranger comment rights' + it_should_behave_like 'user with update own comment rights' + it_should_behave_like 'user without destroy comment rights' + end + + context 'for project writer user' do + before(:each) do + @user = Factory(:user) + set_session_for(@user) + @project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'writer') + + @own_comment = Factory(:comment, :commentable => @issue, :user => @user) + end + + it_should_behave_like 'user with create comment rights' + it_should_behave_like 'user without update stranger comment rights' + it_should_behave_like 'user with update own comment rights' + it_should_behave_like 'user without destroy comment rights' + end end diff --git a/spec/controllers/issues_controller_spec.rb b/spec/controllers/issues_controller_spec.rb index 37aad58cf..63003491e 100644 --- a/spec/controllers/issues_controller_spec.rb +++ b/spec/controllers/issues_controller_spec.rb @@ -78,8 +78,6 @@ describe IssuesController do @project = Factory(:project) @issue_user = Factory(:user) - @create_params = {:project => {:name => 'pro'}} - @update_params = {:project => {:name => 'pro2'}} any_instance_of(Project, :versions => ['v1.0', 'v2.0']) diff --git a/spec/factories/comments.rb b/spec/factories/comments.rb index f9df3b695..f036eee06 100644 --- a/spec/factories/comments.rb +++ b/spec/factories/comments.rb @@ -1,6 +1,5 @@ -# Read about factories at http://github.com/thoughtbot/factory_girl - -FactoryGirl.define do - factory :comment do - end -end \ No newline at end of file +Factory.define(:comment) do |p| + p.body { Factory.next(:string) } + p.association :user, :factory => :user + p.association :commentable, :factory => :issue +end diff --git a/spec/factories/issues.rb b/spec/factories/issues.rb index 8b8017dbc..79d2ca96a 100644 --- a/spec/factories/issues.rb +++ b/spec/factories/issues.rb @@ -1,6 +1,7 @@ Factory.define(:issue) do |p| p.title { Factory.next(:string) } p.body { Factory.next(:string) } + p.association :project, :factory => :project p.association :user, :factory => :user p.status "open" end From 402133aff6d7df5c249c21be93a06893ad32d5b0 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Thu, 29 Dec 2011 21:03:53 +0400 Subject: [PATCH 10/12] [refs #54] Add some subscribe specs and factory --- spec/controllers/comments_controller_spec.rb | 4 +- .../controllers/subscribes_controller_spec.rb | 64 +++++++++++++++++++ spec/factories/subscribes.rb | 10 ++- 3 files changed, 70 insertions(+), 8 deletions(-) diff --git a/spec/controllers/comments_controller_spec.rb b/spec/controllers/comments_controller_spec.rb index 8e9af23eb..c93ac57f0 100644 --- a/spec/controllers/comments_controller_spec.rb +++ b/spec/controllers/comments_controller_spec.rb @@ -6,7 +6,7 @@ shared_examples_for 'user with create comment rights' do response.should redirect_to(project_issue_path(@project, @issue)) end - it 'should create issue object into db' do + it 'should create subscribe object into db' do lambda{ post :create, @create_params }.should change{ Comment.count }.by(1) end end @@ -17,7 +17,7 @@ shared_examples_for 'user with update own comment rights' do response.should redirect_to([@project, @issue]) end - it 'should update issue title' do + it 'should update subscribe body' do put :update, {:id => @own_comment.id}.merge(@update_params) @own_comment.reload.body.should == 'updated' end diff --git a/spec/controllers/subscribes_controller_spec.rb b/spec/controllers/subscribes_controller_spec.rb index e1c466cb3..7358127ee 100644 --- a/spec/controllers/subscribes_controller_spec.rb +++ b/spec/controllers/subscribes_controller_spec.rb @@ -1,5 +1,69 @@ require 'spec_helper' +shared_examples_for 'user with create subscribe rights' do + it 'should be able to perform create action' do + post :create, @create_params + response.should redirect_to(project_issue_path(@project, @issue)) + end + + it 'should create subscribe object into db' do + lambda{ post :create, @create_params }.should change{ Subscribe.count }.by(1) + end +end + +shared_examples_for 'user without destroy subscribe rights' do + it 'should not be able to perform destroy action' do + delete :destroy, :id => @subscribe.id, :issue_id => @issue.id, :project_id => @project.id + response.should redirect_to(forbidden_path) + end + + it 'should not reduce subscribes count' do + lambda{ delete :destroy, :id => @subscribe.id, :issue_id => @issue.id, :project_id => @project.id }.should change{ Subscribe.count }.by(0) + end +end + describe SubscribesController do + before(:each) do + stub_rsync_methods + + @project = Factory(:project) + @issue = Factory(:issue, :project_id => @project.id) + @subscribe = Factory(:subscribe, :subscribeable => @issue, :user => @user) + + any_instance_of(Project, :versions => ['v1.0', 'v2.0']) + + @request.env['HTTP_REFERER'] = project_issue_path(@project, @issue) + end + + context 'for global admin user' do + before(:each) do + @user = Factory(:admin) + set_session_for(@user) + @project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin') + end + + it 'should be able to perform create action' do + post :create, :project_id => @project.id, :issue_id => @issue.id + response.should redirect_to(project_issue_path(@project, @issue)) + end + + it 'should create issue object into db' do + lambda{ post :create, :project_id => @project.id, :issue_id => @issue.id }.should change{ Subscribe.count }.by(1) + end + + it 'should be able to perform destroy action' do + delete :destroy, :id => @subscribe.id, :issue_id => @issue.id, :project_id => @project.id + response.should redirect_to(forbidden_path) + end + + it 'should reduce subscribes count' do + lambda{ delete :destroy, :id => @subscribe.id, :issue_id => @issue.id, :project_id => @project.id }.should change{ Issue.count }.by(-1) + end + + #it_should_behave_like 'user with create subscribe rights' + #it_should_behave_like 'user with update stranger subscribe rights' + #it_should_behave_like 'user with update own subscribe rights' + #it_should_behave_like 'user without destroy subscribe rights' + end end diff --git a/spec/factories/subscribes.rb b/spec/factories/subscribes.rb index f0644816f..55a75a8ee 100644 --- a/spec/factories/subscribes.rb +++ b/spec/factories/subscribes.rb @@ -1,6 +1,4 @@ -# Read about factories at http://github.com/thoughtbot/factory_girl - -FactoryGirl.define do - factory :subscribe do - end -end \ No newline at end of file +Factory.define(:subscribe) do |p| + p.association :subscribeable, :factory => :issue + p.association :user, :factory => :user +end From 3f72082e0ec4511423f8beacdf551a0db2da7ea0 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Fri, 30 Dec 2011 18:21:08 +0400 Subject: [PATCH 11/12] [refs #54] Add comments, subscribes models specs. Finish subscribes controller specs. Some ability.rb fixes --- app/models/ability.rb | 2 + .../controllers/subscribes_controller_spec.rb | 86 +++++++++--- spec/models/comment_spec.rb | 122 +++++++++++++++++- spec/models/subscribe_spec.rb | 74 ++++++++++- 4 files changed, 262 insertions(+), 22 deletions(-) diff --git a/app/models/ability.rb b/app/models/ability.rb index a0bd61c8d..1b7509a2b 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -13,6 +13,8 @@ class Ability if user.admin? can :manage, :all + cannot :destroy, Subscribe + cannot :create, Subscribe else # Shared rights between guests and registered users can :forbidden, Platform diff --git a/spec/controllers/subscribes_controller_spec.rb b/spec/controllers/subscribes_controller_spec.rb index 7358127ee..378af911d 100644 --- a/spec/controllers/subscribes_controller_spec.rb +++ b/spec/controllers/subscribes_controller_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -shared_examples_for 'user with create subscribe rights' do +shared_examples_for 'can subscribe' do it 'should be able to perform create action' do post :create, @create_params response.should redirect_to(project_issue_path(@project, @issue)) @@ -11,14 +11,42 @@ shared_examples_for 'user with create subscribe rights' do end end -shared_examples_for 'user without destroy subscribe rights' do +shared_examples_for 'can not subscribe' do + it 'should not be able to perform create action' do + post :create, @create_params + response.should redirect_to(forbidden_path) + end + + it 'should not create subscribe object into db' do + lambda{ post :create, @create_params }.should change{ Subscribe.count }.by(0) + end +end + +shared_examples_for 'can unsubscribe' do + it 'should be able to perform destroy action' do + #set_objects_to_destroy + delete :destroy, @destroy_params + + response.should redirect_to([@project, @issue]) + end + + it 'should reduce subscribes count' do + #set_objects_to_destroy + lambda{ delete :destroy, @destroy_params }.should change{ Subscribe.count }.by(-1) + end +end + +shared_examples_for 'can not unsubscribe' do it 'should not be able to perform destroy action' do - delete :destroy, :id => @subscribe.id, :issue_id => @issue.id, :project_id => @project.id + #set_objects_to_destroy + delete :destroy, @destroy_params + response.should redirect_to(forbidden_path) end it 'should not reduce subscribes count' do - lambda{ delete :destroy, :id => @subscribe.id, :issue_id => @issue.id, :project_id => @project.id }.should change{ Subscribe.count }.by(0) + #set_objects_to_destroy + lambda{ delete :destroy, @destroy_params }.should change{ Subscribe.count }.by(0) end end @@ -28,7 +56,9 @@ describe SubscribesController do @project = Factory(:project) @issue = Factory(:issue, :project_id => @project.id) - @subscribe = Factory(:subscribe, :subscribeable => @issue, :user => @user) + + @create_params = {:issue_id => @issue.serial_id, :project_id => @project.id} + @destroy_params = {:issue_id => @issue.serial_id, :project_id => @project.id} any_instance_of(Project, :versions => ['v1.0', 'v2.0']) @@ -40,30 +70,46 @@ describe SubscribesController do @user = Factory(:admin) set_session_for(@user) @project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin') + @destroy_params = @destroy_params.merge({:id => @user.id}) end - it 'should be able to perform create action' do - post :create, :project_id => @project.id, :issue_id => @issue.id - response.should redirect_to(project_issue_path(@project, @issue)) + context 'subscribed' do + before(:each) do + ss = @issue.subscribes.build(:user => @user) + ss.save! + end + + it_should_behave_like 'can unsubscribe' + it_should_behave_like 'can not subscribe' end - it 'should create issue object into db' do - lambda{ post :create, :project_id => @project.id, :issue_id => @issue.id }.should change{ Subscribe.count }.by(1) + context 'not subscribed' do + it_should_behave_like 'can subscribe' + #it_should_behave_like 'can not unsubscribe' + end + end + + context 'for simple user' do + before(:each) do + @user = Factory(:user) + set_session_for(@user) + @destroy_params = @destroy_params.merge({:id => @user.id}) end - it 'should be able to perform destroy action' do - delete :destroy, :id => @subscribe.id, :issue_id => @issue.id, :project_id => @project.id - response.should redirect_to(forbidden_path) + context 'subscribed' do + before(:each) do + ss = @issue.subscribes.build(:user => @user) + ss.save! + end + + it_should_behave_like 'can unsubscribe' + it_should_behave_like 'can not subscribe' end - it 'should reduce subscribes count' do - lambda{ delete :destroy, :id => @subscribe.id, :issue_id => @issue.id, :project_id => @project.id }.should change{ Issue.count }.by(-1) + context 'not subscribed' do + it_should_behave_like 'can subscribe' + #it_should_behave_like 'can not unsubscribe' end - - #it_should_behave_like 'user with create subscribe rights' - #it_should_behave_like 'user with update stranger subscribe rights' - #it_should_behave_like 'user with update own subscribe rights' - #it_should_behave_like 'user without destroy subscribe rights' end end diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb index 505e33d36..0b969c134 100644 --- a/spec/models/comment_spec.rb +++ b/spec/models/comment_spec.rb @@ -1,5 +1,125 @@ require 'spec_helper' +require "cancan/matchers" + +def set_testable_data + @ability = Ability.new(@user) + + @project = Factory(:project) + @issue = Factory(:issue, :project_id => @project.id) + + @comment = Factory(:comment, :commentable => @issue, :user => @user) + @stranger_comment = Factory(:comment, :commentable => @issue, :user => @stranger) + + any_instance_of(Project, :versions => ['v1.0', 'v2.0']) +end describe Comment do - pending "add some examples to (or delete) #{__FILE__}" + context 'for global admin user' do + before(:each) do + @user = Factory(:admin) + @stranger = Factory(:user) + + set_testable_data + end + + it 'should create comment' do + @ability.should be_able_to(:create, Comment.new(:commentable => @issue, :user => @user)) + end + + it 'should update comment' do + @ability.should be_able_to(:update, @comment) + end + + it 'should update stranger comment' do + @ability.should be_able_to(:update, @stranger_comment) + end + + it 'should destroy own comment' do + @ability.should be_able_to(:destroy, @comment) + end + + it 'should destroy stranger comment' do + @ability.should be_able_to(:destroy, @stranger_comment) + end + end + + context 'for project admin user' do + before(:each) do + @user = Factory(:user) + @stranger = Factory(:user) + + set_testable_data + + @project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin') + end + + it 'should create comment' do + @ability.should be_able_to(:create, Comment.new(:commentable => @issue, :user => @user)) + end + + it 'should update comment' do + @ability.should be_able_to(:update, @comment) + end + + it 'should update stranger comment' do + @ability.should be_able_to(:update, @stranger_comment) + end + + it 'should not destroy comment' do + @ability.should_not be_able_to(:destroy, @comment) + end + end + + context 'for project owner user' do + before(:each) do + @user = Factory(:user) + @stranger = Factory(:user) + + set_testable_data + + @project.update_attribute(:owner, @user) + @project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin') + end + + it 'should create comment' do + @ability.should be_able_to(:create, Comment.new(:commentable => @issue, :user => @user)) + end + + it 'should update comment' do + @ability.should be_able_to(:update, @comment) + end + + it 'should update stranger comment' do + @ability.should be_able_to(:update, @stranger_comment) + end + + it 'should not destroy comment' do + @ability.should_not be_able_to(:destroy, @comment) + end + end + + context 'for simple user' do + before(:each) do + @user = Factory(:user) + @stranger = Factory(:user) + + set_testable_data + end + + it 'should create comment' do + @ability.should be_able_to(:create, Comment.new(:commentable => @issue, :user => @user)) + end + + it 'should update comment' do + @ability.should be_able_to(:update, @comment) + end + + it 'should not update stranger comment' do + @ability.should_not be_able_to(:update, @stranger_comment) + end + + it 'should not destroy comment' do + @ability.should_not be_able_to(:destroy, @comment) + end + end end diff --git a/spec/models/subscribe_spec.rb b/spec/models/subscribe_spec.rb index 0df4fbb42..7d496da07 100644 --- a/spec/models/subscribe_spec.rb +++ b/spec/models/subscribe_spec.rb @@ -1,5 +1,77 @@ require 'spec_helper' +require "cancan/matchers" + +def set_testable_data + @ability = Ability.new(@user) + + @project = Factory(:project) + @issue = Factory(:issue, :project_id => @project.id) + + any_instance_of(Project, :versions => ['v1.0', 'v2.0']) +end describe Subscribe do - pending "add some examples to (or delete) #{__FILE__}" + context 'for global admin user' do + before(:each) do + @user = Factory(:admin) + @stranger = Factory(:user) + + set_testable_data + end + + it 'should create subscribe' do + @ability.should be_able_to(:create, Subscribe.new(:subscribeable => @issue, :user => @user)) + end + + context 'destroy' do + before(:each) do + @subscribe = Factory(:subscribe, :subscribeable => @issue, :user => @user) + @stranger_subscribe = Factory(:subscribe, :subscribeable => @issue, :user => @stranger) + end + + context 'own subscribe' do + it 'should destroy subscribe' do + @ability.should be_able_to(:destroy, @subscribe) + end + end + + context 'stranger subscribe' do + it 'should not destroy subscribe' do + @ability.should_not be_able_to(:destroy, @stranger_subscribe) + end + end + end + end + + context 'for simple user' do + before(:each) do + @user = Factory(:user) + @stranger = Factory(:user) + + set_testable_data + end + + it 'should create subscribe' do + @ability.should be_able_to(:create, Subscribe.new(:subscribeable => @issue, :user => @user)) + end + + context 'destroy' do + before(:each) do + @subscribe = Factory(:subscribe, :subscribeable => @issue, :user => @user) + @stranger_subscribe = Factory(:subscribe, :subscribeable => @issue, :user => @stranger) + end + + context 'own subscribe' do + it 'should destroy subscribe' do + @ability.should be_able_to(:destroy, @subscribe) + end + end + + context 'stranger subscribe' do + it 'should not destroy subscribe' do + @ability.should_not be_able_to(:destroy, @stranger_subscribe) + end + end + end + end end From a44530980ed8344ad4925346b163ac4f274d69ce Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Fri, 30 Dec 2011 18:44:47 +0400 Subject: [PATCH 12/12] [refs #54] Remove some unnessacary comments --- config/routes.rb | 6 ------ spec/controllers/issues_controller_spec.rb | 5 ----- spec/controllers/subscribes_controller_spec.rb | 6 ------ spec/helpers/comments_helper_spec.rb | 15 --------------- spec/helpers/issues_helper_spec.rb | 15 --------------- spec/helpers/subscribes_helper_spec.rb | 15 --------------- 6 files changed, 62 deletions(-) delete mode 100644 spec/helpers/comments_helper_spec.rb delete mode 100644 spec/helpers/issues_helper_spec.rb delete mode 100644 spec/helpers/subscribes_helper_spec.rb diff --git a/config/routes.rb b/config/routes.rb index c6b729fd7..7f3449cde 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -78,12 +78,6 @@ Rosa::Application.routes.draw do resources :categories, :only => [:index, :show] end - #match "issues/:issue_id/subscribe" => 'subscribes#create', :as => :subscribe_issue, :via => :post - #match "issues/:issue_id/unsubscribe" => 'subscribes#destroy', :as => :unsubscribe_issue, :via => :delete - - #match "projects/:project_id/issues/:serial_id" => 'issues#show', :serial_id => /\d+/, :as => :show_issue, :via => :get - #match "projects/:project_id/issues/:serial_id/edit" => 'issues#edit', :serial_id => /\d+/, :as => :edit_issue, :via => :get - resources :projects do resources :issues do resources :comments, :only => [:edit, :create, :update, :destroy] diff --git a/spec/controllers/issues_controller_spec.rb b/spec/controllers/issues_controller_spec.rb index 63003491e..829957dee 100644 --- a/spec/controllers/issues_controller_spec.rb +++ b/spec/controllers/issues_controller_spec.rb @@ -1,7 +1,6 @@ require 'spec_helper' shared_examples_for 'issue user with project reader rights' do - #it_should_behave_like 'user with rights to view issues' it 'should be able to perform index action' do get :index, :project_id => @project.id response.should render_template(:index) @@ -62,7 +61,6 @@ end shared_examples_for 'project with issues turned off' do pending 'should not be able to perform index action' do get :index, :project_id => @project_with_turned_off_issues.id - #response.should redirect_to(forbidden_path) response.should render_template(:index) end @@ -114,8 +112,6 @@ describe IssuesController do context 'for project admin user' do before(:each) do - #@admin = Factory(:admin) - #set_session_for(@admin) @user = Factory(:user) set_session_for(@user) @project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin') @@ -182,7 +178,6 @@ describe IssuesController do context 'for issue assign user' do before(:each) do set_session_for(@issue_user) - #@project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'writer') end it_should_behave_like 'user with issue update rights' diff --git a/spec/controllers/subscribes_controller_spec.rb b/spec/controllers/subscribes_controller_spec.rb index 378af911d..6db7e2c24 100644 --- a/spec/controllers/subscribes_controller_spec.rb +++ b/spec/controllers/subscribes_controller_spec.rb @@ -24,28 +24,24 @@ end shared_examples_for 'can unsubscribe' do it 'should be able to perform destroy action' do - #set_objects_to_destroy delete :destroy, @destroy_params response.should redirect_to([@project, @issue]) end it 'should reduce subscribes count' do - #set_objects_to_destroy lambda{ delete :destroy, @destroy_params }.should change{ Subscribe.count }.by(-1) end end shared_examples_for 'can not unsubscribe' do it 'should not be able to perform destroy action' do - #set_objects_to_destroy delete :destroy, @destroy_params response.should redirect_to(forbidden_path) end it 'should not reduce subscribes count' do - #set_objects_to_destroy lambda{ delete :destroy, @destroy_params }.should change{ Subscribe.count }.by(0) end end @@ -85,7 +81,6 @@ describe SubscribesController do context 'not subscribed' do it_should_behave_like 'can subscribe' - #it_should_behave_like 'can not unsubscribe' end end @@ -108,7 +103,6 @@ describe SubscribesController do context 'not subscribed' do it_should_behave_like 'can subscribe' - #it_should_behave_like 'can not unsubscribe' end end diff --git a/spec/helpers/comments_helper_spec.rb b/spec/helpers/comments_helper_spec.rb deleted file mode 100644 index cc93aa9b6..000000000 --- a/spec/helpers/comments_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 CommentsHelper. For example: -# -# describe CommentsHelper do -# describe "string concat" do -# it "concats two strings with spaces" do -# helper.concat_strings("this","that").should == "this that" -# end -# end -# end -describe CommentsHelper do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/helpers/issues_helper_spec.rb b/spec/helpers/issues_helper_spec.rb deleted file mode 100644 index 2e20f1cf1..000000000 --- a/spec/helpers/issues_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 IssuesHelper. For example: -# -# describe IssuesHelper do -# describe "string concat" do -# it "concats two strings with spaces" do -# helper.concat_strings("this","that").should == "this that" -# end -# end -# end -describe IssuesHelper do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/helpers/subscribes_helper_spec.rb b/spec/helpers/subscribes_helper_spec.rb deleted file mode 100644 index c72869cf9..000000000 --- a/spec/helpers/subscribes_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 SubscribesHelper. For example: -# -# describe SubscribesHelper do -# describe "string concat" do -# it "concats two strings with spaces" do -# helper.concat_strings("this","that").should == "this that" -# end -# end -# end -describe SubscribesHelper do - pending "add some examples to (or delete) #{__FILE__}" -end