     view.installButton.click()
     expect(@packageManager.install).toHaveBeenCalled()
 
-  it "can be installed if currently not installed and package engine match atom version", ->
+  it "can be installed if currently not installed and package latest release engine match atom version", ->
+    @packageManager.requestPackage.andCallFake (packageName, callback) ->
+      pack =
+        name: packageName
+        releases:
+          latest: '0.1.0'
+        versions:
+          '0.0.1':
+            name: packageName
+            version: '0.0.1'
+            engines:
+              atom: '>0.0.0'
+          '0.1.0':
+            name: packageName
+            version: '0.1.0'
+            engines:
+              atom: '>0.50.0'
+
+      callback(null, pack)
+
     setPackageStatusSpies {installed: false, disabled: false}
 
     view = new AvailablePackageView {
       name: 'test-package'
+      version: '0.1.0'
       engines:
         atom: '>0.50.0'
     }, @packageManager
-    
+
     expect(view.installButton.css('display')).not.toBe('none')
     expect(view.uninstallButton.css('display')).toBe('none')
     view.installButton.click()
     expect(@packageManager.install).toHaveBeenCalled()
+    expect(@packageManager.install.mostRecentCall.args[0]).toEqual({
+      name: 'test-package'
+      version: '0.1.0'
+      engines:
+        atom: '>0.50.0'
+    })
 
-  it "can't be installed if the atom version doesn't match the package engine version", ->
+  it "can be installed with a previous version whose engine match the current atom version", ->
+    @packageManager.requestPackage.andCallFake (packageName, callback) ->
+      pack =
+        name: packageName
+        releases:
+          latest: '0.1.0'
+        versions:
+          '0.0.1':
+            name: packageName
+            version: '0.0.1'
+            engines:
+              atom: '>0.50.0'
+          '0.1.0':
+            name: packageName
+            version: '0.0.1'
+            engines:
+              atom: '>99.0.0'
+
+      callback(null, pack)
+
+    setPackageStatusSpies {installed: false, disabled: false}
+
+    view = new AvailablePackageView {
+      name: 'test-package'
+      version: '0.1.0'
+      engines:
+        atom: '>99.0.0'
+    }, @packageManager
+
+    expect(view.installButton.css('display')).not.toBe('none')
+    expect(view.uninstallButton.css('display')).toBe('none')
+    view.installButton.click()
+    expect(@packageManager.install).toHaveBeenCalled()
+    expect(@packageManager.install.mostRecentCall.args[0]).toEqual({
+      name: 'test-package'
+      version: '0.0.1'
+      engines:
+        atom: '>0.50.0'
+    })
+
+  it "can't be installed if there is no version compatible with the current atom version", ->
+    @packageManager.requestPackage.andCallFake (packageName, callback) ->
+      pack =
+        name: packageName
+        releases:
+          latest: '0.1.0'
+        versions:
+          '0.1.0':
+            engines:
+              atom: '>99.0.0'
+
+      callback(null, pack)
+
     setPackageStatusSpies {installed: false, disabled: false}
 
     view = new AvailablePackageView {


    expect(view.installButton.css('display')).toBe('none')
    expect(view.uninstallButton.css('display')).toBe('none')



  beforeEach ->
    @packageManager = jasmine.createSpyObj('packageManager', ['on', 'getClient', 'emit', 'install', 'uninstall', 'requestPackage', 'getLatestCompatibleVersion'])
    @packageManager.getLatestCompatibleVersion.andCallFake ->
      PackageManager.prototype.getLatestCompatibleVersion(arguments...)
    @packageManager.getClient.andCallFake -> jasmine.createSpyObj('client', ['avatar', 'package'])
    @packageManager.requestPackage.andCallFake (packageName, callback) ->
      pack =
        name: packageName
        releases:
          latest: '0.1.0'
        versions:
          '0.1.0':
            engines:
              atom: '>0.50.0'

      callback(null, pack)

  it "doesn't show the disable control for a theme", ->
    setPackageStatusSpies {installed: true, disabled: false}
