add_put_and_post_test.patch

Mizuki ISHIKAWA, 2018-11-28 06:31

Download (2.34 KB)

View differences:

test/fixtures/versions.yml
19 19
  effective_date: <%= 20.day.from_now.to_date.to_s(:db) %>
20 20
  status: locked
21 21
  sharing: 'none'
22
  wiki_page_title: ECookBookV1
22 23
versions_003: 
23 24
  created_on: 2006-07-19 21:00:33 +02:00
24 25
  name: "2.0"
test/integration/api_test/versions_test.rb
69 69
    assert_select 'version id', :text => version.id.to_s
70 70
  end
71 71

  
72
  test "POST /projects/:project_id/versions.xml should create the version with wiki page title" do
73
    assert_difference 'Version.count' do
74
      post '/projects/1/versions.xml',
75
        :params => {:version => {:name => 'API test', :wiki_page_title => WikiPage.first.title}},
76
        :headers => credentials('jsmith')
77
    end
78

  
79
    version = Version.order('id DESC').first
80
    assert_equal 'API test', version.name
81
    assert_equal WikiPage.first, version.wiki_page
82

  
83
    assert_response :created
84
    assert_equal 'application/xml', @response.content_type
85
    assert_select 'version id', :text => version.id.to_s
86
  end
87

  
72 88
  test "POST /projects/:project_id/versions.xml should create the version with custom fields" do
73 89
    field = VersionCustomField.generate!
74 90

  
......
114 130
      assert_select 'id', :text => '2'
115 131
      assert_select 'name', :text => '1.0'
116 132
      assert_select 'sharing', :text => 'none'
133
      assert_select 'wiki_page_title', :text => 'ECookBookV1'
117 134
    end
118 135
  end
119 136

  
120 137
  test "PUT /versions/:id.xml should update the version" do
121 138
    put '/versions/2.xml',
122
      :params => {:version => {:name => 'API update'}},
139
      :params => {:version => {:name => 'API update', :wiki_page_title => WikiPage.first.title}},
123 140
      :headers => credentials('jsmith')
124 141

  
125 142
    assert_response :ok
126 143
    assert_equal '', @response.body
127 144
    assert_equal 'API update', Version.find(2).name
145
    assert_equal WikiPage.first, Version.find(2).wiki_page
128 146
  end
129 147

  
130 148
  test "DELETE /versions/:id.xml should destroy the version" do