#465: Update specs
This commit is contained in:
parent
2bc7c9b2c3
commit
e736586129
|
@ -724,17 +724,17 @@ class BuildList < ActiveRecord::Base
|
|||
save
|
||||
end
|
||||
|
||||
def current_ability
|
||||
@current_ability ||= Ability.new(user)
|
||||
end
|
||||
# def current_ability
|
||||
# @current_ability ||= Ability.new(user)
|
||||
# end
|
||||
|
||||
def prepare_extra_repositories
|
||||
if save_to_platform && save_to_platform.main?
|
||||
self.extra_repositories = nil
|
||||
else
|
||||
self.extra_repositories = Repository.joins(:platform).
|
||||
self.extra_repositories = PlatformPolicy::Scope.new(user, Repository.joins(:platform)).show.
|
||||
where(id: extra_repositories, platforms: {platform_type: 'personal'}).
|
||||
accessible_by(current_ability, :read).pluck('repositories.id')
|
||||
pluck('repositories.id')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ module Feed::Issue
|
|||
)
|
||||
end
|
||||
# dont remove outdated issues link
|
||||
::Comment.create_link_on_issues_from_item(self) if previous_changes['title'].present? || previous_changes['body'].present?
|
||||
::Comment.create_link_on_issues_from_item(self) if title_changed? || body_changed?
|
||||
end
|
||||
|
||||
def send_hooks(action = :create)
|
||||
|
|
|
@ -4,7 +4,6 @@ describe BuildLists::DependentPackagesJob do
|
|||
let(:build_list) { FactoryGirl.build(:build_list, id: 123) }
|
||||
let(:user) { build_list.user }
|
||||
let(:project) { build_list.project }
|
||||
let(:ability) { double(:ability) }
|
||||
let(:project_ids) { [build_list.project_id] }
|
||||
let(:arch_ids) { [build_list.arch_id] }
|
||||
let(:options) { {
|
||||
|
@ -18,14 +17,12 @@ describe BuildLists::DependentPackagesJob do
|
|||
before do
|
||||
stub_symlink_methods
|
||||
allow(BuildList).to receive(:find).with(123).and_return(build_list)
|
||||
# BuildList::Package.stub_chain(:joins, :where, :reorder, :uniq, :pluck).and_return([project.id])
|
||||
Project.stub_chain(:where, :to_a).and_return([project])
|
||||
Arch.stub_chain(:where, :to_a).and_return([build_list.arch])
|
||||
allow(Project).to receive_message_chain(:where, :to_a).and_return([project])
|
||||
allow(Arch).to receive_message_chain(:where, :to_a).and_return([build_list.arch])
|
||||
|
||||
allow(Ability).to receive(:new).and_return(ability)
|
||||
allow(ability).to receive(:can?).with(:show, build_list).and_return(true)
|
||||
allow(ability).to receive(:can?).with(:write, project).and_return(true)
|
||||
allow(ability).to receive(:can?).with(:create, anything).and_return(true)
|
||||
allow_any_instance_of(BuildListPolicy).to receive(:show?).and_return(true)
|
||||
allow_any_instance_of(ProjectPolicy).to receive(:write?).and_return(true)
|
||||
allow_any_instance_of(BuildListPolicy).to receive(:create?).and_return(true)
|
||||
end
|
||||
|
||||
subject { BuildLists::DependentPackagesJob }
|
||||
|
@ -43,21 +40,21 @@ describe BuildLists::DependentPackagesJob do
|
|||
end
|
||||
|
||||
it 'ensures that do nothing if user has no access for show of build_list' do
|
||||
allow(ability).to receive(:can?).with(:show, build_list).and_return(false)
|
||||
allow_any_instance_of(BuildListPolicy).to receive(:show?).and_return(false)
|
||||
expect do
|
||||
subject.perform build_list.id, user.id, project_ids, arch_ids, options
|
||||
end.to change(BuildList, :count).by(0)
|
||||
end
|
||||
|
||||
it 'ensures that do nothing if user has no access for write of project' do
|
||||
allow(ability).to receive(:can?).with(:write, project).and_return(false)
|
||||
allow_any_instance_of(ProjectPolicy).to receive(:write?).and_return(false)
|
||||
expect do
|
||||
subject.perform build_list.id, user.id, project_ids, arch_ids, options
|
||||
end.to change(BuildList, :count).by(0)
|
||||
end
|
||||
|
||||
it 'ensures that do nothing if user has no access for create of build_list' do
|
||||
allow(ability).to receive(:can?).with(:create, anything).and_return(false)
|
||||
allow_any_instance_of(BuildListPolicy).to receive(:create?).and_return(false)
|
||||
expect do
|
||||
subject.perform build_list.id, user.id, project_ids, arch_ids, options
|
||||
end.to change(BuildList, :count).by(0)
|
||||
|
|
|
@ -53,8 +53,8 @@ describe Issue do
|
|||
it 'should create automatic comment after updating another issue body' do
|
||||
create_issue(@user)
|
||||
another_issue = FactoryGirl.create(:issue, project: @project)
|
||||
another_issue = Issue.find another_issue.id
|
||||
another_issue.update_attribute(:title, "[##{@issue.serial_id}]")
|
||||
another_issue.send(:send_assign_notifications)
|
||||
|
||||
Comment.where(automatic: true, commentable_type: 'Issue',
|
||||
created_from_issue_id: another_issue.id).count.should == 1
|
||||
|
@ -63,8 +63,9 @@ describe Issue do
|
|||
it 'should send email message to new assignee' do
|
||||
create_issue(@user)
|
||||
ActionMailer::Base.deliveries = []
|
||||
@issue = Issue.find @issue.id
|
||||
@issue.update_attribute :assignee_id, @user.id
|
||||
@issue.send(:send_assign_notifications, :update)
|
||||
|
||||
ActionMailer::Base.deliveries.count.should == 1
|
||||
end
|
||||
end
|
||||
|
|
|
@ -35,14 +35,4 @@ describe ProductBuildList do
|
|||
it { is_expected.to allow_mass_assignment_of(:status) }
|
||||
it { is_expected.to allow_mass_assignment_of(:base_url) }
|
||||
end
|
||||
|
||||
# see app/ability.rb
|
||||
# can :read, ProductBuildList#, product: {platform: {visibility: 'open'}} # double nested hash don't work
|
||||
it 'should generate correct sql to get product build lists' do
|
||||
FactoryGirl.create(:arch, name: 'x86_64')
|
||||
FactoryGirl.create(:product_build_list)
|
||||
user = FactoryGirl.create(:user)
|
||||
ability = Ability.new user
|
||||
expect(ProductBuildList.accessible_by(ability).count).to eq 1
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue