#465: Fixed: undefined method 'uname' for nil:NilClass
This commit is contained in:
parent
bb8a4aa227
commit
08db1ad59a
|
@ -15,11 +15,14 @@ class ProjectPolicy < ApplicationPolicy
|
|||
local_reader?
|
||||
end
|
||||
alias_method :read?, :show?
|
||||
alias_method :fork?, :show?
|
||||
alias_method :archive?, :show?
|
||||
alias_method :get_id?, :show?
|
||||
alias_method :refs_list?, :show?
|
||||
|
||||
def fork?
|
||||
!user.guest? && show?
|
||||
end
|
||||
|
||||
def create?
|
||||
return false if user.guest?
|
||||
return true if is_admin?
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
'ng-init' => "init('#{@project.name_with_owner}', '#{@treeish}', '#{@path}')" }
|
||||
.files
|
||||
.pull-left= render 'whereami'
|
||||
.pull-right= render 'fork'
|
||||
- if policy(@project).fork?
|
||||
.pull-right= render 'fork'
|
||||
.clearfix
|
||||
%table.table.table-hover
|
||||
%thead
|
||||
|
|
|
@ -16,7 +16,7 @@ RSpec.describe ProjectPolicy, type: :policy do
|
|||
end
|
||||
end
|
||||
|
||||
%i(show? read? fork? archive? get_id? refs_list?).each do |perm|
|
||||
%i(show? read? archive? get_id? refs_list?).each do |perm|
|
||||
permissions perm do
|
||||
it "grants access to anonymous user" do
|
||||
expect(subject).to permit(User.new, project)
|
||||
|
@ -53,6 +53,41 @@ RSpec.describe ProjectPolicy, type: :policy do
|
|||
end
|
||||
end
|
||||
|
||||
permissions :fork? do
|
||||
it "denies access to anonymous user" do
|
||||
expect(subject).to_not permit(User.new, project)
|
||||
end
|
||||
|
||||
it "grants access to user" do
|
||||
expect(subject).to permit(user, project)
|
||||
end
|
||||
|
||||
context 'hidden project' do
|
||||
before do
|
||||
project.visibility = 'hidden'
|
||||
end
|
||||
|
||||
it "grants access for owner of project" do
|
||||
expect(subject).to permit(project.owner, project)
|
||||
end
|
||||
|
||||
it "grants access for member of project owner group" do
|
||||
project = FactoryGirl.build(:group_project)
|
||||
allow_any_instance_of(ProjectPolicy).to receive(:user_group_ids).and_return([project.owner_id])
|
||||
expect(subject).to permit(user, project)
|
||||
end
|
||||
|
||||
it "grants access for reader of project" do
|
||||
allow_any_instance_of(ProjectPolicy).to receive(:local_reader?).and_return(true)
|
||||
expect(subject).to permit(user, project)
|
||||
end
|
||||
|
||||
it "grants access for to global admin" do
|
||||
expect(subject).to permit(FactoryGirl.create(:admin), project)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
permissions :create? do
|
||||
it "denies access to anonymous user" do
|
||||
expect(subject).to_not permit(User.new, project)
|
||||
|
|
Loading…
Reference in New Issue