Merge branch 'master' into 19-gfm

Conflicts:
	app/views/projects/issues/_issue.html.haml
This commit is contained in:
Alexander Machehin 2013-04-08 17:04:59 +06:00
commit 914a2967c3
33 changed files with 266 additions and 132 deletions

View File

@ -0,0 +1,47 @@
$(document).ready(function() {
jQuery(window).bind('hashchange', function(e) {
var hash = location.hash;
if (/^#(diff|discussion)-F[0-9]+(L|R)[0-9]+/.test(hash)) {
highlightDiff(hash);
} else if (/^#L[0-9]+/.test(hash)) {
highlightShow(hash);
}
});
// Since the event is only triggered when the hash changes, we need to trigger
// the event now, to handle the hash the page may have loaded with.
jQuery(window).trigger('hashchange');
});
function highlightShow(id) {
$('.highlight-line').remove();
var from = to = id.substring(2);
if (/[0-9]+\-L[0-9]+$/.test(from)) {
var index = to.indexOf('-');
to = to.substring(index + 2);
from = from.substring(0, index);
}
from = parseInt(from);
to = parseInt(to);
if (from && to) {
if (from > to) {
var x = to; to = from; from = x;
}
var el = $('#L' + from);
$(document).scrollTop( el.offset().top );
while (el.length > 0) {
el.append('<div class="highlight-line"></div>');
if (from == to) { return true; }
from += 1;
el = $('#L' + from);
}
}
}
function highlightDiff(id) {
$('.highlight-line').removeClass('highlight-line');
$(id).parent().find('td.code').addClass('highlight-line');
}

View File

@ -325,6 +325,18 @@ article div.file table {
background-color: #DDFFDD;
}
#repo-wrapper table.diff tr td.code.highlight-line {
background-color: #FFFFCC;
}
.gutter .highlight-line {
background-color: #FF9900;
width: 805px;
height: 12px;
margin: -12px 0 0 50px;
opacity: 0.2;
position: absolute;
}
#repo-wrapper table.diff tr td.code.ins .idiff {
background-color: #BAFBAD;
}

View File

@ -1674,49 +1674,49 @@ table.tablesorter.tracker td.td0{
padding-right: 0px;
}
table.tablesorter.tracker .td3.td3-pull {
min-width: 130px;
}
table.tablesorter.tracker td.td3{
min-width: 110px;
padding-top: 10px;
min-width: 110px;
.code {
height: 23px;
width: 15px;
background: #FFF;
color: #009fe3;
border: 1px solid #83d1f2;
font-size: 16px;
padding: 5px 0px 0px 5px;
margin-right: 3px;
cursor: pointer;
}
.avatar {
margin-right: 8px;
cursor: pointer;
}
.answers {
height: 28px;
background: #FFF;
color: #009fe3;
border: 1px solid #83d1f2;
font-size: 16px;
cursor: pointer;
.pic {
float: left;
margin: 2px;
margin-top: 6px;
}
.count {
float: left;
margin: 4px 5px 0px 2px;
}
}
}
table.tablesorter.tracker td.td3 div.code {
height: 23px;
width: 15px;
background: #FFF;
color: #009fe3;
border: 1px solid #83d1f2;
font-size: 16px;
padding: 5px 0px 0px 5px;
.tablesorter.tracker .td3 > a {
float: left;
margin-right: 3px;
cursor: pointer;
}
table.tablesorter.tracker td.td3 div.avatar {
float: left;
margin-right: 8px;
cursor: pointer;
}
table.tablesorter.tracker td.td3 div.answers {
height: 28px;
background: #FFF;
color: #009fe3;
border: 1px solid #83d1f2;
font-size: 16px;
float: left;
cursor: pointer;
}
table.tablesorter.tracker td.td3 div.answers div.pic {
float: left;
margin: 2px;
margin-top: 6px;
}
table.tablesorter.tracker td.td3 div.answers div.count {
float: left;
margin: 4px 5px 0px 2px;
}
table.tablesorter.tracker div.smalltext {

View File

@ -33,6 +33,8 @@ class Api::V1::BuildListsController < Api::V1::BaseController
end
def publish
@build_list.publisher = current_user
@build_list.save
render_json :publish
end

View File

@ -1,6 +1,7 @@
#class MassBuildsController < ApplicationController
class Platforms::MassBuildsController < Platforms::BaseController
before_filter :authenticate_user!
skip_before_filter :authenticate_user!, :only => [:index, :get_list] if APP_CONFIG['anonymous_access']
load_and_authorize_resource :platform
load_and_authorize_resource
@ -29,16 +30,14 @@ class Platforms::MassBuildsController < Platforms::BaseController
def publish
if params[:status] == 'test_failed'
@mass_build.publish_test_faild_builds
@mass_build.publish_test_faild_builds current_user
else
@mass_build.publish_success_builds
@mass_build.publish_success_builds current_user
end
redirect_to(platform_mass_builds_path(@mass_build.platform), :notice => t("flash.platform.publish_success"))
end
def index
authorize! :local_admin_manage, @platform
@mass_builds = MassBuild.by_platform(@platform).order('created_at DESC').paginate(:page => params[:page], :per_page => 20)
@auto_publish_selected = true
end

View File

@ -173,6 +173,7 @@ class Projects::BuildListsController < Projects::BaseController
end
@build_list.publisher = current_user
if @build_list.save && @build_list.can_publish? && @build_list.now_publish
redirect_to :back, :notice => t('layout.build_lists.publish_success')
else

View File

@ -52,6 +52,7 @@ module DiffHelper
def prepare(args)
@url, @diff_counter, @in_discussion = args[:url], args[:diff_counter], args[:in_discussion]
@filepath, @line_comments = args[:filepath], args[:comments]
@diff_prefix = args[:diff_prefix] || 'diff'
@add_reply_id, @num_line = if @in_discussion
[@line_comments[0].id, @line_comments[0].data[:line].to_i - @line_comments[0].data[:strings].lines.count.to_i-1]
else
@ -74,7 +75,7 @@ module DiffHelper
set_line_number
"<tr class='changes'>
<td class='line_numbers'></td>
#{td_line_link "diff-F#{@diff_counter}R#{line.new_number}", line.new_number}
#{td_line_link "#{@diff_prefix}-F#{@diff_counter}R#{line.new_number}", line.new_number}
<td class='code ins'>
#{line_comment}
<pre>#{render_line(line)}</pre>
@ -86,7 +87,7 @@ module DiffHelper
def remline(line)
set_line_number
"<tr class='changes'>
#{td_line_link "diff-F#{@diff_counter}L#{line.old_number}", line.old_number}
#{td_line_link "#{@diff_prefix}-F#{@diff_counter}L#{line.old_number}", line.old_number}
<td class='line_numbers'></td>
<td class='code del'>
#{line_comment}
@ -99,8 +100,8 @@ module DiffHelper
def modline(line)
set_line_number
"<tr clas='chanes line'>
#{td_line_link "diff-F#{@diff_counter}L#{line.old_number}", line.old_number}
#{td_line_link "diff-F#{@diff_counter}R#{line.new_number}", line.new_number}
#{td_line_link "#{@diff_prefix}-F#{@diff_counter}L#{line.old_number}", line.old_number}
#{td_line_link "#{@diff_prefix}-F#{@diff_counter}R#{line.new_number}", line.new_number}
<td class='code unchanged modline'>
#{line_comment}
<pre>#{render_line(line)}</pre>
@ -112,8 +113,8 @@ module DiffHelper
def unmodline(line)
set_line_number
"<tr class='changes unmodline'>
#{td_line_link "diff-F#{@diff_counter}L#{line.old_number}", line.old_number}
#{td_line_link "diff-F#{@diff_counter}R#{line.new_number}", line.new_number}
#{td_line_link "#{@diff_prefix}-F#{@diff_counter}L#{line.old_number}", line.old_number}
#{td_line_link "#{@diff_prefix}-F#{@diff_counter}R#{line.new_number}", line.new_number}
<td class='code unchanged unmodline'>
#{line_comment}
<pre>#{render_line(line)}</pre>
@ -133,8 +134,8 @@ module DiffHelper
def nonewlineline(line)
set_line_number
"<tr class='changes'>
#{td_line_link "diff-F#{@diff_counter}L#{line.old_number}", line.old_number}
#{td_line_link "diff-F#{@diff_counter}R#{line.new_number}", line.new_number}
#{td_line_link "#{@diff_prefix}-F#{@diff_counter}L#{line.old_number}", line.old_number}
#{td_line_link "#{@diff_prefix}-F#{@diff_counter}R#{line.new_number}", line.new_number}
<td class='code modline unmodline'>
#{line_comment}
<pre>#{render_line(line)}</pre>

View File

@ -62,7 +62,7 @@ class UserMailer < ActionMailer::Base
mail(
:to => email_with_name(user, user.email),
:subject => subject,
:from => email_with_name(build_list.user)
:from => email_with_name(build_list.publisher || build_list.user)
) do |format|
format.html
end

View File

@ -26,6 +26,7 @@ class Ability
# Platforms block
can [:show, :members, :advisories], Platform, :visibility => 'open'
can :platforms_for_build, Platform, :visibility => 'open', :platform_type => 'main'
can(:get_list, MassBuild) {|mass_build| mass_build.platform.main? && can?(:show, mass_build.platform) }
can [:read, :projects_list, :projects], Repository, :platform => {:visibility => 'open'}
can :read, Product, :platform => {:visibility => 'open'}
@ -98,7 +99,7 @@ class Ability
can([:update, :destroy], Platform) {|platform| owner?(platform) }
can([:local_admin_manage, :members, :add_member, :remove_member, :remove_members] , Platform) {|platform| owner?(platform) || local_admin?(platform) }
can([:get_list, :create, :publish], MassBuild) {|mass_build| (owner?(mass_build.platform) || local_admin?(mass_build.platform)) && mass_build.platform.main?}
can([:create, :publish], MassBuild) {|mass_build| (owner?(mass_build.platform) || local_admin?(mass_build.platform)) && mass_build.platform.main?}
can(:cancel, MassBuild) {|mass_build| (owner?(mass_build.platform) || local_admin?(mass_build.platform)) && !mass_build.stop_build && mass_build.platform.main?}
can [:read, :projects_list, :projects], Repository, :platform => {:owner_type => 'User', :owner_id => user.id}

View File

@ -2,6 +2,15 @@
class ActivityFeedObserver < ActiveRecord::Observer
observe :issue, :comment, :user, :build_list
BUILD_LIST_STATUSES = [
BuildList::BUILD_PUBLISHED,
BuildList::SUCCESS,
BuildList::BUILD_ERROR,
BuildList::PROJECT_VERSION_NOT_FOUND,
BuildList::FAILED_PUBLISH,
BuildList::TESTS_FAILED
].freeze
def after_create(record)
case record.class.to_s
when 'User'
@ -138,21 +147,28 @@ class ActivityFeedObserver < ActiveRecord::Observer
end
when 'BuildList'
if [BuildList::BUILD_PUBLISHED,
BuildList::SUCCESS,
BuildList::BUILD_ERROR,
BuildList::PROJECT_VERSION_NOT_FOUND,
BuildList::FAILED_PUBLISH,
BuildList::TESTS_FAILED
].include? record.status or
(record.status == BuildList::BUILD_PENDING && record.bs_id_changed?)
if record.mass_build.blank? && ( # Do not show mass build activity in activity feeds
record.status_changed? && BUILD_LIST_STATUSES.include?(record.status) ||
record.status == BuildList::BUILD_PENDING && record.bs_id_changed?
)
record.project.admins.each do |recipient|
user = record.publisher || record.user
ActivityFeed.create(
:user => recipient,
:kind => 'build_list_notification',
:data => {:task_num => record.bs_id, :build_list_id => record.id, :status => record.status, :updated_at => record.updated_at,
:project_id => record.project_id, :project_name => record.project.name, :project_owner => record.project.owner.uname,
:user_name => record.user.name, :user_email => record.user.email, :user_id => record.user_id}
:data => {
:task_num => record.bs_id,
:build_list_id => record.id,
:status => record.status,
:updated_at => record.updated_at,
:project_id => record.project_id,
:project_name => record.project.name,
:project_owner => record.project.owner.uname,
:user_name => user.name,
:user_email => user.email,
:user_id => user.id
}
)
end
end

View File

@ -10,6 +10,7 @@ class BuildList < ActiveRecord::Base
belongs_to :save_to_repository, :class_name => 'Repository'
belongs_to :build_for_platform, :class_name => 'Platform'
belongs_to :user
belongs_to :publisher, :class_name => 'User'
belongs_to :advisory
belongs_to :mass_build, :counter_cache => true
has_many :items, :class_name => "BuildList::Item", :dependent => :destroy
@ -85,7 +86,7 @@ class BuildList < ActiveRecord::Base
BUILD_ERROR,
PROJECT_VERSION_NOT_FOUND,
TESTS_FAILED
]
].freeze
HUMAN_STATUSES = { WAITING_FOR_RESPONSE => :waiting_for_response,
BUILD_CANCELED => :build_canceled,
@ -100,7 +101,7 @@ class BuildList < ActiveRecord::Base
SUCCESS => :success,
PROJECT_VERSION_NOT_FOUND => :project_version_not_found,
TESTS_FAILED => :tests_failed
}
}.freeze
scope :recent, order("#{table_name}.updated_at DESC")
scope :for_status, lambda {|status| where(:status => status) }
@ -156,6 +157,7 @@ class BuildList < ActiveRecord::Base
after_transition :on => :published,
:do => [:set_version_and_tag, :actualize_packages]
after_transition :on => :publish, :do => :set_publisher
after_transition :on => :cancel, :do => :cancel_job
after_transition :on => [:published, :fail_publish, :build_error, :tests_failed], :do => :notify_users
@ -226,7 +228,7 @@ class BuildList < ActiveRecord::Base
BUILD_PUBLISHED => :container_published,
BUILD_PUBLISH => :container_publish,
FAILED_PUBLISH => :container_failed_publish
}
}.freeze
state_machine :container_status, :initial => :waiting_for_publish do
@ -476,6 +478,11 @@ class BuildList < ActiveRecord::Base
self.use_save_to_repository = true if save_to_platform.main?
end
def set_publisher
self.publisher ||= user
save
end
def current_ability
@current_ability ||= Ability.new(user)
end

View File

@ -77,20 +77,22 @@ class MassBuild < ActiveRecord::Base
end
later :cancel_all, :queue => :clone_build
def publish_success_builds
publish BuildList::SUCCESS, BuildList::FAILED_PUBLISH
def publish_success_builds(user)
publish user, BuildList::SUCCESS, BuildList::FAILED_PUBLISH
end
later :publish_success_builds, :queue => :clone_build
def publish_test_faild_builds
publish BuildList::TESTS_FAILED
def publish_test_faild_builds(user)
publish user, BuildList::TESTS_FAILED
end
later :publish_test_faild_builds, :queue => :clone_build
private
def publish(*statuses)
build_lists.where(:status => statuses).order(:id).find_in_batches(:batch_size => 50) do |bls|
def publish(user, *statuses)
builds = build_lists.where(:status => statuses)
builds.update_all(:publisher_id => user.id)
builds.order(:id).find_in_batches(:batch_size => 50) do |bls|
bls.each{ |bl| bl.can_publish? && bl.now_publish }
end
end

View File

@ -22,7 +22,7 @@ class ProductBuildList < ActiveRecord::Base
BUILD_PENDING,
BUILD_CANCELED,
BUILD_CANCELING
]
].freeze
HUMAN_STATUSES = { BUILD_STARTED => :build_started,
BUILD_COMPLETED => :build_completed,
@ -30,7 +30,7 @@ class ProductBuildList < ActiveRecord::Base
BUILD_PENDING => :build_pending,
BUILD_CANCELED => :build_canceled,
BUILD_CANCELING => :build_canceling
}
}.freeze
belongs_to :product
belongs_to :project

View File

@ -40,7 +40,13 @@ json.build_list do |json|
:json => json_build_for_platform
end
json.partial! 'api/v1/shared/owner', :owner => @build_list.project.owner
json.user do |json_user|
json.partial! 'api/v1/shared/member', :member => @build_list.user, :tag => json_user
end
json.publisher do |json_publisher|
json.partial! 'api/v1/shared/member', :member => @build_list.publisher, :tag => json_publisher
end if @build_list.publisher
inc_repos = Repository.includes(:platform).where(:id => @build_list.include_repos)
json.include_repos inc_repos do |json_include_repos, repo|

View File

@ -13,7 +13,7 @@
- if can? :show, @platform
%li{:class => (act == :index && contr == :maintainers) ? 'active' : nil}
= link_to t("layout.platforms.maintainers"), platform_maintainers_path(@platform)
- if can? :edit, @platform
- if @platform.main? && can?(:show, @platform)
%li{:class => (contr == :mass_builds && [:index, :create].include?(act)) ? 'active' : ''}
= link_to t("layout.platforms.mass_build"), platform_mass_builds_path(@platform)
- if can? :read, @platform.products.build

View File

@ -0,0 +1,17 @@
= form_for :build, :url => platform_mass_builds_path(@platform), :html => { :class => 'form mass_build', :method => :post } do |f|
%section.left
=render 'repos_or_list_choice'
%br
= f.submit t("layout.projects.build_button")
%section.right
%h3= t("activerecord.attributes.build_list.arch")
- Arch.recent.each do |arch|
.lefter
= check_box_tag "arches[]", arch.id, (params[:arches]||[]).include?(arch.id.to_s), :id => "arches_#{arch.id}"
= label_tag "arches_#{arch.id}", arch.name
.both
%h3= t("activerecord.attributes.build_list.preferences")
.both.bottom_20
= check_box_tag :auto_publish, true, @auto_publish_selected, :id => 'auto_publish'
= label_tag :auto_publish, t('activerecord.attributes.build_list.auto_publish')
.both

View File

@ -1,24 +1,7 @@
= render 'platforms/base/submenu'
= render 'platforms/base/sidebar'
= form_for :build, :url => platform_mass_builds_path(@platform), :html => { :class => 'form mass_build', :method => :post } do |f|
%section.left
=render 'repos_or_list_choice'
%br
= f.submit t("layout.projects.build_button")
%section.right
%h3= t("activerecord.attributes.build_list.arch")
- Arch.recent.each do |arch|
.lefter
= check_box_tag "arches[]", arch.id, (params[:arches]||[]).include?(arch.id.to_s), :id => "arches_#{arch.id}"
= label_tag "arches_#{arch.id}", arch.name
.both
%h3= t("activerecord.attributes.build_list.preferences")
.both.bottom_20
= check_box_tag :auto_publish, true, @auto_publish_selected, :id => 'auto_publish'
= label_tag :auto_publish, t('activerecord.attributes.build_list.auto_publish')
%br
%br
= render 'form' if can? :create, @platform.mass_builds.new
%table.tablesorter.unbordered{:cellpadding => "0", :cellspacing => "0"}
%thead

View File

@ -25,6 +25,10 @@
.rightlist
= link_to @build_list.user.try(:fullname), @build_list.user
.both
.leftlist= t("activerecord.attributes.build_list.publisher")
.rightlist
= link_to @build_list.publisher.try(:fullname), @build_list.publisher if @build_list.publisher
.both
.leftlist= t("activerecord.attributes.build_list.build_for_platform")
.rightlist
- bfp = @build_list.build_for_platform

View File

@ -10,6 +10,5 @@
:javascript
$(document).ready(function() {
var text = $('#code').text().replace(/&amp;/gi, '&');
CodeMirror.runMode(text, "#{@blob.raw_mime_type.content_type}", document.getElementById("output"));
});
CodeMirror.runMode($('#code').text().replace(/&amp;/gi, '&'), "#{@blob.raw_mime_type.content_type}", document.getElementById("output"));
});

View File

@ -1,4 +1,4 @@
-path = polymorphic_path [@project, issue.pull_request ? issue.pull_request : issue]
- path = polymorphic_path [@project, issue.pull_request ? issue.pull_request : issue]
%tr#row1{:name => "row", :class => issue.labels.map(&:name).compact}
%td.td0
@ -15,14 +15,11 @@
.left.nomargin
.label.selected.tracker.left
.labeltext.selected{:style => "background: ##{label.color};"}=label.name
%td.td3
-if issue.pull_request
%td.td3{:class => (issue.pull_request ? 'td3-pull' : '')}
- if issue.pull_request
%a{:href => path}
.code #
.avatar
=link_to image_tag(avatar_url(issue.assignee), :alt => 'avatar'), user_path(issue.assignee) if issue.assignee
%a{:href => "#{path}#block-list"}
.answers
.pic= image_tag 'answers.png'
.count=issue.comments.where(:automatic => false).count
.both
= link_to image_tag(avatar_url(issue.assignee), :alt => 'avatar', :class => 'avatar'), user_path(issue.assignee) if issue.assignee
%a.answers{:href => "#{path}#block-list"}
= image_tag 'answers.png', :class => 'pic'
.count=issue.comments.where(:automatic => false).count

View File

@ -13,7 +13,7 @@
.container
.image
= image_tag(avatar_url(user, :micro), :alt => 'avatar')
%span.name= link_to(user.uname, user_path(user))
%span.name= link_to(user.fullname, user_path(user))
%span= t('layout.issues.is_assigned')
= hidden_field_tag "user-#{index}", user.id, :name => "issue[assignee_id]"
.both

View File

@ -2,7 +2,7 @@
- if user
.image
=image_tag(avatar_url(user, :micro), :alt => 'avatar')
%span.name= link_to(user.uname, user_path(user))
%span.name= link_to(user.fullname, user_path(user))
%span= t('layout.issues.is_assigned')
- else
%span= t('layout.issues.no_one_is_assigned')

View File

@ -1,5 +1,6 @@
.hr
-commits_queue = []
- commits_queue = []
- diff_counter = 0
-merge_activity(@comments, @commits).each do |item| #
-if item.is_a? Comment
=render 'projects/git/commits/commits_small', :commits => commits_queue if commits_queue.present?
@ -20,7 +21,8 @@
=t '.show_outdated_diff'
%span.data-expander.collapsed{:id => exp_id} &nbsp;
.hidden{:id => "content-#{exp_id}"}
=render 'projects/pull_requests/discussion_comments', :item => item, :add_id => nil
=render 'projects/pull_requests/discussion_comments', :item => item, :diff_counter => diff_counter
-else
=render 'projects/pull_requests/discussion_comments', :item => item, :add_id => nil
=render 'projects/pull_requests/discussion_comments', :item => item, :diff_counter => diff_counter
- diff_counter += 1
=render 'projects/git/commits/commits_small', :commits => commits_queue if commits_queue.present?

View File

@ -11,5 +11,5 @@
=t'projects.pull_requests.outdated_diff'
=image_tag 'x.png'
.clear
.diff_data=render_diff(comment.inline_diff, :diff_counter => 0, :comments => item[1], :filepath => comment.data[:path])
.diff_data=render_diff(comment.inline_diff, :diff_counter => diff_counter, :comments => item[1], :filepath => comment.data[:path], :diff_prefix => 'discussion')

View File

@ -29,6 +29,7 @@ en:
auto_publish: Automated publising
project_version: Version
user: User
publisher: Publisher
preferences: Preferences
started_at: Build started at
duration: Build duration in seconds

View File

@ -29,6 +29,7 @@ ru:
auto_publish: Автоматическая публикация
project_version: Версия
user: Пользователь
publisher: Публикатор
preferences: Настройки
duration: Длительность билда в секундах
mass_build_id: Массовая сборка

View File

@ -137,7 +137,7 @@ Rosa::Application.routes.draw do
get :members
post :remove_members # fixme: change post to delete
delete :remove_member
put :add_member
post :add_member
post :make_clone
get :advisories
end

View File

@ -0,0 +1,5 @@
class AddPublishedUserToBuildList < ActiveRecord::Migration
def change
add_column :build_lists, :publisher_id, :integer
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20130327120129) do
ActiveRecord::Schema.define(:version => 20130328112110) do
create_table "activity_feeds", :force => true do |t|
t.integer "user_id", :null => false
@ -137,6 +137,7 @@ ActiveRecord::Schema.define(:version => 20130327120129) do
t.boolean "auto_create_container", :default => false
t.text "extra_repositories"
t.text "extra_build_lists"
t.integer "publisher_id"
end
add_index "build_lists", ["advisory_id"], :name => "index_build_lists_on_advisory_id"

View File

@ -7,4 +7,7 @@ end
%w(rosa_system iso_worker_1 file_store).each do |uname|
user = User.new uname: uname, email: "#{uname}@rosalinux.ru", password: SecureRandom.base64
user.confirmed_at, user.role = Time.now.utc, 'system'; user.save
end
end
admin = User.new uname: 'admin_user', email: 'admin_user@rosalinux.ru', password: 'admin_user'
admin.confirmed_at, admin.role = Time.now.utc, 'admin'; admin.save

View File

@ -3,7 +3,7 @@ class ReservedNameValidator < ActiveModel::EachValidator
about account add admin administrator api autocomplete_group_uname
app apps archive archives auth
blog
config connect contact create commit commits
config connect contact create commit commits
dashboard delete direct_messages downloads
edit email
faq favorites feed feeds follow followers following
@ -12,18 +12,17 @@ class ReservedNameValidator < ActiveModel::EachValidator
jobs
login log-in log_in logout log-out log_out logs
map maps
new
new none
oauth oauth_clients openid
privacy
register remove replies rss root
save search sessions settings
signup sign-up sign_up signin sign-in sign_in signout sign-out sign_out
sitemap ssl subscribe
teams terms test trends tree
teams terms test tour trends tree
unfollow unsubscribe url user
widget widgets wiki
xfn xmpp
tour
}
def reserved_names

View File

@ -42,6 +42,11 @@ shared_examples_for 'mass_build platform owner' do
lambda { post :create, @create_params }.should change{ MassBuild.count }.by(1)
end
it 'should be able to perform get_list action' do
get :get_list, :platform_id => @platform, :id => @mass_build, :kind => 'failed_builds_list'
response.should be_success
end
context 'for personal platform' do
before(:each) do
Platform.update_all(:platform_type => 'personal')
@ -57,14 +62,22 @@ shared_examples_for 'mass_build platform owner' do
end
shared_examples_for 'mass_build platform reader' do
[:index, :create].each do |action|
it "should not be able to perform #{ action } action" do
get action, :platform_id => @platform
response.should redirect_to(forbidden_path)
end
it 'should be able to perform index action' do
get :index, :platform_id => @platform
response.should render_template(:index)
end
[:cancel, :get_list, :publish].each do |action|
it 'should be able to perform get_list action' do
get :get_list, :platform_id => @platform, :id => @mass_build, :kind => 'failed_builds_list'
response.should be_success
end
it "should not be able to perform create action" do
get :create, :platform_id => @platform
response.should redirect_to(forbidden_path)
end
[:cancel, :publish].each do |action|
it "should not be able to perform #{ action } action" do
get action, :platform_id => @platform, :id => @mass_build.id
response.should redirect_to(forbidden_path)
@ -111,15 +124,29 @@ describe Platforms::MassBuildsController do
end
context 'for guest' do
[:index, :create].each do |action|
it "should not be able to perform #{ action } action" do
get action, :platform_id => @platform
response.should redirect_to(new_user_session_path)
end
it 'should be able to perform index action', :anonymous_access => true do
get :index, :platform_id => @platform
response.should render_template(:index)
end
it "should not be able to get failed builds list" do
it 'should not be able to perform index action', :anonymous_access => false do
get :index, :platform_id => @platform
response.should redirect_to(new_user_session_path)
end
it 'should be able to perform get_list action', :anonymous_access => true do
get :get_list, :platform_id => @platform, :id => @mass_build, :kind => 'failed_builds_list'
response.should be_success
end
it "should not be able to get failed builds list", :anonymous_access => false do
get :get_list, :platform_id => @platform, :id => @mass_build, :kind => 'failed_builds_list'
response.should redirect_to(new_user_session_path)
end
it "should not be able to perform create action" do
get :create, :platform_id => @platform
response.should redirect_to(new_user_session_path)
end

View File

@ -4,6 +4,7 @@ require 'spec_helper'
describe ProductBuildList do
before do
stub_symlink_methods
stub_redis
FactoryGirl.create(:product_build_list)
end