Commit de89dcc2 authored by Gabriel Mazetto's avatar Gabriel Mazetto

Some codestyle changes and fixes for GitLab pages

parent fff5ebdc
...@@ -1222,7 +1222,8 @@ class Project < ActiveRecord::Base ...@@ -1222,7 +1222,8 @@ class Project < ActiveRecord::Base
end end
def pages_path def pages_path
File.join(Settings.pages.path, disk_path) # TODO: when we migrate Pages to work with new storage types, change here to use disk_path
File.join(Settings.pages.path, full_path)
end end
def public_pages_path def public_pages_path
......
...@@ -2318,6 +2318,10 @@ describe Project do ...@@ -2318,6 +2318,10 @@ describe Project do
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
let(:gitlab_shell) { Gitlab::Shell.new } let(:gitlab_shell) { Gitlab::Shell.new }
before do
allow(project).to receive(:gitlab_shell).and_return(gitlab_shell)
end
describe '#base_dir' do describe '#base_dir' do
it 'returns base_dir based on namespace only' do it 'returns base_dir based on namespace only' do
expect(project.base_dir).to eq(project.namespace.full_path) expect(project.base_dir).to eq(project.namespace.full_path)
...@@ -2331,10 +2335,6 @@ describe Project do ...@@ -2331,10 +2335,6 @@ describe Project do
end end
describe '#ensure_storage_path_exist' do describe '#ensure_storage_path_exist' do
before do
allow(project).to receive(:gitlab_shell).and_return(gitlab_shell)
end
it 'delegates to gitlab_shell to ensure namespace is created' do it 'delegates to gitlab_shell to ensure namespace is created' do
expect(gitlab_shell).to receive(:add_namespace).with(project.repository_storage_path, project.base_dir) expect(gitlab_shell).to receive(:add_namespace).with(project.repository_storage_path, project.base_dir)
...@@ -2392,6 +2392,12 @@ describe Project do ...@@ -2392,6 +2392,12 @@ describe Project do
it { expect { subject }.to raise_error(StandardError) } it { expect { subject }.to raise_error(StandardError) }
end end
end end
describe '#pages_path' do
it 'returns a path where pages are stored' do
expect(project.pages_path).to eq(File.join(Settings.pages.path, project.namespace.full_path, project.path))
end
end
end end
context 'hashed storage' do context 'hashed storage' do
...@@ -2402,6 +2408,7 @@ describe Project do ...@@ -2402,6 +2408,7 @@ describe Project do
before do before do
stub_application_setting(hashed_storage_enabled: true) stub_application_setting(hashed_storage_enabled: true)
allow(Digest::SHA2).to receive(:hexdigest) { hash } allow(Digest::SHA2).to receive(:hexdigest) { hash }
allow(project).to receive(:gitlab_shell).and_return(gitlab_shell)
end end
describe '#base_dir' do describe '#base_dir' do
...@@ -2411,7 +2418,7 @@ describe Project do ...@@ -2411,7 +2418,7 @@ describe Project do
end end
describe '#disk_path' do describe '#disk_path' do
it 'returns disk_path based on has of project id' do it 'returns disk_path based on hash of project id' do
hashed_path = '6b/86/6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b' hashed_path = '6b/86/6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b'
expect(project.disk_path).to eq(hashed_path) expect(project.disk_path).to eq(hashed_path)
...@@ -2419,10 +2426,6 @@ describe Project do ...@@ -2419,10 +2426,6 @@ describe Project do
end end
describe '#ensure_storage_path_exist' do describe '#ensure_storage_path_exist' do
before do
allow(project).to receive(:gitlab_shell).and_return(gitlab_shell)
end
it 'delegates to gitlab_shell to ensure namespace is created' do it 'delegates to gitlab_shell to ensure namespace is created' do
expect(gitlab_shell).to receive(:add_namespace).with(project.repository_storage_path, '6b/86') expect(gitlab_shell).to receive(:add_namespace).with(project.repository_storage_path, '6b/86')
...@@ -2472,5 +2475,11 @@ describe Project do ...@@ -2472,5 +2475,11 @@ describe Project do
it { expect { subject }.to raise_error(StandardError) } it { expect { subject }.to raise_error(StandardError) }
end end
end end
describe '#pages_path' do
it 'returns a path where pages are stored' do
expect(project.pages_path).to eq(File.join(Settings.pages.path, project.namespace.full_path, project.path))
end
end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment