From 90c20f76d5b91e8edde24476630af2fbed29ddbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Dur=C3=A1n=20Roca?= Date: Wed, 4 Sep 2019 18:34:43 +0200 Subject: [PATCH 01/20] Codeclimate - Ignore lib files (#150) Ignored ThreeJS loaders and helpers which are used in the 3D viewer --- .codeclimate.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.codeclimate.yml b/.codeclimate.yml index 8a39dff..10f74ac 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -3,4 +3,8 @@ exclude_patterns: - "public/js/PLYLoader.js" - "public/js/STLLoader.js" - "public/js/three.min.js" +- "public/js/OBJLoader.js" +- "public/js/OBJLoader2.js" +- "public/js/LoaderSupport.js" +- "public/js/OutlinePass.js" - "db" From 8f4546f02bdda3e4793f7030e0c70d9305491f07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Dur=C3=A1n=20Roca?= Date: Wed, 4 Sep 2019 18:56:41 +0200 Subject: [PATCH 02/20] RestoredObject - View - Removed sort sentence (#151) --- app/views/restored_objects/index.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/restored_objects/index.html.erb b/app/views/restored_objects/index.html.erb index d565077..bf6c7e5 100644 --- a/app/views/restored_objects/index.html.erb +++ b/app/views/restored_objects/index.html.erb @@ -52,7 +52,7 @@
- <% @objects.sort[3..-1].each_with_index do |obj, index| %> + <% @objects.each_with_index do |obj, index| %>
<%= link_to image_tag(obj.featured_image, class:'card-img-top'), obj %>
From ea0e40d263da60fb72243b7d037316c73365b7c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Dur=C3=A1n=20Roca?= Date: Wed, 4 Sep 2019 19:04:45 +0200 Subject: [PATCH 03/20] Codeclimate - Updated .codecliamte file with more ignored files (#152) --- .codeclimate.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.codeclimate.yml b/.codeclimate.yml index 10f74ac..17c7963 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -7,4 +7,6 @@ exclude_patterns: - "public/js/OBJLoader2.js" - "public/js/LoaderSupport.js" - "public/js/OutlinePass.js" +- "public/js/MTLLoader.js" +- "public/js/EffectComposer.js" - "db" From 97dbc7bdfee803a8e19300d4f155b4541110807e Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 4 Sep 2019 19:07:48 +0200 Subject: [PATCH 04/20] [Security] Bump nokogiri from 1.10.3 to 1.10.4 (#141) Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.10.3 to 1.10.4. **This update includes a security fix.** - [Release notes](https://github.com/sparklemotion/nokogiri/releases) - [Changelog](https://github.com/sparklemotion/nokogiri/blob/master/CHANGELOG.md) - [Commits](https://github.com/sparklemotion/nokogiri/compare/v1.10.3...v1.10.4) Signed-off-by: dependabot-preview[bot] --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 07cf239..052e5a9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -154,9 +154,9 @@ GEM minitest (5.11.3) multi_json (1.13.1) nio4r (2.4.0) - nokogiri (1.10.3) + nokogiri (1.10.4) mini_portile2 (~> 2.4.0) - nokogiri (1.10.3-x86-mingw32) + nokogiri (1.10.4-x86-mingw32) mini_portile2 (~> 2.4.0) orm_adapter (0.5.0) pg (1.1.4) From 3da7f9157e203658371903d9511fa73859acfe7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Dur=C3=A1n=20Roca?= Date: Wed, 4 Sep 2019 19:56:54 +0200 Subject: [PATCH 05/20] Travis - Updated Travis CI to Rails 2.4.0 (#153) * Travis - Updated Travis CI to Rails 2.4.0 * Travis - Updated Travis CI to Rails 2.4.4 * Travis - Updated Travis CI to Rails 2.5.0 * Travis - Post build scripts removed --- .travis.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3da92c0..2904984 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,9 +11,5 @@ before_install: env: - DB=postgresql -before_script: - - rails db:create - - rails db:migrate - rvm: - - 2.3.3 + - 2.5.0 From 82a68da9b2408f4720ec11ceb5382327f774283f Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 9 Sep 2019 19:12:50 +0200 Subject: [PATCH 06/20] Bump devise from 4.6.2 to 4.7.1 (#155) Bumps [devise](https://github.com/plataformatec/devise) from 4.6.2 to 4.7.1. - [Release notes](https://github.com/plataformatec/devise/releases) - [Changelog](https://github.com/plataformatec/devise/blob/master/CHANGELOG.md) - [Commits](https://github.com/plataformatec/devise/compare/v4.6.2...v4.7.1) Signed-off-by: dependabot-preview[bot] --- Gemfile.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 052e5a9..1a320b4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -99,10 +99,10 @@ GEM coffee-script-source (1.12.2) concurrent-ruby (1.1.5) crass (1.0.4) - devise (4.6.2) + devise (4.7.1) bcrypt (~> 3.0) orm_adapter (~> 0.1) - railties (>= 4.1.0, < 6.0) + railties (>= 4.1.0) responders warden (~> 1.2.3) devise-i18n (1.8.0) @@ -187,7 +187,7 @@ GEM rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) - rails-html-sanitizer (1.0.4) + rails-html-sanitizer (1.2.0) loofah (~> 2.2, >= 2.2.2) railties (5.2.3) actionpack (= 5.2.3) From 09ebd30e5858dcebe527b5cbe147763e76010680 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 9 Sep 2019 19:24:10 +0200 Subject: [PATCH 07/20] Bump devise-i18n from 1.8.0 to 1.8.1 (#138) Bumps [devise-i18n](https://github.com/tigrish/devise-i18n) from 1.8.0 to 1.8.1. - [Release notes](https://github.com/tigrish/devise-i18n/releases) - [Changelog](https://github.com/tigrish/devise-i18n/blob/master/CHANGELOG.md) - [Commits](https://github.com/tigrish/devise-i18n/compare/v1.8.0...v1.8.1) Signed-off-by: dependabot-preview[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 1a320b4..14d075e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -105,7 +105,7 @@ GEM railties (>= 4.1.0) responders warden (~> 1.2.3) - devise-i18n (1.8.0) + devise-i18n (1.8.1) devise (>= 4.6) erubi (1.8.0) execjs (2.7.0) From d5d4b926c9d85a4f31d9515adde447d6a8d30fa7 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 9 Sep 2019 19:24:38 +0200 Subject: [PATCH 08/20] Bump bcrypt from `011b67b` to `2875dbf` (#145) Bumps [bcrypt](https://github.com/codahale/bcrypt-ruby) from `011b67b` to `2875dbf`. - [Release notes](https://github.com/codahale/bcrypt-ruby/releases) - [Commits](https://github.com/codahale/bcrypt-ruby/compare/011b67ba550457dab5d6084128888f08476f278a...2875dbf4359ef9ce88775f4aae67aaa011f930fa) Signed-off-by: dependabot-preview[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 14d075e..adead94 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,6 @@ GIT remote: https://github.com/codahale/bcrypt-ruby.git - revision: 011b67ba550457dab5d6084128888f08476f278a + revision: 2875dbf4359ef9ce88775f4aae67aaa011f930fa specs: bcrypt (3.1.13) From 78fd7a907a1bc5550f3a2ad3cb6d8328076c8158 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Dur=C3=A1n=20Roca?= Date: Wed, 18 Sep 2019 17:06:12 +0200 Subject: [PATCH 09/20] INDEX - Nil check needed. If there is not a featured museum in the bda it was crashing. (#159) --- app/views/home/index.html.erb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index 94c08b0..2ca5192 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -18,6 +18,7 @@
+<% if @featured_museum != nil %> <%= link_to @featured_museum, class: "no-decoration" do %>
+<% end %>
@@ -132,4 +134,4 @@ function render() { document.addEventListener("turbolinks:load", function() { render(); }); - \ No newline at end of file + From 74c712bb1ea9de846fe99e683993b98a295d3599 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Dur=C3=A1n=20Roca?= Date: Tue, 1 Oct 2019 18:31:23 +0200 Subject: [PATCH 10/20] Feature/badges generator (#165) * BADGES - Added test badge and app folder * BADGES - Basic badges generator file. Connected with the github API using https req * README - Readme comments tests and badges remove code * README - AUTOGENERATED README TEST * BADGES - Now update the contributors badge when execute the script * BADGES - Fix new line addition bug * BADGES - Added a new class and re-factored the scrip in several methods * BADGES - Added several options as global variables inside the class --- README.md | 29 +++++++++- badges/badgesGen.rb | 138 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 166 insertions(+), 1 deletion(-) create mode 100644 badges/badgesGen.rb diff --git a/README.md b/README.md index 3bbd8d5..aa8228b 100644 --- a/README.md +++ b/README.md @@ -3,4 +3,31 @@ [![Build Status](https://travis-ci.org/FragmentX/FRAGMENTX.svg?branch=master)](https://travis-ci.org/FragmentX/FRAGMENTX) [![Maintainability](https://api.codeclimate.com/v1/badges/900fd8a114c8d71e0142/maintainability)](https://codeclimate.com/github/FragmentX/FRAGMENTX/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/900fd8a114c8d71e0142/test_coverage)](https://codeclimate.com/github/FragmentX/FRAGMENTX/test_coverage) [![security](https://hakiri.io/github/FragmentX/FRAGMENTX/master.svg)](https://hakiri.io/github/FragmentX/FRAGMENTX/master) -http://scanviewer.herokuapp.com/ \ No newline at end of file +[//]: # (badges) +[![security](https://img.shields.io/badge/contributors-4-blue)](https://img.shields.io/badge/contributors-4-blue) + +[//]: # (badges) + + + + +http://scanviewer.herokuapp.com/ + +## Version + +#### Features + +#### Bugs + +#### Changes + +## Dependencies + +## Guide + +## References + +## Contributors + +[//]: # (contributors) + diff --git a/badges/badgesGen.rb b/badges/badgesGen.rb new file mode 100644 index 0000000..ef9fd81 --- /dev/null +++ b/badges/badgesGen.rb @@ -0,0 +1,138 @@ +require 'httparty' +require 'json' + +localhost_format = false +verbose_mode = false +write_post_stats = false + +ARGV.each do |command| + case command + when "-v" # Verbose mode + verbose_mode = true + when "-w" # Store POST request in localhost + write_post_stats = true + when "-l" # Localhost mode + localhost_format = true + end +end + +class BadgeGenerator + + @verbose_mode = false + @localhost_format = false + + def initialize verbose_mode_tmp, localhost_format_tmp + @verbose_mode = verbose_mode_tmp + @localhost_format = localhost_format_tmp + end + + def getGeneralInformation + return HTTParty.get('https://api.github.com/repos/FragmentX/FRAGMENTX').body + end + + def getStatsInformation + return HTTParty.get('https://api.github.com/repos/FragmentX/FRAGMENTX/stats/contributors').body + end + + def getGeneralInformationFromLocalhost(file_name = "test_G.json") + tmp_file_content = File.open(file_name, "r").read + return tmp_file_content + end + + def getStatsInformationFromLocalhost(file_name = "test_S.json") + tmp_file_content = File.open(file_name, "r").read + return tmp_file_content + end + + def saveGenInfoGetRequest(file_name = "test_G.json") + writeFile(file_name, getGeneralInformation) + end + + def saveStatInfoGetRequest(file_name = "test_S.json") + writeFile(file_name, getStatsInformation) + end + + def writeFile(file_name = "test.json", data) + file = File.open(file_name, "w") + file.puts data + file.close + end + + def readREADMEFile + tmp_file_content = File.open("../README.md", "r").read + return tmp_file_content + end + + def writeREADMEFile(data) + file = File.open("../README.md", "w") + file.puts data + file.close + end + + def getNumberofcontributors + if @localhost_format + return JSON.parse(getStatsInformationFromLocalhost)[0]['total'] + else + return JSON.parse(getStatsInformation)[0]['total'] + end + end + + def getContributorsBadge + number_of_contributors = getNumberofcontributors + return crateBadge "contributors", (number_of_contributors.to_s), "blue" + end + + def createContributorsSticker + contributors_badge_raw = getContributorsBadge + return crateReadmeSticker contributors_badge_raw + end + + def crateBadge label, message, color + return "https://img.shields.io/badge/" + label + "-" + message + "-" + color + end + + def crateReadmeSticker stickerURL, stickerLink = nil + if stickerLink.nil? + stickerLink = stickerURL + end + return "[![security](" + stickerURL + ")]("+ stickerLink +")" + end + + def createFixedStickerList + stickerList = createContributorsSticker + return stickerList + end + + def createFileStickerList + + end + + def createStickersList + return createFixedStickerList + end + + def createUpdateStickerText + sticker_list = createStickersList + return readREADMEFile.sub /\[\/\/\]: # \(badges\)(.|\n)*\[\/\/\]: # \(badges\)/, "[//]: # (badges)\n" + sticker_list + "\n\n[//]: # (badges)" + end + + def updateReadme + updated_readme_file = createUpdateStickerText + writeREADMEFile updated_readme_file + if @verbose_mode + puts updated_readme_file + end + end +end + +generator = BadgeGenerator. new false, localhost_format + +generator.updateReadme + +if write_post_stats + generator.getStatsInformationFromLocalhost + generator.saveGenInfoGetRequest +end + +#puts JSON.parse(getStatsInformationFromLocalhost)[1]['author'] + From 2884a314a3ae819a421026691f1648531c39df5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Dur=C3=A1n=20Roca?= Date: Wed, 2 Oct 2019 17:41:28 +0200 Subject: [PATCH 11/20] WIP: Features/add tests (#166) * Fixtures - Removed non used and bad implemented fixtures. Removed object_format which was not used in the application * TESTS - Configured two basic tests(model and controller) and create a travis job to execute the job * TEST - Added travis dba creation * TRAVIS - Added postgresql 9.6 to travis file --- .travis.yml | 7 +++++++ app/models/object_format.rb | 2 -- test/controllers/categories_controller_test.rb | 8 ++++++++ test/{fixtures => fixtures-back}/categories.yml | 0 .../categories_restored_objects.yml | 0 test/{fixtures => fixtures-back}/collections.yml | 0 .../collections_restored_objects.yml | 0 test/{fixtures => fixtures-back}/compositions.yml | 0 test/{fixtures => fixtures-back}/deteriorations.yml | 0 .../deteriorations_restored_objects.yml | 0 test/{fixtures => fixtures-back}/materials.yml | 0 test/{fixtures => fixtures-back}/pieces.yml | 0 test/{fixtures => fixtures-back}/priorities.yml | 0 test/{fixtures => fixtures-back}/protections.yml | 0 test/{fixtures => fixtures-back}/restored_objects.yml | 2 -- test/{fixtures => fixtures-back}/states.yml | 0 test/{fixtures => fixtures-back}/units.yml | 0 test/{fixtures => fixtures-back}/users.yml | 0 test/fixtures/object_formats.yml | 7 ------- test/models/material_test.rb | 8 ++++++++ 20 files changed, 23 insertions(+), 11 deletions(-) delete mode 100644 app/models/object_format.rb create mode 100644 test/controllers/categories_controller_test.rb rename test/{fixtures => fixtures-back}/categories.yml (100%) rename test/{fixtures => fixtures-back}/categories_restored_objects.yml (100%) rename test/{fixtures => fixtures-back}/collections.yml (100%) rename test/{fixtures => fixtures-back}/collections_restored_objects.yml (100%) rename test/{fixtures => fixtures-back}/compositions.yml (100%) rename test/{fixtures => fixtures-back}/deteriorations.yml (100%) rename test/{fixtures => fixtures-back}/deteriorations_restored_objects.yml (100%) rename test/{fixtures => fixtures-back}/materials.yml (100%) rename test/{fixtures => fixtures-back}/pieces.yml (100%) rename test/{fixtures => fixtures-back}/priorities.yml (100%) rename test/{fixtures => fixtures-back}/protections.yml (100%) rename test/{fixtures => fixtures-back}/restored_objects.yml (88%) rename test/{fixtures => fixtures-back}/states.yml (100%) rename test/{fixtures => fixtures-back}/units.yml (100%) rename test/{fixtures => fixtures-back}/users.yml (100%) delete mode 100644 test/fixtures/object_formats.yml create mode 100644 test/models/material_test.rb diff --git a/.travis.yml b/.travis.yml index 2904984..51f08eb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,6 @@ +addons: + postgresql: 9.6 + language: ruby os: linux @@ -11,5 +14,9 @@ before_install: env: - DB=postgresql +script: + - rails db:drop db:create db:migrate RAILS_ENV=test + - rails test + rvm: - 2.5.0 diff --git a/app/models/object_format.rb b/app/models/object_format.rb deleted file mode 100644 index 33293ad..0000000 --- a/app/models/object_format.rb +++ /dev/null @@ -1,2 +0,0 @@ -class ObjectFormat < ApplicationRecord -end diff --git a/test/controllers/categories_controller_test.rb b/test/controllers/categories_controller_test.rb new file mode 100644 index 0000000..8e8d6d7 --- /dev/null +++ b/test/controllers/categories_controller_test.rb @@ -0,0 +1,8 @@ +require 'test_helper' + +class CategoriesControllerTest < ActionDispatch::IntegrationTest + test "show categories index" do + get '/categories' + assert_response :success + end +end \ No newline at end of file diff --git a/test/fixtures/categories.yml b/test/fixtures-back/categories.yml similarity index 100% rename from test/fixtures/categories.yml rename to test/fixtures-back/categories.yml diff --git a/test/fixtures/categories_restored_objects.yml b/test/fixtures-back/categories_restored_objects.yml similarity index 100% rename from test/fixtures/categories_restored_objects.yml rename to test/fixtures-back/categories_restored_objects.yml diff --git a/test/fixtures/collections.yml b/test/fixtures-back/collections.yml similarity index 100% rename from test/fixtures/collections.yml rename to test/fixtures-back/collections.yml diff --git a/test/fixtures/collections_restored_objects.yml b/test/fixtures-back/collections_restored_objects.yml similarity index 100% rename from test/fixtures/collections_restored_objects.yml rename to test/fixtures-back/collections_restored_objects.yml diff --git a/test/fixtures/compositions.yml b/test/fixtures-back/compositions.yml similarity index 100% rename from test/fixtures/compositions.yml rename to test/fixtures-back/compositions.yml diff --git a/test/fixtures/deteriorations.yml b/test/fixtures-back/deteriorations.yml similarity index 100% rename from test/fixtures/deteriorations.yml rename to test/fixtures-back/deteriorations.yml diff --git a/test/fixtures/deteriorations_restored_objects.yml b/test/fixtures-back/deteriorations_restored_objects.yml similarity index 100% rename from test/fixtures/deteriorations_restored_objects.yml rename to test/fixtures-back/deteriorations_restored_objects.yml diff --git a/test/fixtures/materials.yml b/test/fixtures-back/materials.yml similarity index 100% rename from test/fixtures/materials.yml rename to test/fixtures-back/materials.yml diff --git a/test/fixtures/pieces.yml b/test/fixtures-back/pieces.yml similarity index 100% rename from test/fixtures/pieces.yml rename to test/fixtures-back/pieces.yml diff --git a/test/fixtures/priorities.yml b/test/fixtures-back/priorities.yml similarity index 100% rename from test/fixtures/priorities.yml rename to test/fixtures-back/priorities.yml diff --git a/test/fixtures/protections.yml b/test/fixtures-back/protections.yml similarity index 100% rename from test/fixtures/protections.yml rename to test/fixtures-back/protections.yml diff --git a/test/fixtures/restored_objects.yml b/test/fixtures-back/restored_objects.yml similarity index 88% rename from test/fixtures/restored_objects.yml rename to test/fixtures-back/restored_objects.yml index ac01ab2..add51f2 100644 --- a/test/fixtures/restored_objects.yml +++ b/test/fixtures-back/restored_objects.yml @@ -3,11 +3,9 @@ one: title: MyString description: MyText - category: 1 user_id: 1 two: title: MyString description: MyText - category: 1 user_id: 1 diff --git a/test/fixtures/states.yml b/test/fixtures-back/states.yml similarity index 100% rename from test/fixtures/states.yml rename to test/fixtures-back/states.yml diff --git a/test/fixtures/units.yml b/test/fixtures-back/units.yml similarity index 100% rename from test/fixtures/units.yml rename to test/fixtures-back/units.yml diff --git a/test/fixtures/users.yml b/test/fixtures-back/users.yml similarity index 100% rename from test/fixtures/users.yml rename to test/fixtures-back/users.yml diff --git a/test/fixtures/object_formats.yml b/test/fixtures/object_formats.yml deleted file mode 100644 index 56066c6..0000000 --- a/test/fixtures/object_formats.yml +++ /dev/null @@ -1,7 +0,0 @@ -# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html - -one: - name: MyString - -two: - name: MyString diff --git a/test/models/material_test.rb b/test/models/material_test.rb new file mode 100644 index 0000000..62c3248 --- /dev/null +++ b/test/models/material_test.rb @@ -0,0 +1,8 @@ +require 'test_helper' + +class MaterialTest < ActiveSupport::TestCase + test "create material without arguments" do + material = Material.new + assert material.save + end +end \ No newline at end of file From 58ae0d5ecdfe66e16135f2366ae1888575895649 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Dur=C3=A1n=20Roca?= Date: Mon, 7 Oct 2019 17:55:15 +0200 Subject: [PATCH 12/20] Feature/update readme (#169) * README - Update readme with more information,installation and history of the project * README - Updated badges * RESTORED-OBJECT - Removed console traces and comments --- README.md | 129 +++++++++++++++++- .../restored_objects_controller.rb | 11 -- 2 files changed, 123 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index aa8228b..10ce53c 100644 --- a/README.md +++ b/README.md @@ -1,33 +1,150 @@ # FragmentX + ## 3D Visualization of restored objects [![Build Status](https://travis-ci.org/FragmentX/FRAGMENTX.svg?branch=master)](https://travis-ci.org/FragmentX/FRAGMENTX) [![Maintainability](https://api.codeclimate.com/v1/badges/900fd8a114c8d71e0142/maintainability)](https://codeclimate.com/github/FragmentX/FRAGMENTX/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/900fd8a114c8d71e0142/test_coverage)](https://codeclimate.com/github/FragmentX/FRAGMENTX/test_coverage) [![security](https://hakiri.io/github/FragmentX/FRAGMENTX/master.svg)](https://hakiri.io/github/FragmentX/FRAGMENTX/master) + + [//]: # (badges) [![security](https://img.shields.io/badge/contributors-4-blue)](https://img.shields.io/badge/contributors-4-blue) [//]: # (badges) +> [FragmentX web](http://scanviewer.herokuapp.com/) +> +> [http://scanviewer.herokuapp.com/](http://scanviewer.herokuapp.com/) +> +## Description + FragmentX is an open source 3D objects viewer build using Ruby on Rails and Three JS. Is part of an European project in the UPV and the final degree project of one of the creators. +FragmentX tries to bring to museums in particular and people in general a tool to store and visualize masterpieces and any type of 3D objects. Often this kind of objects are fragmented or divided in several pieces. Our 3D viewer is able to show all the fragments of these objects. -http://scanviewer.herokuapp.com/ +The platform created is on the web because we wanted to create a more accessible tool for everybody. It could be used in any device. ## Version +The application is under development. This means that there is not a release or a beta version yet. The FragmentX team and its community is working on its first beta release. +### 0.2 Alpha 20181127 #### Features - +* [X] OBJ file format loader +* [X] Orthographic and Perspective cameras switch +* [X] Added continuous Integration +* [X] Added code quality checker +* [X] Added vulnerability checker +* [X] Added dependaBot #### Bugs +* [X] Orthographic fails when is switched a few times + #### Changes +* [X] Redesigned interface +* [X] Refactored Code -## Dependencies -## Guide +### 0.1 Alpha 20180713 -## References +#### Features +* [X] STL file format loader +* [X] ZIP automatic restored object loader +* [X] 3D Restored Object viewer +* [X] Clipping X, Y, Z planes +* [X] Canvas Screenshoot +* [X] Pieces measurement +* [X] Show nearby pieces +* [X] Basic design and lading page +* [X] Async pieces loader using ThreeJS web workers +* [X] Automatic deploy on Heroku +* [X] Translations (English and Spanish) + + +## Installation + +### Dependecies +* Ruby version: [2.6](https://www.ruby-lang.org/es/news/2019/03/13/ruby-2-6-2-released/) +* Rails version: [5.2.3](https://weblog.rubyonrails.org/2019/3/28/Rails-5-2-3-has-been-released/) +* PostgreSQL version: [9.5](https://www.postgresql.org/docs/9.5/index.html) +* NodeJS version: [10.16.3](https://nodejs.org/uk/blog/release/v0.10.16/) +* gcc and g++ version: [5.4](https://ftp.gnu.org/gnu/gcc/gcc-5.4.0/) + +### Recomended +* Ubuntu 16.04~18.04, Kubuntu, or Debian based OS +* Git +### Installation steps + +* Update the Ubuntu repositories +```shell +sudo apt-get update +``` +* Install basic dependencies for Ruby on Rails (Git is optional) +```shell +sudo apt-get install git +sudo apt install curl +sudo apt install -y nodejs +sudo apt install gcc g++ make +``` +* Clone the repo from our master branch +```shell +git clone https://github.com/FragmentX/FRAGMENTX.git +cd FRAGMENTX/ +``` +* Ruby installation and basic setup of the rvm +```shell +gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB +curl -sSL https://get.rvm.io | bash -s stable --ruby +source /home/duxy1996/.rvm/scripts/rvm +rvm install ruby-2.6.1 +rvm --default use ruby-2.6.1 +``` +* Rails 5.2.0 installation +```shell +gem update --system +gem install rails -v 5.2.0 +``` +* PostgreSQL database installation and postgresql gem installation +```shell +sudo apt install postgresql postgresql-contrib libpq-dev -y +systemctl start postgresql +systemctl enable postgresql +``` +* Ruby basic gem installation +```shell +sudo apt-get install ruby-railties +sudo apt install ruby-bundler +bundle install +``` +* Database creation and migration. Applies all the changes made in the migrations folder. It is empty, to feed the database should run ` rails db:seed`. With the `rails s` command the appplication is launched in localhost:3000 +```shell +rails db:create +rails db:migrate +rails s +``` +#### Optional +PostgreSQL sometimes is not well set up. You have to modify the file **pg_hba.conf** to allow to enter to the database and create the profile/user for manage the application databases. +```shell +sudo gedit /etc/postgresql/9.5/main/pg_hba.conf +``` ## Contributors -[//]: # (contributors) + + [Álvaro Casado Coscollá.](https://github.com/alvarocasadoc) Architect and developer + + [ Carlos Durán Roca.](https://github.com/Duxy1996) Architect and developer + + [Dependa Baller bot.](https://github.com/marketplace/dependabot-preview) + +[//]: # (contributors) + + + + +## References + + +* [Ruby tests for models and controllers](https://guides.rubyonrails.org/testing.html) +* [PostgreSQL test database initialization error](https://stackoverflow.com/questions/19097558/pg-undefinedtable-error-relation-users-does-not-exist) +* [PostgreSQL test fixture error](https://stackoverflow.com/questions/58190137/database-error-on-executing-test-ruby-on-rails-with-postgres) +* [PostgreSQL Travis configuration](https://medium.com/hexient-labs/configuring-travis-ci-for-a-rails-project-d25bc2f2ba7e) diff --git a/app/controllers/restored_objects_controller.rb b/app/controllers/restored_objects_controller.rb index 97842d4..f05790e 100644 --- a/app/controllers/restored_objects_controller.rb +++ b/app/controllers/restored_objects_controller.rb @@ -52,24 +52,13 @@ def create authorize @object if params[:zip_file] params[:pieces_attributes] = nil - puts "About to read the file" Zip::File.open(params[:zip_file].path) do |zipfile| - puts "Reading zip file" zipfile.glob('*{ply,stl,obj}') do |file| - puts "Reading #{file.name}" - # tempfile = Tempfile.new(File.basename(file.name)) - # tempfile.binmode - # tempfile.write file.get_input_stream.read - - puts "Reading matrix" matrix = zipfile.glob("#{file.name.split('.').first}.txt").first.get_input_stream.read - puts matrix - piece = @object.pieces.create(name: file.name, matrix: matrix) end end end - respond_to do |format| if @object.save format.html { redirect_to @object } From 893b3463b7e0fe71776151c5678275b96c0d8942 Mon Sep 17 00:00:00 2001 From: Carlos Duran Date: Mon, 7 Oct 2019 18:11:54 +0200 Subject: [PATCH 13/20] CATEGORY - [FRAGMENTX-15] - Model validation for category model and tests --- app/models/category.rb | 2 ++ test/models/category_test.rb | 15 +++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 test/models/category_test.rb diff --git a/app/models/category.rb b/app/models/category.rb index f035210..a611af9 100644 --- a/app/models/category.rb +++ b/app/models/category.rb @@ -1,4 +1,6 @@ class Category < ApplicationRecord has_many :categories_restored_objects has_many :restored_objects, through: :categories_restored_objects + + validates :name, presence: true end diff --git a/test/models/category_test.rb b/test/models/category_test.rb new file mode 100644 index 0000000..0e103b3 --- /dev/null +++ b/test/models/category_test.rb @@ -0,0 +1,15 @@ +require 'test_helper' + +class CategoryTest < ActiveSupport::TestCase + test "create category without arguments" do + material = Category.new + assert_not material.save + end +end + +class CategoryTest < ActiveSupport::TestCase + test "create category with name" do + material = Category.new(name: "Glass") + assert material.save + end +end \ No newline at end of file From 7850457b06565802c24e84b3e21b710d479c0afc Mon Sep 17 00:00:00 2001 From: Carlos Duran Date: Mon, 7 Oct 2019 18:12:54 +0200 Subject: [PATCH 14/20] GITIGNORE - Added json files type to ignore list --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 66124c7..2930112 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,5 @@ .byebug_history *.DS_Store + +*.json From 4aca860c7a31923faab776ee9e4267fc0419cbb6 Mon Sep 17 00:00:00 2001 From: Carlos Duran Date: Mon, 7 Oct 2019 18:23:48 +0200 Subject: [PATCH 15/20] GEMFILE - Updated railszip gem --- Gemfile | 2 +- Gemfile.lock | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index 527521b..eebb07b 100644 --- a/Gemfile +++ b/Gemfile @@ -31,7 +31,7 @@ gem 'bootstrap' gem 'geocoder' -gem 'rubyzip' +gem 'rubyzip', '>= 1.3.0' gem 'bootstrap4-kaminari-views' gem 'kaminari' diff --git a/Gemfile.lock b/Gemfile.lock index adead94..db1521e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -205,7 +205,7 @@ GEM responders (3.0.0) actionpack (>= 5.0) railties (>= 5.0) - rubyzip (1.2.3) + rubyzip (1.3.0) sass (3.7.4) sass-listen (~> 4.0.0) sass-listen (4.0.0) @@ -290,7 +290,7 @@ DEPENDENCIES pundit rack-cors rails (~> 5.2.1) - rubyzip + rubyzip (>= 1.3.0) sass-rails (~> 5.0) selenium-webdriver turbolinks (~> 5) @@ -300,4 +300,4 @@ DEPENDENCIES wicked BUNDLED WITH - 1.17.2 + 1.17.3 From 9059251b57775990b4b4cdcd0289a7220ff07132 Mon Sep 17 00:00:00 2001 From: Carlos Duran Date: Tue, 8 Oct 2019 18:22:22 +0200 Subject: [PATCH 16/20] CATEGORY - Fixed copy paste typo in category test fle --- test/models/category_test.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/models/category_test.rb b/test/models/category_test.rb index 0e103b3..1f19051 100644 --- a/test/models/category_test.rb +++ b/test/models/category_test.rb @@ -2,14 +2,14 @@ class CategoryTest < ActiveSupport::TestCase test "create category without arguments" do - material = Category.new - assert_not material.save + category = Category.new + assert_not category.save end end class CategoryTest < ActiveSupport::TestCase test "create category with name" do - material = Category.new(name: "Glass") - assert material.save + category = Category.new(name: "Glass") + assert category.save end end \ No newline at end of file From 2364a87e8bbc10a1ff18a92218700e4a7a818f9c Mon Sep 17 00:00:00 2001 From: Carlos Duran Date: Tue, 8 Oct 2019 18:22:50 +0200 Subject: [PATCH 17/20] MATERIAL - Added name validation for material model --- app/models/material.rb | 2 ++ test/models/material_test.rb | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/app/models/material.rb b/app/models/material.rb index 62c9153..63a02b0 100644 --- a/app/models/material.rb +++ b/app/models/material.rb @@ -1,4 +1,6 @@ class Material < ApplicationRecord has_many :compositions has_many :restored_objects, through: :compositions + + validates :name, presence: true end diff --git a/test/models/material_test.rb b/test/models/material_test.rb index 62c3248..58225e9 100644 --- a/test/models/material_test.rb +++ b/test/models/material_test.rb @@ -3,6 +3,13 @@ class MaterialTest < ActiveSupport::TestCase test "create material without arguments" do material = Material.new + assert_not material.save + end +end + +class MaterialTest < ActiveSupport::TestCase + test "create material with name" do + material = Material.new(name: "Glass") assert material.save end end \ No newline at end of file From 0668e77bc2d2f251e429f227bbf95de6122211af Mon Sep 17 00:00:00 2001 From: Carlos Duran Date: Thu, 10 Oct 2019 19:33:40 +0200 Subject: [PATCH 18/20] COLLECTION - Added valdiation tests for collection --- app/models/collection.rb | 4 ++++ test/models/collection_test.rb | 36 ++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 test/models/collection_test.rb diff --git a/app/models/collection.rb b/app/models/collection.rb index e0f6709..6d59b3c 100644 --- a/app/models/collection.rb +++ b/app/models/collection.rb @@ -15,4 +15,8 @@ def featured_image '/object.svg' end end + + validates :title, presence: true + validates :title, length: { minimum: 2 } + validates :description, length: { maximum: 500 } end diff --git a/test/models/collection_test.rb b/test/models/collection_test.rb new file mode 100644 index 0000000..8526601 --- /dev/null +++ b/test/models/collection_test.rb @@ -0,0 +1,36 @@ +require 'test_helper' + +class CollectionTest < ActiveSupport::TestCase + + long_description = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus in est nec ex condimentum molestie. Nam luctus ex vitae consectetur lacinia. Nunc non augue fermentum, aliquam ex in, lobortis orci. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vel augue tincidunt, fringilla magna id, gravida elit. Cras id ante blandit, rutrum justo vel, lobortis dolor. Phasellus urna tortor, scelerisque sed ligula eu, vestibulum dapibus nulla. Integer vitae metus non enim luctus feugiat id metus." + + test "create collection without arguments" do + collection = Collection.new + assert_not collection.save + end + + test "create collection without title," do + collection = Collection.new( user_id: 1, description: "Lorem ipsum dolor sit amet") + assert_not collection.save + end + + test "create collection with short title," do + collection = Collection.new(title: "t", description: "Lorem ipsum dolor sit amet") + assert_not collection.save + end + + test "create collection with long description" do + collection = Collection.new(title: "title-test", user_id: 1, description: long_description) + assert_not collection.save + end + + test "create collection without description," do + collection = Collection.new(title: "title-test", user_id: 1) + assert collection.save + end + + test "create collection with title," do + collection = Collection.new(title: "title-test", user_id: 1, description: "Lorem ipsum dolor sit amet") + assert collection.save + end +end \ No newline at end of file From 4987890ac28e688e7baafd27656ed4af0abbd979 Mon Sep 17 00:00:00 2001 From: Carlos Duran Date: Thu, 10 Oct 2019 19:53:47 +0200 Subject: [PATCH 19/20] USER - Added several validation test for user model (DEVISE) --- app/models/user.rb | 10 +++++++++- test/models/user_test.rb | 31 +++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 test/models/user_test.rb diff --git a/app/models/user.rb b/app/models/user.rb index bfbd659..e4d48cc 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -6,7 +6,7 @@ class User < ApplicationRecord has_many :collections has_one_attached :avatar - + has_one_attached :header def header_image @@ -24,4 +24,12 @@ def avatar_image '/user.svg' end end + + validates :name, presence: true + validates :name, length: { minimum: 2 } + validates :bio, length: { maximum: 500 } + validates :password, presence: true + validates :password, length: { in: 6..20 } + validates :email, presence: true + end diff --git a/test/models/user_test.rb b/test/models/user_test.rb new file mode 100644 index 0000000..fdbd55c --- /dev/null +++ b/test/models/user_test.rb @@ -0,0 +1,31 @@ +require 'test_helper' + +class UserTest < ActiveSupport::TestCase + + def_password = 'TestPassword123' + def_email = 'test@gmail.com' + def_name = 'testName' + + test 'Create user withour email' do + user = User.new(password: def_password, + password_confirmation: def_password, + name: def_name) + assert_equal user.valid?, false + end + + test 'Create user withour name' do + user = User.new(email:def_email, + password: def_password, + password_confirmation: def_password) + assert_equal user.valid?, false + end + + test 'Valid User' do + user = User.new(email:def_email, + password: def_password, + password_confirmation: def_password, + name: def_name) + assert_equal user.valid?, true + end + +end \ No newline at end of file From 842b12ba8a636e3aa835549dc75dccc9d7f84e67 Mon Sep 17 00:00:00 2001 From: Carlos Duran Date: Thu, 10 Oct 2019 20:05:29 +0200 Subject: [PATCH 20/20] COLLECTION - Fixed travis test issue. Needed a user in db to pass the test --- test/models/collection_test.rb | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/test/models/collection_test.rb b/test/models/collection_test.rb index 8526601..e93fad5 100644 --- a/test/models/collection_test.rb +++ b/test/models/collection_test.rb @@ -2,35 +2,45 @@ class CollectionTest < ActiveSupport::TestCase + def_password = 'TestPassword123' + def_email = 'testCollection@gmail.com' + def_name = 'testCollectionName' + long_description = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus in est nec ex condimentum molestie. Nam luctus ex vitae consectetur lacinia. Nunc non augue fermentum, aliquam ex in, lobortis orci. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vel augue tincidunt, fringilla magna id, gravida elit. Cras id ante blandit, rutrum justo vel, lobortis dolor. Phasellus urna tortor, scelerisque sed ligula eu, vestibulum dapibus nulla. Integer vitae metus non enim luctus feugiat id metus." + userCollection = User.new(email:def_email, + password: def_password, + password_confirmation: def_password, + name: def_name) + userCollection.save + test "create collection without arguments" do collection = Collection.new assert_not collection.save end test "create collection without title," do - collection = Collection.new( user_id: 1, description: "Lorem ipsum dolor sit amet") + collection = Collection.new( user_id: userCollection.id, description: "Lorem ipsum dolor sit amet") assert_not collection.save end test "create collection with short title," do - collection = Collection.new(title: "t", description: "Lorem ipsum dolor sit amet") + collection = Collection.new(title: "t", user_id: userCollection.id, description: "Lorem ipsum dolor sit amet") assert_not collection.save end test "create collection with long description" do - collection = Collection.new(title: "title-test", user_id: 1, description: long_description) + collection = Collection.new(title: "title-test", user_id: userCollection.id, description: long_description) assert_not collection.save end test "create collection without description," do - collection = Collection.new(title: "title-test", user_id: 1) + collection = Collection.new(title: "title-test", user_id: userCollection.id) assert collection.save end test "create collection with title," do - collection = Collection.new(title: "title-test", user_id: 1, description: "Lorem ipsum dolor sit amet") + collection = Collection.new(title: "title-test", user_id: userCollection.id, description: "Lorem ipsum dolor sit amet") assert collection.save end end \ No newline at end of file