- <% @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 %>
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 "[]("+ 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']
+
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/category_test.rb b/test/models/category_test.rb
new file mode 100644
index 0000000..1f19051
--- /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
+ category = Category.new
+ assert_not category.save
+ end
+end
+
+class CategoryTest < ActiveSupport::TestCase
+ test "create category with name" do
+ category = Category.new(name: "Glass")
+ assert category.save
+ end
+end
\ No newline at end of file
diff --git a/test/models/collection_test.rb b/test/models/collection_test.rb
new file mode 100644
index 0000000..e93fad5
--- /dev/null
+++ b/test/models/collection_test.rb
@@ -0,0 +1,46 @@
+require 'test_helper'
+
+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: 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", 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: userCollection.id, description: long_description)
+ assert_not collection.save
+ end
+
+ test "create collection without description," do
+ 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: userCollection.id, description: "Lorem ipsum dolor sit amet")
+ assert collection.save
+ end
+end
\ No newline at end of file
diff --git a/test/models/material_test.rb b/test/models/material_test.rb
new file mode 100644
index 0000000..58225e9
--- /dev/null
+++ b/test/models/material_test.rb
@@ -0,0 +1,15 @@
+require 'test_helper'
+
+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
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