summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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