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

adds tests and fixes some broken code to main language mr

parent 2aea71e82b11
......@@ -89,7 +89,7 @@ def update_forks_visibility_level
# 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 @@ def wiki
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 @@
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 @@
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