diff options
author | Robert Speicher <rspeicher@gmail.com> | 2015-01-30 15:40:04 -0500 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2015-01-30 15:51:10 -0500 |
commit | ab6f7164e03139889c09a6a207e9df3481e57b3b (patch) | |
tree | c1c107612a9db89bbdc4f10c222bfcb4f5b44119 /spec/models/project_services/jira_service_spec.rb | |
parent | c47328948b5fff218c68279260a57ab6b03e7423 (diff) | |
download | gitlab-ce-ab6f7164e03139889c09a6a207e9df3481e57b3b.tar.gz |
Make the structure of spec/models match app/models
Diffstat (limited to 'spec/models/project_services/jira_service_spec.rb')
-rw-r--r-- | spec/models/project_services/jira_service_spec.rb | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/spec/models/project_services/jira_service_spec.rb b/spec/models/project_services/jira_service_spec.rb new file mode 100644 index 00000000000..0c73a68c924 --- /dev/null +++ b/spec/models/project_services/jira_service_spec.rb @@ -0,0 +1,83 @@ +require 'spec_helper' + +describe JiraService do + 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 :project_url } + it { should validate_presence_of :issues_url } + it { should 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" + } + } + Gitlab.config.stub(: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 |