diff --git a/app/models/warpable.rb b/app/models/warpable.rb index a044b1149..cb5da2182 100755 --- a/app/models/warpable.rb +++ b/app/models/warpable.rb @@ -63,14 +63,6 @@ def placed? !self.width.nil? && self.nodes != '' end - ######################################################## - # this is for migration to paperclip only; remove later! - # Returns true/false if an attachment is thumbnailable. A thumbnailable attachment has an image content type and the parent_id attribute. - def thumbnailable? - !self.image.nil? && self.parent_id.nil? - end - ######################################################## - def poly_area area = 0 nodes = self.nodes_array diff --git a/test/fixtures/demo.png b/test/fixtures/demo.png new file mode 100644 index 000000000..3c94776ba Binary files /dev/null and b/test/fixtures/demo.png differ diff --git a/test/fixtures/nodes.yml b/test/fixtures/nodes.yml index 5bf02933a..3759b4cee 100644 --- a/test/fixtures/nodes.yml +++ b/test/fixtures/nodes.yml @@ -1,7 +1,58 @@ # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html -# one: -# column: value -# -# two: -# column: value +one: + id: 1 + color: "black" + author: "anonymous" + lat: 41.8403113680142 + lon: -71.3983854668186 + way_id: 0 + order: 0 + name: "" + description: "" + map_id: 1 + way_order: 0 + body: nil + +two: + id: 2 + color: "black" + author: "anonymous" + lat: 41.8397358653566 + lon: -71.3916477577732 + way_id: 0 + order: 0 + name: "" + description: "" + map_id: 1 + way_order: 0 + body: nil + +three: + id: 3 + color: "black" + author: "anonymous" + lat: 41.8351476451765 + lon: -71.392699183707 + way_id: 0 + order: 0 + name: "" + description: "" + map_id: 1 + way_order: 0 + body: nil + +four: + id: 4 + color: "black" + author: "anonymous" + lat: 41.8377535388085 + lon: -71.3981708900974 + way_id: 0 + order: 0 + name: "" + description: "" + map_id: 1 + way_order: 0 + body: nil + diff --git a/test/fixtures/warpables.yml b/test/fixtures/warpables.yml index 5bf02933a..f73760bfc 100644 --- a/test/fixtures/warpables.yml +++ b/test/fixtures/warpables.yml @@ -1,7 +1,18 @@ # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html -# one: -# column: value -# -# two: -# column: value +one: + id: 1 + parent_id: nil + image_content_type: "image/png" + image_file_name: "demo.png" + thumbnail: nil + image_file_size: 574286 + width: 756 + height: 392 + history: '' + map_id: 1 + nodes: "1,2,3,4" + locked: false + deleted: false + cm_per_pixel: 99.86133660017036> + diff --git a/test/unit/warpable_test.rb b/test/unit/warpable_test.rb new file mode 100644 index 000000000..481f62dca --- /dev/null +++ b/test/unit/warpable_test.rb @@ -0,0 +1,39 @@ +require 'test_helper' + +class WarpableTest < ActiveSupport::TestCase + test "basics" do + w = warpables(:one) + assert_not_nil w.as_json + assert_not_nil w.fup_json + assert_not_nil w.fup_error_json + assert_not_nil w.placed? + assert w.placed? + assert !Warpable.new.placed? + assert_not_nil w.poly_area + assert_not_nil w.get_cm_per_pixel + + assert_not_nil Warpable.histogram_cm_per_pixel + assert_not_nil w.nodes + assert_not_nil w.nodes_array + assert_equal 4, w.nodes_array.length + + # TODO: test with local image? + #assert_not_nil w.url() + end + + test "try export" do + system('mkdir -p public/system/images/1/original') + system('cp test/fixtures/demo.png public/system/images/1/original/') + system('mkdir -p public/warps/saugus-landfill-incinerator') + system('touch public/warps/saugus-landfill-incinerator/folder') + assert File.exist?('public/warps/saugus-landfill-incinerator/folder') + w = warpables(:one) + assert_not_nil w.save_dimensions + assert_not_nil w.generate_perspectival_distort(10, w.map.slug) + assert_not_nil w.delete_temp_files(w.map.slug) + assert_not_nil w.working_directory(w.map.slug) + assert_not_nil w.warps_directory(w.map.slug) + assert_not_nil w.user_id + assert File.exist?('public/warps/saugus-landfill-incinerator/1-geo.tif') + end +end