Sha256: 8068ce3ef6886c897901e42243de7c2eabe68671bd6543faa4485a1d20331181

Contents?: true

Size: 1.56 KB

Versions: 3

Compression:

Stored size: 1.56 KB

Contents

require "spec_helper"

describe "Image crop with JS", :js => true do

  it "crops an image with javascript" do
    visit landscapes_path

    click_link "New Landscape"

    fill_in "Name", :with => "Mountains"
    find("#landscape_picture").native.send_keys(File.expand_path("../../../test_app/test/fixtures/matterhorn.jpg", __FILE__))
    click_button "Create Landscape"

    sleep 2
    page.execute_script("jcrop_api.setSelect([300, 200, 700, 500])")
    page.execute_script('if ($("#picture_crop_y").val() == "199"){$("#picture_crop_y").val("200")}')
    page.execute_script('if ($("#picture_crop_w").val() == "399"){$("#picture_crop_w").val("400")}')

    click_button "Crop image"

    sleep 1
    compare_images(CROPPED_IMG_PATH, Landscape.last.picture.path(:medium)).should eq(0.0)
  end


  it "crops an image by ajax call" do
    visit landscapes_path

    click_link "New Landscape"

    fill_in "Name", :with => "Mountains"
    find("#landscape_picture").native.send_keys(File.expand_path("../../../test_app/test/fixtures/matterhorn.jpg", __FILE__))
    click_button "Create Landscape"

    click_button "Crop image"
    click_link "Back"

    click_link "Crop"

    sleep 2
    page.execute_script("jcrop_api.setSelect([300, 200, 700, 500])")
    page.execute_script('if ($("#picture_crop_y").val() == "199"){$("#picture_crop_y").val("200")}')
    page.execute_script('if ($("#picture_crop_w").val() == "399"){$("#picture_crop_w").val("400")}')

    click_button "Crop image"

    sleep 1
    compare_images(CROPPED_IMG_PATH, Landscape.last.picture.path(:medium)).should eq(0.0)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
papercrop-0.1.1 spec/integration/papercrop_js_spec.rb
papercrop-0.1.0 spec/integration/papercrop_js_spec.rb
papercrop-0.0.7 spec/integration/papercrop_js_spec.rb