Commit d72e6ad2 authored by tiagonbotelho's avatar tiagonbotelho Committed by Yorick Peterse

adds tests and fixes some broken code to main language mr

parent c2c5572e
......@@ -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
......@@ -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 }
......
......@@ -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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment