Skip to content

Commit

Permalink
カーソルのある entry property から issue id と updated_on を取得する関数を追加 #5
Browse files Browse the repository at this point in the history
  • Loading branch information
gongo committed Jul 20, 2011
1 parent d973886 commit db2042c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
18 changes: 16 additions & 2 deletions org-redmine.el
Expand Up @@ -35,6 +35,8 @@ default is 25, maximum is 100.
see http://www.redmine.org/projects/redmine/wiki/Rest_api#Collection-resources-and-pagination")

(defconst org-redmine-property-id-name "issue_id")
(defconst org-redmine-property-updated-name "updated_on")
(defconst org-redmine-template-header-default "#%i% %s% :%t_n%:")
(defconst org-redmine-template-%-sequences
'(("%as_i%" "assigned_to" "id")
Expand Down Expand Up @@ -274,6 +276,18 @@ Example.
(org-redmine-issue-uri issue) ;; => \"http://localhost/redmine/issues/1\""
(format "%s/issues/%s" org-redmine-uri (orutil-gethash issue "id")))

;;------------------------------
;; org-redmine emtry function
;;------------------------------
(defun org-redmine-entry-get-update-info ()
"Get property values that necessary to issue update.
Return cons (issue_id . updated_on)"
(let ((properties (org-entry-properties)))
(cons
(cdr (assoc org-redmine-property-id-name properties))
(cdr (assoc org-redmine-property-updated-name properties)))))

;;------------------------------
;; org-redmine buffer function
;;------------------------------
Expand Down Expand Up @@ -301,8 +315,8 @@ Example.
(nth 1 org-redmine-template-set)
'()))
property key value)
(org-set-property "issue_id" (int-to-string (orutil-gethash issue "id")))
(org-set-property "updated_on" (orutil-gethash issue "updated_on"))
(org-set-property org-redmine-property-id-name (int-to-string (orutil-gethash issue "id")))
(org-set-property org-redmine-property-updated-name (orutil-gethash issue "updated_on"))
(while properties
(setq property (car properties))
(org-set-property (car property)
Expand Down
11 changes: 10 additions & 1 deletion test/org-redmine-test.el
@@ -1,7 +1,7 @@
(require 'org-redmine)

;; setup
(require 'org-redmine-test-fixture)
(load-file "./org-redmine-test-fixture.el")

;; batch 処理の時に、message 関数が端末に出力されるのがいやだったので wrap した
(when noninteractive
Expand Down Expand Up @@ -288,4 +288,13 @@
(let ((d1 "2011/07/06 21:22:01 -0900")
(d2 "2011/07/06 21:22:01 +0900"))
(orutil-date-cmp d1 d2)))

(desc "org-redmine-entry-get-update-info")
(expect '("1" . "2011/07/06 21:27:04 +0900")
(stub org-redmine-curl-get => fixture-issue-json)
(with-current-buffer (exps-tmpbuf)
(change-buffer-to 'org-mode)
(change-buffer-to 'org-mode)
(org-redmine-get-issue "1")
(org-redmine-entry-get-update-info)))
)
1 change: 0 additions & 1 deletion test/run.sh
Expand Up @@ -12,7 +12,6 @@ OUTPUT=aaa
$EMACS -q --no-site-file --batch $OPTIONS \
-l org-redmine \
-l el-expectations \
-l el-mock \
-f batch-expectations $OUTPUT org-redmine-test.el
ret=$?
cat $OUTPUT
Expand Down

0 comments on commit db2042c

Please sign in to comment.