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

adds test for git push service for updating the language of the project

parent 4e8a5343
...@@ -51,16 +51,18 @@ class GitPushService < BaseService ...@@ -51,16 +51,18 @@ class GitPushService < BaseService
update_merge_requests update_merge_requests
end end
protected
def update_main_language def update_main_language
current_language = @project.repository.main_language current_language = @project.repository.main_language
unless current_language == @project.main_language unless current_language == @project.main_language
@project.update_attributes(main_language: current_language) return @project.update_attributes(main_language: current_language)
end end
true
end end
protected
def update_merge_requests def update_merge_requests
@project.update_merge_requests(params[:oldrev], params[:newrev], params[:ref], current_user) @project.update_merge_requests(params[:oldrev], params[:newrev], params[:ref], current_user)
......
...@@ -155,6 +155,23 @@ describe GitPushService, services: true do ...@@ -155,6 +155,23 @@ describe GitPushService, services: true do
end end
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 describe "Web Hooks" do
context "execute web hooks" do context "execute web hooks" do
it "when pushing a branch for the first time" do it "when pushing a branch for the first time" do
......
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