Right merge branch 'master' into 18-commit_comments
Conflicts: app/controllers/comments_controller.rb app/views/comments/edit.html.haml app/views/issues/show.html.haml db/schema.rb
This commit is contained in:
commit
bf4e4f02ed
|
@ -80,7 +80,12 @@ class BuildListsController < ApplicationController
|
|||
end
|
||||
|
||||
def publish_build
|
||||
@build_list.status = (params[:status].to_i == 0 ? BuildList::BUILD_PUBLISHED : BuildList::FAILED_PUBLISH)
|
||||
if params[:status].to_i == 0 # ok
|
||||
@build_list.status = BuildList::BUILD_PUBLISHED
|
||||
@build_list.package_version = "#{params[:version]}-#{params[:release]}"
|
||||
else
|
||||
@build_list.status = BuildList::FAILED_PUBLISH
|
||||
end
|
||||
@build_list.notified_at = Time.current
|
||||
@build_list.save
|
||||
|
||||
|
|
|
@ -36,8 +36,8 @@ class CommentsController < ApplicationController
|
|||
def update
|
||||
if @comment.update_attributes(params[:comment])
|
||||
flash[:notice] = I18n.t("flash.comment.saved")
|
||||
#redirect_to :back
|
||||
redirect_to @commentable_path
|
||||
redirect_to :back
|
||||
#redirect_to @commentable.class == Issue ? project_issue_path(@project, @commentable) : commit_path(@project.id, @commentable.id)
|
||||
else
|
||||
flash[:error] = I18n.t("flash.comment.save_error")
|
||||
render :action => 'new'
|
||||
|
@ -61,7 +61,7 @@ class CommentsController < ApplicationController
|
|||
#end
|
||||
#nil
|
||||
if params[:issue_id].present?
|
||||
return Issue.find(params[:issue_id])
|
||||
return Issue.find_by_serial_id_and_project_id(params[:issue_id], params[:project_id])
|
||||
elsif params[:commit_id].present?
|
||||
return @project.git_repository.commit(params[:commit_id])
|
||||
end
|
||||
|
@ -70,7 +70,6 @@ class CommentsController < ApplicationController
|
|||
def set_commentable
|
||||
find_project
|
||||
@commentable = find_commentable
|
||||
@commentable_path = @commentable.class == Issue ? project_issue_path(@project, @commentable) : commit_path(@project.id, @commentable.id)
|
||||
end
|
||||
|
||||
def find_comment
|
||||
|
|
|
@ -30,7 +30,10 @@ class IssuesController < ApplicationController
|
|||
@issue = Issue.new(params[:issue])
|
||||
@issue.user_id = @user_id
|
||||
@issue.project_id = @project.id
|
||||
|
||||
if @issue.save
|
||||
@issue.subscribe_creator(current_user.id)
|
||||
|
||||
flash[:notice] = I18n.t("flash.issue.saved")
|
||||
redirect_to project_issues_path(@project)
|
||||
else
|
||||
|
@ -41,12 +44,12 @@ class IssuesController < ApplicationController
|
|||
|
||||
def edit
|
||||
@user_id = @issue.user_id
|
||||
@user_uname = @issue.user.uname
|
||||
@user_uname = @issue.assign_uname
|
||||
end
|
||||
|
||||
def update
|
||||
@user_id = params[:user_id].blank? ? @issue.user_id : params[:user_id]
|
||||
@user_uname = params[:user_uname].blank? ? @issue.user.uname : params[:user_uname]
|
||||
@user_uname = params[:user_uname].blank? ? @issue.assign_uname : params[:user_uname]
|
||||
|
||||
if @issue.update_attributes( params[:issue].merge({:user_id => @user_id}) )
|
||||
flash[:notice] = I18n.t("flash.issue.saved")
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
class Settings::NotifiersController < ApplicationController
|
||||
layout "sessions"
|
||||
|
||||
before_filter :authenticate_user!
|
||||
|
||||
load_and_authorize_resource :user
|
||||
load_and_authorize_resource :class => Settings::Notifier, :through => :user, :singleton => true, :shallow => true
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
def update
|
||||
if @notifier.update_attributes(params[:settings_notifier])
|
||||
flash[:notice] = I18n.t("flash.settings.saved")
|
||||
redirect_to [@user, @notifier]
|
||||
else
|
||||
flash[:notice] = I18n.t("flash.settings.save_error")
|
||||
redirect_to [@user, @notifier]
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,2 @@
|
|||
module Settings::NotifiersHelper
|
||||
end
|
|
@ -18,6 +18,14 @@ class UserMailer < ActionMailer::Base
|
|||
end
|
||||
end
|
||||
|
||||
def new_comment_reply_notification(comment, user)
|
||||
@user = user
|
||||
@comment = comment
|
||||
mail(:to => user.email, :subject => I18n.t("notifications.subjects.new_comment_reply_notification")) do |format|
|
||||
format.html
|
||||
end
|
||||
end
|
||||
|
||||
def new_issue_notification(issue, user)
|
||||
@user = user
|
||||
@issue = issue
|
||||
|
|
|
@ -28,6 +28,8 @@ class Ability
|
|||
else # Registered user rights
|
||||
can [:show, :autocomplete_user_uname], User
|
||||
|
||||
can [:show, :update], Settings::Notifier, :user_id => user.id
|
||||
|
||||
can [:read, :create], Group
|
||||
can [:update, :manage_members], Group do |group|
|
||||
group.objects.exists?(:object_type => 'User', :object_id => user.id, :role => 'admin') # or group.owner_id = user.id
|
||||
|
|
|
@ -5,7 +5,8 @@ class Comment < ActiveRecord::Base
|
|||
|
||||
validates :body, :user_id, :commentable_id, :commentable_type, :presence => true
|
||||
|
||||
after_create :deliver_new_comment_notification
|
||||
after_create :subscribe_on_reply, :unless => "commentable_type == 'Grit::Commit'"
|
||||
after_create :deliver_new_comment_notification, :unless => "commentable_type == 'Grit::Commit'"
|
||||
|
||||
protected
|
||||
|
||||
|
@ -13,8 +14,17 @@ class Comment < ActiveRecord::Base
|
|||
return if self.commentable_type == 'Grit::Commit' # FIXME
|
||||
subscribes = self.commentable.subscribes
|
||||
subscribes.each do |subscribe|
|
||||
recipient = subscribe.user
|
||||
UserMailer.delay.new_comment_notification(self, recipient)
|
||||
if self.user_id != subscribe.user_id && User.find(subscribe.user).notifier.new_comment_reply && User.find(subscribe.user).notifier.can_notify
|
||||
if self.commentable.comments.exists?(:user_id => subscribe.user.id)
|
||||
UserMailer.delay.new_comment_reply_notification(self, subscribe.user)
|
||||
else
|
||||
UserMailer.delay.new_comment_notification(self, subscribe.user)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def subscribe_on_reply
|
||||
self.commentable.subscribes.create(:user_id => self.user_id) if !self.commentable.subscribes.exists?(:user_id => self.user_id)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,10 +5,12 @@ class Issue < ActiveRecord::Base
|
|||
belongs_to :user
|
||||
|
||||
has_many :comments, :as => :commentable,
|
||||
:finder_sql => 'SELECT comments.* FROM comments ' +
|
||||
'WHERE comments.commentable_id = \'#{self.id}\' ' +
|
||||
' AND comments.commentable_type = \'#{self.class.name}\' ' +
|
||||
'ORDER BY comments.created_at'
|
||||
:finder_sql => proc { "comments.commentable_id = '#{self.id}' " +
|
||||
" AND comments.commentable_type = '#{self.class.name}'"}
|
||||
#'SELECT comments.* FROM comments ' +
|
||||
#'WHERE comments.commentable_id = \'#{self.id}\' ' +
|
||||
#' AND comments.commentable_type = \'#{self.class.name}\' ' +
|
||||
#'ORDER BY comments.created_at'
|
||||
has_many :subscribes, :as => :subscribeable
|
||||
|
||||
validates :title, :body, :project_id, :presence => true
|
||||
|
@ -20,6 +22,7 @@ class Issue < ActiveRecord::Base
|
|||
after_create :deliver_new_issue_notification
|
||||
after_create :deliver_issue_assign_notification
|
||||
after_update :deliver_issue_assign_notification
|
||||
after_update :subscribe_issue_assigned_user
|
||||
|
||||
def assign_uname
|
||||
user.uname if user
|
||||
|
@ -29,6 +32,12 @@ class Issue < ActiveRecord::Base
|
|||
serial_id.to_s
|
||||
end
|
||||
|
||||
def subscribe_creator(creator_id)
|
||||
if !self.subscribes.exists?(:user_id => creator_id)
|
||||
self.subscribes.create(:user_id => creator_id)
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def set_serial_id
|
||||
|
@ -40,12 +49,12 @@ class Issue < ActiveRecord::Base
|
|||
recipients = collect_recipient_ids
|
||||
recipients.each do |recipient_id|
|
||||
recipient = User.find(recipient_id)
|
||||
UserMailer.delay.new_issue_notification(self, recipient)#.deliver
|
||||
UserMailer.delay.new_issue_notification(self, recipient) if User.find(recipient).notifier.can_notify && User.find(recipient).notifier.new_issue
|
||||
end
|
||||
end
|
||||
|
||||
def deliver_issue_assign_notification
|
||||
UserMailer.delay.issue_assign_notification(self, self.user) if self.user_id_was != self.user_id
|
||||
UserMailer.delay.issue_assign_notification(self, self.user) if self.user_id_was != self.user_id && self.user.notifier.issue_assign && self.user.notifier.can_notify
|
||||
end
|
||||
|
||||
def subscribe_users
|
||||
|
@ -60,7 +69,21 @@ class Issue < ActiveRecord::Base
|
|||
recipients = self.project.relations.by_role('admin').where(:object_type => 'User').map { |rel| rel.read_attribute(:object_id) }
|
||||
recipients = recipients | [self.user_id] if self.user_id
|
||||
recipients = recipients | [self.project.owner_id] if self.project.owner_type == 'User'
|
||||
|
||||
# filter by notification settings
|
||||
recipients = recipients.select do |recipient|
|
||||
User.find(recipient).notifier.new_issue && User.find(recipient).notifier.can_notify
|
||||
end
|
||||
|
||||
recipients
|
||||
end
|
||||
|
||||
def subscribe_issue_assigned_user
|
||||
if self.user_id_was != self.user_id
|
||||
self.subscribes.where(:user_id => self.user_id_was).first.destroy unless self.user_id_was.blank?
|
||||
if self.user.notifier.issue_assign && !self.subscribes.exists?(:user_id => self.user_id)
|
||||
self.subscribes.create(:user_id => self.user_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
module Settings
|
||||
def self.table_name_prefix
|
||||
'settings_'
|
||||
end
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
class Settings::Notifier < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
|
||||
validates :user_id, :presence => true
|
||||
end
|
|
@ -4,6 +4,8 @@ class User < ActiveRecord::Base
|
|||
devise :database_authenticatable, :registerable, :omniauthable, # :token_authenticatable, :encryptable, :timeoutable
|
||||
:recoverable, :rememberable, :validatable #, :trackable, :confirmable, :lockable
|
||||
|
||||
has_one :notifier, :class_name => 'Settings::Notifier' #:notifier
|
||||
|
||||
has_many :authentications, :dependent => :destroy
|
||||
has_many :build_lists, :dependent => :destroy
|
||||
|
||||
|
@ -31,6 +33,8 @@ class User < ActiveRecord::Base
|
|||
attr_readonly :uname
|
||||
attr_accessor :login
|
||||
|
||||
after_create :create_settings_notifier
|
||||
|
||||
def admin?
|
||||
role == 'admin'
|
||||
end
|
||||
|
@ -75,5 +79,11 @@ class User < ActiveRecord::Base
|
|||
clean_up_passwords
|
||||
result
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def create_settings_notifier
|
||||
self.create_notifier
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -14,11 +14,11 @@
|
|||
%br
|
||||
%br
|
||||
- if commentable.class == Issue
|
||||
- edit_path = edit_project_issue_comment_path(project, commentable.id, comment)
|
||||
- delete_path = project_issue_comment_path(project, commentable.id, comment)
|
||||
- edit_path = edit_project_issue_comment_path(project, commentable, comment)
|
||||
- delete_path = project_issue_comment_path(project, commentable, comment)
|
||||
- elsif commentable.class == Grit::Commit
|
||||
- edit_path = edit_project_commit_comment_path(project, commentable.id, comment)
|
||||
- delete_path = project_commit_comment_path(project, commentable.id, comment)
|
||||
- edit_path = edit_project_commit_comment_path(project, commentable, comment)
|
||||
- delete_path = project_commit_comment_path(project, commentable, comment)
|
||||
= link_to t("layout.edit"), edit_path if can? :update, comment
|
||||
= link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), delete_path, :method => "delete", :class => "button", :confirm => t("layout.comments.confirm_delete") if can? :delete, comment
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
|||
%h2.title
|
||||
= t("layout.comments.new_header")
|
||||
.inner
|
||||
- new_path = project_issue_comments_path(project, commentable.id) if commentable.class == Issue
|
||||
- new_path = project_commit_comments_path(project, commentable.id) if commentable.class == Grit::Commit
|
||||
- new_path = project_issue_comments_path(project, commentable) if commentable.class == Issue
|
||||
- new_path = project_commit_comments_path(project, commentable) if commentable.class == Grit::Commit
|
||||
= form_for :comment, :url => new_path, :method => :post, :html => { :class => :form } do |f|
|
||||
= render :partial => "comments/form", :locals => {:f => f}
|
||||
|
|
|
@ -68,3 +68,5 @@
|
|||
%span.text_button_padding
|
||||
= link_to t('layout.back'), :back, :class => "text_button_padding link_button"
|
||||
|
||||
.group.navform.wat-cf
|
||||
= link_to t('layout.settings.notifier'), user_settings_notifier_path(current_user)#, :class => "text_button_padding link_button"
|
||||
|
|
|
@ -19,4 +19,4 @@
|
|||
= render :partial => 'issues/list'
|
||||
.actions-bar.wat-cf
|
||||
.actions
|
||||
= will_paginate @issues, :param_name => :issue_page
|
||||
= will_paginate @issues#, :param_name => :issue_page
|
||||
|
|
|
@ -29,4 +29,4 @@
|
|||
- else
|
||||
= link_to t('layout.issues.subscribe_btn'), project_issue_subscribes_path(@project, @issue), :method => :post
|
||||
|
||||
= render :partial => "comments/list", :locals => {:list => @issue.comments, :project => @project, :commentable => @issue}
|
||||
= render :partial => "comments/list", :locals => {:list => @issue.comments.order(:created_at), :project => @project, :commentable => @issue}
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
.group
|
||||
= f.label :can_notify, t('activerecord.attributes.settings.notifier.can_notify'), :class => :label
|
||||
= f.check_box :can_notify#, :class => 'text_field'
|
||||
|
||||
.group
|
||||
= f.label :new_comment, t('activerecord.attributes.settings.notifier.new_comment'), :class => :label
|
||||
= f.check_box :new_comment, :class => 'notify_cbx'
|
||||
|
||||
.group
|
||||
= f.label :new_comment_reply, t('activerecord.attributes.settings.notifier.new_comment_reply'), :class => :label
|
||||
= f.check_box :new_comment_reply, :class => 'notify_cbx'
|
||||
|
||||
.group
|
||||
= f.label :new_issue, t('activerecord.attributes.settings.notifier.new_issue'), :class => :label
|
||||
= f.check_box :new_issue, :class => 'notify_cbx'
|
||||
|
||||
.group
|
||||
= f.label :issue_assign, t('activerecord.attributes.settings.notifier.issue_assign'), :class => :label
|
||||
= f.check_box :issue_assign, :class => 'notify_cbx'
|
||||
|
||||
.group.navform.wat-cf
|
||||
%button.button{:type => "submit"}
|
||||
= image_tag("web-app-theme/icons/tick.png", :alt => t("layout.save"))
|
||||
= t("layout.save")
|
||||
%span.text_button_padding= t("layout.or")
|
||||
= link_to t("layout.cancel"), user_settings_notifier_path(@user), :class => "text_button_padding link_button"
|
||||
|
||||
:javascript
|
||||
disableNotifierCbx($('#settings_notifier_can_notify'));
|
|
@ -0,0 +1,5 @@
|
|||
#block-signup.block
|
||||
%h2= title t("layout.settings.notifiers.edit_header")
|
||||
.content
|
||||
= form_for @notifier, :url => user_settings_notifier_path(@user), :html => { :class => :form } do |f|
|
||||
= render :partial => "form", :locals => {:f => f}
|
|
@ -0,0 +1,9 @@
|
|||
%p== Здравствуйте, #{@user.name}.
|
||||
|
||||
|
||||
%p На Ваш комментарий в задаче #{ link_to @comment.commentable.title, [@comment.commentable.project, @comment.commentable] } был дан ответ.
|
||||
|
||||
%p "#{ @comment.body }"
|
||||
|
||||
|
||||
%p== Команда поддержки «ROSA Build System»
|
|
@ -40,6 +40,10 @@ ru:
|
|||
not_access: Нет доступа!
|
||||
owner: Владелец
|
||||
confirm: Уверенны?
|
||||
settings:
|
||||
notifier: Настройки оповещений
|
||||
notifiers:
|
||||
edit_header: Настройки оповещений
|
||||
processing: Обрабатывается...
|
||||
|
||||
downloads:
|
||||
|
@ -365,6 +369,11 @@ ru:
|
|||
project_version_not_found: версия не найден
|
||||
|
||||
flash:
|
||||
settings:
|
||||
saved: Настройки успешно сохранены
|
||||
save_error: При обновлении настроек произошла ошибка
|
||||
|
||||
|
||||
subscribe:
|
||||
saved: Вы подписаны на оповещения для этой задачи
|
||||
destroyed: Подписка на оповещения для этой задачи убрана
|
||||
|
@ -490,8 +499,18 @@ ru:
|
|||
build_list_item: Элемент сборочного листа
|
||||
download: Статистика
|
||||
auto_build_list: Автоматическая пересборка пакетов
|
||||
settings:
|
||||
notifier: Настройки оповещений
|
||||
|
||||
attributes:
|
||||
settings:
|
||||
notifier:
|
||||
can_notify: Включить оповещения по электронной почте
|
||||
new_comment: Оповещать о новом комментарии в задаче
|
||||
new_comment_reply: Оповещать о новом ответе на мой комментарий
|
||||
new_issue: Оповещать о новых задачах в моих проектах
|
||||
issue_assign: Оповещать, когда на меня выставляют задачу
|
||||
|
||||
auto_build_list:
|
||||
project_id: Проект
|
||||
project: Проект
|
||||
|
|
|
@ -9,6 +9,9 @@ Rosa::Application.routes.draw do
|
|||
resources :users do
|
||||
resources :groups, :only => [:new, :create, :index]
|
||||
get :autocomplete_user_uname, :on => :collection
|
||||
namespace :settings do
|
||||
resource :notifier, :only => [:show, :update]
|
||||
end
|
||||
end
|
||||
|
||||
resources :event_logs, :only => :index
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
class CreateSettingsNotifiers < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_table :settings_notifiers do |t|
|
||||
t.integer :user_id, :null => false
|
||||
|
||||
t.boolean :can_notify, :default => true
|
||||
t.boolean :new_comment, :default => true
|
||||
t.boolean :new_comment_reply, :default => true
|
||||
t.boolean :new_issue, :default => true
|
||||
t.boolean :issue_assign, :default => true
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
|
||||
def self.down
|
||||
drop_table :settings_notifiers
|
||||
end
|
||||
end
|
|
@ -0,0 +1,13 @@
|
|||
class AddSettingsNotifierToAllUsers < ActiveRecord::Migration
|
||||
def self.up
|
||||
User.all.each do |user|
|
||||
user.create_notifier
|
||||
end
|
||||
end
|
||||
|
||||
def self.down
|
||||
User.all.each do |user|
|
||||
user.notifier.destroy
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,9 @@
|
|||
class AddIssueStatusDefaultValue < ActiveRecord::Migration
|
||||
def self.up
|
||||
change_column :issues, :status, :string, :default => 'open'
|
||||
end
|
||||
|
||||
def self.down
|
||||
change_column :issues, :status, :string, :null => true
|
||||
end
|
||||
end
|
|
@ -0,0 +1,9 @@
|
|||
class AddPackageVersionToBuildLists < ActiveRecord::Migration
|
||||
def self.up
|
||||
add_column :build_lists, :package_version, :string
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_column :build_lists, :package_version
|
||||
end
|
||||
end
|
16
db/schema.rb
16
db/schema.rb
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20120111080234) do
|
||||
ActiveRecord::Schema.define(:version => 20120113151305) do
|
||||
|
||||
create_table "arches", :force => true do |t|
|
||||
t.string "name", :null => false
|
||||
|
@ -72,6 +72,7 @@ ActiveRecord::Schema.define(:version => 20120111080234) do
|
|||
t.text "include_repos"
|
||||
t.integer "user_id"
|
||||
t.boolean "auto_publish", :default => true
|
||||
t.string "package_version"
|
||||
end
|
||||
|
||||
add_index "build_lists", ["arch_id"], :name => "index_build_lists_on_arch_id"
|
||||
|
@ -158,7 +159,7 @@ ActiveRecord::Schema.define(:version => 20120111080234) do
|
|||
t.integer "user_id"
|
||||
t.string "title"
|
||||
t.text "body"
|
||||
t.string "status"
|
||||
t.string "status", :default => "open"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
end
|
||||
|
@ -287,6 +288,17 @@ ActiveRecord::Schema.define(:version => 20120111080234) 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 "settings_notifiers", :force => true do |t|
|
||||
t.integer "user_id", :null => false
|
||||
t.boolean "can_notify", :default => true
|
||||
t.boolean "new_comment", :default => true
|
||||
t.boolean "new_comment_reply", :default => true
|
||||
t.boolean "new_issue", :default => true
|
||||
t.boolean "issue_assign", :default => true
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
create_table "subscribes", :force => true do |t|
|
||||
t.integer "subscribeable_id"
|
||||
t.string "subscribeable_type"
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
function disableNotifierCbx(global_cbx) {
|
||||
if ($(global_cbx).attr('checked')) {
|
||||
$('.notify_cbx').removeAttr('disabled');
|
||||
$('.notify_cbx').each(function(i,el) { $(el).prev().removeAttr('disabled'); })
|
||||
} else {
|
||||
$('.notify_cbx').attr('disabled', 'disabled');
|
||||
$('.notify_cbx').each(function(i,el) { $(el).prev().attr('disabled', 'disabled'); })
|
||||
}
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$('select#build_list_pl_id').change(function() {
|
||||
var platform_id = $(this).val();
|
||||
|
@ -29,4 +39,8 @@ $(document).ready(function() {
|
|||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#settings_notifier_can_notify').click(function() {
|
||||
disableNotifierCbx($(this));
|
||||
});
|
||||
});
|
||||
|
|
|
@ -300,13 +300,15 @@ describe BuildListsController do
|
|||
|
||||
describe 'publish_build' do
|
||||
def do_get(status)
|
||||
get :publish_build, :id => build_list.bs_id, :status => status
|
||||
get :publish_build, :id => build_list.bs_id, :status => status, :version => '4.7.5.3', :release => '1'
|
||||
build_list.reload
|
||||
end
|
||||
|
||||
it { do_get(BuildServer::SUCCESS); response.should be_ok }
|
||||
it { lambda{ do_get(BuildServer::SUCCESS) }.should change(build_list, :status).to(BuildList::BUILD_PUBLISHED) }
|
||||
it { lambda{ do_get(BuildServer::SUCCESS) }.should change(build_list, :package_version).to('4.7.5.3-1') }
|
||||
it { lambda{ do_get(BuildServer::ERROR) }.should change(build_list, :status).to(BuildList::FAILED_PUBLISH) }
|
||||
it { lambda{ do_get(BuildServer::ERROR) }.should_not change(build_list, :package_version) }
|
||||
it { lambda{ do_get(BuildServer::ERROR) }.should change(build_list, :notified_at) }
|
||||
end
|
||||
|
||||
|
|
|
@ -60,12 +60,12 @@ 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
|
||||
# delete :destroy, :id => @comment.id, :issue_id => @issue.serial_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)
|
||||
# lambda{ delete :destroy, :id => @comment.id, :issue_id => @issue.serial_id, :project_id => @project.id }.should change{ Comment.count }.by(-1)
|
||||
# end
|
||||
#end
|
||||
|
||||
|
|
|
@ -49,12 +49,12 @@ 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
|
||||
delete :destroy, :id => @comment.id, :issue_id => @issue.serial_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)
|
||||
lambda{ delete :destroy, :id => @comment.id, :issue_id => @issue.serial_id, :project_id => @project.id }.should change{ Issue.count }.by(0)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -77,8 +77,8 @@ describe CommentsController do
|
|||
@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}
|
||||
@create_params = {:comment => {:body => 'I am a comment!'}, :project_id => @project.id, :issue_id => @issue.serial_id}
|
||||
@update_params = {:comment => {:body => 'updated'}, :project_id => @project.id, :issue_id => @issue.serial_id}
|
||||
|
||||
any_instance_of(Project, :versions => ['v1.0', 'v2.0'])
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Settings::NotifiersController do
|
||||
|
||||
end
|
|
@ -0,0 +1,6 @@
|
|||
# Read about factories at http://github.com/thoughtbot/factory_girl
|
||||
|
||||
FactoryGirl.define do
|
||||
factory :notifier do
|
||||
end
|
||||
end
|
|
@ -0,0 +1,15 @@
|
|||
require 'spec_helper'
|
||||
|
||||
# Specs in this file have access to a helper object that includes
|
||||
# the Settings::NotifiersHelper. For example:
|
||||
#
|
||||
# describe Settings::NotifiersHelper do
|
||||
# describe "string concat" do
|
||||
# it "concats two strings with spaces" do
|
||||
# helper.concat_strings("this","that").should == "this that"
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
describe Settings::NotifiersHelper do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
|
@ -1,7 +1,7 @@
|
|||
require 'spec_helper'
|
||||
require "cancan/matchers"
|
||||
|
||||
def set_comments_data
|
||||
def set_commentable_data
|
||||
@ability = Ability.new(@user)
|
||||
|
||||
@project = Factory(:project)
|
||||
|
@ -19,7 +19,7 @@ describe Comment do
|
|||
@user = Factory(:admin)
|
||||
@stranger = Factory(:user)
|
||||
|
||||
set_comments_data
|
||||
set_commentable_data
|
||||
end
|
||||
|
||||
it 'should create comment' do
|
||||
|
@ -52,7 +52,7 @@ describe Comment do
|
|||
@user = Factory(:user)
|
||||
@stranger = Factory(:user)
|
||||
|
||||
set_comments_data
|
||||
set_commentable_data
|
||||
|
||||
@project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin')
|
||||
end
|
||||
|
@ -79,7 +79,7 @@ describe Comment do
|
|||
@user = Factory(:user)
|
||||
@stranger = Factory(:user)
|
||||
|
||||
set_comments_data
|
||||
set_commentable_data
|
||||
|
||||
@project.update_attribute(:owner, @user)
|
||||
@project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin')
|
||||
|
@ -107,7 +107,7 @@ describe Comment do
|
|||
@user = Factory(:user)
|
||||
@stranger = Factory(:user)
|
||||
|
||||
set_comments_data
|
||||
set_commentable_data
|
||||
end
|
||||
|
||||
it 'should create comment' do
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Settings::Notifier do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
Loading…
Reference in New Issue