From 73535b80b246248e932e6a88c462bc827d510e24 Mon Sep 17 00:00:00 2001 From: tiagonbotelho Date: Sun, 28 Feb 2016 17:27:22 +0000 Subject: [PATCH 01/16] adds language names to projects list github style --- app/models/project.rb | 9 +++++++++ app/views/shared/projects/_project.html.haml | 3 +++ 2 files changed, 12 insertions(+) diff --git a/app/models/project.rb b/app/models/project.rb index 3235a1cee50..2fdd4bfbbc1 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -945,4 +945,13 @@ class Project < ActiveRecord::Base def wiki @wiki ||= ProjectWiki.new(self, self.owner) end + + def main_language + if !empty_repo? + languages = Linguist::Repository.new( + @repository.rugged, + @repository.rugged.head.target_id).languages + return languages.key(languages.values.max) + end + end end diff --git a/app/views/shared/projects/_project.html.haml b/app/views/shared/projects/_project.html.haml index 99e48e86e38..97cfb76cdb0 100644 --- a/app/views/shared/projects/_project.html.haml +++ b/app/views/shared/projects/_project.html.haml @@ -28,6 +28,9 @@ = project.name .controls + - if project.main_language + %span + = project.main_language - if ci_commit %span = render_ci_status(ci_commit) From fe934a2da2be153d7346c90671103a5423b13833 Mon Sep 17 00:00:00 2001 From: tiagonbotelho Date: Sun, 28 Feb 2016 21:29:27 +0000 Subject: [PATCH 02/16] adds cache to languages list --- app/models/project.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/project.rb b/app/models/project.rb index 2fdd4bfbbc1..3a41812f3c9 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -948,10 +948,10 @@ class Project < ActiveRecord::Base def main_language if !empty_repo? - languages = Linguist::Repository.new( - @repository.rugged, - @repository.rugged.head.target_id).languages - return languages.key(languages.values.max) + Rails.cache.fetch([self, "language"]) do + languages = Linguist::Repository.new(@repository.rugged, @repository.rugged.head.target_id).languages + languages.key(languages.values.max) + end end end end From 85de3f69558af88ad0af8716ee6fb7197b2d28df Mon Sep 17 00:00:00 2001 From: tiagonbotelho Date: Mon, 29 Feb 2016 10:15:53 +0000 Subject: [PATCH 03/16] changes if ! to unless and now asks for language instead of languages --- app/models/project.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/models/project.rb b/app/models/project.rb index 3a41812f3c9..92aef8a60f4 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -947,10 +947,11 @@ class Project < ActiveRecord::Base end def main_language - if !empty_repo? + unless empty_repo? Rails.cache.fetch([self, "language"]) do - languages = Linguist::Repository.new(@repository.rugged, @repository.rugged.head.target_id).languages - languages.key(languages.values.max) + Linguist::Repository.new( + @repository.rugged, + @repository.rugged.head.target_id).language end end end From d9e646a796795de43b23a27b74289f44255810e3 Mon Sep 17 00:00:00 2001 From: tiagonbotelho Date: Mon, 29 Feb 2016 16:50:59 +0000 Subject: [PATCH 04/16] moves method to repository model --- app/models/project.rb | 8 +------- app/models/repository.rb | 12 ++++++++++++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/app/models/project.rb b/app/models/project.rb index 92aef8a60f4..3b565ef809a 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -947,12 +947,6 @@ class Project < ActiveRecord::Base end def main_language - unless empty_repo? - Rails.cache.fetch([self, "language"]) do - Linguist::Repository.new( - @repository.rugged, - @repository.rugged.head.target_id).language - end - end + @main_language = repository.main_language end end diff --git a/app/models/repository.rb b/app/models/repository.rb index c135ab61f6a..f911611acab 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -812,6 +812,18 @@ class Repository raw_repository.ls_files(actual_ref) end + def main_language + return @main_language unless @main_language.nil? + + unless empty? + @main_language = cache.fetch(:main_language) do + Linguist::Repository.new( + rugged, + rugged.head.target_id).language + end + end + end + private def cache From a14b98f858cadf60c67db4cbd23aa10ae0d5213b Mon Sep 17 00:00:00 2001 From: tiagonbotelho Date: Tue, 1 Mar 2016 01:55:36 +0000 Subject: [PATCH 05/16] implements project languages saving them onto the database --- app/models/.project.rb.swo | Bin 0 -> 49152 bytes app/models/project.rb | 12 ++++++++++ ...9193553_add_main_language_to_repository.rb | 21 ++++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 app/models/.project.rb.swo create mode 100644 db/migrate/20160229193553_add_main_language_to_repository.rb diff --git a/app/models/.project.rb.swo b/app/models/.project.rb.swo new file mode 100644 index 0000000000000000000000000000000000000000..5d264ccfaaa42e0a6f93323aa8baf0a4e1fa7cf3 GIT binary patch literal 49152 zcmeI537A}0b?1w)*?_TGJ_!4h8oR5VR%vIcSi9S{uq?@~#W+F~ud7~nm%29BtCG~V zgbf&Dwh%JG_5`y!fY~O&2@DJlJAolEOt1-S1`GiL1k4te@MUIx=iGbWyYF?ixpAzFbEnoE+<95>)Y66mpK}U@r~LfxgHzi!|ISA{_bK%1;Y__Di%?>q?DwHEj4%o|{QUKh7=f5U`T->1%?zDQea4dAq9pM_zz2gUgtrDYbpKj*cx1EzweX# zzQ6r_hW$R2dw)Os`@xI6ch9%m_hByn19H!A%e{Y~{e8XtzMn0iE2k^ht@izmx%X$< z=Qr8!C)*0U_z$wrue0C(E%*Mu_PG;iloq%3JfVQq`;5@LkbKj zFr>hc0z(Q6DezlKfv{F6e2x4~z@XTVEA4Qv8W0Ka-@q40Td z2WWxw!MD#U6y6A~1y2R%fKNZ9P`DjD4{Qa$Mi6i}cqizA_241kTQK1N1^gkH1Eb)Z zFzp`(uLFm`qruN$^nU_=3_bqo)+z`MZP!P|h)`^}&Mwt+{1Un5NTB=`h)1CZbE3G6418q=j_SZ`GtVQZ!z&P2hc z!2Me&xM1C=(~j%Cc6Ywi?a$0awbE=9)=IswI}`OP_1ah|iL+>wahsY8Nk+Ts{jK`S~|)S&h0V1<`))a>-;w*=>%7igiYvlKY01;I#AosFt2`N6s#ToYNE{xGR%q}6FOSya`c%D9@6A^l(b1?u z74wg5RLYu5I3Fz1Q#rLR5=#L zl&ls_2mMYh>_rvLrjjodVZ!NN)UB9ML3ydrBR0K!j=g~P&^-JWu&GtsjefILEH}cq zR|%`V`ca{1*c-Pk-;F3?jR#}4%rTuXA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aRqVKZ7g5 zeS!G-yBs_L$T|DF!SjHetv?2Q0zUjWxDb379{Wyk1K1571O6VK`5oXW*bIc9{t^7~ zz2JplC3p+`@6*8lf*wMXd7;bymyhq;!Se&LJm(Gvt>XwJx^$EDj*6Uj2R{$%(FcuS z?xgI`;JU;*`Ejc`tGKyqGI=w=tHh*Ufh)&{sb>n4vX{*A>R^)EYk2C@sEBH>QP|84 z9OCg}d%xb0t2s_V5vE>YO-vGE8fSI1*d=iNwZ5}52BY?)OKVzFbe7F)vR_^$cNopP zQx+;i%v|=%%186qr+P}KuD(oZQX6qm=bR0h6SpO6v(h%yPSusVkYl=)E;ZwyB)tt7 z;-r1ddz|!;Ooayp7+C8}Ech8wTN~UCnUFMOx66#}7fRQ>io8k6%8tIB3Z$PG5z70iiN zb}k_4+zK@?^-OW}WOY2qdli2)fTf*B`!NhkQs z`I)8Z0BYuI!9*e|pr-%48LgH6_W$4@93ymV-2e zqm|qcZ;O&i!GBK*OE-cmUs}U_=~8EX>Tk}DoKwwDx=vb_NC$v39B>LNOGd8Z0HfVB zmM*6q8QCQ2+PLpFV|>ZX{QKvZ3@l1DNI<&FPF;M!R5=}9c7&<0In_p)dzq!zP1ziW z&dZJwH;~ONJM>J{Y{9Gdo6C+7; Date: Tue, 1 Mar 2016 01:58:02 +0000 Subject: [PATCH 06/16] removes unused methods that I forgot --- app/models/project.rb | 4 ---- app/models/repository.rb | 12 ------------ 2 files changed, 16 deletions(-) diff --git a/app/models/project.rb b/app/models/project.rb index 4d2ff11cc11..3d3fd6f76a2 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -957,8 +957,4 @@ class Project < ActiveRecord::Base def wiki @wiki ||= ProjectWiki.new(self, self.owner) end - - def main_language - @main_language = repository.main_language - end end diff --git a/app/models/repository.rb b/app/models/repository.rb index f911611acab..c135ab61f6a 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -812,18 +812,6 @@ class Repository raw_repository.ls_files(actual_ref) end - def main_language - return @main_language unless @main_language.nil? - - unless empty? - @main_language = cache.fetch(:main_language) do - Linguist::Repository.new( - rugged, - rugged.head.target_id).language - end - end - end - private def cache From c2c5572e22d8e03b111859f3cf143181edd8c20f Mon Sep 17 00:00:00 2001 From: tiagonbotelho Date: Tue, 1 Mar 2016 11:42:47 +0000 Subject: [PATCH 07/16] adds swp and swo to gitignore and improves migration for project main_language --- app/models/.project.rb.swo | Bin 49152 -> 0 bytes app/models/project.rb | 18 ++++++++++------ app/models/repository.rb | 6 ++++++ ...9193553_add_main_language_to_repository.rb | 20 ++---------------- 4 files changed, 20 insertions(+), 24 deletions(-) delete mode 100644 app/models/.project.rb.swo diff --git a/app/models/.project.rb.swo b/app/models/.project.rb.swo deleted file mode 100644 index 5d264ccfaaa42e0a6f93323aa8baf0a4e1fa7cf3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 49152 zcmeI537A}0b?1w)*?_TGJ_!4h8oR5VR%vIcSi9S{uq?@~#W+F~ud7~nm%29BtCG~V zgbf&Dwh%JG_5`y!fY~O&2@DJlJAolEOt1-S1`GiL1k4te@MUIx=iGbWyYF?ixpAzFbEnoE+<95>)Y66mpK}U@r~LfxgHzi!|ISA{_bK%1;Y__Di%?>q?DwHEj4%o|{QUKh7=f5U`T->1%?zDQea4dAq9pM_zz2gUgtrDYbpKj*cx1EzweX# zzQ6r_hW$R2dw)Os`@xI6ch9%m_hByn19H!A%e{Y~{e8XtzMn0iE2k^ht@izmx%X$< z=Qr8!C)*0U_z$wrue0C(E%*Mu_PG;iloq%3JfVQq`;5@LkbKj zFr>hc0z(Q6DezlKfv{F6e2x4~z@XTVEA4Qv8W0Ka-@q40Td z2WWxw!MD#U6y6A~1y2R%fKNZ9P`DjD4{Qa$Mi6i}cqizA_241kTQK1N1^gkH1Eb)Z zFzp`(uLFm`qruN$^nU_=3_bqo)+z`MZP!P|h)`^}&Mwt+{1Un5NTB=`h)1CZbE3G6418q=j_SZ`GtVQZ!z&P2hc z!2Me&xM1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}D%cO&b&4NN1iuJ?Z3ma0z|?)br!r7y7b8(G zK@XHmHoe}+O2@sJNpq{An7r2Yf$`u5Nx@WEmCw?rHW-#zRnCB?`?72j*)1EY-e;C! zij;~SWCR)UktWOVI0YdWp`r@72hq;#YIu(tYL+_N7t^b z<~B}IVw7_X%PwTz4PYTugFy-|MKSL)nGipB=B3wO|0)GOlcrV?85RMJT}8 z-^+RaRbVT4IQTlez1aC*2Sh(V0K)5k1pF~L0Dc#I1OELUa09py>;S($6aRqVKZ7g5 zeS!G-yBs_L$T|DF!SjHetv?2Q0zUjWxDb379{Wyk1K1571O6VK`5oXW*bIc9{t^7~ zz2JplC3p+`@6*8lf*wMXd7;bymyhq;!Se&LJm(Gvt>XwJx^$EDj*6Uj2R{$%(FcuS z?xgI`;JU;*`Ejc`tGKyqGI=w=tHh*Ufh)&{sb>n4vX{*A>R^)EYk2C@sEBH>QP|84 z9OCg}d%xb0t2s_V5vE>YO-vGE8fSI1*d=iNwZ5}52BY?)OKVzFbe7F)vR_^$cNopP zQx+;i%v|=%%186qr+P}KuD(oZQX6qm=bR0h6SpO6v(h%yPSusVkYl=)E;ZwyB)tt7 z;-r1ddz|!;Ooayp7+C8}Ech8wTN~UCnUFMOx66#}7fRQ>io8k6%8tIB3Z$PG5z70iiN zb}k_4+zK@?^-OW}WOY2qdli2)fTf*B`!NhkQs z`I)8Z0BYuI!9*e|pr-%48LgH6_W$4@93ymV-2e zqm|qcZ;O&i!GBK*OE-cmUs}U_=~8EX>Tk}DoKwwDx=vb_NC$v39B>LNOGd8Z0HfVB zmM*6q8QCQ2+PLpFV|>ZX{QKvZ3@l1DNI<&FPF;M!R5=}9c7&<0In_p)dzq!zP1ziW z&dZJwH;~ONJM>J{Y{9Gdo6C+7; Date: Tue, 1 Mar 2016 19:45:55 +0000 Subject: [PATCH 08/16] adds tests and fixes some broken code to main language mr --- app/models/project.rb | 6 +++--- spec/models/project_spec.rb | 8 ++++++++ spec/models/repository_spec.rb | 6 ++++++ 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 From 4b3f3167a4d7f1b1415052e350bc1f79ef5528dc Mon Sep 17 00:00:00 2001 From: tiagonbotelho Date: Wed, 2 Mar 2016 12:55:01 +0000 Subject: [PATCH 09/16] implements test to simulate empty repo --- spec/models/repository_spec.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index 2094667565e..150422ac349 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -600,5 +600,11 @@ describe Repository, models: true do it 'shows the main language of the project' do expect(repository.main_language).to eq("Ruby") end + + it 'returns nil when the repository is empty' do + allow(repository).to receive(:empty?).and_return(true) + + expect(repository.main_language).to be_nil + end end end From 93fb4ce2c5f9c7db40a0ab698cd4812a5cb7373b Mon Sep 17 00:00:00 2001 From: tiagonbotelho Date: Wed, 2 Mar 2016 13:01:00 +0000 Subject: [PATCH 10/16] removes redundant self --- app/models/project.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/project.rb b/app/models/project.rb index 470fa2194de..a8731514b9f 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 self.commit_count_changed? + if commit_count_changed? self.main_language = repository.main_language end end From 68d6f5bce19bac95e63de165f3e9597273ef97b1 Mon Sep 17 00:00:00 2001 From: tiagonbotelho Date: Wed, 2 Mar 2016 13:06:21 +0000 Subject: [PATCH 11/16] fixes typo --- app/models/project.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/project.rb b/app/models/project.rb index a8731514b9f..34787f5fa3c 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -90,7 +90,7 @@ class Project < ActiveRecord::Base before_save :check_main_language def check_main_language if commit_count_changed? - self.main_language = repository.main_language + main_language = repository.main_language end end From 337cb45226cfc4955fdd79a15088522a91058b3c Mon Sep 17 00:00:00 2001 From: tiagonbotelho Date: Wed, 2 Mar 2016 18:21:53 +0000 Subject: [PATCH 12/16] removes automatic setting of main_language to project for it to set a main language you have now to make a commit to the project --- app/models/project.rb | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/app/models/project.rb b/app/models/project.rb index 34787f5fa3c..137fa42a9b9 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -953,14 +953,4 @@ class Project < ActiveRecord::Base def wiki @wiki ||= ProjectWiki.new(self, self.owner) end - - def main_language - language = read_attribute(:main_language) - - return language if language - - update_attributes(main_language: repository.main_language) - - read_attribute(:main_language) - end end From 8039bbf7f8e686bdf1e8c00c44faa8a97a6c6fdb Mon Sep 17 00:00:00 2001 From: tiagonbotelho Date: Wed, 2 Mar 2016 18:23:11 +0000 Subject: [PATCH 13/16] removes the test file of the project spec for invalid method --- spec/models/project_spec.rb | 8 -------- 1 file changed, 8 deletions(-) diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 60b0f55b31d..f9842d23afa 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -560,14 +560,6 @@ 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 } From 96c02551070a5f2d90beea7068fc6fddbf1498e8 Mon Sep 17 00:00:00 2001 From: tiagonbotelho Date: Thu, 3 Mar 2016 10:51:48 +0000 Subject: [PATCH 14/16] moves the main_language update logic to git push service --- app/models/project.rb | 8 -------- app/services/git_push_service.rb | 12 ++++++++++++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/app/models/project.rb b/app/models/project.rb index 137fa42a9b9..3235a1cee50 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -86,14 +86,6 @@ class Project < ActiveRecord::Base end end - # checks if the language main language of the project changed - before_save :check_main_language - def check_main_language - if commit_count_changed? - main_language = repository.main_language - end - end - ActsAsTaggableOn.strict_case_match = true acts_as_taggable_on :tags diff --git a/app/services/git_push_service.rb b/app/services/git_push_service.rb index 9ba200f7bde..ab883b6ef2c 100644 --- a/app/services/git_push_service.rb +++ b/app/services/git_push_service.rb @@ -14,6 +14,7 @@ class GitPushService < BaseService # 3. Recognizes cross-references from commit messages # 4. Executes the project's web hooks # 5. Executes the project's services + # 6. Checks if the project's main language has changed # def execute @project.repository.after_push_commit(branch_name) @@ -42,6 +43,9 @@ class GitPushService < BaseService @push_commits = @project.repository.commits_between(params[:oldrev], params[:newrev]) process_commit_messages end + # Checks if the main language has changed in the project and if so + # it updates it accordingly + update_main_language # Update merge requests that may be affected by this push. A new branch # could cause the last commit of a merge request to change. update_merge_requests @@ -49,6 +53,14 @@ class GitPushService < BaseService protected + def update_main_language + current_language = @project.repository.main_language + + unless current_language == @project.main_language + @project.update_attributes(main_language: current_language) + end + end + def update_merge_requests @project.update_merge_requests(params[:oldrev], params[:newrev], params[:ref], current_user) From 4e8a5343972e179022ff84954475a6aa0f8901f8 Mon Sep 17 00:00:00 2001 From: tiagonbotelho Date: Thu, 3 Mar 2016 11:06:37 +0000 Subject: [PATCH 15/16] add my mr to changelog --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index a8dc00ed814..5b3b18ef2dc 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -15,6 +15,7 @@ v 8.6.0 (unreleased) - Don't show Issues/MRs from archived projects in Groups view - Increase the notes polling timeout over time (Roberto Dip) - Show labels in dashboard and group milestone views + - Add main language of a project in the list of projects (Tiago Botelho) v 8.5.4 - Do not cache requests for badges (including builds badge) From 49295924586d89eaff899a4efc83a336148f3862 Mon Sep 17 00:00:00 2001 From: tiagonbotelho Date: Thu, 3 Mar 2016 15:40:05 +0000 Subject: [PATCH 16/16] adds test for git push service for updating the language of the project --- app/services/git_push_service.rb | 8 +++++--- spec/services/git_push_service_spec.rb | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/app/services/git_push_service.rb b/app/services/git_push_service.rb index ab883b6ef2c..736b82e3571 100644 --- a/app/services/git_push_service.rb +++ b/app/services/git_push_service.rb @@ -51,16 +51,18 @@ class GitPushService < BaseService update_merge_requests end - protected - def update_main_language current_language = @project.repository.main_language unless current_language == @project.main_language - @project.update_attributes(main_language: current_language) + return @project.update_attributes(main_language: current_language) end + + true end + protected + def update_merge_requests @project.update_merge_requests(params[:oldrev], params[:newrev], params[:ref], current_user) diff --git a/spec/services/git_push_service_spec.rb b/spec/services/git_push_service_spec.rb index 994585fb32c..f5c51e46e8b 100644 --- a/spec/services/git_push_service_spec.rb +++ b/spec/services/git_push_service_spec.rb @@ -155,6 +155,23 @@ describe GitPushService, services: true do end end + describe "Updates main language" do + + context "before push" do + it { expect(project.main_language).to eq(nil) } + end + + context "after push" do + before do + @service = execute_service(project, user, @oldrev, @newrev, @ref) + end + + it { expect(@service.update_main_language).to eq(true) } + it { expect(project.main_language).to eq("Ruby") } + end + end + + describe "Web Hooks" do context "execute web hooks" do it "when pushing a branch for the first time" do