confluencer 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.4
1
+ 0.2.5
data/confluencer.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{confluencer}
8
- s.version = "0.2.4"
8
+ s.version = "0.2.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Gabor Ratky"]
@@ -13,14 +13,26 @@ module Confluence
13
13
  end
14
14
 
15
15
  def store
16
- # check for existing page
17
- existing_page = Page.find_by_id(page_id)
18
-
19
- # take version from existing page if available
20
- self.version = existing_page.version if existing_page
16
+ unless self.version
17
+ # check for existing page by id or title
18
+ existing_page = if page_id
19
+ Page.find_by_id(page_id)
20
+ else
21
+ Page.find_by_title(space, title)
22
+ end
23
+
24
+ # take page_id and version from existing page if available
25
+ if existing_page
26
+ self.page_id = existing_page.page_id
27
+ self.version = existing_page.version
28
+ end
29
+ end
21
30
 
22
31
  # reinitialize page after storing it
23
32
  initialize(client.storePage(attributes))
33
+
34
+ # return self
35
+ self
24
36
  end
25
37
 
26
38
  def remove
@@ -3,8 +3,14 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
3
3
  module PageHelperMethods
4
4
  include SessionHelperMethods
5
5
 
6
- def create_test_page
7
- Confluence::Page.new :space => config[:space], :title => config[:page_title], :content => "foobar"
6
+ def create_test_page(content = "foobar")
7
+ Confluence::Page.new :space => config[:space], :title => config[:page_title], :content => content
8
+ end
9
+
10
+ def store_test_page
11
+ new_session do
12
+ return create_test_page.store
13
+ end
8
14
  end
9
15
  end
10
16
 
@@ -50,22 +56,14 @@ describe Confluence::Page do
50
56
  end
51
57
  end
52
58
 
53
- it "should update an existing page in Confluence" do
54
- page = nil
55
-
56
- new_session do
57
- # initialize test page
58
- page = create_test_page
59
-
60
- # store page
61
- page.store
62
- end
59
+ it "should update an existing page in Confluence by id" do
60
+ page = store_test_page
63
61
 
64
62
  new_session do
65
63
  # create test page with same id but updated content
66
- updated_page = create_test_page
64
+ updated_page = create_test_page "updated content"
65
+
67
66
  updated_page.page_id = page.page_id
68
- updated_page.content = "updated content"
69
67
 
70
68
  # store page
71
69
  updated_page.store
@@ -75,4 +73,24 @@ describe Confluence::Page do
75
73
  updated_page.content.should == "updated content"
76
74
  end
77
75
  end
76
+
77
+ it "should update an existing page in Confluence by space and title" do
78
+ page = store_test_page
79
+
80
+ new_session do
81
+ # create test page with same title but updated content
82
+ updated_page = create_test_page "updated content"
83
+
84
+ updated_page.page_id.should be_nil
85
+ updated_page.title.should == page.title
86
+ updated_page.space.should == page.space
87
+
88
+ # store page
89
+ updated_page.store
90
+
91
+ # assert version
92
+ updated_page.version.should > page.version
93
+ updated_page.content.should == "updated content"
94
+ end
95
+ end
78
96
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 4
9
- version: 0.2.4
8
+ - 5
9
+ version: 0.2.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - Gabor Ratky