Fix old version warning when viewing wiki latest version via version_id
This commit is contained in:
		
							parent
							
								
									b4b41b4ca6
								
							
						
					
					
						commit
						aa30088f6e
					
				| 
						 | 
					@ -110,7 +110,7 @@ class WikiPage
 | 
				
			||||||
  # Returns boolean True or False if this instance
 | 
					  # Returns boolean True or False if this instance
 | 
				
			||||||
  # is an old version of the page.
 | 
					  # is an old version of the page.
 | 
				
			||||||
  def historical?
 | 
					  def historical?
 | 
				
			||||||
    @page.historical?
 | 
					    @page.historical? && versions.first.sha != version.sha
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  # Returns boolean True or False if this instance
 | 
					  # Returns boolean True or False if this instance
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -189,6 +189,38 @@ describe WikiPage, models: true do
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  describe '#historical?' do
 | 
				
			||||||
 | 
					    before do
 | 
				
			||||||
 | 
					      create_page('Update', 'content')
 | 
				
			||||||
 | 
					      @page = wiki.find_page('Update')
 | 
				
			||||||
 | 
					      3.times { |i| @page.update("content #{i}") }
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    after do
 | 
				
			||||||
 | 
					      destroy_page('Update')
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    it 'returns true when requesting an old version' do
 | 
				
			||||||
 | 
					      old_version = @page.versions.last.to_s
 | 
				
			||||||
 | 
					      old_page = wiki.find_page('Update', old_version)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      expect(old_page.historical?).to eq true
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    it 'returns false when requesting latest version' do
 | 
				
			||||||
 | 
					      latest_version = @page.versions.first.to_s
 | 
				
			||||||
 | 
					      latest_page = wiki.find_page('Update', latest_version)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      expect(latest_page.historical?).to eq false
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    it 'returns false when version is nil' do
 | 
				
			||||||
 | 
					      latest_page = wiki.find_page('Update', nil)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      expect(latest_page.historical?).to eq false
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  private
 | 
					  private
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def remove_temp_repo(path)
 | 
					  def remove_temp_repo(path)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue