summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortiagonbotelho <tiagonbotelho@hotmail.com>2016-03-01 19:45:55 +0000
committerYorick Peterse <yorickpeterse@gmail.com>2016-03-07 21:59:39 +0100
commitd72e6ad2a176d5d73cbefbb971ed34a75f327923 (patch)
tree7a4c19a71593c408c9b822ef09fc593b23865eab
parentc2c5572e22d8e03b111859f3cf143181edd8c20f (diff)
downloadgitlab-ce-d72e6ad2a176d5d73cbefbb971ed34a75f327923.tar.gz
adds tests and fixes some broken code to main language mr
-rw-r--r--app/models/project.rb6
-rw-r--r--spec/models/project_spec.rb8
-rw-r--r--spec/models/repository_spec.rb6
3 files changed, 17 insertions, 3 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index 9400d8a17af..470fa2194de 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -89,7 +89,7 @@ class Project < ActiveRecord::Base
# checks if the language main language of the project changed
before_save :check_main_language
def check_main_language
- if commit_count.changed?
+ if self.commit_count_changed?
self.main_language = repository.main_language
end
end
@@ -955,12 +955,12 @@ class Project < ActiveRecord::Base
end
def main_language
- language = read_attributes(:main_language)
+ language = read_attribute(:main_language)
return language if language
update_attributes(main_language: repository.main_language)
- read_attributes(:main_language)
+ read_attribute(:main_language)
end
end
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index f9842d23afa..60b0f55b31d 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -560,6 +560,14 @@ describe Project, models: true do
end
end
+ describe "#main_language" do
+ let(:project) { create :project }
+
+ it 'shows the main language of the project' do
+ expect(project.main_language).to eq("Ruby")
+ end
+ end
+
describe '#visibility_level_allowed?' do
let(:project) { create :project, visibility_level: Gitlab::VisibilityLevel::INTERNAL }
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb
index 1c7d66398cb..2094667565e 100644
--- a/spec/models/repository_spec.rb
+++ b/spec/models/repository_spec.rb
@@ -595,4 +595,10 @@ describe Repository, models: true do
repository.after_remove_branch
end
end
+
+ describe "#main_language" do
+ it 'shows the main language of the project' do
+ expect(repository.main_language).to eq("Ruby")
+ end
+ end
end