koppen/redmine_github_hook — pull request #58 by tofi86 (2014-07-12 17:48:00+00:00)
Title: Feature/update repo from url param

Second try to fix #54 *("long processing for POST payload from github")*

As I still don't know any rails unit testing this pull request unfortunately comes without any additional tests. Maybe you can have a look...

However, I tested on Redmine installation and it works well!

New webhook url must have the form `[redmine_url]/github_hook?project_id=[identifier]&repo_id=[repository]`

----

This is my live test with a wrong `repo_id` parameter which isn't in the list of `gittest` project repositories
```
Started POST "/github_hook?project_id=gittest&repo_id=wrong-repo-id" for 192.30.252.44 at 2014-07-12 19:36:41 +0200
Processing by GithubHookController#index as */*
Parameters: {"project_id"=>"gittest", "repo_id"=>"wrong-repo-id", "payload"=>"{.........}"}
Current user: anonymous
GithubHook: The repository 'wrong-repo-id' isn't in the list of projects repos. Updating all repos instead.
GithubHook: Redmine repository updated: redmine-test-repo (Git: 4812.8ms, Redmine: 407.4ms)
GithubHook: Redmine repository updated: redminetest (Git: 3314.4ms, Redmine: 49.0ms)
Rendered text template (0.0ms)
Completed 200 OK in 8735.5ms (Views: 105.1ms | ActiveRecord: 241.3ms)
```
As the `wrong-repo-id` repository doesn't exist in the list of `gittest` project repositories, ALL (two) repositories of the project `gittest` are updated.

And this is my live test with a correct `repo_id` parameter, a repo which is in the list of `gittest` project repositories:
```
Started POST "/github_hook?project_id=gittest&repo_id=redmine-test-repo" for 192.30.252.38 at 2014-07-12 19:37:47 +0200
Processing by GithubHookController#index as */*
Parameters: {"project_id"=>"gittest", "repo_id"=>"redmine-test-repo", "payload"=>"{.........}"}
Current user: anonymous
GithubHook: Redmine repository updated: redmine-test-repo (Git: 5076.1ms, Redmine: 170.1ms)
Rendered text template (0.0ms)
Completed 200 OK in 5256.0ms (Views: 1.1ms | ActiveRecord: 38.5ms)
```
This one only updates the repo specified in the url parameter.

----

I also added profiling time information for how long the fetch and redmine import commands have taken. Feel free to remove them again, but I think this piece of information is quite useful.