Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/application_setting_spec.rb24
-rw-r--r--spec/models/broadcast_message_spec.rb39
-rw-r--r--spec/models/commit_spec.rb80
-rw-r--r--spec/models/concerns/issuable_spec.rb66
-rw-r--r--spec/models/concerns/mentionable_spec.rb14
-rw-r--r--spec/models/deploy_key_spec.rb25
-rw-r--r--spec/models/deploy_keys_project_spec.rb72
-rw-r--r--spec/models/event_spec.rb67
-rw-r--r--spec/models/external_wiki_service_spec.rb39
-rw-r--r--spec/models/forked_project_link_spec.rb67
-rw-r--r--spec/models/group_spec.rb73
-rw-r--r--spec/models/hooks/project_hook_spec.rb36
-rw-r--r--spec/models/hooks/service_hook_spec.rb24
-rw-r--r--spec/models/hooks/system_hook_spec.rb100
-rw-r--r--spec/models/hooks/web_hook_spec.rb74
-rw-r--r--spec/models/issue_spec.rb67
-rw-r--r--spec/models/key_spec.rb88
-rw-r--r--spec/models/label_link_spec.rb21
-rw-r--r--spec/models/label_spec.rb43
-rw-r--r--spec/models/member_spec.rb148
-rw-r--r--spec/models/members/group_member_spec.rb46
-rw-r--r--spec/models/members/project_member_spec.rb92
-rw-r--r--spec/models/merge_request_spec.rb127
-rw-r--r--spec/models/milestone_spec.rb143
-rw-r--r--spec/models/namespace_spec.rb96
-rw-r--r--spec/models/note_spec.rb637
-rw-r--r--spec/models/project_security_spec.rb126
-rw-r--r--spec/models/project_services/asana_service_spec.rb65
-rw-r--r--spec/models/project_services/assembla_service_spec.rb53
-rw-r--r--spec/models/project_services/buildkite_service_spec.rb82
-rw-r--r--spec/models/project_services/flowdock_service_spec.rb52
-rw-r--r--spec/models/project_services/gemnasium_service_spec.rb48
-rw-r--r--spec/models/project_services/gitlab_ci_service_spec.rb70
-rw-r--r--spec/models/project_services/gitlab_issue_tracker_service_spec.rb66
-rw-r--r--spec/models/project_services/hipchat_service_spec.rb217
-rw-r--r--spec/models/project_services/irker_service_spec.rb108
-rw-r--r--spec/models/project_services/jira_service_spec.rb102
-rw-r--r--spec/models/project_services/pushover_service_spec.rb74
-rw-r--r--spec/models/project_services/slack_service/issue_message_spec.rb56
-rw-r--r--spec/models/project_services/slack_service/merge_message_spec.rb51
-rw-r--r--spec/models/project_services/slack_service/note_message_spec.rb129
-rw-r--r--spec/models/project_services/slack_service/push_message_spec.rb88
-rw-r--r--spec/models/project_services/slack_service_spec.rb170
-rw-r--r--spec/models/project_snippet_spec.rb31
-rw-r--r--spec/models/project_spec.rb360
-rw-r--r--spec/models/project_team_spec.rb70
-rw-r--r--spec/models/project_wiki_spec.rb244
-rw-r--r--spec/models/protected_branch_spec.rb27
-rw-r--r--spec/models/repository_spec.rb28
-rw-r--r--spec/models/service_spec.rb92
-rw-r--r--spec/models/snippet_spec.rb40
-rw-r--r--spec/models/user_spec.rb532
-rw-r--r--spec/models/wiki_page_spec.rb210
53 files changed, 0 insertions, 5499 deletions
diff --git a/spec/models/application_setting_spec.rb b/spec/models/application_setting_spec.rb
deleted file mode 100644
index b4f0b2c201a..00000000000
--- a/spec/models/application_setting_spec.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-# == Schema Information
-#
-# Table name: application_settings
-#
-# id :integer not null, primary key
-# default_projects_limit :integer
-# default_branch_protection :integer
-# signup_enabled :boolean
-# signin_enabled :boolean
-# gravatar_enabled :boolean
-# sign_in_text :text
-# created_at :datetime
-# updated_at :datetime
-# home_page_url :string(255)
-# default_branch_protection :integer default(2)
-# twitter_sharing_enabled :boolean default(TRUE)
-# restricted_visibility_levels :text
-#
-
-require 'spec_helper'
-
-describe ApplicationSetting, models: true do
- it { expect(ApplicationSetting.create_from_defaults).to be_valid }
-end
diff --git a/spec/models/broadcast_message_spec.rb b/spec/models/broadcast_message_spec.rb
deleted file mode 100644
index 8ab72151a69..00000000000
--- a/spec/models/broadcast_message_spec.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-# == Schema Information
-#
-# Table name: broadcast_messages
-#
-# id :integer not null, primary key
-# message :text not null
-# starts_at :datetime
-# ends_at :datetime
-# alert_type :integer
-# created_at :datetime
-# updated_at :datetime
-# color :string(255)
-# font :string(255)
-#
-
-require 'spec_helper'
-
-describe BroadcastMessage do
- subject { create(:broadcast_message) }
-
- it { is_expected.to be_valid }
-
- describe :current do
- it "should return last message if time match" do
- broadcast_message = create(:broadcast_message, starts_at: Time.now.yesterday, ends_at: Time.now.tomorrow)
- expect(BroadcastMessage.current).to eq(broadcast_message)
- end
-
- it "should return nil if time not come" do
- broadcast_message = create(:broadcast_message, starts_at: Time.now.tomorrow, ends_at: Time.now + 2.days)
- expect(BroadcastMessage.current).to be_nil
- end
-
- it "should return nil if time has passed" do
- broadcast_message = create(:broadcast_message, starts_at: Time.now - 2.days, ends_at: Time.now.yesterday)
- expect(BroadcastMessage.current).to be_nil
- end
- end
-end
diff --git a/spec/models/commit_spec.rb b/spec/models/commit_spec.rb
deleted file mode 100644
index 11cc7762ce4..00000000000
--- a/spec/models/commit_spec.rb
+++ /dev/null
@@ -1,80 +0,0 @@
-require 'spec_helper'
-
-describe Commit do
- let(:project) { create :project }
- let(:commit) { project.repository.commit }
-
- describe '#title' do
- it "returns no_commit_message when safe_message is blank" do
- allow(commit).to receive(:safe_message).and_return('')
- expect(commit.title).to eq("--no commit message")
- end
-
- it "truncates a message without a newline at 80 characters" do
- message = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sodales id felis id blandit. Vivamus egestas lacinia lacus, sed rutrum mauris.'
-
- allow(commit).to receive(:safe_message).and_return(message)
- expect(commit.title).to eq("#{message[0..79]}…")
- end
-
- it "truncates a message with a newline before 80 characters at the newline" do
- message = commit.safe_message.split(" ").first
-
- allow(commit).to receive(:safe_message).and_return(message + "\n" + message)
- expect(commit.title).to eq(message)
- end
-
- it "does not truncates a message with a newline after 80 but less 100 characters" do
- message =<<eos
-Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sodales id felis id blandit.
-Vivamus egestas lacinia lacus, sed rutrum mauris.
-eos
-
- allow(commit).to receive(:safe_message).and_return(message)
- expect(commit.title).to eq(message.split("\n").first)
- end
- end
-
- describe "delegation" do
- subject { commit }
-
- it { is_expected.to respond_to(:message) }
- it { is_expected.to respond_to(:authored_date) }
- it { is_expected.to respond_to(:committed_date) }
- it { is_expected.to respond_to(:committer_email) }
- it { is_expected.to respond_to(:author_email) }
- it { is_expected.to respond_to(:parents) }
- it { is_expected.to respond_to(:date) }
- it { is_expected.to respond_to(:diffs) }
- it { is_expected.to respond_to(:tree) }
- it { is_expected.to respond_to(:id) }
- it { is_expected.to respond_to(:to_patch) }
- end
-
- describe '#closes_issues' do
- let(:issue) { create :issue, project: project }
- let(:other_project) { create :project, :public }
- let(:other_issue) { create :issue, project: other_project }
-
- it 'detects issues that this commit is marked as closing' do
- commit.stub(safe_message: "Fixes ##{issue.iid}")
- expect(commit.closes_issues(project)).to eq([issue])
- end
-
- it 'does not detect issues from other projects' do
- ext_ref = "#{other_project.path_with_namespace}##{other_issue.iid}"
- commit.stub(safe_message: "Fixes #{ext_ref}")
- expect(commit.closes_issues(project)).to be_empty
- end
- end
-
- it_behaves_like 'a mentionable' do
- let(:subject) { commit }
- let(:mauthor) { create :user, email: commit.author_email }
- let(:backref_text) { "commit #{subject.id}" }
- let(:set_mentionable_text) { ->(txt){ subject.stub(safe_message: txt) } }
-
- # Include the subject in the repository stub.
- let(:extra_commits) { [subject] }
- end
-end
diff --git a/spec/models/concerns/issuable_spec.rb b/spec/models/concerns/issuable_spec.rb
deleted file mode 100644
index 557c71b4d2c..00000000000
--- a/spec/models/concerns/issuable_spec.rb
+++ /dev/null
@@ -1,66 +0,0 @@
-require 'spec_helper'
-
-describe Issue, "Issuable" do
- let(:issue) { create(:issue) }
-
- describe "Associations" do
- it { is_expected.to belong_to(:project) }
- it { is_expected.to belong_to(:author) }
- it { is_expected.to belong_to(:assignee) }
- it { is_expected.to have_many(:notes).dependent(:destroy) }
- end
-
- describe "Validation" do
- before { subject.stub(set_iid: false) }
- it { is_expected.to validate_presence_of(:project) }
- it { is_expected.to validate_presence_of(:iid) }
- it { is_expected.to validate_presence_of(:author) }
- it { is_expected.to validate_presence_of(:title) }
- it { is_expected.to ensure_length_of(:title).is_at_least(0).is_at_most(255) }
- end
-
- describe "Scope" do
- it { expect(described_class).to respond_to(:opened) }
- it { expect(described_class).to respond_to(:closed) }
- it { expect(described_class).to respond_to(:assigned) }
- end
-
- describe ".search" do
- let!(:searchable_issue) { create(:issue, title: "Searchable issue") }
-
- it "matches by title" do
- expect(described_class.search('able')).to eq([searchable_issue])
- end
- end
-
- describe "#today?" do
- it "returns true when created today" do
- # Avoid timezone differences and just return exactly what we want
- allow(Date).to receive(:today).and_return(issue.created_at.to_date)
- expect(issue.today?).to be_truthy
- end
-
- it "returns false when not created today" do
- allow(Date).to receive(:today).and_return(Date.yesterday)
- expect(issue.today?).to be_falsey
- end
- end
-
- describe "#new?" do
- it "returns true when created today and record hasn't been updated" do
- allow(issue).to receive(:today?).and_return(true)
- expect(issue.new?).to be_truthy
- end
-
- it "returns false when not created today" do
- allow(issue).to receive(:today?).and_return(false)
- expect(issue.new?).to be_falsey
- end
-
- it "returns false when record has been updated" do
- allow(issue).to receive(:today?).and_return(true)
- issue.touch
- expect(issue.new?).to be_falsey
- end
- end
-end
diff --git a/spec/models/concerns/mentionable_spec.rb b/spec/models/concerns/mentionable_spec.rb
deleted file mode 100644
index eadb941a3fa..00000000000
--- a/spec/models/concerns/mentionable_spec.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-require 'spec_helper'
-
-describe Issue, "Mentionable" do
- describe :mentioned_users do
- let!(:user) { create(:user, username: 'stranger') }
- let!(:user2) { create(:user, username: 'john') }
- let!(:issue) { create(:issue, description: '@stranger mentioned') }
-
- subject { issue.mentioned_users }
-
- it { is_expected.to include(user) }
- it { is_expected.not_to include(user2) }
- end
-end
diff --git a/spec/models/deploy_key_spec.rb b/spec/models/deploy_key_spec.rb
deleted file mode 100644
index b32be8d7a7c..00000000000
--- a/spec/models/deploy_key_spec.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-# == Schema Information
-#
-# Table name: keys
-#
-# id :integer not null, primary key
-# user_id :integer
-# created_at :datetime
-# updated_at :datetime
-# key :text
-# title :string(255)
-# type :string(255)
-# fingerprint :string(255)
-#
-
-require 'spec_helper'
-
-describe DeployKey do
- let(:project) { create(:project) }
- let(:deploy_key) { create(:deploy_key, projects: [project]) }
-
- describe "Associations" do
- it { is_expected.to have_many(:deploy_keys_projects) }
- it { is_expected.to have_many(:projects) }
- end
-end
diff --git a/spec/models/deploy_keys_project_spec.rb b/spec/models/deploy_keys_project_spec.rb
deleted file mode 100644
index 7032b777144..00000000000
--- a/spec/models/deploy_keys_project_spec.rb
+++ /dev/null
@@ -1,72 +0,0 @@
-# == Schema Information
-#
-# Table name: deploy_keys_projects
-#
-# id :integer not null, primary key
-# deploy_key_id :integer not null
-# project_id :integer not null
-# created_at :datetime
-# updated_at :datetime
-#
-
-require 'spec_helper'
-
-describe DeployKeysProject do
- describe "Associations" do
- it { is_expected.to belong_to(:deploy_key) }
- it { is_expected.to belong_to(:project) }
- end
-
- describe "Validation" do
- it { is_expected.to validate_presence_of(:project_id) }
- it { is_expected.to validate_presence_of(:deploy_key_id) }
- end
-
- describe "Destroying" do
- let(:project) { create(:project) }
- subject { create(:deploy_keys_project, project: project) }
- let(:deploy_key) { subject.deploy_key }
-
- context "when the deploy key is only used by this project" do
- context "when the deploy key is public" do
- before do
- deploy_key.update_attribute(:public, true)
- end
-
- it "doesn't destroy the deploy key" do
- subject.destroy
-
- expect {
- deploy_key.reload
- }.not_to raise_error(ActiveRecord::RecordNotFound)
- end
- end
-
- context "when the deploy key is private" do
- it "destroys the deploy key" do
- subject.destroy
-
- expect {
- deploy_key.reload
- }.to raise_error(ActiveRecord::RecordNotFound)
- end
- end
- end
-
- context "when the deploy key is used by more than one project" do
- let!(:other_project) { create(:project) }
-
- before do
- other_project.deploy_keys << deploy_key
- end
-
- it "doesn't destroy the deploy key" do
- subject.destroy
-
- expect {
- deploy_key.reload
- }.not_to raise_error(ActiveRecord::RecordNotFound)
- end
- end
- end
-end
diff --git a/spec/models/event_spec.rb b/spec/models/event_spec.rb
deleted file mode 100644
index 0f32f162a10..00000000000
--- a/spec/models/event_spec.rb
+++ /dev/null
@@ -1,67 +0,0 @@
-# == Schema Information
-#
-# Table name: events
-#
-# id :integer not null, primary key
-# target_type :string(255)
-# target_id :integer
-# title :string(255)
-# data :text
-# project_id :integer
-# created_at :datetime
-# updated_at :datetime
-# action :integer
-# author_id :integer
-#
-
-require 'spec_helper'
-
-describe Event do
- describe "Associations" do
- it { is_expected.to belong_to(:project) }
- it { is_expected.to belong_to(:target) }
- end
-
- describe "Respond to" do
- it { is_expected.to respond_to(:author_name) }
- it { is_expected.to respond_to(:author_email) }
- it { is_expected.to respond_to(:issue_title) }
- it { is_expected.to respond_to(:merge_request_title) }
- it { is_expected.to respond_to(:commits) }
- end
-
- describe "Push event" do
- before do
- project = create(:project)
- @user = project.owner
-
- data = {
- before: Gitlab::Git::BLANK_SHA,
- after: "0220c11b9a3e6c69dc8fd35321254ca9a7b98f7e",
- ref: "refs/heads/master",
- user_id: @user.id,
- user_name: @user.name,
- repository: {
- name: project.name,
- url: "localhost/rubinius",
- description: "",
- homepage: "localhost/rubinius",
- private: true
- }
- }
-
- @event = Event.create(
- project: project,
- action: Event::PUSHED,
- data: data,
- author_id: @user.id
- )
- end
-
- it { expect(@event.push?).to be_truthy }
- it { expect(@event.proper?).to be_truthy }
- it { expect(@event.tag?).to be_falsey }
- it { expect(@event.branch_name).to eq("master") }
- it { expect(@event.author).to eq(@user) }
- end
-end
diff --git a/spec/models/external_wiki_service_spec.rb b/spec/models/external_wiki_service_spec.rb
deleted file mode 100644
index 78ef687d29c..00000000000
--- a/spec/models/external_wiki_service_spec.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-require 'spec_helper'
-
-describe ExternalWikiService do
- include ExternalWikiHelper
- describe "Associations" do
- it { should belong_to :project }
- it { should have_one :service_hook }
- end
-
- describe "Validations" do
- context "active" do
- before do
- subject.active = true
- end
-
- it { should validate_presence_of :external_wiki_url }
- end
- end
-
- describe 'External wiki' do
- let(:project) { create(:project) }
-
- context 'when it is active' do
- before do
- properties = { 'external_wiki_url' => 'https://gitlab.com' }
- @service = project.create_external_wiki_service(active: true, properties: properties)
- end
-
- after do
- @service.destroy!
- end
-
- it 'should replace the wiki url' do
- wiki_path = get_project_wiki_path(project)
- wiki_path.should match('https://gitlab.com')
- end
- end
- end
-end
diff --git a/spec/models/forked_project_link_spec.rb b/spec/models/forked_project_link_spec.rb
deleted file mode 100644
index 7d0ad44a92c..00000000000
--- a/spec/models/forked_project_link_spec.rb
+++ /dev/null
@@ -1,67 +0,0 @@
-# == Schema Information
-#
-# Table name: forked_project_links
-#
-# id :integer not null, primary key
-# forked_to_project_id :integer not null
-# forked_from_project_id :integer not null
-# created_at :datetime
-# updated_at :datetime
-#
-
-require 'spec_helper'
-
-describe ForkedProjectLink, "add link on fork" do
- let(:project_from) { create(:project) }
- let(:namespace) { create(:namespace) }
- let(:user) { create(:user, namespace: namespace) }
-
- before do
- @project_to = fork_project(project_from, user)
- end
-
- it "project_to should know it is forked" do
- expect(@project_to.forked?).to be_truthy
- end
-
- it "project should know who it is forked from" do
- expect(@project_to.forked_from_project).to eq(project_from)
- end
-end
-
-describe :forked_from_project do
- let(:forked_project_link) { build(:forked_project_link) }
- let(:project_from) { create(:project) }
- let(:project_to) { create(:project, forked_project_link: forked_project_link) }
-
-
- before :each do
- forked_project_link.forked_from_project = project_from
- forked_project_link.forked_to_project = project_to
- forked_project_link.save!
- end
-
-
- it "project_to should know it is forked" do
- expect(project_to.forked?).to be_truthy
- end
-
- it "project_from should not be forked" do
- expect(project_from.forked?).to be_falsey
- end
-
- it "project_to.destroy should destroy fork_link" do
- expect(forked_project_link).to receive(:destroy)
- project_to.destroy
- end
-
-end
-
-def fork_project(from_project, user)
- context = Projects::ForkService.new(from_project, user)
- shell = double("gitlab_shell")
- shell.stub(fork_repository: true)
- context.stub(gitlab_shell: shell)
- context.execute
-end
-
diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb
deleted file mode 100644
index 9428224a64f..00000000000
--- a/spec/models/group_spec.rb
+++ /dev/null
@@ -1,73 +0,0 @@
-# == Schema Information
-#
-# Table name: namespaces
-#
-# id :integer not null, primary key
-# name :string(255) not null
-# path :string(255) not null
-# owner_id :integer
-# created_at :datetime
-# updated_at :datetime
-# type :string(255)
-# description :string(255) default(""), not null
-# avatar :string(255)
-#
-
-require 'spec_helper'
-
-describe Group do
- let!(:group) { create(:group) }
-
- describe "Associations" do
- it { is_expected.to have_many :projects }
- it { is_expected.to have_many :group_members }
- end
-
- it { is_expected.to validate_presence_of :name }
- it { is_expected.to validate_uniqueness_of(:name) }
- it { is_expected.to validate_presence_of :path }
- it { is_expected.to validate_uniqueness_of(:path) }
- it { is_expected.not_to validate_presence_of :owner }
-
- describe :users do
- it { expect(group.users).to eq(group.owners) }
- end
-
- describe :human_name do
- it { expect(group.human_name).to eq(group.name) }
- end
-
- describe :add_users do
- let(:user) { create(:user) }
- before { group.add_user(user, GroupMember::MASTER) }
-
- it { expect(group.group_members.masters.map(&:user)).to include(user) }
- end
-
- describe :add_users do
- let(:user) { create(:user) }
- before { group.add_users([user.id], GroupMember::GUEST) }
-
- it "should update the group permission" do
- expect(group.group_members.guests.map(&:user)).to include(user)
- group.add_users([user.id], GroupMember::DEVELOPER)
- expect(group.group_members.developers.map(&:user)).to include(user)
- expect(group.group_members.guests.map(&:user)).not_to include(user)
- end
- end
-
- describe :avatar_type do
- let(:user) { create(:user) }
- before { group.add_user(user, GroupMember::MASTER) }
-
- it "should be true if avatar is image" do
- group.update_attribute(:avatar, 'uploads/avatar.png')
- expect(group.avatar_type).to be_truthy
- end
-
- it "should be false if avatar is html page" do
- group.update_attribute(:avatar, 'uploads/avatar.html')
- expect(group.avatar_type).to eq(["only images allowed"])
- end
- end
-end
diff --git a/spec/models/hooks/project_hook_spec.rb b/spec/models/hooks/project_hook_spec.rb
deleted file mode 100644
index 4e0d50d7f3f..00000000000
--- a/spec/models/hooks/project_hook_spec.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-# == Schema Information
-#
-# Table name: web_hooks
-#
-# id :integer not null, primary key
-# url :string(255)
-# project_id :integer
-# created_at :datetime
-# updated_at :datetime
-# type :string(255) default("ProjectHook")
-# service_id :integer
-# push_events :boolean default(TRUE), not null
-# issues_events :boolean default(FALSE), not null
-# merge_requests_events :boolean default(FALSE), not null
-# tag_push_events :boolean default(FALSE)
-#
-
-require 'spec_helper'
-
-describe ProjectHook do
- describe '.push_hooks' do
- it 'should return hooks for push events only' do
- hook = create(:project_hook, push_events: true)
- hook2 = create(:project_hook, push_events: false)
- expect(ProjectHook.push_hooks).to eq([hook])
- end
- end
-
- describe '.tag_push_hooks' do
- it 'should return hooks for tag push events only' do
- hook = create(:project_hook, tag_push_events: true)
- hook2 = create(:project_hook, tag_push_events: false)
- expect(ProjectHook.tag_push_hooks).to eq([hook])
- end
- end
-end
diff --git a/spec/models/hooks/service_hook_spec.rb b/spec/models/hooks/service_hook_spec.rb
deleted file mode 100644
index 96bf74d45da..00000000000
--- a/spec/models/hooks/service_hook_spec.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-# == Schema Information
-#
-# Table name: web_hooks
-#
-# id :integer not null, primary key
-# url :string(255)
-# project_id :integer
-# created_at :datetime
-# updated_at :datetime
-# type :string(255) default("ProjectHook")
-# service_id :integer
-# push_events :boolean default(TRUE), not null
-# issues_events :boolean default(FALSE), not null
-# merge_requests_events :boolean default(FALSE), not null
-# tag_push_events :boolean default(FALSE)
-#
-
-require "spec_helper"
-
-describe ServiceHook do
- describe "Associations" do
- it { is_expected.to belong_to :service }
- end
-end
diff --git a/spec/models/hooks/system_hook_spec.rb b/spec/models/hooks/system_hook_spec.rb
deleted file mode 100644
index 810b311a40b..00000000000
--- a/spec/models/hooks/system_hook_spec.rb
+++ /dev/null
@@ -1,100 +0,0 @@
-# == Schema Information
-#
-# Table name: web_hooks
-#
-# id :integer not null, primary key
-# url :string(255)
-# project_id :integer
-# created_at :datetime
-# updated_at :datetime
-# type :string(255) default("ProjectHook")
-# service_id :integer
-# push_events :boolean default(TRUE), not null
-# issues_events :boolean default(FALSE), not null
-# merge_requests_events :boolean default(FALSE), not null
-# tag_push_events :boolean default(FALSE)
-#
-
-require "spec_helper"
-
-describe SystemHook do
- describe "execute" do
- before(:each) do
- @system_hook = create(:system_hook)
- WebMock.stub_request(:post, @system_hook.url)
- end
-
- it "project_create hook" do
- Projects::CreateService.new(create(:user), name: 'empty').execute
- expect(WebMock).to have_requested(:post, @system_hook.url).with(body: /project_create/).once
- end
-
- it "project_destroy hook" do
- user = create(:user)
- project = create(:empty_project, namespace: user.namespace)
- Projects::DestroyService.new(project, user, {}).execute
- expect(WebMock).to have_requested(:post, @system_hook.url).with(body: /project_destroy/).once
- end
-
- it "user_create hook" do
- create(:user)
- expect(WebMock).to have_requested(:post, @system_hook.url).with(body: /user_create/).once
- end
-
- it "user_destroy hook" do
- user = create(:user)
- user.destroy
- expect(WebMock).to have_requested(:post, @system_hook.url).with(body: /user_destroy/).once
- end
-
- it "project_create hook" do
- user = create(:user)
- project = create(:project)
- project.team << [user, :master]
- expect(WebMock).to have_requested(:post, @system_hook.url).with(body: /user_add_to_team/).once
- end
-
- it "project_destroy hook" do
- user = create(:user)
- project = create(:project)
- project.team << [user, :master]
- project.project_members.destroy_all
- expect(WebMock).to have_requested(:post, @system_hook.url).with(body: /user_remove_from_team/).once
- end
-
- it 'group create hook' do
- create(:group)
- expect(WebMock).to have_requested(:post, @system_hook.url).with(
- body: /group_create/
- ).once
- end
-
- it 'group destroy hook' do
- group = create(:group)
- group.destroy
- expect(WebMock).to have_requested(:post, @system_hook.url).with(
- body: /group_destroy/
- ).once
- end
-
- it 'group member create hook' do
- group = create(:group)
- user = create(:user)
- group.add_user(user, Gitlab::Access::MASTER)
- expect(WebMock).to have_requested(:post, @system_hook.url).with(
- body: /user_add_to_group/
- ).once
- end
-
- it 'group member destroy hook' do
- group = create(:group)
- user = create(:user)
- group.add_user(user, Gitlab::Access::MASTER)
- group.group_members.destroy_all
- expect(WebMock).to have_requested(:post, @system_hook.url).with(
- body: /user_remove_from_group/
- ).once
- end
-
- end
-end
diff --git a/spec/models/hooks/web_hook_spec.rb b/spec/models/hooks/web_hook_spec.rb
deleted file mode 100644
index 67ec9193ad7..00000000000
--- a/spec/models/hooks/web_hook_spec.rb
+++ /dev/null
@@ -1,74 +0,0 @@
-# == Schema Information
-#
-# Table name: web_hooks
-#
-# id :integer not null, primary key
-# url :string(255)
-# project_id :integer
-# created_at :datetime
-# updated_at :datetime
-# type :string(255) default("ProjectHook")
-# service_id :integer
-# push_events :boolean default(TRUE), not null
-# issues_events :boolean default(FALSE), not null
-# merge_requests_events :boolean default(FALSE), not null
-# tag_push_events :boolean default(FALSE)
-#
-
-require 'spec_helper'
-
-describe ProjectHook do
- describe "Associations" do
- it { is_expected.to belong_to :project }
- end
-
- describe "Mass assignment" do
- end
-
- describe "Validations" do
- it { is_expected.to validate_presence_of(:url) }
-
- context "url format" do
- it { is_expected.to allow_value("http://example.com").for(:url) }
- it { is_expected.to allow_value("https://excample.com").for(:url) }
- it { is_expected.to allow_value("http://test.com/api").for(:url) }
- it { is_expected.to allow_value("http://test.com/api?key=abc").for(:url) }
- it { is_expected.to allow_value("http://test.com/api?key=abc&type=def").for(:url) }
-
- it { is_expected.not_to allow_value("example.com").for(:url) }
- it { is_expected.not_to allow_value("ftp://example.com").for(:url) }
- it { is_expected.not_to allow_value("herp-and-derp").for(:url) }
- end
- end
-
- describe "execute" do
- before(:each) do
- @project_hook = create(:project_hook)
- @project = create(:project)
- @project.hooks << [@project_hook]
- @data = { before: 'oldrev', after: 'newrev', ref: 'ref'}
-
- WebMock.stub_request(:post, @project_hook.url)
- end
-
- it "POSTs to the web hook URL" do
- @project_hook.execute(@data)
- expect(WebMock).to have_requested(:post, @project_hook.url).once
- end
-
- it "POSTs the data as JSON" do
- json = @data.to_json
-
- @project_hook.execute(@data)
- expect(WebMock).to have_requested(:post, @project_hook.url).with(body: json).once
- end
-
- it "catches exceptions" do
- expect(WebHook).to receive(:post).and_raise("Some HTTP Post error")
-
- expect {
- @project_hook.execute(@data)
- }.to raise_error
- end
- end
-end
diff --git a/spec/models/issue_spec.rb b/spec/models/issue_spec.rb
deleted file mode 100644
index 087e40c3d84..00000000000
--- a/spec/models/issue_spec.rb
+++ /dev/null
@@ -1,67 +0,0 @@
-# == Schema Information
-#
-# Table name: issues
-#
-# id :integer not null, primary key
-# title :string(255)
-# assignee_id :integer
-# author_id :integer
-# project_id :integer
-# created_at :datetime
-# updated_at :datetime
-# position :integer default(0)
-# branch_name :string(255)
-# description :text
-# milestone_id :integer
-# state :string(255)
-# iid :integer
-#
-
-require 'spec_helper'
-
-describe Issue do
- describe "Associations" do
- it { is_expected.to belong_to(:milestone) }
- end
-
- describe "Mass assignment" do
- end
-
- describe 'modules' do
- it { is_expected.to include_module(Issuable) }
- end
-
- subject { create(:issue) }
-
- describe '#is_being_reassigned?' do
- it 'returns true if the issue assignee has changed' do
- subject.assignee = create(:user)
- expect(subject.is_being_reassigned?).to be_truthy
- end
- it 'returns false if the issue assignee has not changed' do
- expect(subject.is_being_reassigned?).to be_falsey
- end
- end
-
- describe '#is_being_reassigned?' do
- it 'returns issues assigned to user' do
- user = create :user
-
- 2.times do
- issue = create :issue, assignee: user
- end
-
- expect(Issue.open_for(user).count).to eq 2
- end
- end
-
- it_behaves_like 'an editable mentionable' do
- let(:subject) { create :issue, project: mproject }
- let(:backref_text) { "issue ##{subject.iid}" }
- let(:set_mentionable_text) { ->(txt){ subject.description = txt } }
- end
-
- it_behaves_like 'a Taskable' do
- let(:subject) { create :issue }
- end
-end
diff --git a/spec/models/key_spec.rb b/spec/models/key_spec.rb
deleted file mode 100644
index 2fb651bef1b..00000000000
--- a/spec/models/key_spec.rb
+++ /dev/null
@@ -1,88 +0,0 @@
-# == Schema Information
-#
-# Table name: keys
-#
-# id :integer not null, primary key
-# user_id :integer
-# created_at :datetime
-# updated_at :datetime
-# key :text
-# title :string(255)
-# type :string(255)
-# fingerprint :string(255)
-#
-
-require 'spec_helper'
-
-describe Key do
- describe "Associations" do
- it { is_expected.to belong_to(:user) }
- end
-
- describe "Mass assignment" do
- end
-
- describe "Validation" do
- it { is_expected.to validate_presence_of(:title) }
- it { is_expected.to validate_presence_of(:key) }
- it { is_expected.to ensure_length_of(:title).is_within(0..255) }
- it { is_expected.to ensure_length_of(:key).is_within(0..5000) }
- end
-
- describe "Methods" do
- it { is_expected.to respond_to :projects }
- end
-
- context "validation of uniqueness" do
- let(:user) { create(:user) }
-
- it "accepts the key once" do
- expect(build(:key, user: user)).to be_valid
- end
-
- it "does not accept the exact same key twice" do
- create(:key, user: user)
- expect(build(:key, user: user)).not_to be_valid
- end
-
- it "does not accept a duplicate key with a different comment" do
- create(:key, user: user)
- duplicate = build(:key, user: user)
- duplicate.key << ' extra comment'
- expect(duplicate).not_to be_valid
- end
- end
-
- context "validate it is a fingerprintable key" do
- it "accepts the fingerprintable key" do
- expect(build(:key)).to be_valid
- end
-
- it 'rejects an unfingerprintable key that contains a space' do
- key = build(:key)
-
- # Not always the middle, but close enough
- key.key = key.key[0..100] + ' ' + key.key[100..-1]
-
- expect(key).not_to be_valid
- end
-
- it 'rejects the unfingerprintable key (not a key)' do
- expect(build(:key, key: 'ssh-rsa an-invalid-key==')).not_to be_valid
- end
- end
-
- context 'callbacks' do
- it 'should add new key to authorized_file' do
- @key = build(:personal_key, id: 7)
- expect(GitlabShellWorker).to receive(:perform_async).with(:add_key, @key.shell_id, @key.key)
- @key.save
- end
-
- it 'should remove key from authorized_file' do
- @key = create(:personal_key)
- expect(GitlabShellWorker).to receive(:perform_async).with(:remove_key, @key.shell_id, @key.key)
- @key.destroy
- end
- end
-end
diff --git a/spec/models/label_link_spec.rb b/spec/models/label_link_spec.rb
deleted file mode 100644
index 8c240826582..00000000000
--- a/spec/models/label_link_spec.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-# == Schema Information
-#
-# Table name: label_links
-#
-# id :integer not null, primary key
-# label_id :integer
-# target_id :integer
-# target_type :string(255)
-# created_at :datetime
-# updated_at :datetime
-#
-
-require 'spec_helper'
-
-describe LabelLink do
- let(:label) { create(:label_link) }
- it { expect(label).to be_valid }
-
- it { is_expected.to belong_to(:label) }
- it { is_expected.to belong_to(:target) }
-end
diff --git a/spec/models/label_spec.rb b/spec/models/label_spec.rb
deleted file mode 100644
index 8644ac46605..00000000000
--- a/spec/models/label_spec.rb
+++ /dev/null
@@ -1,43 +0,0 @@
-# == Schema Information
-#
-# Table name: labels
-#
-# id :integer not null, primary key
-# title :string(255)
-# color :string(255)
-# project_id :integer
-# created_at :datetime
-# updated_at :datetime
-#
-
-require 'spec_helper'
-
-describe Label do
- let(:label) { create(:label) }
- it { expect(label).to be_valid }
-
- it { is_expected.to belong_to(:project) }
-
- describe 'Validation' do
- it 'should validate color code' do
- expect(build(:label, color: 'G-ITLAB')).not_to be_valid
- expect(build(:label, color: 'AABBCC')).not_to be_valid
- expect(build(:label, color: '#AABBCCEE')).not_to be_valid
- expect(build(:label, color: '#GGHHII')).not_to be_valid
- expect(build(:label, color: '#')).not_to be_valid
- expect(build(:label, color: '')).not_to be_valid
-
- expect(build(:label, color: '#AABBCC')).to be_valid
- end
-
- it 'should validate title' do
- expect(build(:label, title: 'G,ITLAB')).not_to be_valid
- expect(build(:label, title: 'G?ITLAB')).not_to be_valid
- expect(build(:label, title: 'G&ITLAB')).not_to be_valid
- expect(build(:label, title: '')).not_to be_valid
-
- expect(build(:label, title: 'GITLAB')).to be_valid
- expect(build(:label, title: 'gitlab')).to be_valid
- end
- end
-end
diff --git a/spec/models/member_spec.rb b/spec/models/member_spec.rb
deleted file mode 100644
index 56d030a03b3..00000000000
--- a/spec/models/member_spec.rb
+++ /dev/null
@@ -1,148 +0,0 @@
-require 'spec_helper'
-
-describe Member do
- describe "Associations" do
- it { is_expected.to belong_to(:user) }
- end
-
- describe "Validation" do
- subject { Member.new(access_level: Member::GUEST) }
-
- it { is_expected.to validate_presence_of(:user) }
- it { is_expected.to validate_presence_of(:source) }
- it { is_expected.to validate_inclusion_of(:access_level).in_array(Gitlab::Access.values) }
-
- context "when an invite email is provided" do
- let(:member) { build(:project_member, invite_email: "user@example.com", user: nil) }
-
- it "doesn't require a user" do
- expect(member).to be_valid
- end
-
- it "requires a valid invite email" do
- member.invite_email = "nope"
-
- expect(member).not_to be_valid
- end
-
- it "requires a unique invite email scoped to this source" do
- create(:project_member, source: member.source, invite_email: member.invite_email)
-
- expect(member).not_to be_valid
- end
-
- it "is valid otherwise" do
- expect(member).to be_valid
- end
- end
-
- context "when an invite email is not provided" do
- let(:member) { build(:project_member) }
-
- it "requires a user" do
- member.user = nil
-
- expect(member).not_to be_valid
- end
-
- it "is valid otherwise" do
- expect(member).to be_valid
- end
- end
- end
-
- describe "Delegate methods" do
- it { is_expected.to respond_to(:user_name) }
- it { is_expected.to respond_to(:user_email) }
- end
-
- describe ".add_user" do
- let!(:user) { create(:user) }
- let(:project) { create(:project) }
-
- context "when called with a user id" do
- it "adds the user as a member" do
- Member.add_user(project.project_members, user.id, ProjectMember::MASTER)
-
- expect(project.users).to include(user)
- end
- end
-
- context "when called with a user object" do
- it "adds the user as a member" do
- Member.add_user(project.project_members, user, ProjectMember::MASTER)
-
- expect(project.users).to include(user)
- end
- end
-
- context "when called with a known user email" do
- it "adds the user as a member" do
- Member.add_user(project.project_members, user.email, ProjectMember::MASTER)
-
- expect(project.users).to include(user)
- end
- end
-
- context "when called with an unknown user email" do
- it "adds a member invite" do
- Member.add_user(project.project_members, "user@example.com", ProjectMember::MASTER)
-
- expect(project.project_members.invite.pluck(:invite_email)).to include("user@example.com")
- end
- end
- end
-
- describe "#accept_invite!" do
- let!(:member) { create(:project_member, invite_email: "user@example.com", user: nil) }
- let(:user) { create(:user) }
-
- it "resets the invite token" do
- member.accept_invite!(user)
-
- expect(member.invite_token).to be_nil
- end
-
- it "sets the invite accepted timestamp" do
- member.accept_invite!(user)
-
- expect(member.invite_accepted_at).not_to be_nil
- end
-
- it "sets the user" do
- member.accept_invite!(user)
-
- expect(member.user).to eq(user)
- end
-
- it "calls #after_accept_invite" do
- expect(member).to receive(:after_accept_invite)
-
- member.accept_invite!(user)
- end
- end
-
- describe "#decline_invite!" do
- let!(:member) { create(:project_member, invite_email: "user@example.com", user: nil) }
-
- it "destroys the member" do
- member.decline_invite!
-
- expect(member).to be_destroyed
- end
-
- it "calls #after_decline_invite" do
- expect(member).to receive(:after_decline_invite)
-
- member.decline_invite!
- end
- end
-
- describe "#generate_invite_token" do
- let!(:member) { create(:project_member, invite_email: "user@example.com", user: nil) }
-
- it "sets the invite token" do
- expect { member.generate_invite_token }.to change { member.invite_token}
- end
- end
-end
diff --git a/spec/models/members/group_member_spec.rb b/spec/models/members/group_member_spec.rb
deleted file mode 100644
index e206c11f33a..00000000000
--- a/spec/models/members/group_member_spec.rb
+++ /dev/null
@@ -1,46 +0,0 @@
-# == Schema Information
-#
-# Table name: members
-#
-# id :integer not null, primary key
-# access_level :integer not null
-# source_id :integer not null
-# source_type :string(255) not null
-# user_id :integer not null
-# notification_level :integer not null
-# type :string(255)
-# created_at :datetime
-# updated_at :datetime
-#
-
-require 'spec_helper'
-
-describe GroupMember do
- context 'notification' do
- describe "#after_create" do
- it "should send email to user" do
- membership = build(:group_member)
- membership.stub(notification_service: double('NotificationService').as_null_object)
- expect(membership).to receive(:notification_service)
- membership.save
- end
- end
-
- describe "#after_update" do
- before do
- @group_member = create :group_member
- @group_member.stub(notification_service: double('NotificationService').as_null_object)
- end
-
- it "should send email to user" do
- expect(@group_member).to receive(:notification_service)
- @group_member.update_attribute(:access_level, GroupMember::MASTER)
- end
-
- it "does not send an email when the access level has not changed" do
- expect(@group_member).not_to receive(:notification_service)
- @group_member.update_attribute(:access_level, GroupMember::OWNER)
- end
- end
- end
-end
diff --git a/spec/models/members/project_member_spec.rb b/spec/models/members/project_member_spec.rb
deleted file mode 100644
index 521721f3577..00000000000
--- a/spec/models/members/project_member_spec.rb
+++ /dev/null
@@ -1,92 +0,0 @@
-# == Schema Information
-#
-# Table name: members
-#
-# id :integer not null, primary key
-# access_level :integer not null
-# source_id :integer not null
-# source_type :string(255) not null
-# user_id :integer not null
-# notification_level :integer not null
-# type :string(255)
-# created_at :datetime
-# updated_at :datetime
-#
-
-require 'spec_helper'
-
-describe ProjectMember do
- describe :import_team do
- before do
- @abilities = Six.new
- @abilities << Ability
-
- @project_1 = create :project
- @project_2 = create :project
-
- @user_1 = create :user
- @user_2 = create :user
-
- @project_1.team << [ @user_1, :developer ]
- @project_2.team << [ @user_2, :reporter ]
-
- @status = @project_2.team.import(@project_1)
- end
-
- it { expect(@status).to be_truthy }
-
- describe 'project 2 should get user 1 as developer. user_2 should not be changed' do
- it { expect(@project_2.users).to include(@user_1) }
- it { expect(@project_2.users).to include(@user_2) }
-
- it { expect(@abilities.allowed?(@user_1, :write_project, @project_2)).to be_truthy }
- it { expect(@abilities.allowed?(@user_2, :read_project, @project_2)).to be_truthy }
- end
-
- describe 'project 1 should not be changed' do
- it { expect(@project_1.users).to include(@user_1) }
- it { expect(@project_1.users).not_to include(@user_2) }
- end
- end
-
- describe :add_users_into_projects do
- before do
- @project_1 = create :project
- @project_2 = create :project
-
- @user_1 = create :user
- @user_2 = create :user
-
- ProjectMember.add_users_into_projects(
- [@project_1.id, @project_2.id],
- [@user_1.id, @user_2.id],
- ProjectMember::MASTER
- )
- end
-
- it { expect(@project_1.users).to include(@user_1) }
- it { expect(@project_1.users).to include(@user_2) }
-
-
- it { expect(@project_2.users).to include(@user_1) }
- it { expect(@project_2.users).to include(@user_2) }
- end
-
- describe :truncate_teams do
- before do
- @project_1 = create :project
- @project_2 = create :project
-
- @user_1 = create :user
- @user_2 = create :user
-
- @project_1.team << [ @user_1, :developer]
- @project_2.team << [ @user_2, :reporter]
-
- ProjectMember.truncate_teams([@project_1.id, @project_2.id])
- end
-
- it { expect(@project_1.users).to be_empty }
- it { expect(@project_2.users).to be_empty }
- end
-end
diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb
deleted file mode 100644
index d40503d791c..00000000000
--- a/spec/models/merge_request_spec.rb
+++ /dev/null
@@ -1,127 +0,0 @@
-# == Schema Information
-#
-# Table name: merge_requests
-#
-# id :integer not null, primary key
-# target_branch :string(255) not null
-# source_branch :string(255) not null
-# source_project_id :integer not null
-# author_id :integer
-# assignee_id :integer
-# title :string(255)
-# created_at :datetime
-# updated_at :datetime
-# milestone_id :integer
-# state :string(255)
-# merge_status :string(255)
-# target_project_id :integer not null
-# iid :integer
-# description :text
-# position :integer default(0)
-# locked_at :datetime
-#
-
-require 'spec_helper'
-
-describe MergeRequest do
- describe "Validation" do
- it { is_expected.to validate_presence_of(:target_branch) }
- it { is_expected.to validate_presence_of(:source_branch) }
- end
-
- describe "Mass assignment" do
- end
-
- describe "Respond to" do
- it { is_expected.to respond_to(:unchecked?) }
- it { is_expected.to respond_to(:can_be_merged?) }
- it { is_expected.to respond_to(:cannot_be_merged?) }
- end
-
- describe 'modules' do
- it { is_expected.to include_module(Issuable) }
- end
-
- describe "#mr_and_commit_notes" do
- let!(:merge_request) { create(:merge_request) }
-
- before do
- allow(merge_request).to receive(:commits) { [merge_request.source_project.repository.commit] }
- create(:note, commit_id: merge_request.commits.first.id, noteable_type: 'Commit', project: merge_request.project)
- create(:note, noteable: merge_request, project: merge_request.project)
- end
-
- it "should include notes for commits" do
- expect(merge_request.commits).not_to be_empty
- expect(merge_request.mr_and_commit_notes.count).to eq(2)
- end
- end
-
- subject { create(:merge_request) }
-
- describe '#is_being_reassigned?' do
- it 'returns true if the merge_request assignee has changed' do
- subject.assignee = create(:user)
- expect(subject.is_being_reassigned?).to be_truthy
- end
- it 'returns false if the merge request assignee has not changed' do
- expect(subject.is_being_reassigned?).to be_falsey
- end
- end
-
- describe '#for_fork?' do
- it 'returns true if the merge request is for a fork' do
- subject.source_project = create(:project, namespace: create(:group))
- subject.target_project = create(:project, namespace: create(:group))
-
- expect(subject.for_fork?).to be_truthy
- end
-
- it 'returns false if is not for a fork' do
- expect(subject.for_fork?).to be_falsey
- end
- end
-
- describe 'detection of issues to be closed' do
- let(:issue0) { create :issue, project: subject.project }
- let(:issue1) { create :issue, project: subject.project }
- let(:commit0) { double('commit0', closes_issues: [issue0]) }
- let(:commit1) { double('commit1', closes_issues: [issue0]) }
- let(:commit2) { double('commit2', closes_issues: [issue1]) }
-
- before do
- subject.stub(commits: [commit0, commit1, commit2])
- end
-
- it 'accesses the set of issues that will be closed on acceptance' do
- subject.project.stub(default_branch: subject.target_branch)
-
- expect(subject.closes_issues).to eq([issue0, issue1].sort_by(&:id))
- end
-
- it 'only lists issues as to be closed if it targets the default branch' do
- subject.project.stub(default_branch: 'master')
- subject.target_branch = 'something-else'
-
- expect(subject.closes_issues).to be_empty
- end
-
- it 'detects issues mentioned in the description' do
- issue2 = create(:issue, project: subject.project)
- subject.description = "Closes ##{issue2.iid}"
- subject.project.stub(default_branch: subject.target_branch)
-
- expect(subject.closes_issues).to include(issue2)
- end
- end
-
- it_behaves_like 'an editable mentionable' do
- let(:subject) { create :merge_request, source_project: mproject, target_project: mproject }
- let(:backref_text) { "merge request !#{subject.iid}" }
- let(:set_mentionable_text) { ->(txt){ subject.title = txt } }
- end
-
- it_behaves_like 'a Taskable' do
- let(:subject) { create :merge_request, :simple }
- end
-end
diff --git a/spec/models/milestone_spec.rb b/spec/models/milestone_spec.rb
deleted file mode 100644
index 45171e1bf64..00000000000
--- a/spec/models/milestone_spec.rb
+++ /dev/null
@@ -1,143 +0,0 @@
-# == Schema Information
-#
-# Table name: milestones
-#
-# id :integer not null, primary key
-# title :string(255) not null
-# project_id :integer not null
-# description :text
-# due_date :date
-# created_at :datetime
-# updated_at :datetime
-# state :string(255)
-# iid :integer
-#
-
-require 'spec_helper'
-
-describe Milestone do
- describe "Associations" do
- it { is_expected.to belong_to(:project) }
- it { is_expected.to have_many(:issues) }
- end
-
- describe "Mass assignment" do
- end
-
- describe "Validation" do
- before { subject.stub(set_iid: false) }
- it { is_expected.to validate_presence_of(:title) }
- it { is_expected.to validate_presence_of(:project) }
- end
-
- let(:milestone) { create(:milestone) }
- let(:issue) { create(:issue) }
-
- describe "#percent_complete" do
- it "should not count open issues" do
- milestone.issues << issue
- expect(milestone.percent_complete).to eq(0)
- end
-
- it "should count closed issues" do
- issue.close
- milestone.issues << issue
- expect(milestone.percent_complete).to eq(100)
- end
-
- it "should recover from dividing by zero" do
- expect(milestone.issues).to receive(:count).and_return(0)
- expect(milestone.percent_complete).to eq(100)
- end
- end
-
- describe "#expires_at" do
- it "should be nil when due_date is unset" do
- milestone.update_attributes(due_date: nil)
- expect(milestone.expires_at).to be_nil
- end
-
- it "should not be nil when due_date is set" do
- milestone.update_attributes(due_date: Date.tomorrow)
- expect(milestone.expires_at).to be_present
- end
- end
-
- describe :expired? do
- context "expired" do
- before do
- milestone.stub(due_date: Date.today.prev_year)
- end
-
- it { expect(milestone.expired?).to be_truthy }
- end
-
- context "not expired" do
- before do
- milestone.stub(due_date: Date.today.next_year)
- end
-
- it { expect(milestone.expired?).to be_falsey }
- end
- end
-
- describe :percent_complete do
- before do
- milestone.stub(
- closed_items_count: 3,
- total_items_count: 4
- )
- end
-
- it { expect(milestone.percent_complete).to eq(75) }
- end
-
- describe :items_count do
- before do
- milestone.issues << create(:issue)
- milestone.issues << create(:closed_issue)
- milestone.merge_requests << create(:merge_request)
- end
-
- it { expect(milestone.closed_items_count).to eq(1) }
- it { expect(milestone.open_items_count).to eq(2) }
- it { expect(milestone.total_items_count).to eq(3) }
- it { expect(milestone.is_empty?).to be_falsey }
- end
-
- describe :can_be_closed? do
- it { expect(milestone.can_be_closed?).to be_truthy }
- end
-
- describe :is_empty? do
- before do
- issue = create :closed_issue, milestone: milestone
- merge_request = create :merge_request, milestone: milestone
- end
-
- it 'Should return total count of issues and merge requests assigned to milestone' do
- expect(milestone.total_items_count).to eq 2
- end
- end
-
- describe :can_be_closed? do
- before do
- milestone = create :milestone
- create :closed_issue, milestone: milestone
-
- issue = create :issue
- end
-
- it 'should be true if milestone active and all nested issues closed' do
- expect(milestone.can_be_closed?).to be_truthy
- end
-
- it 'should be false if milestone active and not all nested issues closed' do
- issue.milestone = milestone
- issue.save
-
- expect(milestone.can_be_closed?).to be_falsey
- end
- end
-
-end
diff --git a/spec/models/namespace_spec.rb b/spec/models/namespace_spec.rb
deleted file mode 100644
index e87432fdf62..00000000000
--- a/spec/models/namespace_spec.rb
+++ /dev/null
@@ -1,96 +0,0 @@
-# == Schema Information
-#
-# Table name: namespaces
-#
-# id :integer not null, primary key
-# name :string(255) not null
-# path :string(255) not null
-# owner_id :integer
-# created_at :datetime
-# updated_at :datetime
-# type :string(255)
-# description :string(255) default(""), not null
-# avatar :string(255)
-#
-
-require 'spec_helper'
-
-describe Namespace do
- let!(:namespace) { create(:namespace) }
-
- it { is_expected.to have_many :projects }
- it { is_expected.to validate_presence_of :name }
- it { is_expected.to validate_uniqueness_of(:name) }
- it { is_expected.to validate_presence_of :path }
- it { is_expected.to validate_uniqueness_of(:path) }
- it { is_expected.to validate_presence_of :owner }
-
- describe "Mass assignment" do
- end
-
- describe "Respond to" do
- it { is_expected.to respond_to(:human_name) }
- it { is_expected.to respond_to(:to_param) }
- end
-
- describe :to_param do
- it { expect(namespace.to_param).to eq(namespace.path) }
- end
-
- describe :human_name do
- it { expect(namespace.human_name).to eq(namespace.owner_name) }
- end
-
- describe :search do
- before do
- @namespace = create :namespace
- end
-
- it { expect(Namespace.search(@namespace.path)).to eq([@namespace]) }
- it { expect(Namespace.search('unknown')).to eq([]) }
- end
-
- describe :move_dir do
- before do
- @namespace = create :namespace
- @namespace.stub(path_changed?: true)
- end
-
- it "should raise error when directory exists" do
- expect { @namespace.move_dir }.to raise_error("namespace directory cannot be moved")
- end
-
- it "should move dir if path changed" do
- new_path = @namespace.path + "_new"
- @namespace.stub(path_was: @namespace.path)
- @namespace.stub(path: new_path)
- expect(@namespace.move_dir).to be_truthy
- end
- end
-
- describe :rm_dir do
- it "should remove dir" do
- expect(namespace.rm_dir).to be_truthy
- end
- end
-
- describe :find_by_path_or_name do
- before do
- @namespace = create(:namespace, name: 'WoW', path: 'woW')
- end
-
- it { expect(Namespace.find_by_path_or_name('wow')).to eq(@namespace) }
- it { expect(Namespace.find_by_path_or_name('WOW')).to eq(@namespace) }
- it { expect(Namespace.find_by_path_or_name('unknown')).to eq(nil) }
- end
-
- describe ".clean_path" do
-
- let!(:user) { create(:user, username: "johngitlab-etc") }
- let!(:namespace) { create(:namespace, path: "JohnGitLab-etc1") }
-
- it "cleans the path and makes sure it's available" do
- expect(Namespace.clean_path("-john+gitlab-ETC%.git@gmail.com")).to eq("johngitlab-ETC2")
- end
- end
-end
diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb
deleted file mode 100644
index a7bf5081d5b..00000000000
--- a/spec/models/note_spec.rb
+++ /dev/null
@@ -1,637 +0,0 @@
-# == Schema Information
-#
-# Table name: notes
-#
-# id :integer not null, primary key
-# note :text
-# noteable_type :string(255)
-# author_id :integer
-# created_at :datetime
-# updated_at :datetime
-# project_id :integer
-# attachment :string(255)
-# line_code :string(255)
-# commit_id :string(255)
-# noteable_id :integer
-# system :boolean default(FALSE), not null
-# st_diff :text
-#
-
-require 'spec_helper'
-
-describe Note do
- describe "Associations" do
- it { is_expected.to belong_to(:project) }
- it { is_expected.to belong_to(:noteable) }
- it { is_expected.to belong_to(:author).class_name('User') }
- end
-
- describe "Mass assignment" do
- end
-
- describe "Validation" do
- it { is_expected.to validate_presence_of(:note) }
- it { is_expected.to validate_presence_of(:project) }
- end
-
- describe "Voting score" do
- let(:project) { create(:project) }
-
- it "recognizes a neutral note" do
- note = create(:votable_note, note: "This is not a +1 note")
- expect(note).not_to be_upvote
- expect(note).not_to be_downvote
- end
-
- it "recognizes a neutral emoji note" do
- note = build(:votable_note, note: "I would :+1: this, but I don't want to")
- expect(note).not_to be_upvote
- expect(note).not_to be_downvote
- end
-
- it "recognizes a +1 note" do
- note = create(:votable_note, note: "+1 for this")
- expect(note).to be_upvote
- end
-
- it "recognizes a +1 emoji as a vote" do
- note = build(:votable_note, note: ":+1: for this")
- expect(note).to be_upvote
- end
-
- it "recognizes a thumbsup emoji as a vote" do
- note = build(:votable_note, note: ":thumbsup: for this")
- expect(note).to be_upvote
- end
-
- it "recognizes a -1 note" do
- note = create(:votable_note, note: "-1 for this")
- expect(note).to be_downvote
- end
-
- it "recognizes a -1 emoji as a vote" do
- note = build(:votable_note, note: ":-1: for this")
- expect(note).to be_downvote
- end
-
- it "recognizes a thumbsdown emoji as a vote" do
- note = build(:votable_note, note: ":thumbsdown: for this")
- expect(note).to be_downvote
- end
- end
-
- let(:project) { create(:project) }
-
- describe "Commit notes" do
- let!(:note) { create(:note_on_commit, note: "+1 from me") }
- let!(:commit) { note.noteable }
-
- it "should be accessible through #noteable" do
- expect(note.commit_id).to eq(commit.id)
- expect(note.noteable).to be_a(Commit)
- expect(note.noteable).to eq(commit)
- end
-
- it "should save a valid note" do
- expect(note.commit_id).to eq(commit.id)
- note.noteable == commit
- end
-
- it "should be recognized by #for_commit?" do
- expect(note).to be_for_commit
- end
-
- it "should not be votable" do
- expect(note).not_to be_votable
- end
- end
-
- describe "Commit diff line notes" do
- let!(:note) { create(:note_on_commit_diff, note: "+1 from me") }
- let!(:commit) { note.noteable }
-
- it "should save a valid note" do
- expect(note.commit_id).to eq(commit.id)
- expect(note.noteable.id).to eq(commit.id)
- end
-
- it "should be recognized by #for_diff_line?" do
- expect(note).to be_for_diff_line
- end
-
- it "should be recognized by #for_commit_diff_line?" do
- expect(note).to be_for_commit_diff_line
- end
-
- it "should not be votable" do
- expect(note).not_to be_votable
- end
- end
-
- describe "Issue notes" do
- let!(:note) { create(:note_on_issue, note: "+1 from me") }
-
- it "should not be votable" do
- expect(note).to be_votable
- end
- end
-
- describe "Merge request notes" do
- let!(:note) { create(:note_on_merge_request, note: "+1 from me") }
-
- it "should be votable" do
- expect(note).to be_votable
- end
- end
-
- describe "Merge request diff line notes" do
- let!(:note) { create(:note_on_merge_request_diff, note: "+1 from me") }
-
- it "should not be votable" do
- expect(note).not_to be_votable
- end
- end
-
- describe '#create_status_change_note' do
- let(:project) { create(:project) }
- let(:thing) { create(:issue, project: project) }
- let(:author) { create(:user) }
- let(:status) { 'new_status' }
-
- subject { Note.create_status_change_note(thing, project, author, status, nil) }
-
- it 'creates and saves a Note' do
- is_expected.to be_a Note
- expect(subject.id).not_to be_nil
- end
-
- describe '#noteable' do
- subject { super().noteable }
- it { is_expected.to eq(thing) }
- end
-
- describe '#project' do
- subject { super().project }
- it { is_expected.to eq(thing.project) }
- end
-
- describe '#author' do
- subject { super().author }
- it { is_expected.to eq(author) }
- end
-
- describe '#note' do
- subject { super().note }
- it { is_expected.to eq("Status changed to #{status}") }
- end
-
- it 'appends a back-reference if a closing mentionable is supplied' do
- commit = double('commit', gfm_reference: 'commit 123456')
- n = Note.create_status_change_note(thing, project, author, status, commit)
-
- expect(n.note).to eq("Status changed to #{status} by commit 123456")
- end
- end
-
- describe '#create_assignee_change_note' do
- let(:project) { create(:project) }
- let(:thing) { create(:issue, project: project) }
- let(:author) { create(:user) }
- let(:assignee) { create(:user, username: "assigned_user") }
-
- subject { Note.create_assignee_change_note(thing, project, author, assignee) }
-
- context 'creates and saves a Note' do
- it { is_expected.to be_a Note }
-
- describe '#id' do
- subject { super().id }
- it { is_expected.not_to be_nil }
- end
- end
-
- describe '#noteable' do
- subject { super().noteable }
- it { is_expected.to eq(thing) }
- end
-
- describe '#project' do
- subject { super().project }
- it { is_expected.to eq(thing.project) }
- end
-
- describe '#author' do
- subject { super().author }
- it { is_expected.to eq(author) }
- end
-
- describe '#note' do
- subject { super().note }
- it { is_expected.to eq('Reassigned to @assigned_user') }
- end
-
- context 'assignee is removed' do
- let(:assignee) { nil }
-
- describe '#note' do
- subject { super().note }
- it { is_expected.to eq('Assignee removed') }
- end
- end
- end
-
- describe '#create_labels_change_note' do
- let(:project) { create(:project) }
- let(:thing) { create(:issue, project: project) }
- let(:author) { create(:user) }
- let(:label1) { create(:label) }
- let(:label2) { create(:label) }
- let(:added_labels) { [label1, label2] }
- let(:removed_labels) { [] }
-
- subject { Note.create_labels_change_note(thing, project, author, added_labels, removed_labels) }
-
- context 'creates and saves a Note' do
- it { is_expected.to be_a Note }
-
- describe '#id' do
- subject { super().id }
- it { is_expected.not_to be_nil }
- end
- end
-
- describe '#noteable' do
- subject { super().noteable }
- it { is_expected.to eq(thing) }
- end
-
- describe '#project' do
- subject { super().project }
- it { is_expected.to eq(thing.project) }
- end
-
- describe '#author' do
- subject { super().author }
- it { is_expected.to eq(author) }
- end
-
- describe '#note' do
- subject { super().note }
- it { is_expected.to eq("Added ~#{label1.id} ~#{label2.id} labels") }
- end
-
- context 'label is removed' do
- let(:added_labels) { [label1] }
- let(:removed_labels) { [label2] }
-
- describe '#note' do
- subject { super().note }
- it { is_expected.to eq("Added ~#{label1.id} and removed ~#{label2.id} labels") }
- end
- end
- end
-
- describe '#create_milestone_change_note' do
- let(:project) { create(:project) }
- let(:thing) { create(:issue, project: project) }
- let(:milestone) { create(:milestone, project: project, title: "first_milestone") }
- let(:author) { create(:user) }
-
- subject { Note.create_milestone_change_note(thing, project, author, milestone) }
-
- context 'creates and saves a Note' do
- it { is_expected.to be_a Note }
-
- describe '#id' do
- subject { super().id }
- it { is_expected.not_to be_nil }
- end
- end
-
- describe '#project' do
- subject { super().project }
- it { is_expected.to eq(thing.project) }
- end
-
- describe '#author' do
- subject { super().author }
- it { is_expected.to eq(author) }
- end
-
- describe '#note' do
- subject { super().note }
- it { is_expected.to eq("Milestone changed to first_milestone") }
- end
- end
-
- describe '#create_cross_reference_note' do
- let(:project) { create(:project) }
- let(:author) { create(:user) }
- let(:issue) { create(:issue, project: project) }
- let(:mergereq) { create(:merge_request, :simple, target_project: project, source_project: project) }
- let(:commit) { project.repository.commit }
-
- # Test all of {issue, merge request, commit} in both the referenced and referencing
- # roles, to ensure that the correct information can be inferred from any argument.
-
- context 'issue from a merge request' do
- subject { Note.create_cross_reference_note(issue, mergereq, author, project) }
-
- it { is_expected.to be_valid }
-
- describe '#noteable' do
- subject { super().noteable }
- it { is_expected.to eq(issue) }
- end
-
- describe '#project' do
- subject { super().project }
- it { is_expected.to eq(issue.project) }
- end
-
- describe '#author' do
- subject { super().author }
- it { is_expected.to eq(author) }
- end
-
- describe '#note' do
- subject { super().note }
- it { is_expected.to eq("mentioned in merge request !#{mergereq.iid}") }
- end
- end
-
- context 'issue from a commit' do
- subject { Note.create_cross_reference_note(issue, commit, author, project) }
-
- it { is_expected.to be_valid }
-
- describe '#noteable' do
- subject { super().noteable }
- it { is_expected.to eq(issue) }
- end
-
- describe '#note' do
- subject { super().note }
- it { is_expected.to eq("mentioned in commit #{commit.sha}") }
- end
- end
-
- context 'merge request from an issue' do
- subject { Note.create_cross_reference_note(mergereq, issue, author, project) }
-
- it { is_expected.to be_valid }
-
- describe '#noteable' do
- subject { super().noteable }
- it { is_expected.to eq(mergereq) }
- end
-
- describe '#project' do
- subject { super().project }
- it { is_expected.to eq(mergereq.project) }
- end
-
- describe '#note' do
- subject { super().note }
- it { is_expected.to eq("mentioned in issue ##{issue.iid}") }
- end
- end
-
- context 'commit from a merge request' do
- subject { Note.create_cross_reference_note(commit, mergereq, author, project) }
-
- it { is_expected.to be_valid }
-
- describe '#noteable' do
- subject { super().noteable }
- it { is_expected.to eq(commit) }
- end
-
- describe '#project' do
- subject { super().project }
- it { is_expected.to eq(project) }
- end
-
- describe '#note' do
- subject { super().note }
- it { is_expected.to eq("mentioned in merge request !#{mergereq.iid}") }
- end
- end
-
- context 'commit contained in a merge request' do
- subject { Note.create_cross_reference_note(mergereq.commits.first, mergereq, author, project) }
-
- it { is_expected.to be_nil }
- end
-
- context 'commit from issue' do
- subject { Note.create_cross_reference_note(commit, issue, author, project) }
-
- it { is_expected.to be_valid }
-
- describe '#noteable_type' do
- subject { super().noteable_type }
- it { is_expected.to eq("Commit") }
- end
-
- describe '#noteable_id' do
- subject { super().noteable_id }
- it { is_expected.to be_nil }
- end
-
- describe '#commit_id' do
- subject { super().commit_id }
- it { is_expected.to eq(commit.id) }
- end
-
- describe '#note' do
- subject { super().note }
- it { is_expected.to eq("mentioned in issue ##{issue.iid}") }
- end
- end
-
- context 'commit from commit' do
- let(:parent_commit) { commit.parents.first }
- subject { Note.create_cross_reference_note(commit, parent_commit, author, project) }
-
- it { is_expected.to be_valid }
-
- describe '#noteable_type' do
- subject { super().noteable_type }
- it { is_expected.to eq("Commit") }
- end
-
- describe '#noteable_id' do
- subject { super().noteable_id }
- it { is_expected.to be_nil }
- end
-
- describe '#commit_id' do
- subject { super().commit_id }
- it { is_expected.to eq(commit.id) }
- end
-
- describe '#note' do
- subject { super().note }
- it { is_expected.to eq("mentioned in commit #{parent_commit.id}") }
- end
- end
- end
-
- describe '#cross_reference_exists?' do
- let(:project) { create :project }
- let(:author) { create :user }
- let(:issue) { create :issue }
- let(:commit0) { project.repository.commit }
- let(:commit1) { project.repository.commit('HEAD~2') }
-
- before do
- Note.create_cross_reference_note(issue, commit0, author, project)
- end
-
- it 'detects if a mentionable has already been mentioned' do
- expect(Note.cross_reference_exists?(issue, commit0)).to be_truthy
- end
-
- it 'detects if a mentionable has not already been mentioned' do
- expect(Note.cross_reference_exists?(issue, commit1)).to be_falsey
- end
-
- context 'commit on commit' do
- before do
- Note.create_cross_reference_note(commit0, commit1, author, project)
- end
-
- it { expect(Note.cross_reference_exists?(commit0, commit1)).to be_truthy }
- it { expect(Note.cross_reference_exists?(commit1, commit0)).to be_falsey }
- end
-
- context 'legacy note with Markdown emphasis' do
- let(:issue2) { create :issue, project: project }
- let!(:note) do
- create :note, system: true, noteable_id: issue2.id,
- noteable_type: "Issue", note: "_mentioned in issue " \
- "#{issue.project.path_with_namespace}##{issue.iid}_"
- end
-
- it 'detects if a mentionable with emphasis has been mentioned' do
- expect(Note.cross_reference_exists?(issue2, issue)).to be_truthy
- end
- end
- end
-
- describe '#cross_references_with_underscores?' do
- let(:project) { create :project, path: "first_project" }
- let(:second_project) { create :project, path: "second_project" }
-
- let(:author) { create :user }
- let(:issue0) { create :issue, project: project }
- let(:issue1) { create :issue, project: second_project }
- let!(:note) { Note.create_cross_reference_note(issue0, issue1, author, project) }
-
- it 'detects if a mentionable has already been mentioned' do
- expect(Note.cross_reference_exists?(issue0, issue1)).to be_truthy
- end
-
- it 'detects if a mentionable has not already been mentioned' do
- expect(Note.cross_reference_exists?(issue1, issue0)).to be_falsey
- end
-
- it 'detects that text has underscores' do
- expect(note.note).to eq("mentioned in issue #{second_project.path_with_namespace}##{issue1.iid}")
- end
- end
-
- describe '#system?' do
- let(:project) { create(:project) }
- let(:issue) { create(:issue, project: project) }
- let(:other) { create(:issue, project: project) }
- let(:author) { create(:user) }
- let(:assignee) { create(:user) }
- let(:label) { create(:label) }
- let(:milestone) { create(:milestone) }
-
- it 'should recognize user-supplied notes as non-system' do
- @note = create(:note_on_issue)
- expect(@note).not_to be_system
- end
-
- it 'should identify status-change notes as system notes' do
- @note = Note.create_status_change_note(issue, project, author, 'closed', nil)
- expect(@note).to be_system
- end
-
- it 'should identify cross-reference notes as system notes' do
- @note = Note.create_cross_reference_note(issue, other, author, project)
- expect(@note).to be_system
- end
-
- it 'should identify assignee-change notes as system notes' do
- @note = Note.create_assignee_change_note(issue, project, author, assignee)
- expect(@note).to be_system
- end
-
- it 'should identify label-change notes as system notes' do
- @note = Note.create_labels_change_note(issue, project, author, [label], [])
- expect(@note).to be_system
- end
-
- it 'should identify milestone-change notes as system notes' do
- @note = Note.create_milestone_change_note(issue, project, author, milestone)
- expect(@note).to be_system
- end
- end
-
- describe :authorization do
- before do
- @p1 = create(:project)
- @p2 = create(:project)
- @u1 = create(:user)
- @u2 = create(:user)
- @u3 = create(:user)
- @abilities = Six.new
- @abilities << Ability
- end
-
- describe :read do
- before do
- @p1.project_members.create(user: @u2, access_level: ProjectMember::GUEST)
- @p2.project_members.create(user: @u3, access_level: ProjectMember::GUEST)
- end
-
- it { expect(@abilities.allowed?(@u1, :read_note, @p1)).to be_falsey }
- it { expect(@abilities.allowed?(@u2, :read_note, @p1)).to be_truthy }
- it { expect(@abilities.allowed?(@u3, :read_note, @p1)).to be_falsey }
- end
-
- describe :write do
- before do
- @p1.project_members.create(user: @u2, access_level: ProjectMember::DEVELOPER)
- @p2.project_members.create(user: @u3, access_level: ProjectMember::DEVELOPER)
- end
-
- it { expect(@abilities.allowed?(@u1, :write_note, @p1)).to be_falsey }
- it { expect(@abilities.allowed?(@u2, :write_note, @p1)).to be_truthy }
- it { expect(@abilities.allowed?(@u3, :write_note, @p1)).to be_falsey }
- end
-
- describe :admin do
- before do
- @p1.project_members.create(user: @u1, access_level: ProjectMember::REPORTER)
- @p1.project_members.create(user: @u2, access_level: ProjectMember::MASTER)
- @p2.project_members.create(user: @u3, access_level: ProjectMember::MASTER)
- end
-
- it { expect(@abilities.allowed?(@u1, :admin_note, @p1)).to be_falsey }
- it { expect(@abilities.allowed?(@u2, :admin_note, @p1)).to be_truthy }
- it { expect(@abilities.allowed?(@u3, :admin_note, @p1)).to be_falsey }
- end
- end
-
- it_behaves_like 'an editable mentionable' do
- let(:issue) { create :issue, project: project }
- let(:subject) { create :note, noteable: issue, project: project }
- let(:backref_text) { issue.gfm_reference }
- let(:set_mentionable_text) { ->(txt) { subject.note = txt } }
- end
-end
diff --git a/spec/models/project_security_spec.rb b/spec/models/project_security_spec.rb
deleted file mode 100644
index 1ee19003543..00000000000
--- a/spec/models/project_security_spec.rb
+++ /dev/null
@@ -1,126 +0,0 @@
-require 'spec_helper'
-
-describe Project do
- describe :authorization do
- before do
- @p1 = create(:project)
-
- @u1 = create(:user)
- @u2 = create(:user)
- @u3 = create(:user)
- @u4 = @p1.owner
-
- @abilities = Six.new
- @abilities << Ability
- end
-
- let(:guest_actions) { Ability.project_guest_rules }
- let(:report_actions) { Ability.project_report_rules }
- let(:dev_actions) { Ability.project_dev_rules }
- let(:master_actions) { Ability.project_master_rules }
- let(:admin_actions) { Ability.project_admin_rules }
-
- describe "Non member rules" do
- it "should deny for non-project users any actions" do
- admin_actions.each do |action|
- expect(@abilities.allowed?(@u1, action, @p1)).to be_falsey
- end
- end
- end
-
- describe "Guest Rules" do
- before do
- @p1.project_members.create(project: @p1, user: @u2, access_level: ProjectMember::GUEST)
- end
-
- it "should allow for project user any guest actions" do
- guest_actions.each do |action|
- expect(@abilities.allowed?(@u2, action, @p1)).to be_truthy
- end
- end
- end
-
- describe "Report Rules" do
- before do
- @p1.project_members.create(project: @p1, user: @u2, access_level: ProjectMember::REPORTER)
- end
-
- it "should allow for project user any report actions" do
- report_actions.each do |action|
- expect(@abilities.allowed?(@u2, action, @p1)).to be_truthy
- end
- end
- end
-
- describe "Developer Rules" do
- before do
- @p1.project_members.create(project: @p1, user: @u2, access_level: ProjectMember::REPORTER)
- @p1.project_members.create(project: @p1, user: @u3, access_level: ProjectMember::DEVELOPER)
- end
-
- it "should deny for developer master-specific actions" do
- [dev_actions - report_actions].each do |action|
- expect(@abilities.allowed?(@u2, action, @p1)).to be_falsey
- end
- end
-
- it "should allow for project user any dev actions" do
- dev_actions.each do |action|
- expect(@abilities.allowed?(@u3, action, @p1)).to be_truthy
- end
- end
- end
-
- describe "Master Rules" do
- before do
- @p1.project_members.create(project: @p1, user: @u2, access_level: ProjectMember::DEVELOPER)
- @p1.project_members.create(project: @p1, user: @u3, access_level: ProjectMember::MASTER)
- end
-
- it "should deny for developer master-specific actions" do
- [master_actions - dev_actions].each do |action|
- expect(@abilities.allowed?(@u2, action, @p1)).to be_falsey
- end
- end
-
- it "should allow for project user any master actions" do
- master_actions.each do |action|
- expect(@abilities.allowed?(@u3, action, @p1)).to be_truthy
- end
- end
- end
-
- describe "Admin Rules" do
- before do
- @p1.project_members.create(project: @p1, user: @u2, access_level: ProjectMember::DEVELOPER)
- @p1.project_members.create(project: @p1, user: @u3, access_level: ProjectMember::MASTER)
- end
-
- it "should deny for masters admin-specific actions" do
- [admin_actions - master_actions].each do |action|
- expect(@abilities.allowed?(@u2, action, @p1)).to be_falsey
- end
- end
-
- it "should allow for project owner any admin actions" do
- admin_actions.each do |action|
- expect(@abilities.allowed?(@u4, action, @p1)).to be_truthy
- end
- end
- end
- end
-end
-# == Schema Information
-#
-# Table name: projects
-#
-# id :integer not null, primary key
-# name :string(255)
-# path :string(255)
-# description :text
-# created_at :datetime
-# updated_at :datetime
-# private_flag :boolean default(TRUE), not null
-# code :string(255)
-#
-
diff --git a/spec/models/project_services/asana_service_spec.rb b/spec/models/project_services/asana_service_spec.rb
deleted file mode 100644
index 13c8d54a2af..00000000000
--- a/spec/models/project_services/asana_service_spec.rb
+++ /dev/null
@@ -1,65 +0,0 @@
-# == Schema Information
-#
-# Table name: services
-#
-# id :integer not null, primary key
-# type :string(255)
-# title :string(255)
-# project_id :integer
-# created_at :datetime
-# updated_at :datetime
-# active :boolean default(FALSE), not null
-# properties :text
-# template :boolean default(FALSE)
-# push_events :boolean default(TRUE)
-# issues_events :boolean default(TRUE)
-# merge_requests_events :boolean default(TRUE)
-# tag_push_events :boolean default(TRUE)
-#
-
-require 'spec_helper'
-
-describe AsanaService, models: true do
- describe 'Associations' do
- it { is_expected.to belong_to :project }
- it { is_expected.to have_one :service_hook }
- end
-
- describe 'Validations' do
- context 'active' do
- before do
- subject.active = true
- end
-
- it { is_expected.to validate_presence_of :api_key }
- end
- end
-
- describe 'Execute' do
- let(:user) { create(:user) }
- let(:project) { create(:project) }
-
- before do
- @asana = AsanaService.new
- @asana.stub(
- project: project,
- project_id: project.id,
- service_hook: true,
- api_key: 'verySecret',
- restrict_to_branch: 'master'
- )
- end
-
- it 'should call Asana service to created a story' do
- expect(Asana::Task).to receive(:find).with('123456').once
-
- @asana.check_commit('related to #123456', 'pushed')
- end
-
- it 'should call Asana service to created a story and close a task' do
- expect(Asana::Task).to receive(:find).with('456789').twice
-
- @asana.check_commit('fix #456789', 'pushed')
- end
- end
-end
diff --git a/spec/models/project_services/assembla_service_spec.rb b/spec/models/project_services/assembla_service_spec.rb
deleted file mode 100644
index 91730da1eec..00000000000
--- a/spec/models/project_services/assembla_service_spec.rb
+++ /dev/null
@@ -1,53 +0,0 @@
-# == Schema Information
-#
-# Table name: services
-#
-# id :integer not null, primary key
-# type :string(255)
-# title :string(255)
-# project_id :integer
-# created_at :datetime
-# updated_at :datetime
-# active :boolean default(FALSE), not null
-# properties :text
-# template :boolean default(FALSE)
-# push_events :boolean default(TRUE)
-# issues_events :boolean default(TRUE)
-# merge_requests_events :boolean default(TRUE)
-# tag_push_events :boolean default(TRUE)
-#
-
-require 'spec_helper'
-
-describe AssemblaService, models: true do
- describe "Associations" do
- it { is_expected.to belong_to :project }
- it { is_expected.to have_one :service_hook }
- end
-
- describe "Execute" do
- let(:user) { create(:user) }
- let(:project) { create(:project) }
-
- before do
- @assembla_service = AssemblaService.new
- @assembla_service.stub(
- project_id: project.id,
- project: project,
- service_hook: true,
- token: 'verySecret',
- subdomain: 'project_name'
- )
- @sample_data = Gitlab::PushDataBuilder.build_sample(project, user)
- @api_url = 'https://atlas.assembla.com/spaces/project_name/github_tool?secret_key=verySecret'
- WebMock.stub_request(:post, @api_url)
- end
-
- it "should call Assembla API" do
- @assembla_service.execute(@sample_data)
- expect(WebMock).to have_requested(:post, @api_url).with(
- body: /#{@sample_data[:before]}.*#{@sample_data[:after]}.*#{project.path}/
- ).once
- end
- end
-end
diff --git a/spec/models/project_services/buildkite_service_spec.rb b/spec/models/project_services/buildkite_service_spec.rb
deleted file mode 100644
index e987241f3ca..00000000000
--- a/spec/models/project_services/buildkite_service_spec.rb
+++ /dev/null
@@ -1,82 +0,0 @@
-# == Schema Information
-#
-# Table name: services
-#
-# id :integer not null, primary key
-# type :string(255)
-# title :string(255)
-# project_id :integer
-# created_at :datetime
-# updated_at :datetime
-# active :boolean default(FALSE), not null
-# properties :text
-# template :boolean default(FALSE)
-# push_events :boolean default(TRUE)
-# issues_events :boolean default(TRUE)
-# merge_requests_events :boolean default(TRUE)
-# tag_push_events :boolean default(TRUE)
-#
-
-require 'spec_helper'
-
-describe BuildkiteService do
- describe 'Associations' do
- it { is_expected.to belong_to :project }
- it { is_expected.to have_one :service_hook }
- end
-
- describe 'commits methods' do
- before do
- @project = Project.new
- @project.stub(
- default_branch: 'default-brancho'
- )
-
- @service = BuildkiteService.new
- @service.stub(
- project: @project,
- service_hook: true,
- project_url: 'https://buildkite.com/account-name/example-project',
- token: 'secret-sauce-webhook-token:secret-sauce-status-token'
- )
- end
-
- describe :webhook_url do
- it 'returns the webhook url' do
- expect(@service.webhook_url).to eq(
- 'https://webhook.buildkite.com/deliver/secret-sauce-webhook-token'
- )
- end
- end
-
- describe :commit_status_path do
- it 'returns the correct status page' do
- expect(@service.commit_status_path('2ab7834c')).to eq(
- 'https://gitlab.buildkite.com/status/secret-sauce-status-token.json?commit=2ab7834c'
- )
- end
- end
-
- describe :build_page do
- it 'returns the correct build page' do
- expect(@service.build_page('2ab7834c', nil)).to eq(
- 'https://buildkite.com/account-name/example-project/builds?commit=2ab7834c'
- )
- end
- end
-
- describe :builds_page do
- it 'returns the correct path to the builds page' do
- expect(@service.builds_path).to eq(
- 'https://buildkite.com/account-name/example-project/builds?branch=default-brancho'
- )
- end
- end
-
- describe :status_img_path do
- it 'returns the correct path to the status image' do
- expect(@service.status_img_path).to eq('https://badge.buildkite.com/secret-sauce-status-token.svg')
- end
- end
- end
-end
diff --git a/spec/models/project_services/flowdock_service_spec.rb b/spec/models/project_services/flowdock_service_spec.rb
deleted file mode 100644
index 73f68301a34..00000000000
--- a/spec/models/project_services/flowdock_service_spec.rb
+++ /dev/null
@@ -1,52 +0,0 @@
-# == Schema Information
-#
-# Table name: services
-#
-# id :integer not null, primary key
-# type :string(255)
-# title :string(255)
-# project_id :integer
-# created_at :datetime
-# updated_at :datetime
-# active :boolean default(FALSE), not null
-# properties :text
-# template :boolean default(FALSE)
-# push_events :boolean default(TRUE)
-# issues_events :boolean default(TRUE)
-# merge_requests_events :boolean default(TRUE)
-# tag_push_events :boolean default(TRUE)
-#
-
-require 'spec_helper'
-
-describe FlowdockService do
- describe "Associations" do
- it { is_expected.to belong_to :project }
- it { is_expected.to have_one :service_hook }
- end
-
- describe "Execute" do
- let(:user) { create(:user) }
- let(:project) { create(:project) }
-
- before do
- @flowdock_service = FlowdockService.new
- @flowdock_service.stub(
- project_id: project.id,
- project: project,
- service_hook: true,
- token: 'verySecret'
- )
- @sample_data = Gitlab::PushDataBuilder.build_sample(project, user)
- @api_url = 'https://api.flowdock.com/v1/git/verySecret'
- WebMock.stub_request(:post, @api_url)
- end
-
- it "should call FlowDock API" do
- @flowdock_service.execute(@sample_data)
- expect(WebMock).to have_requested(:post, @api_url).with(
- body: /#{@sample_data[:before]}.*#{@sample_data[:after]}.*#{project.path}/
- ).once
- end
- end
-end
diff --git a/spec/models/project_services/gemnasium_service_spec.rb b/spec/models/project_services/gemnasium_service_spec.rb
deleted file mode 100644
index d44064bbe6a..00000000000
--- a/spec/models/project_services/gemnasium_service_spec.rb
+++ /dev/null
@@ -1,48 +0,0 @@
-# == Schema Information
-#
-# Table name: services
-#
-# id :integer not null, primary key
-# type :string(255)
-# title :string(255)
-# project_id :integer
-# created_at :datetime
-# updated_at :datetime
-# active :boolean default(FALSE), not null
-# properties :text
-# template :boolean default(FALSE)
-# push_events :boolean default(TRUE)
-# issues_events :boolean default(TRUE)
-# merge_requests_events :boolean default(TRUE)
-# tag_push_events :boolean default(TRUE)
-#
-
-require 'spec_helper'
-
-describe GemnasiumService do
- describe "Associations" do
- it { is_expected.to belong_to :project }
- it { is_expected.to have_one :service_hook }
- end
-
- describe "Execute" do
- let(:user) { create(:user) }
- let(:project) { create(:project) }
-
- before do
- @gemnasium_service = GemnasiumService.new
- @gemnasium_service.stub(
- project_id: project.id,
- project: project,
- service_hook: true,
- token: 'verySecret',
- api_key: 'GemnasiumUserApiKey'
- )
- @sample_data = Gitlab::PushDataBuilder.build_sample(project, user)
- end
- it "should call Gemnasium service" do
- expect(Gemnasium::GitlabService).to receive(:execute).with(an_instance_of(Hash)).once
- @gemnasium_service.execute(@sample_data)
- end
- end
-end
diff --git a/spec/models/project_services/gitlab_ci_service_spec.rb b/spec/models/project_services/gitlab_ci_service_spec.rb
deleted file mode 100644
index 6a557d839ca..00000000000
--- a/spec/models/project_services/gitlab_ci_service_spec.rb
+++ /dev/null
@@ -1,70 +0,0 @@
-# == Schema Information
-#
-# Table name: services
-#
-# id :integer not null, primary key
-# type :string(255)
-# title :string(255)
-# project_id :integer
-# created_at :datetime
-# updated_at :datetime
-# active :boolean default(FALSE), not null
-# properties :text
-# template :boolean default(FALSE)
-# push_events :boolean default(TRUE)
-# issues_events :boolean default(TRUE)
-# merge_requests_events :boolean default(TRUE)
-# tag_push_events :boolean default(TRUE)
-#
-
-require 'spec_helper'
-
-describe GitlabCiService do
- describe "Associations" do
- it { is_expected.to belong_to :project }
- it { is_expected.to have_one :service_hook }
- end
-
- describe "Mass assignment" do
- end
-
- describe 'commits methods' do
- before do
- @service = GitlabCiService.new
- @service.stub(
- service_hook: true,
- project_url: 'http://ci.gitlab.org/projects/2',
- token: 'verySecret'
- )
- end
-
- describe :commit_status_path do
- it { expect(@service.commit_status_path("2ab7834c", 'master')).to eq("http://ci.gitlab.org/projects/2/refs/master/commits/2ab7834c/status.json?token=verySecret")}
- end
-
- describe :build_page do
- it { expect(@service.build_page("2ab7834c", 'master')).to eq("http://ci.gitlab.org/projects/2/refs/master/commits/2ab7834c")}
- end
- end
-
- describe "Fork registration" do
- before do
- @old_project = create(:empty_project)
- @project = create(:empty_project)
- @user = create(:user)
-
- @service = GitlabCiService.new
- @service.stub(
- service_hook: true,
- project_url: 'http://ci.gitlab.org/projects/2',
- token: 'verySecret',
- project: @old_project
- )
- end
-
- it "performs http reuquest to ci" do
- stub_request(:post, "http://ci.gitlab.org/api/v1/forks")
- @service.fork_registration(@project, @user.private_token)
- end
- end
-end
diff --git a/spec/models/project_services/gitlab_issue_tracker_service_spec.rb b/spec/models/project_services/gitlab_issue_tracker_service_spec.rb
deleted file mode 100644
index f94bef5c365..00000000000
--- a/spec/models/project_services/gitlab_issue_tracker_service_spec.rb
+++ /dev/null
@@ -1,66 +0,0 @@
-# == Schema Information
-#
-# Table name: services
-#
-# id :integer not null, primary key
-# type :string(255)
-# title :string(255)
-# project_id :integer
-# created_at :datetime
-# updated_at :datetime
-# active :boolean default(FALSE), not null
-# properties :text
-# template :boolean default(FALSE)
-# push_events :boolean default(TRUE)
-# issues_events :boolean default(TRUE)
-# merge_requests_events :boolean default(TRUE)
-# tag_push_events :boolean default(TRUE)
-#
-
-require 'spec_helper'
-
-describe GitlabIssueTrackerService do
- describe "Associations" do
- it { is_expected.to belong_to :project }
- it { is_expected.to have_one :service_hook }
- end
-
-
- describe 'project and issue urls' do
- let(:project) { create(:project) }
-
- context 'with absolute urls' do
- before do
- GitlabIssueTrackerService.default_url_options[:script_name] = "/gitlab/root"
- @service = project.create_gitlab_issue_tracker_service(active: true)
- end
-
- after do
- @service.destroy!
- end
-
- it 'should give the correct path' do
- expect(@service.project_url).to eq("http://localhost/gitlab/root/#{project.path_with_namespace}/issues")
- expect(@service.new_issue_url).to eq("http://localhost/gitlab/root/#{project.path_with_namespace}/issues/new")
- expect(@service.issue_url(432)).to eq("http://localhost/gitlab/root/#{project.path_with_namespace}/issues/432")
- end
- end
-
- context 'with relative urls' do
- before do
- GitlabIssueTrackerService.default_url_options[:script_name] = "/gitlab/root"
- @service = project.create_gitlab_issue_tracker_service(active: true)
- end
-
- after do
- @service.destroy!
- end
-
- it 'should give the correct path' do
- expect(@service.project_path).to eq("/gitlab/root/#{project.path_with_namespace}/issues")
- expect(@service.new_issue_path).to eq("/gitlab/root/#{project.path_with_namespace}/issues/new")
- expect(@service.issue_path(432)).to eq("/gitlab/root/#{project.path_with_namespace}/issues/432")
- end
- end
- end
-end
diff --git a/spec/models/project_services/hipchat_service_spec.rb b/spec/models/project_services/hipchat_service_spec.rb
deleted file mode 100644
index 8ab847e6432..00000000000
--- a/spec/models/project_services/hipchat_service_spec.rb
+++ /dev/null
@@ -1,217 +0,0 @@
-# == Schema Information
-#
-# Table name: services
-#
-# id :integer not null, primary key
-# type :string(255)
-# title :string(255)
-# project_id :integer not null
-# created_at :datetime
-# updated_at :datetime
-# active :boolean default(FALSE), not null
-# properties :text
-# push_events :boolean default(TRUE)
-# issues_events :boolean default(TRUE)
-# merge_requests_events :boolean default(TRUE)
-# tag_push_events :boolean default(TRUE)
-#
-
-require 'spec_helper'
-
-describe HipchatService do
- describe "Associations" do
- it { is_expected.to belong_to :project }
- it { is_expected.to have_one :service_hook }
- end
-
- describe "Execute" do
- let(:hipchat) { HipchatService.new }
- let(:user) { create(:user, username: 'username') }
- let(:project) { create(:project, name: 'project') }
- let(:api_url) { 'https://hipchat.example.com/v2/room/123456/notification?auth_token=verySecret' }
- let(:project_name) { project.name_with_namespace.gsub(/\s/, '') }
-
- before(:each) do
- hipchat.stub(
- project_id: project.id,
- project: project,
- room: 123456,
- server: 'https://hipchat.example.com',
- token: 'verySecret'
- )
- WebMock.stub_request(:post, api_url)
- end
-
- context 'push events' do
- let(:push_sample_data) { Gitlab::PushDataBuilder.build_sample(project, user) }
-
- it "should call Hipchat API for push events" do
- hipchat.execute(push_sample_data)
-
- expect(WebMock).to have_requested(:post, api_url).once
- end
-
- it "should create a push message" do
- message = hipchat.send(:create_push_message, push_sample_data)
-
- obj_attr = push_sample_data[:object_attributes]
- branch = push_sample_data[:ref].gsub('refs/heads/', '')
- expect(message).to include("#{user.name} pushed to branch " \
- "<a href=\"#{project.web_url}/commits/#{branch}\">#{branch}</a> of " \
- "<a href=\"#{project.web_url}\">#{project_name}</a>")
- end
- end
-
- context 'tag_push events' do
- let(:push_sample_data) { Gitlab::PushDataBuilder.build(project, user, Gitlab::Git::BLANK_SHA, '1' * 40, 'refs/tags/test', []) }
-
- it "should call Hipchat API for tag push events" do
- hipchat.execute(push_sample_data)
-
- expect(WebMock).to have_requested(:post, api_url).once
- end
-
- it "should create a tag push message" do
- message = hipchat.send(:create_push_message, push_sample_data)
-
- obj_attr = push_sample_data[:object_attributes]
- expect(message).to eq("#{user.name} pushed new tag " \
- "<a href=\"#{project.web_url}/commits/test\">test</a> to " \
- "<a href=\"#{project.web_url}\">#{project_name}</a>\n")
- end
- end
-
- context 'issue events' do
- let(:issue) { create(:issue, title: 'Awesome issue', description: 'please fix') }
- let(:issue_service) { Issues::CreateService.new(project, user) }
- let(:issues_sample_data) { issue_service.hook_data(issue, 'open') }
-
- it "should call Hipchat API for issue events" do
- hipchat.execute(issues_sample_data)
-
- expect(WebMock).to have_requested(:post, api_url).once
- end
-
- it "should create an issue message" do
- message = hipchat.send(:create_issue_message, issues_sample_data)
-
- obj_attr = issues_sample_data[:object_attributes]
- expect(message).to eq("#{user.name} opened " \
- "<a href=\"#{obj_attr[:url]}\">issue ##{obj_attr["iid"]}</a> in " \
- "<a href=\"#{project.web_url}\">#{project_name}</a>: " \
- "<b>Awesome issue</b>" \
- "<pre>please fix</pre>")
- end
- end
-
- context 'merge request events' do
- let(:merge_request) { create(:merge_request, description: 'please fix', title: 'Awesome merge request', target_project: project, source_project: project) }
- let(:merge_service) { MergeRequests::CreateService.new(project, user) }
- let(:merge_sample_data) { merge_service.hook_data(merge_request, 'open') }
-
- it "should call Hipchat API for merge requests events" do
- hipchat.execute(merge_sample_data)
-
- expect(WebMock).to have_requested(:post, api_url).once
- end
-
- it "should create a merge request message" do
- message = hipchat.send(:create_merge_request_message,
- merge_sample_data)
-
- obj_attr = merge_sample_data[:object_attributes]
- expect(message).to eq("#{user.name} opened " \
- "<a href=\"#{obj_attr[:url]}\">merge request ##{obj_attr["iid"]}</a> in " \
- "<a href=\"#{project.web_url}\">#{project_name}</a>: " \
- "<b>Awesome merge request</b>" \
- "<pre>please fix</pre>")
- end
- end
-
- context "Note events" do
- let(:user) { create(:user) }
- let(:project) { create(:project, creator_id: user.id) }
- let(:issue) { create(:issue, project: project) }
- let(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
- let(:snippet) { create(:project_snippet, project: project) }
- let(:commit_note) { create(:note_on_commit, author: user, project: project, commit_id: project.repository.commit.id, note: 'a comment on a commit') }
- let(:merge_request_note) { create(:note_on_merge_request, noteable_id: merge_request.id, note: "merge request note") }
- let(:issue_note) { create(:note_on_issue, noteable_id: issue.id, note: "issue note")}
- let(:snippet_note) { create(:note_on_project_snippet, noteable_id: snippet.id, note: "snippet note") }
-
- it "should call Hipchat API for commit comment events" do
- data = Gitlab::NoteDataBuilder.build(commit_note, user)
- hipchat.execute(data)
-
- expect(WebMock).to have_requested(:post, api_url).once
-
- message = hipchat.send(:create_message, data)
-
- obj_attr = data[:object_attributes]
- commit_id = Commit.truncate_sha(data[:commit][:id])
- title = hipchat.send(:format_title, data[:commit][:message])
-
- expect(message).to eq("#{user.name} commented on " \
- "<a href=\"#{obj_attr[:url]}\">commit #{commit_id}</a> in " \
- "<a href=\"#{project.web_url}\">#{project_name}</a>: " \
- "#{title}" \
- "<pre>a comment on a commit</pre>")
- end
-
- it "should call Hipchat API for merge request comment events" do
- data = Gitlab::NoteDataBuilder.build(merge_request_note, user)
- hipchat.execute(data)
-
- expect(WebMock).to have_requested(:post, api_url).once
-
- message = hipchat.send(:create_message, data)
-
- obj_attr = data[:object_attributes]
- merge_id = data[:merge_request]['iid']
- title = data[:merge_request]['title']
-
- expect(message).to eq("#{user.name} commented on " \
- "<a href=\"#{obj_attr[:url]}\">merge request ##{merge_id}</a> in " \
- "<a href=\"#{project.web_url}\">#{project_name}</a>: " \
- "<b>#{title}</b>" \
- "<pre>merge request note</pre>")
- end
-
- it "should call Hipchat API for issue comment events" do
- data = Gitlab::NoteDataBuilder.build(issue_note, user)
- hipchat.execute(data)
-
- message = hipchat.send(:create_message, data)
-
- obj_attr = data[:object_attributes]
- issue_id = data[:issue]['iid']
- title = data[:issue]['title']
-
- expect(message).to eq("#{user.name} commented on " \
- "<a href=\"#{obj_attr[:url]}\">issue ##{issue_id}</a> in " \
- "<a href=\"#{project.web_url}\">#{project_name}</a>: " \
- "<b>#{title}</b>" \
- "<pre>issue note</pre>")
- end
-
- it "should call Hipchat API for snippet comment events" do
- data = Gitlab::NoteDataBuilder.build(snippet_note, user)
- hipchat.execute(data)
-
- expect(WebMock).to have_requested(:post, api_url).once
-
- message = hipchat.send(:create_message, data)
-
- obj_attr = data[:object_attributes]
- snippet_id = data[:snippet]['id']
- title = data[:snippet]['title']
-
- expect(message).to eq("#{user.name} commented on " \
- "<a href=\"#{obj_attr[:url]}\">snippet ##{snippet_id}</a> in " \
- "<a href=\"#{project.web_url}\">#{project_name}</a>: " \
- "<b>#{title}</b>" \
- "<pre>snippet note</pre>")
- end
- end
- end
-end
diff --git a/spec/models/project_services/irker_service_spec.rb b/spec/models/project_services/irker_service_spec.rb
deleted file mode 100644
index d55399bc360..00000000000
--- a/spec/models/project_services/irker_service_spec.rb
+++ /dev/null
@@ -1,108 +0,0 @@
-# == Schema Information
-#
-# Table name: services
-#
-# id :integer not null, primary key
-# type :string(255)
-# title :string(255)
-# project_id :integer
-# created_at :datetime
-# updated_at :datetime
-# active :boolean default(FALSE), not null
-# properties :text
-# template :boolean default(FALSE)
-# push_events :boolean default(TRUE)
-# issues_events :boolean default(TRUE)
-# merge_requests_events :boolean default(TRUE)
-# tag_push_events :boolean default(TRUE)
-#
-
-require 'spec_helper'
-require 'socket'
-require 'json'
-
-describe IrkerService do
- describe 'Associations' do
- it { should belong_to :project }
- it { should have_one :service_hook }
- end
-
- describe 'Validations' do
- before do
- subject.active = true
- subject.properties['recipients'] = _recipients
- end
-
- context 'active' do
- let(:_recipients) { nil }
- it { should validate_presence_of :recipients }
- end
-
- context 'too many recipients' do
- let(:_recipients) { 'a b c d' }
- it 'should add an error if there is too many recipients' do
- subject.send :check_recipients_count
- subject.errors.should_not be_blank
- end
- end
-
- context '3 recipients' do
- let(:_recipients) { 'a b c' }
- it 'should not add an error if there is 3 recipients' do
- subject.send :check_recipients_count
- subject.errors.should be_blank
- end
- end
- end
-
- describe 'Execute' do
- let(:irker) { IrkerService.new }
- let(:user) { create(:user) }
- let(:project) { create(:project) }
- let(:sample_data) { Gitlab::PushDataBuilder.build_sample(project, user) }
-
- let(:recipients) { '#commits' }
- let(:colorize_messages) { '1' }
-
- before do
- irker.stub(
- active: true,
- project: project,
- project_id: project.id,
- service_hook: true,
- properties: {
- 'recipients' => recipients,
- 'colorize_messages' => colorize_messages
- }
- )
- irker.settings = {
- server_ip: 'localhost',
- server_port: 6659,
- max_channels: 3,
- default_irc_uri: 'irc://chat.freenode.net/'
- }
- irker.valid?
- @irker_server = TCPServer.new 'localhost', 6659
- end
-
- after do
- @irker_server.close
- end
-
- it 'should send valid JSON messages to an Irker listener' do
- irker.execute(sample_data)
-
- conn = @irker_server.accept
- conn.readlines.each do |line|
- msg = JSON.load(line.chomp("\n"))
- msg.keys.should match_array(['to', 'privmsg'])
- if msg['to'].is_a?(String)
- msg['to'].should == 'irc://chat.freenode.net/#commits'
- else
- msg['to'].should match_array(['irc://chat.freenode.net/#commits'])
- end
- end
- conn.close
- end
- end
-end
diff --git a/spec/models/project_services/jira_service_spec.rb b/spec/models/project_services/jira_service_spec.rb
deleted file mode 100644
index 355911e6377..00000000000
--- a/spec/models/project_services/jira_service_spec.rb
+++ /dev/null
@@ -1,102 +0,0 @@
-# == Schema Information
-#
-# Table name: services
-#
-# id :integer not null, primary key
-# type :string(255)
-# title :string(255)
-# project_id :integer
-# created_at :datetime
-# updated_at :datetime
-# active :boolean default(FALSE), not null
-# properties :text
-# template :boolean default(FALSE)
-# push_events :boolean default(TRUE)
-# issues_events :boolean default(TRUE)
-# merge_requests_events :boolean default(TRUE)
-# tag_push_events :boolean default(TRUE)
-#
-
-require 'spec_helper'
-
-describe JiraService do
- describe "Associations" do
- it { is_expected.to belong_to :project }
- it { is_expected.to have_one :service_hook }
- end
-
- describe "Validations" do
- context "active" do
- before do
- subject.active = true
- end
-
- it { is_expected.to validate_presence_of :project_url }
- it { is_expected.to validate_presence_of :issues_url }
- it { is_expected.to validate_presence_of :new_issue_url }
- end
- end
-
- describe 'description and title' do
- let(:project) { create(:project) }
-
- context 'when it is not set' do
- before do
- @service = project.create_jira_service(active: true)
- end
-
- after do
- @service.destroy!
- end
-
- it 'should be initialized' do
- expect(@service.title).to eq('JIRA')
- expect(@service.description).to eq("Jira issue tracker")
- end
- end
-
- context 'when it is set' do
- before do
- properties = { 'title' => 'Jira One', 'description' => 'Jira One issue tracker' }
- @service = project.create_jira_service(active: true, properties: properties)
- end
-
- after do
- @service.destroy!
- end
-
- it "should be correct" do
- expect(@service.title).to eq('Jira One')
- expect(@service.description).to eq('Jira One issue tracker')
- end
- end
- end
-
- describe 'project and issue urls' do
- let(:project) { create(:project) }
-
- context 'when gitlab.yml was initialized' do
- before do
- settings = { "jira" => {
- "title" => "Jira",
- "project_url" => "http://jira.sample/projects/project_a",
- "issues_url" => "http://jira.sample/issues/:id",
- "new_issue_url" => "http://jira.sample/projects/project_a/issues/new"
- }
- }
- allow(Gitlab.config).to receive(:issues_tracker).and_return(settings)
- @service = project.create_jira_service(active: true)
- end
-
- after do
- @service.destroy!
- end
-
- it 'should be prepopulated with the settings' do
- expect(@service.properties[:project_url]).to eq('http://jira.sample/projects/project_a')
- expect(@service.properties[:issues_url]).to eq("http://jira.sample/issues/:id")
- expect(@service.properties[:new_issue_url]).to eq("http://jira.sample/projects/project_a/issues/new")
- end
- end
- end
-end
diff --git a/spec/models/project_services/pushover_service_spec.rb b/spec/models/project_services/pushover_service_spec.rb
deleted file mode 100644
index 5a18fd09bfc..00000000000
--- a/spec/models/project_services/pushover_service_spec.rb
+++ /dev/null
@@ -1,74 +0,0 @@
-# == Schema Information
-#
-# Table name: services
-#
-# id :integer not null, primary key
-# type :string(255)
-# title :string(255)
-# project_id :integer
-# created_at :datetime
-# updated_at :datetime
-# active :boolean default(FALSE), not null
-# properties :text
-# template :boolean default(FALSE)
-# push_events :boolean default(TRUE)
-# issues_events :boolean default(TRUE)
-# merge_requests_events :boolean default(TRUE)
-# tag_push_events :boolean default(TRUE)
-#
-
-require 'spec_helper'
-
-describe PushoverService do
- describe 'Associations' do
- it { is_expected.to belong_to :project }
- it { is_expected.to have_one :service_hook }
- end
-
- describe 'Validations' do
- context 'active' do
- before do
- subject.active = true
- end
-
- it { is_expected.to validate_presence_of :api_key }
- it { is_expected.to validate_presence_of :user_key }
- it { is_expected.to validate_presence_of :priority }
- end
- end
-
- describe 'Execute' do
- let(:pushover) { PushoverService.new }
- let(:user) { create(:user) }
- let(:project) { create(:project) }
- let(:sample_data) { Gitlab::PushDataBuilder.build_sample(project, user) }
-
- let(:api_key) { 'verySecret' }
- let(:user_key) { 'verySecret' }
- let(:device) { 'myDevice' }
- let(:priority) { 0 }
- let(:sound) { 'bike' }
- let(:api_url) { 'https://api.pushover.net/1/messages.json' }
-
- before do
- pushover.stub(
- project: project,
- project_id: project.id,
- service_hook: true,
- api_key: api_key,
- user_key: user_key,
- device: device,
- priority: priority,
- sound: sound
- )
-
- WebMock.stub_request(:post, api_url)
- end
-
- it 'should call Pushover API' do
- pushover.execute(sample_data)
-
- expect(WebMock).to have_requested(:post, api_url).once
- end
- end
-end
diff --git a/spec/models/project_services/slack_service/issue_message_spec.rb b/spec/models/project_services/slack_service/issue_message_spec.rb
deleted file mode 100644
index 8bca1fef44c..00000000000
--- a/spec/models/project_services/slack_service/issue_message_spec.rb
+++ /dev/null
@@ -1,56 +0,0 @@
-require 'spec_helper'
-
-describe SlackService::IssueMessage do
- subject { SlackService::IssueMessage.new(args) }
-
- let(:args) {
- {
- user: {
- name: 'Test User',
- username: 'Test User'
- },
- project_name: 'project_name',
- project_url: 'somewhere.com',
-
- object_attributes: {
- title: 'Issue title',
- id: 10,
- iid: 100,
- assignee_id: 1,
- url: 'url',
- action: 'open',
- state: 'opened',
- description: 'issue description'
- }
- }
- }
-
- let(:color) { '#345' }
-
- context 'open' do
- it 'returns a message regarding opening of issues' do
- expect(subject.pretext).to eq(
- 'Test User opened <url|issue #100> in <somewhere.com|project_name>: '\
- '*Issue title*')
- expect(subject.attachments).to eq([
- {
- text: "issue description",
- color: color,
- }
- ])
- end
- end
-
- context 'close' do
- before do
- args[:object_attributes][:action] = 'close'
- args[:object_attributes][:state] = 'closed'
- end
- it 'returns a message regarding closing of issues' do
- expect(subject.pretext). to eq(
- 'Test User closed <url|issue #100> in <somewhere.com|project_name>: '\
- '*Issue title*')
- expect(subject.attachments).to be_empty
- end
- end
-end
diff --git a/spec/models/project_services/slack_service/merge_message_spec.rb b/spec/models/project_services/slack_service/merge_message_spec.rb
deleted file mode 100644
index aeb408aa766..00000000000
--- a/spec/models/project_services/slack_service/merge_message_spec.rb
+++ /dev/null
@@ -1,51 +0,0 @@
-require 'spec_helper'
-
-describe SlackService::MergeMessage do
- subject { SlackService::MergeMessage.new(args) }
-
- let(:args) {
- {
- user: {
- name: 'Test User',
- username: 'Test User'
- },
- project_name: 'project_name',
- project_url: 'somewhere.com',
-
- object_attributes: {
- title: "Issue title\nSecond line",
- id: 10,
- iid: 100,
- assignee_id: 1,
- url: 'url',
- state: 'opened',
- description: 'issue description',
- source_branch: 'source_branch',
- target_branch: 'target_branch',
- }
- }
- }
-
- let(:color) { '#345' }
-
- context 'open' do
- it 'returns a message regarding opening of merge requests' do
- expect(subject.pretext).to eq(
- 'Test User opened <somewhere.com/merge_requests/100|merge request #100> '\
- 'in <somewhere.com|project_name>: *Issue title*')
- expect(subject.attachments).to be_empty
- end
- end
-
- context 'close' do
- before do
- args[:object_attributes][:state] = 'closed'
- end
- it 'returns a message regarding closing of merge requests' do
- expect(subject.pretext).to eq(
- 'Test User closed <somewhere.com/merge_requests/100|merge request #100> '\
- 'in <somewhere.com|project_name>: *Issue title*')
- expect(subject.attachments).to be_empty
- end
- end
-end
diff --git a/spec/models/project_services/slack_service/note_message_spec.rb b/spec/models/project_services/slack_service/note_message_spec.rb
deleted file mode 100644
index 21fb575480b..00000000000
--- a/spec/models/project_services/slack_service/note_message_spec.rb
+++ /dev/null
@@ -1,129 +0,0 @@
-require 'spec_helper'
-
-describe SlackService::NoteMessage do
- let(:color) { '#345' }
-
- before do
- @args = {
- user: {
- name: 'Test User',
- username: 'username',
- avatar_url: 'http://fakeavatar'
- },
- project_name: 'project_name',
- project_url: 'somewhere.com',
- repository: {
- name: 'project_name',
- url: 'somewhere.com',
- },
- object_attributes: {
- id: 10,
- note: 'comment on a commit',
- url: 'url',
- noteable_type: 'Commit'
- }
- }
- end
-
- context 'commit notes' do
- before do
- @args[:object_attributes][:note] = 'comment on a commit'
- @args[:object_attributes][:noteable_type] = 'Commit'
- @args[:commit] = {
- id: '5f163b2b95e6f53cbd428f5f0b103702a52b9a23',
- message: "Added a commit message\ndetails\n123\n"
- }
- end
-
- it 'returns a message regarding notes on commits' do
- message = SlackService::NoteMessage.new(@args)
- expect(message.pretext).to eq("Test User commented on " \
- "<url|commit 5f163b2b> in <somewhere.com|project_name>: " \
- "*Added a commit message*")
- expected_attachments = [
- {
- text: "comment on a commit",
- color: color,
- }
- ]
- expect(message.attachments).to eq(expected_attachments)
- end
- end
-
- context 'merge request notes' do
- before do
- @args[:object_attributes][:note] = 'comment on a merge request'
- @args[:object_attributes][:noteable_type] = 'MergeRequest'
- @args[:merge_request] = {
- id: 1,
- iid: 30,
- title: "merge request title\ndetails\n"
- }
- end
- it 'returns a message regarding notes on a merge request' do
- message = SlackService::NoteMessage.new(@args)
- expect(message.pretext).to eq("Test User commented on " \
- "<url|merge request #30> in <somewhere.com|project_name>: " \
- "*merge request title*")
- expected_attachments = [
- {
- text: "comment on a merge request",
- color: color,
- }
- ]
- expect(message.attachments).to eq(expected_attachments)
- end
- end
-
- context 'issue notes' do
- before do
- @args[:object_attributes][:note] = 'comment on an issue'
- @args[:object_attributes][:noteable_type] = 'Issue'
- @args[:issue] = {
- id: 1,
- iid: 20,
- title: "issue title\ndetails\n"
- }
- end
-
- it 'returns a message regarding notes on an issue' do
- message = SlackService::NoteMessage.new(@args)
- expect(message.pretext).to eq(
- "Test User commented on " \
- "<url|issue #20> in <somewhere.com|project_name>: " \
- "*issue title*")
- expected_attachments = [
- {
- text: "comment on an issue",
- color: color,
- }
- ]
- expect(message.attachments).to eq(expected_attachments)
- end
- end
-
- context 'project snippet notes' do
- before do
- @args[:object_attributes][:note] = 'comment on a snippet'
- @args[:object_attributes][:noteable_type] = 'Snippet'
- @args[:snippet] = {
- id: 5,
- title: "snippet title\ndetails\n"
- }
- end
-
- it 'returns a message regarding notes on a project snippet' do
- message = SlackService::NoteMessage.new(@args)
- expect(message.pretext).to eq("Test User commented on " \
- "<url|snippet #5> in <somewhere.com|project_name>: " \
- "*snippet title*")
- expected_attachments = [
- {
- text: "comment on a snippet",
- color: color,
- }
- ]
- expect(message.attachments).to eq(expected_attachments)
- end
- end
-end
diff --git a/spec/models/project_services/slack_service/push_message_spec.rb b/spec/models/project_services/slack_service/push_message_spec.rb
deleted file mode 100644
index 10963481a12..00000000000
--- a/spec/models/project_services/slack_service/push_message_spec.rb
+++ /dev/null
@@ -1,88 +0,0 @@
-require 'spec_helper'
-
-describe SlackService::PushMessage do
- subject { SlackService::PushMessage.new(args) }
-
- let(:args) {
- {
- after: 'after',
- before: 'before',
- project_name: 'project_name',
- ref: 'refs/heads/master',
- user_name: 'user_name',
- project_url: 'url'
- }
- }
-
- let(:color) { '#345' }
-
- context 'push' do
- before do
- args[:commits] = [
- { message: 'message1', url: 'url1', id: 'abcdefghijkl', author: { name: 'author1' } },
- { message: 'message2', url: 'url2', id: '123456789012', author: { name: 'author2' } },
- ]
- end
-
- it 'returns a message regarding pushes' do
- expect(subject.pretext).to eq(
- 'user_name pushed to branch <url/commits/master|master> of '\
- '<url|project_name> (<url/compare/before...after|Compare changes>)'
- )
- expect(subject.attachments).to eq([
- {
- text: "<url1|abcdefgh>: message1 - author1\n"\
- "<url2|12345678>: message2 - author2",
- color: color,
- }
- ])
- end
- end
-
- context 'tag push' do
- let(:args) {
- {
- after: 'after',
- before: Gitlab::Git::BLANK_SHA,
- project_name: 'project_name',
- ref: 'refs/tags/new_tag',
- user_name: 'user_name',
- project_url: 'url'
- }
- }
-
- it 'returns a message regarding pushes' do
- expect(subject.pretext).to eq('user_name pushed new tag ' \
- '<url/commits/new_tag|new_tag> to ' \
- '<url|project_name>')
- expect(subject.attachments).to be_empty
- end
- end
-
- context 'new branch' do
- before do
- args[:before] = Gitlab::Git::BLANK_SHA
- end
-
- it 'returns a message regarding a new branch' do
- expect(subject.pretext).to eq(
- 'user_name pushed new branch <url/commits/master|master> to '\
- '<url|project_name>'
- )
- expect(subject.attachments).to be_empty
- end
- end
-
- context 'removed branch' do
- before do
- args[:after] = Gitlab::Git::BLANK_SHA
- end
-
- it 'returns a message regarding a removed branch' do
- expect(subject.pretext).to eq(
- 'user_name removed branch master from <url|project_name>'
- )
- expect(subject.attachments).to be_empty
- end
- end
-end
diff --git a/spec/models/project_services/slack_service_spec.rb b/spec/models/project_services/slack_service_spec.rb
deleted file mode 100644
index c36506644b3..00000000000
--- a/spec/models/project_services/slack_service_spec.rb
+++ /dev/null
@@ -1,170 +0,0 @@
-# == Schema Information
-#
-# Table name: services
-#
-# id :integer not null, primary key
-# type :string(255)
-# title :string(255)
-# project_id :integer
-# created_at :datetime
-# updated_at :datetime
-# active :boolean default(FALSE), not null
-# properties :text
-# template :boolean default(FALSE)
-# push_events :boolean default(TRUE)
-# issues_events :boolean default(TRUE)
-# merge_requests_events :boolean default(TRUE)
-# tag_push_events :boolean default(TRUE)
-#
-
-require 'spec_helper'
-
-describe SlackService do
- describe "Associations" do
- it { is_expected.to belong_to :project }
- it { is_expected.to have_one :service_hook }
- end
-
- describe "Validations" do
- context "active" do
- before do
- subject.active = true
- end
-
- it { is_expected.to validate_presence_of :webhook }
- end
- end
-
- describe "Execute" do
- let(:slack) { SlackService.new }
- let(:user) { create(:user) }
- let(:project) { create(:project) }
- let(:push_sample_data) { Gitlab::PushDataBuilder.build_sample(project, user) }
- let(:webhook_url) { 'https://hooks.slack.com/services/SVRWFV0VVAR97N/B02R25XN3/ZBqu7xMupaEEICInN685' }
- let(:username) { 'slack_username' }
- let(:channel) { 'slack_channel' }
-
- before do
- slack.stub(
- project: project,
- project_id: project.id,
- service_hook: true,
- webhook: webhook_url
- )
-
- WebMock.stub_request(:post, webhook_url)
-
- opts = {
- title: 'Awesome issue',
- description: 'please fix'
- }
-
- issue_service = Issues::CreateService.new(project, user, opts)
- @issue = issue_service.execute
- @issues_sample_data = issue_service.hook_data(@issue, 'open')
-
- opts = {
- title: 'Awesome merge_request',
- description: 'please fix',
- source_branch: 'stable',
- target_branch: 'master'
- }
- merge_service = MergeRequests::CreateService.new(project,
- user, opts)
- @merge_request = merge_service.execute
- @merge_sample_data = merge_service.hook_data(@merge_request,
- 'open')
- end
-
- it "should call Slack API for push events" do
- slack.execute(push_sample_data)
-
- expect(WebMock).to have_requested(:post, webhook_url).once
- end
-
- it "should call Slack API for issue events" do
- slack.execute(@issues_sample_data)
-
- expect(WebMock).to have_requested(:post, webhook_url).once
- end
-
- it "should call Slack API for merge requests events" do
- slack.execute(@merge_sample_data)
-
- expect(WebMock).to have_requested(:post, webhook_url).once
- end
-
- it 'should use the username as an option for slack when configured' do
- slack.stub(username: username)
- expect(Slack::Notifier).to receive(:new).
- with(webhook_url, username: username).
- and_return(
- double(:slack_service).as_null_object
- )
- slack.execute(push_sample_data)
- end
-
- it 'should use the channel as an option when it is configured' do
- slack.stub(channel: channel)
- expect(Slack::Notifier).to receive(:new).
- with(webhook_url, channel: channel).
- and_return(
- double(:slack_service).as_null_object
- )
- slack.execute(push_sample_data)
- end
- end
-
- describe "Note events" do
- let(:slack) { SlackService.new }
- let(:user) { create(:user) }
- let(:project) { create(:project, creator_id: user.id) }
- let(:issue) { create(:issue, project: project) }
- let(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
- let(:snippet) { create(:project_snippet, project: project) }
- let(:commit_note) { create(:note_on_commit, author: user, project: project, commit_id: project.repository.commit.id, note: 'a comment on a commit') }
- let(:merge_request_note) { create(:note_on_merge_request, noteable_id: merge_request.id, note: "merge request note") }
- let(:issue_note) { create(:note_on_issue, noteable_id: issue.id, note: "issue note")}
- let(:snippet_note) { create(:note_on_project_snippet, noteable_id: snippet.id, note: "snippet note") }
- let(:webhook_url) { 'https://hooks.slack.com/services/SVRWFV0VVAR97N/B02R25XN3/ZBqu7xMupaEEICInN685' }
-
- before do
- slack.stub(
- project: project,
- project_id: project.id,
- service_hook: true,
- webhook: webhook_url
- )
-
- WebMock.stub_request(:post, webhook_url)
- end
-
- it "should call Slack API for commit comment events" do
- data = Gitlab::NoteDataBuilder.build(commit_note, user)
- slack.execute(data)
-
- expect(WebMock).to have_requested(:post, webhook_url).once
- end
-
- it "should call Slack API for merge request comment events" do
- data = Gitlab::NoteDataBuilder.build(merge_request_note, user)
- slack.execute(data)
-
- expect(WebMock).to have_requested(:post, webhook_url).once
- end
-
- it "should call Slack API for issue comment events" do
- data = Gitlab::NoteDataBuilder.build(issue_note, user)
- slack.execute(data)
-
- expect(WebMock).to have_requested(:post, webhook_url).once
- end
-
- it "should call Slack API for snippet comment events" do
- data = Gitlab::NoteDataBuilder.build(snippet_note, user)
- slack.execute(data)
-
- expect(WebMock).to have_requested(:post, webhook_url).once
- end
- end
-end
diff --git a/spec/models/project_snippet_spec.rb b/spec/models/project_snippet_spec.rb
deleted file mode 100644
index 3e8f106d27f..00000000000
--- a/spec/models/project_snippet_spec.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-# == Schema Information
-#
-# Table name: snippets
-#
-# id :integer not null, primary key
-# title :string(255)
-# content :text
-# author_id :integer not null
-# project_id :integer
-# created_at :datetime
-# updated_at :datetime
-# file_name :string(255)
-# expires_at :datetime
-# type :string(255)
-# visibility_level :integer default(0), not null
-#
-
-require 'spec_helper'
-
-describe ProjectSnippet do
- describe "Associations" do
- it { is_expected.to belong_to(:project) }
- end
-
- describe "Mass assignment" do
- end
-
- describe "Validation" do
- it { is_expected.to validate_presence_of(:project) }
- end
-end
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
deleted file mode 100644
index 879a63dd9f9..00000000000
--- a/spec/models/project_spec.rb
+++ /dev/null
@@ -1,360 +0,0 @@
-# == Schema Information
-#
-# Table name: projects
-#
-# id :integer not null, primary key
-# name :string(255)
-# path :string(255)
-# description :text
-# created_at :datetime
-# updated_at :datetime
-# creator_id :integer
-# issues_enabled :boolean default(TRUE), not null
-# wall_enabled :boolean default(TRUE), not null
-# merge_requests_enabled :boolean default(TRUE), not null
-# wiki_enabled :boolean default(TRUE), not null
-# namespace_id :integer
-# issues_tracker :string(255) default("gitlab"), not null
-# issues_tracker_id :string(255)
-# snippets_enabled :boolean default(TRUE), not null
-# last_activity_at :datetime
-# import_url :string(255)
-# visibility_level :integer default(0), not null
-# archived :boolean default(FALSE), not null
-# import_status :string(255)
-# repository_size :float default(0.0)
-# star_count :integer default(0), not null
-# import_type :string(255)
-# import_source :string(255)
-# avatar :string(255)
-#
-
-require 'spec_helper'
-
-describe Project do
- describe 'Associations' do
- it { is_expected.to belong_to(:group) }
- it { is_expected.to belong_to(:namespace) }
- it { is_expected.to belong_to(:creator).class_name('User') }
- it { is_expected.to have_many(:users) }
- it { is_expected.to have_many(:events).dependent(:destroy) }
- it { is_expected.to have_many(:merge_requests).dependent(:destroy) }
- it { is_expected.to have_many(:issues).dependent(:destroy) }
- it { is_expected.to have_many(:milestones).dependent(:destroy) }
- it { is_expected.to have_many(:project_members).dependent(:destroy) }
- it { is_expected.to have_many(:notes).dependent(:destroy) }
- it { is_expected.to have_many(:snippets).class_name('ProjectSnippet').dependent(:destroy) }
- it { is_expected.to have_many(:deploy_keys_projects).dependent(:destroy) }
- it { is_expected.to have_many(:deploy_keys) }
- it { is_expected.to have_many(:hooks).dependent(:destroy) }
- it { is_expected.to have_many(:protected_branches).dependent(:destroy) }
- it { is_expected.to have_one(:forked_project_link).dependent(:destroy) }
- it { is_expected.to have_one(:slack_service).dependent(:destroy) }
- it { is_expected.to have_one(:pushover_service).dependent(:destroy) }
- it { is_expected.to have_one(:asana_service).dependent(:destroy) }
- end
-
- describe 'Mass assignment' do
- end
-
- describe 'Validation' do
- let!(:project) { create(:project) }
-
- it { is_expected.to validate_presence_of(:name) }
- it { is_expected.to validate_uniqueness_of(:name).scoped_to(:namespace_id) }
- it { is_expected.to ensure_length_of(:name).is_within(0..255) }
-
- it { is_expected.to validate_presence_of(:path) }
- it { is_expected.to validate_uniqueness_of(:path).scoped_to(:namespace_id) }
- it { is_expected.to ensure_length_of(:path).is_within(0..255) }
- it { is_expected.to ensure_length_of(:description).is_within(0..2000) }
- it { is_expected.to validate_presence_of(:creator) }
- it { is_expected.to ensure_length_of(:issues_tracker_id).is_within(0..255) }
- it { is_expected.to validate_presence_of(:namespace) }
-
- it 'should not allow new projects beyond user limits' do
- project2 = build(:project)
- allow(project2).to receive(:creator).and_return(double(can_create_project?: false, projects_limit: 0).as_null_object)
- expect(project2).not_to be_valid
- expect(project2.errors[:limit_reached].first).to match(/Your project limit is 0/)
- end
- end
-
- describe 'Respond to' do
- it { is_expected.to respond_to(:url_to_repo) }
- it { is_expected.to respond_to(:repo_exists?) }
- it { is_expected.to respond_to(:satellite) }
- it { is_expected.to respond_to(:update_merge_requests) }
- it { is_expected.to respond_to(:execute_hooks) }
- it { is_expected.to respond_to(:name_with_namespace) }
- it { is_expected.to respond_to(:owner) }
- it { is_expected.to respond_to(:path_with_namespace) }
- end
-
- it 'should return valid url to repo' do
- project = Project.new(path: 'somewhere')
- expect(project.url_to_repo).to eq(Gitlab.config.gitlab_shell.ssh_path_prefix + 'somewhere.git')
- end
-
- it 'returns the full web URL for this repo' do
- project = Project.new(path: 'somewhere')
- expect(project.web_url).to eq("#{Gitlab.config.gitlab.url}/somewhere")
- end
-
- it 'returns the web URL without the protocol for this repo' do
- project = Project.new(path: 'somewhere')
- expect(project.web_url_without_protocol).to eq("#{Gitlab.config.gitlab.url.split('://')[1]}/somewhere")
- end
-
- describe 'last_activity methods' do
- let(:project) { create(:project) }
- let(:last_event) { double(created_at: Time.now) }
-
- describe 'last_activity' do
- it 'should alias last_activity to last_event' do
- project.stub(last_event: last_event)
- expect(project.last_activity).to eq(last_event)
- end
- end
-
- describe 'last_activity_date' do
- it 'returns the creation date of the project\'s last event if present' do
- last_activity_event = create(:event, project: project)
- expect(project.last_activity_at.to_i).to eq(last_event.created_at.to_i)
- end
-
- it 'returns the project\'s last update date if it has no events' do
- expect(project.last_activity_date).to eq(project.updated_at)
- end
- end
- end
-
- describe :update_merge_requests do
- let(:project) { create(:project) }
- let(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
- let(:key) { create(:key, user_id: project.owner.id) }
- let(:prev_commit_id) { merge_request.commits.last.id }
- let(:commit_id) { merge_request.commits.first.id }
-
- it 'should close merge request if last commit from source branch was pushed to target branch' do
- project.update_merge_requests(prev_commit_id, commit_id, "refs/heads/#{merge_request.target_branch}", key.user)
- merge_request.reload
- expect(merge_request.merged?).to be_truthy
- end
-
- it 'should update merge request commits with new one if pushed to source branch' do
- project.update_merge_requests(prev_commit_id, commit_id, "refs/heads/#{merge_request.source_branch}", key.user)
- merge_request.reload
- expect(merge_request.last_commit.id).to eq(commit_id)
- end
- end
-
- describe :find_with_namespace do
- context 'with namespace' do
- before do
- @group = create :group, name: 'gitlab'
- @project = create(:project, name: 'gitlabhq', namespace: @group)
- end
-
- it { expect(Project.find_with_namespace('gitlab/gitlabhq')).to eq(@project) }
- it { expect(Project.find_with_namespace('gitlab-ci')).to be_nil }
- end
- end
-
- describe :to_param do
- context 'with namespace' do
- before do
- @group = create :group, name: 'gitlab'
- @project = create(:project, name: 'gitlabhq', namespace: @group)
- end
-
- it { expect(@project.to_param).to eq('gitlabhq') }
- end
- end
-
- describe :repository do
- let(:project) { create(:project) }
-
- it 'should return valid repo' do
- expect(project.repository).to be_kind_of(Repository)
- end
- end
-
- describe :issue_exists? do
- let(:project) { create(:project) }
- let(:existed_issue) { create(:issue, project: project) }
- let(:not_existed_issue) { create(:issue) }
- let(:ext_project) { create(:redmine_project) }
-
- it 'should be true or if used internal tracker and issue exists' do
- expect(project.issue_exists?(existed_issue.iid)).to be_truthy
- end
-
- it 'should be false or if used internal tracker and issue not exists' do
- expect(project.issue_exists?(not_existed_issue.iid)).to be_falsey
- end
-
- it 'should always be true if used other tracker' do
- expect(ext_project.issue_exists?(rand(100))).to be_truthy
- end
- end
-
- describe :default_issues_tracker? do
- let(:project) { create(:project) }
- let(:ext_project) { create(:redmine_project) }
-
- it "should be true if used internal tracker" do
- expect(project.default_issues_tracker?).to be_truthy
- end
-
- it "should be false if used other tracker" do
- expect(ext_project.default_issues_tracker?).to be_falsey
- end
- end
-
- describe :can_have_issues_tracker_id? do
- let(:project) { create(:project) }
- let(:ext_project) { create(:redmine_project) }
-
- it 'should be true for projects with external issues tracker if issues enabled' do
- expect(ext_project.can_have_issues_tracker_id?).to be_truthy
- end
-
- it 'should be false for projects with internal issue tracker if issues enabled' do
- expect(project.can_have_issues_tracker_id?).to be_falsey
- end
-
- it 'should be always false if issues disabled' do
- project.issues_enabled = false
- ext_project.issues_enabled = false
-
- expect(project.can_have_issues_tracker_id?).to be_falsey
- expect(ext_project.can_have_issues_tracker_id?).to be_falsey
- end
- end
-
- describe :open_branches do
- let(:project) { create(:project) }
-
- before do
- project.protected_branches.create(name: 'master')
- end
-
- it { expect(project.open_branches.map(&:name)).to include('feature') }
- it { expect(project.open_branches.map(&:name)).not_to include('master') }
- end
-
- describe '#star_count' do
- it 'counts stars from multiple users' do
- user1 = create :user
- user2 = create :user
- project = create :project, :public
-
- expect(project.star_count).to eq(0)
-
- user1.toggle_star(project)
- expect(project.reload.star_count).to eq(1)
-
- user2.toggle_star(project)
- project.reload
- expect(project.reload.star_count).to eq(2)
-
- user1.toggle_star(project)
- project.reload
- expect(project.reload.star_count).to eq(1)
-
- user2.toggle_star(project)
- project.reload
- expect(project.reload.star_count).to eq(0)
- end
-
- it 'counts stars on the right project' do
- user = create :user
- project1 = create :project, :public
- project2 = create :project, :public
-
- expect(project1.star_count).to eq(0)
- expect(project2.star_count).to eq(0)
-
- user.toggle_star(project1)
- project1.reload
- project2.reload
- expect(project1.star_count).to eq(1)
- expect(project2.star_count).to eq(0)
-
- user.toggle_star(project1)
- project1.reload
- project2.reload
- expect(project1.star_count).to eq(0)
- expect(project2.star_count).to eq(0)
-
- user.toggle_star(project2)
- project1.reload
- project2.reload
- expect(project1.star_count).to eq(0)
- expect(project2.star_count).to eq(1)
-
- user.toggle_star(project2)
- project1.reload
- project2.reload
- expect(project1.star_count).to eq(0)
- expect(project2.star_count).to eq(0)
- end
-
- it 'is decremented when an upvoter account is deleted' do
- user = create :user
- project = create :project, :public
- user.toggle_star(project)
- project.reload
- expect(project.star_count).to eq(1)
- user.destroy
- project.reload
- expect(project.star_count).to eq(0)
- end
- end
-
- describe :avatar_type do
- let(:project) { create(:project) }
-
- it 'should be true if avatar is image' do
- project.update_attribute(:avatar, 'uploads/avatar.png')
- expect(project.avatar_type).to be_truthy
- end
-
- it 'should be false if avatar is html page' do
- project.update_attribute(:avatar, 'uploads/avatar.html')
- expect(project.avatar_type).to eq(['only images allowed'])
- end
- end
-
- describe :avatar_url do
- subject { project.avatar_url }
-
- let(:project) { create(:project) }
-
- context 'When avatar file is uploaded' do
- before do
- project.update_columns(avatar: 'uploads/avatar.png')
- allow(project.avatar).to receive(:present?) { true }
- end
-
- let(:avatar_path) do
- "/uploads/project/avatar/#{project.id}/uploads/avatar.png"
- end
-
- it { should eq "http://localhost#{avatar_path}" }
- end
-
- context 'When avatar file in git' do
- before do
- allow(project).to receive(:avatar_in_git) { true }
- end
-
- let(:avatar_path) do
- "/#{project.namespace.name}/#{project.path}/avatar"
- end
-
- it { should eq "http://localhost#{avatar_path}" }
- end
- end
-end
diff --git a/spec/models/project_team_spec.rb b/spec/models/project_team_spec.rb
deleted file mode 100644
index 19201cc15a7..00000000000
--- a/spec/models/project_team_spec.rb
+++ /dev/null
@@ -1,70 +0,0 @@
-require "spec_helper"
-
-describe ProjectTeam do
- let(:master) { create(:user) }
- let(:reporter) { create(:user) }
- let(:guest) { create(:user) }
- let(:nonmember) { create(:user) }
-
- context 'personal project' do
- let(:project) { create(:empty_project) }
-
- before do
- project.team << [master, :master]
- project.team << [reporter, :reporter]
- project.team << [guest, :guest]
- end
-
- describe 'members collection' do
- it { expect(project.team.masters).to include(master) }
- it { expect(project.team.masters).not_to include(guest) }
- it { expect(project.team.masters).not_to include(reporter) }
- it { expect(project.team.masters).not_to include(nonmember) }
- end
-
- describe 'access methods' do
- it { expect(project.team.master?(master)).to be_truthy }
- it { expect(project.team.master?(guest)).to be_falsey }
- it { expect(project.team.master?(reporter)).to be_falsey }
- it { expect(project.team.master?(nonmember)).to be_falsey }
- it { expect(project.team.member?(nonmember)).to be_falsey }
- it { expect(project.team.member?(guest)).to be_truthy }
- end
- end
-
- context 'group project' do
- let(:group) { create(:group) }
- let(:project) { create(:empty_project, group: group) }
-
- before do
- group.add_user(master, Gitlab::Access::MASTER)
- group.add_user(reporter, Gitlab::Access::REPORTER)
- group.add_user(guest, Gitlab::Access::GUEST)
-
- # If user is a group and a project member - GitLab uses highest permission
- # So we add group guest as master and add group master as guest
- # to this project to test highest access
- project.team << [guest, :master]
- project.team << [master, :guest]
- end
-
- describe 'members collection' do
- it { expect(project.team.reporters).to include(reporter) }
- it { expect(project.team.masters).to include(master) }
- it { expect(project.team.masters).to include(guest) }
- it { expect(project.team.masters).not_to include(reporter) }
- it { expect(project.team.masters).not_to include(nonmember) }
- end
-
- describe 'access methods' do
- it { expect(project.team.reporter?(reporter)).to be_truthy }
- it { expect(project.team.master?(master)).to be_truthy }
- it { expect(project.team.master?(guest)).to be_truthy }
- it { expect(project.team.master?(reporter)).to be_falsey }
- it { expect(project.team.master?(nonmember)).to be_falsey }
- it { expect(project.team.member?(nonmember)).to be_falsey }
- it { expect(project.team.member?(guest)).to be_truthy }
- end
- end
-end
-
diff --git a/spec/models/project_wiki_spec.rb b/spec/models/project_wiki_spec.rb
deleted file mode 100644
index 2acdb7dfddc..00000000000
--- a/spec/models/project_wiki_spec.rb
+++ /dev/null
@@ -1,244 +0,0 @@
-require "spec_helper"
-
-describe ProjectWiki do
- let(:project) { create(:empty_project) }
- let(:repository) { project.repository }
- let(:user) { project.owner }
- let(:gitlab_shell) { Gitlab::Shell.new }
- let(:project_wiki) { ProjectWiki.new(project, user) }
-
- subject { project_wiki }
- before { project_wiki.wiki }
-
- describe "#path_with_namespace" do
- it "returns the project path with namespace with the .wiki extension" do
- expect(subject.path_with_namespace).to eq(project.path_with_namespace + ".wiki")
- end
- end
-
- describe "#url_to_repo" do
- it "returns the correct ssh url to the repo" do
- expect(subject.url_to_repo).to eq(gitlab_shell.url_to_repo(subject.path_with_namespace))
- end
- end
-
- describe "#ssh_url_to_repo" do
- it "equals #url_to_repo" do
- expect(subject.ssh_url_to_repo).to eq(subject.url_to_repo)
- end
- end
-
- describe "#http_url_to_repo" do
- it "provides the full http url to the repo" do
- gitlab_url = Gitlab.config.gitlab.url
- repo_http_url = "#{gitlab_url}/#{subject.path_with_namespace}.git"
- expect(subject.http_url_to_repo).to eq(repo_http_url)
- end
- end
-
- describe "#wiki" do
- it "contains a Gollum::Wiki instance" do
- expect(subject.wiki).to be_a Gollum::Wiki
- end
-
- it "creates a new wiki repo if one does not yet exist" do
- expect(project_wiki.create_page("index", "test content")).to be_truthy
- end
-
- it "raises CouldNotCreateWikiError if it can't create the wiki repository" do
- allow(project_wiki).to receive(:init_repo).and_return(false)
- expect { project_wiki.send(:create_repo!) }.to raise_exception(ProjectWiki::CouldNotCreateWikiError)
- end
- end
-
- describe "#empty?" do
- context "when the wiki repository is empty" do
- before do
- allow_any_instance_of(Gitlab::Shell).to receive(:add_repository) do
- create_temp_repo("#{Rails.root}/tmp/test-git-base-path/non-existant.wiki.git")
- end
- allow(project).to receive(:path_with_namespace).and_return("non-existant")
- end
-
- describe '#empty?' do
- subject { super().empty? }
- it { is_expected.to be_truthy }
- end
- end
-
- context "when the wiki has pages" do
- before do
- project_wiki.create_page("index", "This is an awesome new Gollum Wiki")
- end
-
- describe '#empty?' do
- subject { super().empty? }
- it { is_expected.to be_falsey }
- end
- end
- end
-
- describe "#pages" do
- before do
- create_page("index", "This is an awesome new Gollum Wiki")
- @pages = subject.pages
- end
-
- after do
- destroy_page(@pages.first.page)
- end
-
- it "returns an array of WikiPage instances" do
- expect(@pages.first).to be_a WikiPage
- end
-
- it "returns the correct number of pages" do
- expect(@pages.count).to eq(1)
- end
- end
-
- describe "#find_page" do
- before do
- create_page("index page", "This is an awesome Gollum Wiki")
- end
-
- after do
- destroy_page(subject.pages.first.page)
- end
-
- it "returns the latest version of the page if it exists" do
- page = subject.find_page("index page")
- expect(page.title).to eq("index page")
- end
-
- it "returns nil if the page does not exist" do
- expect(subject.find_page("non-existant")).to eq(nil)
- end
-
- it "can find a page by slug" do
- page = subject.find_page("index-page")
- expect(page.title).to eq("index page")
- end
-
- it "returns a WikiPage instance" do
- page = subject.find_page("index page")
- expect(page).to be_a WikiPage
- end
- end
-
- describe '#find_file' do
- before do
- file = Gollum::File.new(subject.wiki)
- allow_any_instance_of(Gollum::Wiki).
- to receive(:file).with('image.jpg', 'master', true).
- and_return(file)
- allow_any_instance_of(Gollum::File).
- to receive(:mime_type).
- and_return('image/jpeg')
- allow_any_instance_of(Gollum::Wiki).
- to receive(:file).with('non-existant', 'master', true).
- and_return(nil)
- end
-
- after do
- allow_any_instance_of(Gollum::Wiki).to receive(:file).and_call_original
- allow_any_instance_of(Gollum::File).to receive(:mime_type).and_call_original
- end
-
- it 'returns the latest version of the file if it exists' do
- file = subject.find_file('image.jpg')
- expect(file.mime_type).to eq('image/jpeg')
- end
-
- it 'returns nil if the page does not exist' do
- expect(subject.find_file('non-existant')).to eq(nil)
- end
-
- it 'returns a Gollum::File instance' do
- file = subject.find_file('image.jpg')
- expect(file).to be_a Gollum::File
- end
- end
-
- describe "#create_page" do
- after do
- destroy_page(subject.pages.first.page)
- end
-
- it "creates a new wiki page" do
- expect(subject.create_page("test page", "this is content")).not_to eq(false)
- expect(subject.pages.count).to eq(1)
- end
-
- it "returns false when a duplicate page exists" do
- subject.create_page("test page", "content")
- expect(subject.create_page("test page", "content")).to eq(false)
- end
-
- it "stores an error message when a duplicate page exists" do
- 2.times { subject.create_page("test page", "content") }
- expect(subject.error_message).to match(/Duplicate page:/)
- end
-
- it "sets the correct commit message" do
- subject.create_page("test page", "some content", :markdown, "commit message")
- expect(subject.pages.first.page.version.message).to eq("commit message")
- end
- end
-
- describe "#update_page" do
- before do
- create_page("update-page", "some content")
- @gollum_page = subject.wiki.paged("update-page")
- subject.update_page(@gollum_page, "some other content", :markdown, "updated page")
- @page = subject.pages.first.page
- end
-
- after do
- destroy_page(@page)
- end
-
- it "updates the content of the page" do
- expect(@page.raw_data).to eq("some other content")
- end
-
- it "sets the correct commit message" do
- expect(@page.version.message).to eq("updated page")
- end
- end
-
- describe "#delete_page" do
- before do
- create_page("index", "some content")
- @page = subject.wiki.paged("index")
- end
-
- it "deletes the page" do
- subject.delete_page(@page)
- expect(subject.pages.count).to eq(0)
- end
- end
-
- private
-
- def create_temp_repo(path)
- FileUtils.mkdir_p path
- system(*%W(git init --quiet --bare -- #{path}))
- end
-
- def remove_temp_repo(path)
- FileUtils.rm_rf path
- end
-
- def commit_details
- commit = {name: user.name, email: user.email, message: "test commit"}
- end
-
- def create_page(name, content)
- subject.wiki.write_page(name, :markdown, content, commit_details)
- end
-
- def destroy_page(page)
- subject.wiki.delete_page(page, commit_details)
- end
-end
diff --git a/spec/models/protected_branch_spec.rb b/spec/models/protected_branch_spec.rb
deleted file mode 100644
index 1e6937b536c..00000000000
--- a/spec/models/protected_branch_spec.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-# == Schema Information
-#
-# Table name: protected_branches
-#
-# id :integer not null, primary key
-# project_id :integer not null
-# name :string(255) not null
-# created_at :datetime
-# updated_at :datetime
-# developers_can_push :boolean default(FALSE), not null
-#
-
-require 'spec_helper'
-
-describe ProtectedBranch do
- describe 'Associations' do
- it { is_expected.to belong_to(:project) }
- end
-
- describe "Mass assignment" do
- end
-
- describe 'Validation' do
- it { is_expected.to validate_presence_of(:project) }
- it { is_expected.to validate_presence_of(:name) }
- end
-end
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb
deleted file mode 100644
index f41e5a97ca3..00000000000
--- a/spec/models/repository_spec.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-require 'spec_helper'
-
-describe Repository do
- include RepoHelpers
-
- let(:repository) { create(:project).repository }
-
- describe :branch_names_contains do
- subject { repository.branch_names_contains(sample_commit.id) }
-
- it { is_expected.to include('master') }
- it { is_expected.not_to include('feature') }
- it { is_expected.not_to include('fix') }
- end
-
- describe :tag_names_contains do
- subject { repository.tag_names_contains(sample_commit.id) }
-
- it { is_expected.to include('v1.1.0') }
- it { is_expected.not_to include('v1.0.0') }
- end
-
- describe :last_commit_for_path do
- subject { repository.last_commit_for_path(sample_commit.id, '.gitignore').id }
-
- it { is_expected.to eq('c1acaa58bbcbc3eafe538cb8274ba387047b69f8') }
- end
-end
diff --git a/spec/models/service_spec.rb b/spec/models/service_spec.rb
deleted file mode 100644
index 735652aea78..00000000000
--- a/spec/models/service_spec.rb
+++ /dev/null
@@ -1,92 +0,0 @@
-# == Schema Information
-#
-# Table name: services
-#
-# id :integer not null, primary key
-# type :string(255)
-# title :string(255)
-# project_id :integer
-# created_at :datetime
-# updated_at :datetime
-# active :boolean default(FALSE), not null
-# properties :text
-# template :boolean default(FALSE)
-# push_events :boolean default(TRUE)
-# issues_events :boolean default(TRUE)
-# merge_requests_events :boolean default(TRUE)
-# tag_push_events :boolean default(TRUE)
-#
-
-require 'spec_helper'
-
-describe Service do
-
- describe "Associations" do
- it { is_expected.to belong_to :project }
- it { is_expected.to have_one :service_hook }
- end
-
- describe "Mass assignment" do
- end
-
- describe "Test Button" do
- before do
- @service = Service.new
- end
-
- describe "Testable" do
- let (:project) { create :project }
-
- before do
- @service.stub(
- project: project
- )
- @testable = @service.can_test?
- end
-
- describe :can_test do
- it { expect(@testable).to eq(true) }
- end
- end
-
- describe "With commits" do
- let (:project) { create :project }
-
- before do
- @service.stub(
- project: project
- )
- @testable = @service.can_test?
- end
-
- describe :can_test do
- it { expect(@testable).to eq(true) }
- end
- end
- end
-
- describe "Template" do
- describe "for pushover service" do
- let(:service_template) {
- PushoverService.create(template: true, properties: {device: 'MyDevice', sound: 'mic', priority: 4, api_key: '123456789'})
- }
- let(:project) { create(:project) }
-
- describe 'should be prefilled for projects pushover service' do
- before do
- service_template
- project.build_missing_services
- end
-
- it "should have all fields prefilled" do
- service = project.pushover_service
- expect(service.template).to eq(false)
- expect(service.device).to eq('MyDevice')
- expect(service.sound).to eq('mic')
- expect(service.priority).to eq(4)
- expect(service.api_key).to eq('123456789')
- end
- end
- end
- end
-end
diff --git a/spec/models/snippet_spec.rb b/spec/models/snippet_spec.rb
deleted file mode 100644
index e37dcc75230..00000000000
--- a/spec/models/snippet_spec.rb
+++ /dev/null
@@ -1,40 +0,0 @@
-# == Schema Information
-#
-# Table name: snippets
-#
-# id :integer not null, primary key
-# title :string(255)
-# content :text
-# author_id :integer not null
-# project_id :integer
-# created_at :datetime
-# updated_at :datetime
-# file_name :string(255)
-# expires_at :datetime
-# type :string(255)
-# visibility_level :integer default(0), not null
-#
-
-require 'spec_helper'
-
-describe Snippet do
- describe "Associations" do
- it { is_expected.to belong_to(:author).class_name('User') }
- it { is_expected.to have_many(:notes).dependent(:destroy) }
- end
-
- describe "Mass assignment" do
- end
-
- describe "Validation" do
- it { is_expected.to validate_presence_of(:author) }
-
- it { is_expected.to validate_presence_of(:title) }
- it { is_expected.to ensure_length_of(:title).is_within(0..255) }
-
- it { is_expected.to validate_presence_of(:file_name) }
- it { is_expected.to ensure_length_of(:title).is_within(0..255) }
-
- it { is_expected.to validate_presence_of(:content) }
- end
-end
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
deleted file mode 100644
index 24384e8bf22..00000000000
--- a/spec/models/user_spec.rb
+++ /dev/null
@@ -1,532 +0,0 @@
-# == Schema Information
-#
-# Table name: users
-#
-# id :integer not null, primary key
-# email :string(255) default(""), not null
-# encrypted_password :string(255) default(""), not null
-# reset_password_token :string(255)
-# reset_password_sent_at :datetime
-# remember_created_at :datetime
-# sign_in_count :integer default(0)
-# current_sign_in_at :datetime
-# last_sign_in_at :datetime
-# current_sign_in_ip :string(255)
-# last_sign_in_ip :string(255)
-# created_at :datetime
-# updated_at :datetime
-# name :string(255)
-# admin :boolean default(FALSE), not null
-# projects_limit :integer default(10)
-# skype :string(255) default(""), not null
-# linkedin :string(255) default(""), not null
-# twitter :string(255) default(""), not null
-# authentication_token :string(255)
-# theme_id :integer default(1), not null
-# bio :string(255)
-# failed_attempts :integer default(0)
-# locked_at :datetime
-# username :string(255)
-# can_create_group :boolean default(TRUE), not null
-# can_create_team :boolean default(TRUE), not null
-# state :string(255)
-# color_scheme_id :integer default(1), not null
-# notification_level :integer default(1), not null
-# password_expires_at :datetime
-# created_by_id :integer
-# last_credential_check_at :datetime
-# avatar :string(255)
-# confirmation_token :string(255)
-# confirmed_at :datetime
-# confirmation_sent_at :datetime
-# unconfirmed_email :string(255)
-# hide_no_ssh_key :boolean default(FALSE)
-# website_url :string(255) default(""), not null
-# github_access_token :string(255)
-# gitlab_access_token :string(255)
-# notification_email :string(255)
-# hide_no_password :boolean default(FALSE)
-# password_automatically_set :boolean default(FALSE)
-# bitbucket_access_token :string(255)
-# bitbucket_access_token_secret :string(255)
-#
-
-require 'spec_helper'
-
-describe User do
- describe "Associations" do
- it { is_expected.to have_one(:namespace) }
- it { is_expected.to have_many(:snippets).class_name('Snippet').dependent(:destroy) }
- it { is_expected.to have_many(:project_members).dependent(:destroy) }
- it { is_expected.to have_many(:groups) }
- it { is_expected.to have_many(:keys).dependent(:destroy) }
- it { is_expected.to have_many(:events).class_name('Event').dependent(:destroy) }
- it { is_expected.to have_many(:recent_events).class_name('Event') }
- it { is_expected.to have_many(:issues).dependent(:destroy) }
- it { is_expected.to have_many(:notes).dependent(:destroy) }
- it { is_expected.to have_many(:assigned_issues).dependent(:destroy) }
- it { is_expected.to have_many(:merge_requests).dependent(:destroy) }
- it { is_expected.to have_many(:assigned_merge_requests).dependent(:destroy) }
- it { is_expected.to have_many(:identities).dependent(:destroy) }
- end
-
- describe "Mass assignment" do
- end
-
- describe 'validations' do
- it { is_expected.to validate_presence_of(:username) }
- it { is_expected.to validate_presence_of(:projects_limit) }
- it { is_expected.to validate_numericality_of(:projects_limit) }
- it { is_expected.to allow_value(0).for(:projects_limit) }
- it { is_expected.not_to allow_value(-1).for(:projects_limit) }
-
- it { is_expected.to ensure_length_of(:bio).is_within(0..255) }
-
- describe 'email' do
- it 'accepts info@example.com' do
- user = build(:user, email: 'info@example.com')
- expect(user).to be_valid
- end
-
- it 'accepts info+test@example.com' do
- user = build(:user, email: 'info+test@example.com')
- expect(user).to be_valid
- end
-
- it "accepts o'reilly@example.com" do
- user = build(:user, email: "o'reilly@example.com")
- expect(user).to be_valid
- end
-
- it 'rejects test@test@example.com' do
- user = build(:user, email: 'test@test@example.com')
- expect(user).to be_invalid
- end
-
- it 'rejects mailto:test@example.com' do
- user = build(:user, email: 'mailto:test@example.com')
- expect(user).to be_invalid
- end
-
- it "rejects lol!'+=?><#$%^&*()@gmail.com" do
- user = build(:user, email: "lol!'+=?><#$%^&*()@gmail.com")
- expect(user).to be_invalid
- end
- end
- end
-
- describe "Respond to" do
- it { is_expected.to respond_to(:is_admin?) }
- it { is_expected.to respond_to(:name) }
- it { is_expected.to respond_to(:private_token) }
- end
-
- describe '#generate_password' do
- it "should execute callback when force_random_password specified" do
- user = build(:user, force_random_password: true)
- expect(user).to receive(:generate_password)
- user.save
- end
-
- it "should not generate password by default" do
- user = create(:user, password: 'abcdefghe')
- expect(user.password).to eq('abcdefghe')
- end
-
- it "should generate password when forcing random password" do
- allow(Devise).to receive(:friendly_token).and_return('123456789')
- user = create(:user, password: 'abcdefg', force_random_password: true)
- expect(user.password).to eq('12345678')
- end
- end
-
- describe 'authentication token' do
- it "should have authentication token" do
- user = create(:user)
- expect(user.authentication_token).not_to be_blank
- end
- end
-
- describe 'projects' do
- before do
- @user = create :user
- @project = create :project, namespace: @user.namespace
- @project_2 = create :project, group: create(:group) # Grant MASTER access to the user
- @project_3 = create :project, group: create(:group) # Grant DEVELOPER access to the user
-
- @project_2.team << [@user, :master]
- @project_3.team << [@user, :developer]
- end
-
- it { expect(@user.authorized_projects).to include(@project) }
- it { expect(@user.authorized_projects).to include(@project_2) }
- it { expect(@user.authorized_projects).to include(@project_3) }
- it { expect(@user.owned_projects).to include(@project) }
- it { expect(@user.owned_projects).not_to include(@project_2) }
- it { expect(@user.owned_projects).not_to include(@project_3) }
- it { expect(@user.personal_projects).to include(@project) }
- it { expect(@user.personal_projects).not_to include(@project_2) }
- it { expect(@user.personal_projects).not_to include(@project_3) }
- end
-
- describe 'groups' do
- before do
- @user = create :user
- @group = create :group
- @group.add_owner(@user)
- end
-
- it { expect(@user.several_namespaces?).to be_truthy }
- it { expect(@user.authorized_groups).to eq([@group]) }
- it { expect(@user.owned_groups).to eq([@group]) }
- end
-
- describe 'group multiple owners' do
- before do
- @user = create :user
- @user2 = create :user
- @group = create :group
- @group.add_owner(@user)
-
- @group.add_user(@user2, GroupMember::OWNER)
- end
-
- it { expect(@user2.several_namespaces?).to be_truthy }
- end
-
- describe 'namespaced' do
- before do
- @user = create :user
- @project = create :project, namespace: @user.namespace
- end
-
- it { expect(@user.several_namespaces?).to be_falsey }
- end
-
- describe 'blocking user' do
- let(:user) { create(:user, name: 'John Smith') }
-
- it "should block user" do
- user.block
- expect(user.blocked?).to be_truthy
- end
- end
-
- describe 'filter' do
- before do
- User.delete_all
- @user = create :user
- @admin = create :user, admin: true
- @blocked = create :user, state: :blocked
- end
-
- it { expect(User.filter("admins")).to eq([@admin]) }
- it { expect(User.filter("blocked")).to eq([@blocked]) }
- it { expect(User.filter("wop")).to include(@user, @admin, @blocked) }
- it { expect(User.filter(nil)).to include(@user, @admin) }
- end
-
- describe :not_in_project do
- before do
- User.delete_all
- @user = create :user
- @project = create :project
- end
-
- it { expect(User.not_in_project(@project)).to include(@user, @project.owner) }
- end
-
- describe 'user creation' do
- describe 'normal user' do
- let(:user) { create(:user, name: 'John Smith') }
-
- it { expect(user.is_admin?).to be_falsey }
- it { expect(user.require_ssh_key?).to be_truthy }
- it { expect(user.can_create_group?).to be_truthy }
- it { expect(user.can_create_project?).to be_truthy }
- it { expect(user.first_name).to eq('John') }
- end
-
- describe 'with defaults' do
- let(:user) { User.new }
-
- it "should apply defaults to user" do
- expect(user.projects_limit).to eq(Gitlab.config.gitlab.default_projects_limit)
- expect(user.can_create_group).to eq(Gitlab.config.gitlab.default_can_create_group)
- expect(user.theme_id).to eq(Gitlab.config.gitlab.default_theme)
- end
- end
-
- describe 'with default overrides' do
- let(:user) { User.new(projects_limit: 123, can_create_group: false, can_create_team: true, theme_id: Gitlab::Theme::BASIC) }
-
- it "should apply defaults to user" do
- expect(user.projects_limit).to eq(123)
- expect(user.can_create_group).to be_falsey
- expect(user.theme_id).to eq(Gitlab::Theme::BASIC)
- end
- end
- end
-
- describe 'search' do
- let(:user1) { create(:user, username: 'James', email: 'james@testing.com') }
- let(:user2) { create(:user, username: 'jameson', email: 'jameson@example.com') }
-
- it "should be case insensitive" do
- expect(User.search(user1.username.upcase).to_a).to eq([user1])
- expect(User.search(user1.username.downcase).to_a).to eq([user1])
- expect(User.search(user2.username.upcase).to_a).to eq([user2])
- expect(User.search(user2.username.downcase).to_a).to eq([user2])
- expect(User.search(user1.username.downcase).to_a.count).to eq(2)
- expect(User.search(user2.username.downcase).to_a.count).to eq(1)
- end
- end
-
- describe 'by_username_or_id' do
- let(:user1) { create(:user, username: 'foo') }
-
- it "should get the correct user" do
- expect(User.by_username_or_id(user1.id)).to eq(user1)
- expect(User.by_username_or_id('foo')).to eq(user1)
- expect(User.by_username_or_id(-1)).to be_nil
- expect(User.by_username_or_id('bar')).to be_nil
- end
- end
-
- describe '.by_login' do
- let(:username) { 'John' }
- let!(:user) { create(:user, username: username) }
-
- it 'should get the correct user' do
- expect(User.by_login(user.email.upcase)).to eq user
- expect(User.by_login(user.email)).to eq user
- expect(User.by_login(username.downcase)).to eq user
- expect(User.by_login(username)).to eq user
- expect(User.by_login(nil)).to be_nil
- expect(User.by_login('')).to be_nil
- end
- end
-
- describe 'all_ssh_keys' do
- it { is_expected.to have_many(:keys).dependent(:destroy) }
-
- it "should have all ssh keys" do
- user = create :user
- key = create :key, key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD33bWLBxu48Sev9Fert1yzEO4WGcWglWF7K/AwblIUFselOt/QdOL9DSjpQGxLagO1s9wl53STIO8qGS4Ms0EJZyIXOEFMjFJ5xmjSy+S37By4sG7SsltQEHMxtbtFOaW5LV2wCrX+rUsRNqLMamZjgjcPO0/EgGCXIGMAYW4O7cwGZdXWYIhQ1Vwy+CsVMDdPkPgBXqK7nR/ey8KMs8ho5fMNgB5hBw/AL9fNGhRw3QTD6Q12Nkhl4VZES2EsZqlpNnJttnPdp847DUsT6yuLRlfiQfz5Cn9ysHFdXObMN5VYIiPFwHeYCZp1X2S4fDZooRE8uOLTfxWHPXwrhqSH", user_id: user.id
-
- expect(user.all_ssh_keys).to include(key.key)
- end
- end
-
- describe :avatar_type do
- let(:user) { create(:user) }
-
- it "should be true if avatar is image" do
- user.update_attribute(:avatar, 'uploads/avatar.png')
- expect(user.avatar_type).to be_truthy
- end
-
- it "should be false if avatar is html page" do
- user.update_attribute(:avatar, 'uploads/avatar.html')
- expect(user.avatar_type).to eq(["only images allowed"])
- end
- end
-
- describe :requires_ldap_check? do
- let(:user) { User.new }
-
- it 'is false when LDAP is disabled' do
- # Create a condition which would otherwise cause 'true' to be returned
- user.stub(ldap_user?: true)
- user.last_credential_check_at = nil
- expect(user.requires_ldap_check?).to be_falsey
- end
-
- context 'when LDAP is enabled' do
- before { Gitlab.config.ldap.stub(enabled: true) }
-
- it 'is false for non-LDAP users' do
- user.stub(ldap_user?: false)
- expect(user.requires_ldap_check?).to be_falsey
- end
-
- context 'and when the user is an LDAP user' do
- before { user.stub(ldap_user?: true) }
-
- it 'is true when the user has never had an LDAP check before' do
- user.last_credential_check_at = nil
- expect(user.requires_ldap_check?).to be_truthy
- end
-
- it 'is true when the last LDAP check happened over 1 hour ago' do
- user.last_credential_check_at = 2.hours.ago
- expect(user.requires_ldap_check?).to be_truthy
- end
- end
- end
- end
-
- describe :ldap_user? do
- it "is true if provider name starts with ldap" do
- user = create(:omniauth_user, provider: 'ldapmain')
- expect( user.ldap_user? ).to be_truthy
- end
-
- it "is false for other providers" do
- user = create(:omniauth_user, provider: 'other-provider')
- expect( user.ldap_user? ).to be_falsey
- end
-
- it "is false if no extern_uid is provided" do
- user = create(:omniauth_user, extern_uid: nil)
- expect( user.ldap_user? ).to be_falsey
- end
- end
-
- describe :ldap_identity do
- it "returns ldap identity" do
- user = create :omniauth_user
- expect(user.ldap_identity.provider).not_to be_empty
- end
- end
-
- describe '#full_website_url' do
- let(:user) { create(:user) }
-
- it 'begins with http if website url omits it' do
- user.website_url = 'test.com'
-
- expect(user.full_website_url).to eq 'http://test.com'
- end
-
- it 'begins with http if website url begins with http' do
- user.website_url = 'http://test.com'
-
- expect(user.full_website_url).to eq 'http://test.com'
- end
-
- it 'begins with https if website url begins with https' do
- user.website_url = 'https://test.com'
-
- expect(user.full_website_url).to eq 'https://test.com'
- end
- end
-
- describe '#short_website_url' do
- let(:user) { create(:user) }
-
- it 'does not begin with http if website url omits it' do
- user.website_url = 'test.com'
-
- expect(user.short_website_url).to eq 'test.com'
- end
-
- it 'does not begin with http if website url begins with http' do
- user.website_url = 'http://test.com'
-
- expect(user.short_website_url).to eq 'test.com'
- end
-
- it 'does not begin with https if website url begins with https' do
- user.website_url = 'https://test.com'
-
- expect(user.short_website_url).to eq 'test.com'
- end
- end
-
- describe "#starred?" do
- it "determines if user starred a project" do
- user = create :user
- project1 = create :project, :public
- project2 = create :project, :public
-
- expect(user.starred?(project1)).to be_falsey
- expect(user.starred?(project2)).to be_falsey
-
- star1 = UsersStarProject.create!(project: project1, user: user)
- expect(user.starred?(project1)).to be_truthy
- expect(user.starred?(project2)).to be_falsey
-
- star2 = UsersStarProject.create!(project: project2, user: user)
- expect(user.starred?(project1)).to be_truthy
- expect(user.starred?(project2)).to be_truthy
-
- star1.destroy
- expect(user.starred?(project1)).to be_falsey
- expect(user.starred?(project2)).to be_truthy
-
- star2.destroy
- expect(user.starred?(project1)).to be_falsey
- expect(user.starred?(project2)).to be_falsey
- end
- end
-
- describe "#toggle_star" do
- it "toggles stars" do
- user = create :user
- project = create :project, :public
-
- expect(user.starred?(project)).to be_falsey
- user.toggle_star(project)
- expect(user.starred?(project)).to be_truthy
- user.toggle_star(project)
- expect(user.starred?(project)).to be_falsey
- end
- end
-
- describe "#sort" do
- before do
- User.delete_all
- @user = create :user, created_at: Date.today, last_sign_in_at: Date.today, name: 'Alpha'
- @user1 = create :user, created_at: Date.today - 1, last_sign_in_at: Date.today - 1, name: 'Omega'
- end
-
- it "sorts users as recently_signed_in" do
- expect(User.sort('recent_sign_in').first).to eq(@user)
- end
-
- it "sorts users as late_signed_in" do
- expect(User.sort('oldest_sign_in').first).to eq(@user1)
- end
-
- it "sorts users as recently_created" do
- expect(User.sort('created_desc').first).to eq(@user)
- end
-
- it "sorts users as late_created" do
- expect(User.sort('created_asc').first).to eq(@user1)
- end
-
- it "sorts users by name when nil is passed" do
- expect(User.sort(nil).first).to eq(@user)
- end
- end
-
- describe "#contributed_projects_ids" do
-
- subject { create(:user) }
- let!(:project1) { create(:project) }
- let!(:project2) { create(:project, forked_from_project: project3) }
- let!(:project3) { create(:project) }
- let!(:merge_request) { create(:merge_request, source_project: project2, target_project: project3, author: subject) }
- let!(:push_event) { create(:event, action: Event::PUSHED, project: project1, target: project1, author: subject) }
- let!(:merge_event) { create(:event, action: Event::CREATED, project: project3, target: merge_request, author: subject) }
-
- before do
- project1.team << [subject, :master]
- project2.team << [subject, :master]
- end
-
- it "includes IDs for projects the user has pushed to" do
- expect(subject.contributed_projects_ids).to include(project1.id)
- end
-
- it "includes IDs for projects the user has had merge requests merged into" do
- expect(subject.contributed_projects_ids).to include(project3.id)
- end
-
- it "doesn't include IDs for unrelated projects" do
- expect(subject.contributed_projects_ids).not_to include(project2.id)
- end
- end
-end
diff --git a/spec/models/wiki_page_spec.rb b/spec/models/wiki_page_spec.rb
deleted file mode 100644
index fceb7668cac..00000000000
--- a/spec/models/wiki_page_spec.rb
+++ /dev/null
@@ -1,210 +0,0 @@
-require "spec_helper"
-
-describe WikiPage do
- let(:project) { create(:empty_project) }
- let(:user) { project.owner }
- let(:wiki) { ProjectWiki.new(project, user) }
-
- subject { WikiPage.new(wiki) }
-
- describe "#initialize" do
- context "when initialized with an existing gollum page" do
- before do
- create_page("test page", "test content")
- @page = wiki.wiki.paged("test page")
- @wiki_page = WikiPage.new(wiki, @page, true)
- end
-
- it "sets the slug attribute" do
- expect(@wiki_page.slug).to eq("test-page")
- end
-
- it "sets the title attribute" do
- expect(@wiki_page.title).to eq("test page")
- end
-
- it "sets the formatted content attribute" do
- expect(@wiki_page.content).to eq("test content")
- end
-
- it "sets the format attribute" do
- expect(@wiki_page.format).to eq(:markdown)
- end
-
- it "sets the message attribute" do
- expect(@wiki_page.message).to eq("test commit")
- end
-
- it "sets the version attribute" do
- expect(@wiki_page.version).to be_a Gollum::Git::Commit
- end
- end
- end
-
- describe "validations" do
- before do
- subject.attributes = {title: 'title', content: 'content'}
- end
-
- it "validates presence of title" do
- subject.attributes.delete(:title)
- expect(subject.valid?).to be_falsey
- end
-
- it "validates presence of content" do
- subject.attributes.delete(:content)
- expect(subject.valid?).to be_falsey
- end
- end
-
- before do
- @wiki_attr = {title: "Index", content: "Home Page", format: "markdown"}
- end
-
- describe "#create" do
- after do
- destroy_page("Index")
- end
-
- context "with valid attributes" do
- it "saves the wiki page" do
- subject.create(@wiki_attr)
- expect(wiki.find_page("Index")).not_to be_nil
- end
-
- it "returns true" do
- expect(subject.create(@wiki_attr)).to eq(true)
- end
- end
- end
-
- describe "dot in the title" do
- let(:title) { 'Index v1.2.3' }
-
- before do
- @wiki_attr = {title: title, content: "Home Page", format: "markdown"}
- end
-
- describe "#create" do
- after do
- destroy_page(title)
- end
-
- context "with valid attributes" do
- it "saves the wiki page" do
- subject.create(@wiki_attr)
- expect(wiki.find_page(title)).not_to be_nil
- end
-
- it "returns true" do
- expect(subject.create(@wiki_attr)).to eq(true)
- end
- end
- end
-
- describe "#update" do
- before do
- create_page(title, "content")
- @page = wiki.find_page(title)
- end
-
- it "updates the content of the page" do
- @page.update("new content")
- @page = wiki.find_page(title)
- end
-
- it "returns true" do
- expect(@page.update("more content")).to be_truthy
- end
- end
- end
-
- describe "#update" do
- before do
- create_page("Update", "content")
- @page = wiki.find_page("Update")
- end
-
- after do
- destroy_page("Update")
- end
-
- context "with valid attributes" do
- it "updates the content of the page" do
- @page.update("new content")
- @page = wiki.find_page("Update")
- end
-
- it "returns true" do
- expect(@page.update("more content")).to be_truthy
- end
- end
- end
-
- describe "#destroy" do
- before do
- create_page("Delete Page", "content")
- @page = wiki.find_page("Delete Page")
- end
-
- it "should delete the page" do
- @page.delete
- expect(wiki.pages).to be_empty
- end
-
- it "should return true" do
- expect(@page.delete).to eq(true)
- end
- end
-
- describe "#versions" do
- before do
- create_page("Update", "content")
- @page = wiki.find_page("Update")
- end
-
- after do
- destroy_page("Update")
- end
-
- it "returns an array of all commits for the page" do
- 3.times { |i| @page.update("content #{i}") }
- expect(@page.versions.count).to eq(4)
- end
- end
-
- describe "#title" do
- before do
- create_page("Title", "content")
- @page = wiki.find_page("Title")
- end
-
- after do
- destroy_page("Title")
- end
-
- it "should be replace a hyphen to a space" do
- @page.title = "Import-existing-repositories-into-GitLab"
- expect(@page.title).to eq("Import existing repositories into GitLab")
- end
- end
-
- private
-
- def remove_temp_repo(path)
- FileUtils.rm_rf path
- end
-
- def commit_details
- commit = {name: user.name, email: user.email, message: "test commit"}
- end
-
- def create_page(name, content)
- wiki.wiki.write_page(name, :markdown, content, commit_details)
- end
-
- def destroy_page(title)
- page = wiki.wiki.paged(title)
- wiki.wiki.delete_page(page, commit_details)
- end
-end