diff options
Diffstat (limited to 'spec/models/project_wiki_spec.rb')
-rw-r--r-- | spec/models/project_wiki_spec.rb | 99 |
1 files changed, 49 insertions, 50 deletions
diff --git a/spec/models/project_wiki_spec.rb b/spec/models/project_wiki_spec.rb index 3ccc706edf2..ac697be636b 100644 --- a/spec/models/project_wiki_spec.rb +++ b/spec/models/project_wiki_spec.rb @@ -1,4 +1,3 @@ -# coding: utf-8 require "spec_helper" describe ProjectWiki do @@ -7,7 +6,7 @@ describe ProjectWiki do let(:repository) { project.repository } let(:gitlab_shell) { Gitlab::Shell.new } let(:project_wiki) { described_class.new(project, user) } - let(:raw_repository) { Gitlab::Git::Repository.new(project.repository_storage, subject.disk_path + '.git', 'foo', 'group/project.wiki') } + let(:raw_repository) { Gitlab::Git::Repository.new(project.repository_storage, subject.disk_path + ".git", "foo", "group/project.wiki") } let(:commit) { project_wiki.repository.head_commit } subject { project_wiki } @@ -17,16 +16,16 @@ describe ProjectWiki do describe "#full_path" do it "returns the project path with namespace with the .wiki extension" do - expect(subject.full_path).to eq(project.full_path + '.wiki') + expect(subject.full_path).to eq(project.full_path + ".wiki") end - it 'returns the same value as #full_path' do + it "returns the same value as #full_path" do expect(subject.full_path).to eq(subject.full_path) end end - describe '#web_url' do - it 'returns the full web URL to the wiki' do + describe "#web_url" do + it "returns the full web URL to the wiki" do expect(subject.web_url).to eq("#{Gitlab.config.gitlab.url}/#{project.full_path}/wikis/home") end end @@ -46,11 +45,11 @@ describe ProjectWiki do describe "#http_url_to_repo" do let(:project) { create :project } - it 'returns the full http url to the repo' do + it "returns the full http url to the repo" do expected_url = "#{Gitlab.config.gitlab.url}/#{subject.full_path}.git" expect(project_wiki.http_url_to_repo).to eq(expected_url) - expect(project_wiki.http_url_to_repo).not_to include('@') + expect(project_wiki.http_url_to_repo).not_to include("@") end end @@ -84,7 +83,7 @@ describe ProjectWiki do describe "#empty?" do context "when the wiki repository is empty" do - describe '#empty?' do + describe "#empty?" do subject { super().empty? } it { is_expected.to be_truthy } end @@ -96,12 +95,12 @@ describe ProjectWiki do project_wiki.create_page("another-page", "This is another page") end - describe '#empty?' do + describe "#empty?" do subject { super().empty? } it { is_expected.to be_falsey } # Re-enable this when https://gitlab.com/gitlab-org/gitaly/issues/1204 is fixed - xit 'only instantiates a Wiki page once' do + xit "only instantiates a Wiki page once" do expect(WikiPage).to receive(:new).once.and_call_original subject @@ -157,7 +156,7 @@ describe ProjectWiki do expect(page).to be_a WikiPage end - context 'pages with multibyte-character title' do + context "pages with multibyte-character title" do before do create_page("autre pagé", "C'est un génial Gollum Wiki") end @@ -168,7 +167,7 @@ describe ProjectWiki do end end - context 'pages with invalidly-encoded content' do + context "pages with invalidly-encoded content" do before do create_page("encoding is fun", "f\xFCr".b) end @@ -180,51 +179,51 @@ describe ProjectWiki do end end - describe '#find_sidebar' do + describe "#find_sidebar" do before do - create_page(described_class::SIDEBAR, 'This is an awesome Sidebar') + create_page(described_class::SIDEBAR, "This is an awesome Sidebar") end after do subject.pages.each { |page| destroy_page(page.page) } end - it 'finds the page defined as _sidebar' do - page = subject.find_page('_sidebar') + it "finds the page defined as _sidebar" do + page = subject.find_page("_sidebar") - expect(page.content).to eq('This is an awesome Sidebar') + expect(page.content).to eq("This is an awesome Sidebar") end end - describe '#find_file' do - let(:image) { File.open(Rails.root.join('spec', 'fixtures', 'big-image.png')) } + describe "#find_file" do + let(:image) { File.open(Rails.root.join("spec", "fixtures", "big-image.png")) } before do subject.wiki # Make sure the wiki repo exists - repo_path = Gitlab::GitalyClient::StorageSettings.allow_disk_access do + repo_path = Gitlab::GitalyClient::StorageSettings.allow_disk_access { subject.repository.path_to_repo - end + } - BareRepoOperations.new(repo_path).commit_file(image, 'image.png') + BareRepoOperations.new(repo_path).commit_file(image, "image.png") end - it 'returns the latest version of the file if it exists' do - file = subject.find_file('image.png') - expect(file.mime_type).to eq('image/png') + it "returns the latest version of the file if it exists" do + file = subject.find_file("image.png") + expect(file.mime_type).to eq("image/png") end - it 'returns nil if the page does not exist' do - expect(subject.find_file('non-existent')).to eq(nil) + it "returns nil if the page does not exist" do + expect(subject.find_file("non-existent")).to eq(nil) end - it 'returns a Gitlab::Git::WikiFile instance' do - file = subject.find_file('image.png') + it "returns a Gitlab::Git::WikiFile instance" do + file = subject.find_file("image.png") expect(file).to be_a Gitlab::Git::WikiFile end - it 'returns the whole file' do - file = subject.find_file('image.png') + it "returns the whole file" do + file = subject.find_file("image.png") image.rewind expect(file.raw_data.b).to eq(image.read.b) @@ -256,16 +255,16 @@ describe ProjectWiki do expect(subject.pages.first.page.version.message).to eq("commit message") end - it 'sets the correct commit email' do - subject.create_page('test page', 'content') + it "sets the correct commit email" do + subject.create_page("test page", "content") expect(user.commit_email).not_to eq(user.email) expect(commit.author_email).to eq(user.commit_email) expect(commit.committer_email).to eq(user.commit_email) end - it 'updates project activity' do - subject.create_page('Test Page', 'This is content') + it "updates project activity" do + subject.create_page("Test Page", "This is content") project.reload @@ -299,18 +298,18 @@ describe ProjectWiki do expect(@page.version.message).to eq("updated page") end - it 'sets the correct commit email' do + it "sets the correct commit email" do expect(user.commit_email).not_to eq(user.email) expect(commit.author_email).to eq(user.commit_email) expect(commit.committer_email).to eq(user.commit_email) end - it 'updates project activity' do + it "updates project activity" do subject.update_page( @gitlab_git_wiki_page, - content: 'Yet more content', + content: "Yet more content", format: :markdown, - message: 'Updated page again' + message: "Updated page again" ) project.reload @@ -331,7 +330,7 @@ describe ProjectWiki do expect(subject.pages.count).to eq(0) end - it 'sets the correct commit email' do + it "sets the correct commit email" do subject.delete_page(@page) expect(user.commit_email).not_to eq(user.email) @@ -339,7 +338,7 @@ describe ProjectWiki do expect(commit.committer_email).to eq(user.commit_email) end - it 'updates project activity' do + it "updates project activity" do subject.delete_page(@page) project.reload @@ -349,10 +348,10 @@ describe ProjectWiki do end end - describe '#create_repo!' do + describe "#create_repo!" do let(:project) { create(:project) } - it 'creates a repository' do + it "creates a repository" do expect(raw_repository.exists?).to eq(false) expect(subject.repository).to receive(:after_create) @@ -362,10 +361,10 @@ describe ProjectWiki do end end - describe '#ensure_repository' do + describe "#ensure_repository" do let(:project) { create(:project) } - it 'creates the repository if it not exist' do + it "creates the repository if it not exist" do expect(raw_repository.exists?).to eq(false) expect(subject).to receive(:create_repo!).and_call_original @@ -374,7 +373,7 @@ describe ProjectWiki do expect(raw_repository.exists?).to eq(true) end - it 'does not create the repository if it exists' do + it "does not create the repository if it exists" do subject.wiki expect(raw_repository.exists?).to eq(true) @@ -384,8 +383,8 @@ describe ProjectWiki do end end - describe '#hook_attrs' do - it 'returns a hash with values' do + describe "#hook_attrs" do + it "returns a hash with values" do expect(subject.hook_attrs).to be_a Hash expect(subject.hook_attrs.keys).to contain_exactly(:web_url, :git_ssh_url, :git_http_url, :path_with_namespace, :default_branch) end @@ -395,7 +394,7 @@ describe ProjectWiki do def create_temp_repo(path) FileUtils.mkdir_p path - system(*%W(#{Gitlab.config.git.bin_path} init --quiet --bare -- #{path})) + system(Gitlab.config.git.bin_path.to_s, "init", "--quiet", "--bare", "--", path.to_s) end def remove_temp_repo(path) |