merge develop
This commit is contained in:
commit
c6fea78054
45 changed files with 727 additions and 839 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -19,6 +19,8 @@ vendor/
|
||||||
log/*.log
|
log/*.log
|
||||||
tmp
|
tmp
|
||||||
|
|
||||||
|
coverage
|
||||||
|
|
||||||
.DS_Store
|
.DS_Store
|
||||||
*/.DS_Store
|
*/.DS_Store
|
||||||
.DS_Store?
|
.DS_Store?
|
||||||
|
|
3
.simplecov
Normal file
3
.simplecov
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
if ENV['COVERAGE'] == 'on'
|
||||||
|
SimpleCov.start 'rails'
|
||||||
|
end
|
2
Gemfile
2
Gemfile
|
@ -42,6 +42,8 @@ group :test do
|
||||||
gem 'rspec-rails'
|
gem 'rspec-rails'
|
||||||
gem 'factory_girl_rails'
|
gem 'factory_girl_rails'
|
||||||
gem 'shoulda-matchers'
|
gem 'shoulda-matchers'
|
||||||
|
gem 'simplecov', require: false
|
||||||
|
gem 'json-schema'
|
||||||
end
|
end
|
||||||
|
|
||||||
group :production do #this is used on heroku
|
group :production do #this is used on heroku
|
||||||
|
|
14
Gemfile.lock
14
Gemfile.lock
|
@ -36,6 +36,7 @@ GEM
|
||||||
minitest (~> 5.1)
|
minitest (~> 5.1)
|
||||||
thread_safe (~> 0.3, >= 0.3.4)
|
thread_safe (~> 0.3, >= 0.3.4)
|
||||||
tzinfo (~> 1.1)
|
tzinfo (~> 1.1)
|
||||||
|
addressable (2.3.8)
|
||||||
arel (6.0.3)
|
arel (6.0.3)
|
||||||
aws-sdk (1.66.0)
|
aws-sdk (1.66.0)
|
||||||
aws-sdk-v1 (= 1.66.0)
|
aws-sdk-v1 (= 1.66.0)
|
||||||
|
@ -78,6 +79,7 @@ GEM
|
||||||
thread_safe (~> 0.1)
|
thread_safe (~> 0.1)
|
||||||
warden (~> 1.2.3)
|
warden (~> 1.2.3)
|
||||||
diff-lcs (1.2.5)
|
diff-lcs (1.2.5)
|
||||||
|
docile (1.1.5)
|
||||||
dotenv (2.0.2)
|
dotenv (2.0.2)
|
||||||
erubis (2.7.0)
|
erubis (2.7.0)
|
||||||
execjs (2.6.0)
|
execjs (2.6.0)
|
||||||
|
@ -104,6 +106,8 @@ GEM
|
||||||
jquery-ui-rails (5.0.5)
|
jquery-ui-rails (5.0.5)
|
||||||
railties (>= 3.2.16)
|
railties (>= 3.2.16)
|
||||||
json (1.8.3)
|
json (1.8.3)
|
||||||
|
json-schema (2.6.0)
|
||||||
|
addressable (~> 2.3.8)
|
||||||
kaminari (0.16.3)
|
kaminari (0.16.3)
|
||||||
actionpack (>= 3.0.0)
|
actionpack (>= 3.0.0)
|
||||||
activesupport (>= 3.0.0)
|
activesupport (>= 3.0.0)
|
||||||
|
@ -203,6 +207,11 @@ GEM
|
||||||
tilt (>= 1.1, < 3)
|
tilt (>= 1.1, < 3)
|
||||||
shoulda-matchers (3.0.1)
|
shoulda-matchers (3.0.1)
|
||||||
activesupport (>= 4.0.0)
|
activesupport (>= 4.0.0)
|
||||||
|
simplecov (0.11.1)
|
||||||
|
docile (~> 1.1.0)
|
||||||
|
json (~> 1.8)
|
||||||
|
simplecov-html (~> 0.10.0)
|
||||||
|
simplecov-html (0.10.0)
|
||||||
slop (3.6.0)
|
slop (3.6.0)
|
||||||
sprockets (3.4.0)
|
sprockets (3.4.0)
|
||||||
rack (> 1, < 3)
|
rack (> 1, < 3)
|
||||||
|
@ -245,6 +254,7 @@ DEPENDENCIES
|
||||||
jquery-rails
|
jquery-rails
|
||||||
jquery-ui-rails
|
jquery-ui-rails
|
||||||
json
|
json
|
||||||
|
json-schema
|
||||||
kaminari
|
kaminari
|
||||||
paperclip
|
paperclip
|
||||||
pg
|
pg
|
||||||
|
@ -258,9 +268,7 @@ DEPENDENCIES
|
||||||
rspec-rails
|
rspec-rails
|
||||||
sass-rails
|
sass-rails
|
||||||
shoulda-matchers
|
shoulda-matchers
|
||||||
|
simplecov
|
||||||
tunemygc
|
tunemygc
|
||||||
uglifier
|
uglifier
|
||||||
uservoice-ruby
|
uservoice-ruby
|
||||||
|
|
||||||
BUNDLED WITH
|
|
||||||
1.11.2
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ Metamaps
|
||||||
=======
|
=======
|
||||||
|
|
||||||
[![Join the chat at https://gitter.im/metamaps/metamaps_gen002](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/metamaps/metamaps_gen002?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
[![Join the chat at https://gitter.im/metamaps/metamaps_gen002](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/metamaps/metamaps_gen002?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||||
![Build Status](https://jenkins.devinhoward.ca/job/metamaps_gen002.develop/badge/icon)
|
[![Build Status](https://jenkins.devinhoward.ca/job/metamaps_gen002.develop/badge/icon)](https://jenkins.devinhoward.ca/job/metamaps_gen002.develop/)
|
||||||
|
|
||||||
Welcome to the Metamaps GitHub repo.
|
Welcome to the Metamaps GitHub repo.
|
||||||
|
|
||||||
|
|
|
@ -869,9 +869,9 @@ Metamaps.JIT = {
|
||||||
}
|
}
|
||||||
// if it's a right click or holding down alt, start synapse creation ->third option is for firefox
|
// if it's a right click or holding down alt, start synapse creation ->third option is for firefox
|
||||||
else if ((e.button == 2 || (e.button == 0 && e.altKey) || e.buttons == 2) && authorized) {
|
else if ((e.button == 2 || (e.button == 0 && e.altKey) || e.buttons == 2) && authorized) {
|
||||||
if (tempInit == false) {
|
if (Metamaps.tempInit == false) {
|
||||||
tempNode = node;
|
Metamaps.tempNode = node;
|
||||||
tempInit = true;
|
Metamaps.tempInit = true;
|
||||||
|
|
||||||
Metamaps.Create.newTopic.hide();
|
Metamaps.Create.newTopic.hide();
|
||||||
Metamaps.Create.newSynapse.hide();
|
Metamaps.Create.newSynapse.hide();
|
||||||
|
@ -887,8 +887,8 @@ Metamaps.JIT = {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Metamaps.Mouse.synapseStartCoordinates = [{
|
Metamaps.Mouse.synapseStartCoordinates = [{
|
||||||
x: tempNode.pos.getc().x,
|
x: Metamaps.tempNode.pos.getc().x,
|
||||||
y: tempNode.pos.getc().y
|
y: Metamaps.tempNode.pos.getc().y
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
Metamaps.Mouse.synapseEndCoordinates = {
|
Metamaps.Mouse.synapseEndCoordinates = {
|
||||||
|
@ -899,11 +899,11 @@ Metamaps.JIT = {
|
||||||
//
|
//
|
||||||
temp = eventInfo.getNode();
|
temp = eventInfo.getNode();
|
||||||
if (temp != false && temp.id != node.id && Metamaps.Selected.Nodes.indexOf(temp) == -1) { // this means a Node has been returned
|
if (temp != false && temp.id != node.id && Metamaps.Selected.Nodes.indexOf(temp) == -1) { // this means a Node has been returned
|
||||||
tempNode2 = temp;
|
Metamaps.tempNode2 = temp;
|
||||||
|
|
||||||
Metamaps.Mouse.synapseEndCoordinates = {
|
Metamaps.Mouse.synapseEndCoordinates = {
|
||||||
x: tempNode2.pos.getc().x,
|
x: Metamaps.tempNode2.pos.getc().x,
|
||||||
y: tempNode2.pos.getc().y
|
y: Metamaps.tempNode2.pos.getc().y
|
||||||
};
|
};
|
||||||
|
|
||||||
// before making the highlighted one bigger, make sure all the others are regular size
|
// before making the highlighted one bigger, make sure all the others are regular size
|
||||||
|
@ -913,7 +913,7 @@ Metamaps.JIT = {
|
||||||
temp.setData('dim', 35, 'current');
|
temp.setData('dim', 35, 'current');
|
||||||
Metamaps.Visualize.mGraph.plot();
|
Metamaps.Visualize.mGraph.plot();
|
||||||
} else if (!temp) {
|
} else if (!temp) {
|
||||||
tempNode2 = null;
|
Metamaps.tempNode2 = null;
|
||||||
Metamaps.Visualize.mGraph.graph.eachNode(function (n) {
|
Metamaps.Visualize.mGraph.graph.eachNode(function (n) {
|
||||||
n.setData('dim', 25, 'current');
|
n.setData('dim', 25, 'current');
|
||||||
});
|
});
|
||||||
|
@ -941,10 +941,10 @@ Metamaps.JIT = {
|
||||||
}
|
}
|
||||||
}, // onDragMoveTopicHandler
|
}, // onDragMoveTopicHandler
|
||||||
onDragCancelHandler: function (node, eventInfo, e) {
|
onDragCancelHandler: function (node, eventInfo, e) {
|
||||||
tempNode = null;
|
Metamaps.tempNode = null;
|
||||||
if (tempNode2) tempNode2.setData('dim', 25, 'current');
|
if (Metamaps.tempNode2) Metamaps.tempNode2.setData('dim', 25, 'current');
|
||||||
tempNode2 = null;
|
Metamaps.tempNode2 = null;
|
||||||
tempInit = false;
|
Metamaps.tempInit = false;
|
||||||
// reset the draw synapse positions to false
|
// reset the draw synapse positions to false
|
||||||
Metamaps.Mouse.synapseStartCoordinates = [];
|
Metamaps.Mouse.synapseStartCoordinates = [];
|
||||||
Metamaps.Mouse.synapseEndCoordinates = null;
|
Metamaps.Mouse.synapseEndCoordinates = null;
|
||||||
|
@ -953,27 +953,27 @@ Metamaps.JIT = {
|
||||||
onDragEndTopicHandler: function (node, eventInfo, e) {
|
onDragEndTopicHandler: function (node, eventInfo, e) {
|
||||||
var midpoint = {}, pixelPos, mapping;
|
var midpoint = {}, pixelPos, mapping;
|
||||||
|
|
||||||
if (tempInit && tempNode2 == null) {
|
if (Metamaps.tempInit && Metamaps.tempNode2 == null) {
|
||||||
// this means you want to add a new topic, and then a synapse
|
// this means you want to add a new topic, and then a synapse
|
||||||
Metamaps.Create.newTopic.addSynapse = true;
|
Metamaps.Create.newTopic.addSynapse = true;
|
||||||
Metamaps.Create.newTopic.open();
|
Metamaps.Create.newTopic.open();
|
||||||
} else if (tempInit && tempNode2 != null) {
|
} else if (Metamaps.tempInit && Metamaps.tempNode2 != null) {
|
||||||
// this means you want to create a synapse between two existing topics
|
// this means you want to create a synapse between two existing topics
|
||||||
Metamaps.Create.newTopic.addSynapse = false;
|
Metamaps.Create.newTopic.addSynapse = false;
|
||||||
Metamaps.Create.newSynapse.topic1id = tempNode.getData('topic').id;
|
Metamaps.Create.newSynapse.topic1id = Metamaps.tempNode.getData('topic').id;
|
||||||
Metamaps.Create.newSynapse.topic2id = tempNode2.getData('topic').id;
|
Metamaps.Create.newSynapse.topic2id = Metamaps.tempNode2.getData('topic').id;
|
||||||
tempNode2.setData('dim', 25, 'current');
|
Metamaps.tempNode2.setData('dim', 25, 'current');
|
||||||
Metamaps.Visualize.mGraph.plot();
|
Metamaps.Visualize.mGraph.plot();
|
||||||
midpoint.x = tempNode.pos.getc().x + (tempNode2.pos.getc().x - tempNode.pos.getc().x) / 2;
|
midpoint.x = Metamaps.tempNode.pos.getc().x + (Metamaps.tempNode2.pos.getc().x - Metamaps.tempNode.pos.getc().x) / 2;
|
||||||
midpoint.y = tempNode.pos.getc().y + (tempNode2.pos.getc().y - tempNode.pos.getc().y) / 2;
|
midpoint.y = Metamaps.tempNode.pos.getc().y + (Metamaps.tempNode2.pos.getc().y - Metamaps.tempNode.pos.getc().y) / 2;
|
||||||
pixelPos = Metamaps.Util.coordsToPixels(midpoint);
|
pixelPos = Metamaps.Util.coordsToPixels(midpoint);
|
||||||
$('#new_synapse').css('left', pixelPos.x + "px");
|
$('#new_synapse').css('left', pixelPos.x + "px");
|
||||||
$('#new_synapse').css('top', pixelPos.y + "px");
|
$('#new_synapse').css('top', pixelPos.y + "px");
|
||||||
Metamaps.Create.newSynapse.open();
|
Metamaps.Create.newSynapse.open();
|
||||||
tempNode = null;
|
Metamaps.tempNode = null;
|
||||||
tempNode2 = null;
|
Metamaps.tempNode2 = null;
|
||||||
tempInit = false;
|
Metamaps.tempInit = false;
|
||||||
} else if (!tempInit && node && !node.nodeFrom) {
|
} else if (!Metamaps.tempInit && node && !node.nodeFrom) {
|
||||||
// this means you dragged an existing node, autosave that to the database
|
// this means you dragged an existing node, autosave that to the database
|
||||||
|
|
||||||
// check whether to save mappings
|
// check whether to save mappings
|
||||||
|
@ -1047,18 +1047,13 @@ Metamaps.JIT = {
|
||||||
Metamaps.TopicCard.hideCard();
|
Metamaps.TopicCard.hideCard();
|
||||||
Metamaps.SynapseCard.hideCard();
|
Metamaps.SynapseCard.hideCard();
|
||||||
Metamaps.Create.newTopic.hide();
|
Metamaps.Create.newTopic.hide();
|
||||||
if ($('#new_synapse').is(":visible")) {
|
|
||||||
// Hide the new_synapse form and create the synapse!
|
|
||||||
Metamaps.Synapse.createSynapseLocally();
|
|
||||||
}//if
|
|
||||||
|
|
||||||
$('.rightclickmenu').remove();
|
$('.rightclickmenu').remove();
|
||||||
// reset the draw synapse positions to false
|
// reset the draw synapse positions to false
|
||||||
Metamaps.Mouse.synapseStartCoordinates = [];
|
Metamaps.Mouse.synapseStartCoordinates = [];
|
||||||
Metamaps.Mouse.synapseEndCoordinates = null;
|
Metamaps.Mouse.synapseEndCoordinates = null;
|
||||||
tempInit = false;
|
Metamaps.tempInit = false;
|
||||||
tempNode = null;
|
Metamaps.tempNode = null;
|
||||||
tempNode2 = null;
|
Metamaps.tempNode2 = null;
|
||||||
if (!e.ctrlKey && !e.shiftKey) {
|
if (!e.ctrlKey && !e.shiftKey) {
|
||||||
Metamaps.Control.deselectAllEdges();
|
Metamaps.Control.deselectAllEdges();
|
||||||
Metamaps.Control.deselectAllNodes();
|
Metamaps.Control.deselectAllNodes();
|
||||||
|
@ -1697,8 +1692,8 @@ Metamaps.JIT = {
|
||||||
easing = 1; // frictional value
|
easing = 1; // frictional value
|
||||||
|
|
||||||
easing = 1;
|
easing = 1;
|
||||||
window.clearInterval(panningInt)
|
window.clearInterval(Metamaps.panningInt)
|
||||||
panningInt = setInterval(function () {
|
Metamaps.panningInt = setInterval(function () {
|
||||||
myTimer()
|
myTimer()
|
||||||
}, 1);
|
}, 1);
|
||||||
|
|
||||||
|
@ -1707,7 +1702,7 @@ Metamaps.JIT = {
|
||||||
$(document).trigger(Metamaps.JIT.events.pan);
|
$(document).trigger(Metamaps.JIT.events.pan);
|
||||||
easing = easing * 0.75;
|
easing = easing * 0.75;
|
||||||
|
|
||||||
if (easing < 0.1) window.clearInterval(panningInt);
|
if (easing < 0.1) window.clearInterval(Metamaps.panningInt);
|
||||||
}
|
}
|
||||||
}, // SmoothPanning
|
}, // SmoothPanning
|
||||||
renderMidArrow: function (from, to, dim, swap, canvas, placement, newSynapse) {
|
renderMidArrow: function (from, to, dim, swap, canvas, placement, newSynapse) {
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
// TODO document this user agent function
|
||||||
|
|
||||||
var labelType, useGradients, nativeTextSupport, animate;
|
var labelType, useGradients, nativeTextSupport, animate;
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
|
@ -14,11 +16,13 @@ var labelType, useGradients, nativeTextSupport, animate;
|
||||||
animate = !(iStuff || !nativeCanvasSupport);
|
animate = !(iStuff || !nativeCanvasSupport);
|
||||||
})();
|
})();
|
||||||
|
|
||||||
// TODO eliminate these 4 global variables
|
// TODO eliminate these 4 top-level variables
|
||||||
var panningInt; // this variable is used to store a 'setInterval' for the Metamaps.JIT.SmoothPanning() function, so that it can be cleared with window.clearInterval
|
Metamaps = {
|
||||||
var tempNode = null,
|
panningInt: null,
|
||||||
tempInit = false,
|
tempNode: null,
|
||||||
tempNode2 = null;
|
tempInit: false,
|
||||||
|
tempNode2: null
|
||||||
|
}
|
||||||
|
|
||||||
Metamaps.Settings = {
|
Metamaps.Settings = {
|
||||||
embed: false, // indicates that the app is on a page that is optimized for embedding in iFrames on other web pages
|
embed: false, // indicates that the app is on a page that is optimized for embedding in iFrames on other web pages
|
||||||
|
@ -736,10 +740,6 @@ Metamaps.Create = {
|
||||||
init: function () {
|
init: function () {
|
||||||
var self = Metamaps.Create.newSynapse;
|
var self = Metamaps.Create.newSynapse;
|
||||||
|
|
||||||
$('#synapse_desc').keyup(function () {
|
|
||||||
Metamaps.Create.newSynapse.description = $(this).val();
|
|
||||||
});
|
|
||||||
|
|
||||||
var synapseBloodhound = new Bloodhound({
|
var synapseBloodhound = new Bloodhound({
|
||||||
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
|
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
|
||||||
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
||||||
|
@ -795,6 +795,22 @@ Metamaps.Create = {
|
||||||
}]
|
}]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$('#synapse_desc').keyup(function (e) {
|
||||||
|
var ESC = 27, BACKSPACE = 8, DELETE = 46;
|
||||||
|
if (e.keyCode === BACKSPACE && $(this).val() === "" ||
|
||||||
|
e.keyCode === DELETE && $(this).val() === "" ||
|
||||||
|
e.keyCode === ESC) {
|
||||||
|
Metamaps.Create.newSynapse.hide();
|
||||||
|
}//if
|
||||||
|
Metamaps.Create.newSynapse.description = $(this).val();
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#synapse_desc').focusout(function() {
|
||||||
|
if (Metamaps.Create.newSynapse.beingCreated) {
|
||||||
|
Metamaps.Synapse.createSynapseLocally();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
$('#synapse_desc').bind('typeahead:select', function (event, datum, dataset) {
|
$('#synapse_desc').bind('typeahead:select', function (event, datum, dataset) {
|
||||||
if (datum.id) { // if they clicked on an existing synapse get it
|
if (datum.id) { // if they clicked on an existing synapse get it
|
||||||
Metamaps.Synapse.getSynapseFromAutocomplete(datum.id);
|
Metamaps.Synapse.getSynapseFromAutocomplete(datum.id);
|
||||||
|
@ -811,7 +827,7 @@ Metamaps.Create = {
|
||||||
topic2id: null,
|
topic2id: null,
|
||||||
newSynapseId: null,
|
newSynapseId: null,
|
||||||
open: function () {
|
open: function () {
|
||||||
$('#new_synapse').fadeIn('fast', function () {
|
$('#new_synapse').fadeIn(100, function () {
|
||||||
$('#synapse_desc').focus();
|
$('#synapse_desc').focus();
|
||||||
});
|
});
|
||||||
Metamaps.Create.newSynapse.beingCreated = true;
|
Metamaps.Create.newSynapse.beingCreated = true;
|
||||||
|
|
|
@ -1,63 +0,0 @@
|
||||||
|
|
||||||
|
|
||||||
.allMetacodes {
|
|
||||||
float:left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.allMetacodes span {
|
|
||||||
margin:4px 8px;
|
|
||||||
color:#67AF9F;
|
|
||||||
}
|
|
||||||
|
|
||||||
.editMetacodes {
|
|
||||||
z-index:12;
|
|
||||||
width:auto;
|
|
||||||
color: #67AF9F;
|
|
||||||
padding:10px;
|
|
||||||
float:left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.editMetacodes ul {
|
|
||||||
display:block;
|
|
||||||
}
|
|
||||||
|
|
||||||
.editMetacodes ul li {
|
|
||||||
clear:both;
|
|
||||||
list-style-type:none;
|
|
||||||
display:block;
|
|
||||||
padding:3px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.editMetacodes ul img {
|
|
||||||
width:40px;
|
|
||||||
height:40px;
|
|
||||||
float:left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.editMetacodes ul p {
|
|
||||||
float:left;
|
|
||||||
display: block;
|
|
||||||
margin: 0;
|
|
||||||
background: none;
|
|
||||||
padding: 10px 4px 2px 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.editMetacodes #filters-one {
|
|
||||||
float:left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.editMetacodes #filters-two {
|
|
||||||
float:left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.editMetacodes #filters-three {
|
|
||||||
float:left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.editMetacodes #filters-four {
|
|
||||||
float:left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.editMetacodes li.toggledOff {
|
|
||||||
opacity: 0.4;
|
|
||||||
}
|
|
188
app/assets/stylesheets/admin.scss.erb
Normal file
188
app/assets/stylesheets/admin.scss.erb
Normal file
|
@ -0,0 +1,188 @@
|
||||||
|
.allMetacodes {
|
||||||
|
float:left;
|
||||||
|
|
||||||
|
span {
|
||||||
|
margin:4px 8px;
|
||||||
|
color:#67AF9F;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.editMetacodes {
|
||||||
|
z-index:12;
|
||||||
|
width:auto;
|
||||||
|
color: #67AF9F;
|
||||||
|
padding:10px;
|
||||||
|
float:left;
|
||||||
|
|
||||||
|
ul {
|
||||||
|
display:block;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul li {
|
||||||
|
clear:both;
|
||||||
|
list-style-type:none;
|
||||||
|
display:block;
|
||||||
|
padding:3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul img {
|
||||||
|
width:40px;
|
||||||
|
height:40px;
|
||||||
|
float:left;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul p {
|
||||||
|
float:left;
|
||||||
|
display: block;
|
||||||
|
margin: 0;
|
||||||
|
background: none;
|
||||||
|
padding: 10px 4px 2px 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#filters-one {
|
||||||
|
float:left;
|
||||||
|
}
|
||||||
|
|
||||||
|
#filters-two {
|
||||||
|
float:left;
|
||||||
|
}
|
||||||
|
|
||||||
|
#filters-three {
|
||||||
|
float:left;
|
||||||
|
}
|
||||||
|
|
||||||
|
#filters-four {
|
||||||
|
float:left;
|
||||||
|
}
|
||||||
|
|
||||||
|
li.toggledOff {
|
||||||
|
opacity: 0.4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.blackBox {
|
||||||
|
width: 760px;
|
||||||
|
margin: 0 auto;
|
||||||
|
padding: 20px 0 60px 20px;
|
||||||
|
background: rgba(0, 0, 0, 0.4);
|
||||||
|
color: white;
|
||||||
|
overflow: hidden;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
.metacodeSetsDescription {
|
||||||
|
width: 314px;
|
||||||
|
}
|
||||||
|
td.metacodeSetDesc {
|
||||||
|
width: 314px;
|
||||||
|
word-wrap: break-word;
|
||||||
|
}
|
||||||
|
.metacodeSetImage {
|
||||||
|
width: 36px;
|
||||||
|
height: 36px;
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
tr {
|
||||||
|
display: table-row;
|
||||||
|
}
|
||||||
|
tr:nth-child(odd) {
|
||||||
|
background: rgba(0, 0, 0, 0.2);
|
||||||
|
}
|
||||||
|
tr:nth-child(even) {
|
||||||
|
background: rgba(0, 0, 0, 0.3);
|
||||||
|
}
|
||||||
|
th,
|
||||||
|
td {
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
td.iconURL {
|
||||||
|
max-width: 415px;
|
||||||
|
word-wrap: break-word;
|
||||||
|
}
|
||||||
|
.field {
|
||||||
|
margin: 15px 0 5px;
|
||||||
|
}
|
||||||
|
label {
|
||||||
|
float: left;
|
||||||
|
width: 100px;
|
||||||
|
margin-right: 15px;
|
||||||
|
margin-top: 0px;
|
||||||
|
}
|
||||||
|
input[type="text"] {
|
||||||
|
width: 336px;
|
||||||
|
height: 32px;
|
||||||
|
font-size: 15px;
|
||||||
|
direction: ltr;
|
||||||
|
-webkit-appearance: none;
|
||||||
|
appearance: none;
|
||||||
|
display: inline-block;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0 8px;
|
||||||
|
background: #fff;
|
||||||
|
border: 1px solid #d9d9d9;
|
||||||
|
border-top: 1px solid #c0c0c0;
|
||||||
|
-webkit-box-sizing: border-box;
|
||||||
|
-moz-box-sizing: border-box;
|
||||||
|
box-sizing: border-box;
|
||||||
|
-webkit-border-radius: 1px;
|
||||||
|
-moz-border-radius: 1px;
|
||||||
|
border-radius: 1px;
|
||||||
|
font: -webkit-small-control;
|
||||||
|
color: initial;
|
||||||
|
letter-spacing: normal;
|
||||||
|
word-spacing: normal;
|
||||||
|
text-transform: none;
|
||||||
|
text-indent: 0px;
|
||||||
|
text-shadow: none;
|
||||||
|
display: inline-block;
|
||||||
|
text-align: start;
|
||||||
|
font-family: arial;
|
||||||
|
}
|
||||||
|
textarea:hover,
|
||||||
|
input[type="text"]:hover {
|
||||||
|
border: 1px solid #b9b9b9;
|
||||||
|
border-top: 1px solid #a0a0a0;
|
||||||
|
-webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
|
||||||
|
-moz-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
|
||||||
|
box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
textarea {
|
||||||
|
padding: 8px;
|
||||||
|
border: 1px solid #d9d9d9;
|
||||||
|
border-top: 1px solid #c0c0c0;
|
||||||
|
resize: none;
|
||||||
|
font: -webkit-small-control;
|
||||||
|
letter-spacing: normal;
|
||||||
|
word-spacing: normal;
|
||||||
|
text-transform: none;
|
||||||
|
text-indent: 0px;
|
||||||
|
text-shadow: none;
|
||||||
|
text-align: start;
|
||||||
|
font-family: arial;
|
||||||
|
font-size: 15px;
|
||||||
|
line-height: 17px;
|
||||||
|
width: 318px;
|
||||||
|
}
|
||||||
|
.allMetacodes {
|
||||||
|
padding: 5px 0;
|
||||||
|
}
|
||||||
|
a.button {
|
||||||
|
margin-right: 20px;
|
||||||
|
line-height: 40px;
|
||||||
|
}
|
||||||
|
a.button,
|
||||||
|
input.add {
|
||||||
|
float: left;
|
||||||
|
margin-top: 5px;
|
||||||
|
height: 40px;
|
||||||
|
font-size: 17px;
|
||||||
|
width: auto;
|
||||||
|
padding: 0 30px;
|
||||||
|
cursor: pointer;
|
||||||
|
font-weight: normal;
|
||||||
|
}
|
||||||
|
a.button:hover,
|
||||||
|
input.add:hover {
|
||||||
|
-webkit-box-shadow: none;
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,7 +2,8 @@ class ApplicationController < ActionController::Base
|
||||||
protect_from_forgery
|
protect_from_forgery
|
||||||
|
|
||||||
before_filter :get_invite_link
|
before_filter :get_invite_link
|
||||||
|
after_action :allow_embedding
|
||||||
|
|
||||||
# this is for global login
|
# this is for global login
|
||||||
include ContentHelper
|
include ContentHelper
|
||||||
|
|
||||||
|
@ -64,9 +65,13 @@ private
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_invite_link
|
def get_invite_link
|
||||||
unsafe_uri = request.env["REQUEST_URI"] || 'https://metamaps.cc'
|
@invite_link = "#{request.base_url}/join" + (current_user ? "?code=#{current_user.code}" : "")
|
||||||
valid_url = /^https?:\/\/([\w\.-]+)(:\d{1,5})?\/?$/
|
end
|
||||||
safe_uri = (unsafe_uri.match(valid_url)) ? unsafe_uri : '//metamaps.cc/'
|
|
||||||
@invite_link = "#{safe_uri}join" + (current_user ? "?code=#{current_user.code}" : "")
|
def allow_embedding
|
||||||
|
#allow all
|
||||||
|
response.headers.except! 'X-Frame-Options'
|
||||||
|
# or allow a whitelist
|
||||||
|
# response.headers['X-Frame-Options'] = 'ALLOW-FROM http://blog.metamaps.cc'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,8 +15,6 @@ class MappingsController < ApplicationController
|
||||||
def create
|
def create
|
||||||
@mapping = Mapping.new(mapping_params)
|
@mapping = Mapping.new(mapping_params)
|
||||||
|
|
||||||
@mapping.map.touch(:updated_at)
|
|
||||||
|
|
||||||
if @mapping.save
|
if @mapping.save
|
||||||
render json: @mapping, status: :created
|
render json: @mapping, status: :created
|
||||||
else
|
else
|
||||||
|
@ -28,8 +26,6 @@ class MappingsController < ApplicationController
|
||||||
def update
|
def update
|
||||||
@mapping = Mapping.find(params[:id])
|
@mapping = Mapping.find(params[:id])
|
||||||
|
|
||||||
@mapping.map.touch(:updated_at)
|
|
||||||
|
|
||||||
if @mapping.update_attributes(mapping_params)
|
if @mapping.update_attributes(mapping_params)
|
||||||
head :no_content
|
head :no_content
|
||||||
else
|
else
|
||||||
|
@ -44,8 +40,6 @@ class MappingsController < ApplicationController
|
||||||
|
|
||||||
@mapping.destroy
|
@mapping.destroy
|
||||||
|
|
||||||
@map.touch(:updated_at)
|
|
||||||
|
|
||||||
head :no_content
|
head :no_content
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
class MapsController < ApplicationController
|
class MapsController < ApplicationController
|
||||||
|
|
||||||
before_filter :require_user, only: [:create, :update, :screenshot, :destroy]
|
before_filter :require_user, only: [:create, :update, :screenshot, :destroy]
|
||||||
|
|
||||||
respond_to :html, :json, :csv
|
respond_to :html, :json, :csv
|
||||||
|
@ -10,38 +9,24 @@ class MapsController < ApplicationController
|
||||||
# GET /explore/featured
|
# GET /explore/featured
|
||||||
# GET /explore/mapper/:id
|
# GET /explore/mapper/:id
|
||||||
def index
|
def index
|
||||||
|
return redirect_to activemaps_url if request.path == "/explore"
|
||||||
if request.path == "/explore"
|
|
||||||
redirect_to activemaps_url and return
|
|
||||||
end
|
|
||||||
|
|
||||||
@current = current_user
|
@current = current_user
|
||||||
@user = nil
|
|
||||||
@maps = []
|
@maps = []
|
||||||
@mapperId = nil
|
page = params[:page].present? ? params[:page] : 1
|
||||||
|
|
||||||
if !params[:page]
|
|
||||||
page = 1
|
|
||||||
else
|
|
||||||
page = params[:page]
|
|
||||||
end
|
|
||||||
|
|
||||||
if request.path.index("/explore/active") != nil
|
if request.path.index("/explore/active") != nil
|
||||||
@maps = Map.where("maps.permission != ?", "private").order("updated_at DESC").page(page).per(20)
|
@maps = Map.where("maps.permission != ?", "private").order("updated_at DESC").page(page).per(20)
|
||||||
@request = "active"
|
@request = "active"
|
||||||
|
|
||||||
elsif request.path.index("/explore/featured") != nil
|
elsif request.path.index("/explore/featured") != nil
|
||||||
@maps = Map.where("maps.featured = ? AND maps.permission != ?", true, "private").order("updated_at DESC").page(page).per(20)
|
@maps = Map.where("maps.featured = ? AND maps.permission != ?", true, "private").order("updated_at DESC").page(page).per(20)
|
||||||
@request = "featured"
|
@request = "featured"
|
||||||
|
|
||||||
elsif request.path.index('/explore/mine') != nil # looking for maps by me
|
elsif request.path.index('/explore/mine') != nil # looking for maps by me
|
||||||
if !authenticated?
|
return redirect_to activemaps_url if !authenticated?
|
||||||
redirect_to activemaps_url and return
|
|
||||||
end
|
|
||||||
# don't need to exclude private maps because they all belong to you
|
# don't need to exclude private maps because they all belong to you
|
||||||
@maps = Map.where("maps.user_id = ?", @current.id).order("updated_at DESC").page(page).per(20)
|
@maps = Map.where("maps.user_id = ?", @current.id).order("updated_at DESC").page(page).per(20)
|
||||||
@request = "you"
|
@request = "you"
|
||||||
|
|
||||||
elsif request.path.index('/explore/mapper/') != nil # looking for maps by a mapper
|
elsif request.path.index('/explore/mapper/') != nil # looking for maps by a mapper
|
||||||
@user = User.find(params[:id])
|
@user = User.find(params[:id])
|
||||||
@maps = Map.where("maps.user_id = ? AND maps.permission != ?", @user.id, "private").order("updated_at DESC").page(page).per(20)
|
@maps = Map.where("maps.user_id = ? AND maps.permission != ?", @user.id, "private").order("updated_at DESC").page(page).per(20)
|
||||||
|
@ -121,7 +106,6 @@ class MapsController < ApplicationController
|
||||||
|
|
||||||
# POST maps
|
# POST maps
|
||||||
def create
|
def create
|
||||||
|
|
||||||
@user = current_user
|
@user = current_user
|
||||||
@map = Map.new()
|
@map = Map.new()
|
||||||
@map.name = params[:name]
|
@map.name = params[:name]
|
||||||
|
@ -129,40 +113,45 @@ class MapsController < ApplicationController
|
||||||
@map.permission = params[:permission]
|
@map.permission = params[:permission]
|
||||||
@map.user = @user
|
@map.user = @user
|
||||||
@map.arranged = false
|
@map.arranged = false
|
||||||
@map.save
|
|
||||||
|
|
||||||
if params[:topicsToMap]
|
if params[:topicsToMap]
|
||||||
@all = params[:topicsToMap]
|
@all = params[:topicsToMap]
|
||||||
@all = @all.split(',')
|
@all = @all.split(',')
|
||||||
@all.each do |topic|
|
@all.each do |topic|
|
||||||
topic = topic.split('/')
|
topic = topic.split('/')
|
||||||
@mapping = Mapping.new()
|
mapping = Mapping.new()
|
||||||
@mapping.user = @user
|
mapping.user = @user
|
||||||
@mapping.map = @map
|
mapping.mappable = Topic.find(topic[0])
|
||||||
@mapping.mappable = Topic.find(topic[0])
|
mapping.xloc = topic[1]
|
||||||
@mapping.xloc = topic[1]
|
mapping.yloc = topic[2]
|
||||||
@mapping.yloc = topic[2]
|
@map.topicmappings << mapping
|
||||||
@mapping.save
|
mapping.save
|
||||||
end
|
end
|
||||||
|
|
||||||
if params[:synapsesToMap]
|
if params[:synapsesToMap]
|
||||||
@synAll = params[:synapsesToMap]
|
@synAll = params[:synapsesToMap]
|
||||||
@synAll = @synAll.split(',')
|
@synAll = @synAll.split(',')
|
||||||
@synAll.each do |synapse_id|
|
@synAll.each do |synapse_id|
|
||||||
@mapping = Mapping.new()
|
mapping = Mapping.new()
|
||||||
@mapping.user = @user
|
mapping.user = @user
|
||||||
@mapping.map = @map
|
mapping.map = @map
|
||||||
@mapping.mappable = Synapse.find(synapse_id)
|
mapping.mappable = Synapse.find(synapse_id)
|
||||||
@mapping.save
|
@map.synapsemappings << mapping
|
||||||
|
mapping.save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@map.arranged = true
|
@map.arranged = true
|
||||||
@map.save
|
|
||||||
end
|
end
|
||||||
|
|
||||||
respond_to do |format|
|
if @map.save
|
||||||
|
respond_to do |format|
|
||||||
format.json { render :json => @map }
|
format.json { render :json => @map }
|
||||||
|
end
|
||||||
|
else
|
||||||
|
respond_to do |format|
|
||||||
|
format.json { render :json => "invalid params" }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,6 @@ class MetacodesController < ApplicationController
|
||||||
# GET /metacodes.json
|
# GET /metacodes.json
|
||||||
def index
|
def index
|
||||||
@metacodes = Metacode.order("name").all
|
@metacodes = Metacode.order("name").all
|
||||||
@metacodes.map do |metacode|
|
|
||||||
metacode.icon = ActionController::Base.helpers.asset_path(metacode.icon)
|
|
||||||
end
|
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html {
|
format.html {
|
||||||
|
@ -15,24 +12,12 @@ class MetacodesController < ApplicationController
|
||||||
redirect_to root_url, notice: "You need to be an admin for that."
|
redirect_to root_url, notice: "You need to be an admin for that."
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
render action: "index"
|
render :index
|
||||||
}
|
}
|
||||||
format.json { render json: @metacodes }
|
format.json { render json: @metacodes }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
### SHOW IS CURRENTLY DISABLED
|
|
||||||
# GET /metacodes/1
|
|
||||||
# GET /metacodes/1.json
|
|
||||||
# def show
|
|
||||||
# @metacode = Metacode.find(params[:id])
|
|
||||||
#
|
|
||||||
# respond_to do |format|
|
|
||||||
# format.html # show.html.erb
|
|
||||||
# format.json { render json: @metacode }
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
|
|
||||||
# GET /metacodes/new
|
# GET /metacodes/new
|
||||||
# GET /metacodes/new.json
|
# GET /metacodes/new.json
|
||||||
def new
|
def new
|
||||||
|
@ -59,7 +44,7 @@ class MetacodesController < ApplicationController
|
||||||
format.html { redirect_to metacodes_url, notice: 'Metacode was successfully created.' }
|
format.html { redirect_to metacodes_url, notice: 'Metacode was successfully created.' }
|
||||||
format.json { render json: @metacode, status: :created, location: metacodes_url }
|
format.json { render json: @metacode, status: :created, location: metacodes_url }
|
||||||
else
|
else
|
||||||
format.html { render action: "new" }
|
format.html { render :new }
|
||||||
format.json { render json: @metacode.errors, status: :unprocessable_entity }
|
format.json { render json: @metacode.errors, status: :unprocessable_entity }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -71,34 +56,20 @@ class MetacodesController < ApplicationController
|
||||||
@metacode = Metacode.find(params[:id])
|
@metacode = Metacode.find(params[:id])
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @metacode.update_attributes(metacode_params)
|
if @metacode.update(metacode_params)
|
||||||
format.html { redirect_to metacodes_url, notice: 'Metacode was successfully updated.' }
|
format.html { redirect_to metacodes_url, notice: 'Metacode was successfully updated.' }
|
||||||
format.json { head :no_content }
|
format.json { head :no_content }
|
||||||
else
|
else
|
||||||
format.html { render action: "edit" }
|
format.html { render :edit }
|
||||||
format.json { render json: @metacode.errors, status: :unprocessable_entity }
|
format.json { render json: @metacode.errors, status: :unprocessable_entity }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
### DESTROY IS CURRENTLY DISABLED
|
|
||||||
# DELETE /metacodes/1
|
|
||||||
# DELETE /metacodes/1.json
|
|
||||||
# def destroy
|
|
||||||
# @metacode = Metacode.find(params[:id])
|
|
||||||
# @metacode.destroy
|
|
||||||
#
|
|
||||||
# respond_to do |format|
|
|
||||||
# format.html { redirect_to metacodes_url }
|
|
||||||
# format.json { head :no_content }
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# Never trust parameters from the scary internet, only allow the white list through.
|
# Never trust parameters from the scary internet, only allow the white list through.
|
||||||
def metacode_params
|
def metacode_params
|
||||||
params.require(:metacode).permit(:id, :name, :icon, :color)
|
params.require(:metacode).permit(:id, :name, :aws_icon, :manual_icon, :color)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -22,7 +22,7 @@ class SynapsesController < ApplicationController
|
||||||
# POST /synapses.json
|
# POST /synapses.json
|
||||||
def create
|
def create
|
||||||
@synapse = Synapse.new(synapse_params)
|
@synapse = Synapse.new(synapse_params)
|
||||||
@synapse.update_attribute :desc, "" if @synapse.desc.nil?
|
@synapse.desc = "" if @synapse.desc.nil?
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @synapse.save
|
if @synapse.save
|
||||||
|
@ -37,7 +37,7 @@ class SynapsesController < ApplicationController
|
||||||
# PUT /synapses/1.json
|
# PUT /synapses/1.json
|
||||||
def update
|
def update
|
||||||
@synapse = Synapse.find(params[:id])
|
@synapse = Synapse.find(params[:id])
|
||||||
@synapse.update_attribute :desc, "" if @synapse.desc.nil?
|
@synapse.desc = "" if @synapse.desc.nil?
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @synapse.update_attributes(synapse_params)
|
if @synapse.update_attributes(synapse_params)
|
||||||
|
|
|
@ -43,41 +43,41 @@ class Map < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def topic_count
|
def topic_count
|
||||||
self.topics.length
|
topics.length
|
||||||
end
|
end
|
||||||
|
|
||||||
def synapse_count
|
def synapse_count
|
||||||
self.synapses.length
|
synapses.length
|
||||||
end
|
end
|
||||||
|
|
||||||
def user_name
|
def user_name
|
||||||
self.user.name
|
user.name
|
||||||
end
|
end
|
||||||
|
|
||||||
def user_image
|
def user_image
|
||||||
self.user.image.url
|
user.image.url
|
||||||
end
|
end
|
||||||
|
|
||||||
def contributor_count
|
def contributor_count
|
||||||
self.contributors.length
|
contributors.length
|
||||||
end
|
end
|
||||||
|
|
||||||
def screenshot_url
|
def screenshot_url
|
||||||
self.screenshot.url(:thumb)
|
screenshot.url(:thumb)
|
||||||
end
|
end
|
||||||
|
|
||||||
def created_at_str
|
def created_at_str
|
||||||
self.created_at.strftime("%m/%d/%Y")
|
created_at.strftime("%m/%d/%Y")
|
||||||
end
|
end
|
||||||
|
|
||||||
def updated_at_str
|
def updated_at_str
|
||||||
self.updated_at.strftime("%m/%d/%Y")
|
updated_at.strftime("%m/%d/%Y")
|
||||||
end
|
end
|
||||||
|
|
||||||
def as_json(options={})
|
def as_json(options={})
|
||||||
json = super(:methods =>[:user_name, :user_image, :topic_count, :synapse_count, :contributor_count, :screenshot_url], :except => [:screenshot_content_type, :screenshot_file_size, :screenshot_file_name, :screenshot_updated_at])
|
json = super(:methods =>[:user_name, :user_image, :topic_count, :synapse_count, :contributor_count, :screenshot_url], :except => [:screenshot_content_type, :screenshot_file_size, :screenshot_file_name, :screenshot_updated_at])
|
||||||
json[:created_at_clean] = self.created_at_str
|
json[:created_at_clean] = created_at_str
|
||||||
json[:updated_at_clean] = self.updated_at_str
|
json[:updated_at_clean] = updated_at_str
|
||||||
json
|
json
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -4,10 +4,15 @@ class Mapping < ActiveRecord::Base
|
||||||
scope :synapsemapping, -> { where(mappable_type: :Synapse) }
|
scope :synapsemapping, -> { where(mappable_type: :Synapse) }
|
||||||
|
|
||||||
belongs_to :mappable, polymorphic: true
|
belongs_to :mappable, polymorphic: true
|
||||||
|
belongs_to :map, :class_name => "Map", :foreign_key => "map_id", touch: true
|
||||||
belongs_to :map, :class_name => "Map", :foreign_key => "map_id"
|
|
||||||
|
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
|
|
||||||
|
validates :xloc, presence: true,
|
||||||
|
unless: Proc.new { |m| m.mappable_type == 'Synapse' }
|
||||||
|
validates :yloc, presence: true,
|
||||||
|
unless: Proc.new { |m| m.mappable_type == 'Synapse' }
|
||||||
|
validates :map, presence: true
|
||||||
|
validates :mappable, presence: true
|
||||||
|
|
||||||
def user_name
|
def user_name
|
||||||
self.user.name
|
self.user.name
|
||||||
|
|
|
@ -1,9 +1,37 @@
|
||||||
class Metacode < ActiveRecord::Base
|
class Metacode < ActiveRecord::Base
|
||||||
|
|
||||||
has_many :in_metacode_sets
|
has_many :in_metacode_sets
|
||||||
has_many :metacode_sets, :through => :in_metacode_sets
|
has_many :metacode_sets, :through => :in_metacode_sets
|
||||||
has_many :topics
|
has_many :topics
|
||||||
|
|
||||||
|
# This method associates the attribute ":aws_icon" with a file attachment
|
||||||
|
has_attached_file :aws_icon, :styles => {
|
||||||
|
:ninetysix => ['96x96#', :png],
|
||||||
|
},
|
||||||
|
:default_url => 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_wildcard.png'
|
||||||
|
|
||||||
|
# Validate the attached icon is image/jpg, image/png, etc
|
||||||
|
validates_attachment_content_type :aws_icon, :content_type => /\Aimage\/.*\Z/
|
||||||
|
|
||||||
|
validate :aws_xor_manual_icon
|
||||||
|
validate :manual_icon_https
|
||||||
|
before_create do
|
||||||
|
self.manual_icon = nil if self.manual_icon == ""
|
||||||
|
end
|
||||||
|
|
||||||
|
def icon(*args)
|
||||||
|
if manual_icon.present?
|
||||||
|
manual_icon
|
||||||
|
else
|
||||||
|
aws_icon(*args)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def as_json(options={})
|
||||||
|
default = super(options)
|
||||||
|
default[:icon] = icon
|
||||||
|
default.except('aws_icon_file_name', 'aws_icon_content_type', 'aws_icon_file_size', 'aws_icon_updated_at', 'manual_icon')
|
||||||
|
end
|
||||||
|
|
||||||
def hasSelected(user)
|
def hasSelected(user)
|
||||||
return true if user.settings.metacodes.include? self.id.to_s
|
return true if user.settings.metacodes.include? self.id.to_s
|
||||||
return false
|
return false
|
||||||
|
@ -13,4 +41,23 @@ class Metacode < ActiveRecord::Base
|
||||||
return true if self.metacode_sets.include? metacode_set
|
return true if self.metacode_sets.include? metacode_set
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def aws_xor_manual_icon
|
||||||
|
if aws_icon.blank? && manual_icon.blank?
|
||||||
|
errors.add(:base, "Either aws_icon or manual_icon is required")
|
||||||
|
end
|
||||||
|
if aws_icon.present? && manual_icon.present?
|
||||||
|
errors.add(:base, "Specify aws_icon or manual_icon, not both")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def manual_icon_https
|
||||||
|
if manual_icon.present?
|
||||||
|
unless manual_icon.starts_with? 'https'
|
||||||
|
errors.add(:base, "Manual icon must begin with https")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
class Synapse < ActiveRecord::Base
|
class Synapse < ActiveRecord::Base
|
||||||
|
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
|
|
||||||
belongs_to :topic1, :class_name => "Topic", :foreign_key => "node1_id"
|
belongs_to :topic1, :class_name => "Topic", :foreign_key => "node1_id"
|
||||||
|
@ -13,17 +12,25 @@ class Synapse < ActiveRecord::Base
|
||||||
validates :permission, presence: true
|
validates :permission, presence: true
|
||||||
validates :permission, inclusion: { in: Perm::ISSIONS.map(&:to_s) }
|
validates :permission, inclusion: { in: Perm::ISSIONS.map(&:to_s) }
|
||||||
|
|
||||||
|
validates :category, inclusion: { in: ['from-to', 'both'], allow_nil: true }
|
||||||
|
|
||||||
|
# :nocov:
|
||||||
def user_name
|
def user_name
|
||||||
self.user.name
|
user.name
|
||||||
end
|
end
|
||||||
|
# :nocov:
|
||||||
|
|
||||||
|
# :nocov:
|
||||||
def user_image
|
def user_image
|
||||||
self.user.image.url
|
user.image.url
|
||||||
end
|
end
|
||||||
|
# :nocov:
|
||||||
|
|
||||||
|
# :nocov:
|
||||||
def as_json(options={})
|
def as_json(options={})
|
||||||
super(:methods =>[:user_name, :user_image])
|
super(:methods =>[:user_name, :user_image])
|
||||||
end
|
end
|
||||||
|
# :nocov:
|
||||||
|
|
||||||
##### PERMISSIONS ######
|
##### PERMISSIONS ######
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,6 @@
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<% # TODO enable ssl on blog.metamaps.cc %>
|
|
||||||
<a id="lightbox_blog" href="http://blog.metamaps.cc" target="_blank">
|
<a id="lightbox_blog" href="http://blog.metamaps.cc" target="_blank">
|
||||||
<div class="lightboxAboutIcon"></div>
|
<div class="lightboxAboutIcon"></div>
|
||||||
blog
|
blog
|
||||||
|
@ -59,8 +58,7 @@
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<% # TODO switch to https:// once we're confident %>
|
<a id="lightbox_term" data-bypass="true" href="https://metamaps.cc/maps/331" target="_blank">
|
||||||
<a id="lightbox_term" data-bypass="true" href="//metamaps.cc/maps/331" target="_blank">
|
|
||||||
<div class="lightboxAboutIcon"></div>
|
<div class="lightboxAboutIcon"></div>
|
||||||
terms
|
terms
|
||||||
</a>
|
</a>
|
||||||
|
@ -154,7 +152,6 @@
|
||||||
<a id="chromeIcon" href="https://www.google.com/chrome/browser/" target="_blank">Chrome</a>
|
<a id="chromeIcon" href="https://www.google.com/chrome/browser/" target="_blank">Chrome</a>
|
||||||
<a id="fireFoxIcon" href="https://www.mozilla.org/en-US/firefox/new/" target="_blank">Firefox</a>
|
<a id="fireFoxIcon" href="https://www.mozilla.org/en-US/firefox/new/" target="_blank">Firefox</a>
|
||||||
<a id="safariIcon" href="http://support.apple.com/downloads/#safari" target="_blank">Safari</a>
|
<a id="safariIcon" href="http://support.apple.com/downloads/#safari" target="_blank">Safari</a>
|
||||||
<% # TODO https for blog.metamaps.cc %>
|
|
||||||
<p id="noIEbody">While it's downloading, explore our <a href="http://blog.metamaps.cc/">blog</a>,<br> watch the <a href="http://vimeo.com/88334167">tutorials</a>, or visit our <a href="http://metamapscc.uservoice.com/">knowledge base</a>!
|
<p id="noIEbody">While it's downloading, explore our <a href="http://blog.metamaps.cc/">blog</a>,<br> watch the <a href="http://vimeo.com/88334167">tutorials</a>, or visit our <a href="http://metamapscc.uservoice.com/">knowledge base</a>!
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -171,7 +168,7 @@
|
||||||
|
|
||||||
<p>If you'd like to know what your money is going towards, we publish our financials transparently - everything is recorded through our <a href="https://docs.google.com/spreadsheets/d/1n6aI77zlf1F9biH6wIbFkaOARK_QfvzqVC0vBsBKY2o">value accounting system</a>.</p>
|
<p>If you'd like to know what your money is going towards, we publish our financials transparently - everything is recorded through our <a href="https://docs.google.com/spreadsheets/d/1n6aI77zlf1F9biH6wIbFkaOARK_QfvzqVC0vBsBKY2o">value accounting system</a>.</p>
|
||||||
<div class="leaveSpace"></div>
|
<div class="leaveSpace"></div>
|
||||||
<script data-gratipay-username="Metamaps.cc" src="//gttp.co/v1.js"></script>
|
<script data-gratipay-username="Metamaps.cc" src="https://gttp.co/v1.js"></script>
|
||||||
<div style="font-size:16px;margin:0 auto;width:300px" class="blockchain-btn"
|
<div style="font-size:16px;margin:0 auto;width:300px" class="blockchain-btn"
|
||||||
data-address="15z24wj6E9tTsJgEBjnK81CtJ7kZZmxJYN"
|
data-address="15z24wj6E9tTsJgEBjnK81CtJ7kZZmxJYN"
|
||||||
data-shared="false">
|
data-shared="false">
|
||||||
|
@ -203,8 +200,7 @@
|
||||||
|
|
||||||
<p>Want to help with design, code, community building, or communications for Metamaps? We're an open value network, which for us means we want to invite and empower peers to participate in creating value together.
|
<p>Want to help with design, code, community building, or communications for Metamaps? We're an open value network, which for us means we want to invite and empower peers to participate in creating value together.
|
||||||
|
|
||||||
<% # TODO change this link to https once it works %>
|
<p>To be a <b>USER</b>, request an invite! We'll expect you to abide by our <a href="https://metamaps.cc/maps/331" target="_blank">terms of service</a>.</p>
|
||||||
<p>To be a <b>USER</b>, request an invite! We'll expect you to abide by our <a href="http://metamaps.cc/maps/331" target="_blank">terms of service</a>.</p>
|
|
||||||
|
|
||||||
<p>To be a <b>CONTRIBUTOR</b>, simply <a href="https://docs.google.com/document/d/1z8FsSmYkHbLRLOsXc8i8M5ubKky8_WB2E9bLBoXJapU" target="_blank">enter our spaces</a> and join the conversation! We'll expect you to follow some guidelines.</p>
|
<p>To be a <b>CONTRIBUTOR</b>, simply <a href="https://docs.google.com/document/d/1z8FsSmYkHbLRLOsXc8i8M5ubKky8_WB2E9bLBoXJapU" target="_blank">enter our spaces</a> and join the conversation! We'll expect you to follow some guidelines.</p>
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
<%#
|
<% #
|
||||||
# @file
|
# @file
|
||||||
# Shows a list of all maps, or just a user's maps.
|
# Shows a list of all maps, or just a user's maps.
|
||||||
# TODO: What url is this accessible at?
|
# GET /explore/active(.:format)
|
||||||
#%>
|
# GET /explore/featured(.:format)
|
||||||
|
# GET /explore/mine(.:format)
|
||||||
|
# GET /explore/mapper/:id(.:format)
|
||||||
|
# GET /maps(.:format)
|
||||||
|
# %>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
<% if @request == "you" %>
|
<% if @request == "you" %>
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
<% if @metacode.errors.any? %>
|
<% if @metacode.errors.any? %>
|
||||||
<div id="error_explanation">
|
<div id="error_explanation">
|
||||||
<h2><%= pluralize(@metacode.errors.count, "error") %> prohibited this metacode from being saved:</h2>
|
<h2><%= pluralize(@metacode.errors.count, "error") %> prohibited this metacode from being saved:</h2>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<% @metacode.errors.full_messages.each do |msg| %>
|
<% @metacode.errors.full_messages.each do |msg| %>
|
||||||
<li><%= msg %></li>
|
<li><%= msg %></li>
|
||||||
|
@ -16,9 +15,20 @@
|
||||||
<%= f.text_field :name %>
|
<%= f.text_field :name %>
|
||||||
<div class="clearfloat"></div>
|
<div class="clearfloat"></div>
|
||||||
</div>
|
</div>
|
||||||
|
<% unless @metacode.new_record? %>
|
||||||
|
<div class="field">
|
||||||
|
<%= f.label 'Current Icon' %>
|
||||||
|
<%= image_tag @metacode.icon, width: 96 %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<%= f.label :icon %>
|
<% if @metacode.new_record? %>
|
||||||
<%= f.text_field :icon %>
|
<%= f.label 'Icon' %>
|
||||||
|
<% else %>
|
||||||
|
<%= f.label 'Replace Icon: ' %>
|
||||||
|
<% end %>
|
||||||
|
<%= f.hidden_field :manual_icon, value: nil %>
|
||||||
|
<%= f.file_field :aws_icon %>
|
||||||
<div class="clearfloat"></div>
|
<div class="clearfloat"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
<% @metacodes.each do |metacode| %>
|
<% @metacodes.each do |metacode| %>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= metacode.name %></td>
|
<td><%= metacode.name %></td>
|
||||||
<td class="iconURL"><%= asset_path metacode.icon %></td>
|
<td class="iconURL"><%= metacode.icon %></td>
|
||||||
<% if metacode.color %>
|
<% if metacode.color %>
|
||||||
<td class="iconColor" style="background-color: <%= metacode.color %>">
|
<td class="iconColor" style="background-color: <%= metacode.color %>">
|
||||||
<%= metacode.color %>
|
<%= metacode.color %>
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
<% else %>
|
<% else %>
|
||||||
<td></td>
|
<td></td>
|
||||||
<% end %>
|
<% end %>
|
||||||
<td><img width='40' src='<%= asset_path metacode.icon %>' /></td>
|
<td><%= image_tag metacode.icon, width: 40 %></td>
|
||||||
<td><%= link_to 'Edit', edit_metacode_path(metacode), :data => { :bypass => 'true'} %></td>
|
<td><%= link_to 'Edit', edit_metacode_path(metacode), :data => { :bypass => 'true'} %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -76,7 +76,8 @@
|
||||||
|
|
||||||
<div id="csCreatingSynapses">
|
<div id="csCreatingSynapses">
|
||||||
<div class="csItem"><span class="csTitle">Open 'Create Synapse' prompt:</span> Right-click & drag from one topic to another</div>
|
<div class="csItem"><span class="csTitle">Open 'Create Synapse' prompt:</span> Right-click & drag from one topic to another</div>
|
||||||
<div class="csItem indented"><span class="csTitle">Enter:</span> Create synapse</div>
|
<div class="csItem indented"><span class="csTitle">Enter or Tab:</span> Create synapse</div>
|
||||||
|
<div class="csItem indented"><span class="csTitle">Esc or Delete:</span> Cancel synapse creation</div>
|
||||||
<div class="csItem indented">*You do not have to add a description</div>
|
<div class="csItem indented">*You do not have to add a description</div>
|
||||||
<div class="csItem"><span class="csTitle">Create new Topic with Synapse:</span> Right-click + drag from topic to open canvas</div>
|
<div class="csItem"><span class="csTitle">Create new Topic with Synapse:</span> Right-click + drag from topic to open canvas</div>
|
||||||
<div class="csItem indented"><span class="csTitle">Enter:</span> Create topic</div>
|
<div class="csItem indented"><span class="csTitle">Enter:</span> Create topic</div>
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
<%#
|
|
||||||
# @file
|
|
||||||
# Partial for rendered a new synapse form
|
|
||||||
# TODO: Is this used? Where?
|
|
||||||
#%>
|
|
||||||
<div class="anypage">
|
|
||||||
<%= form_for Synapse.new, url: synapses_url, remote: true do |form| %>
|
|
||||||
<%= form.text_field :desc, :placeholder => "describe the connection..." %>
|
|
||||||
<% end %>
|
|
||||||
</div>
|
|
|
@ -1,7 +1,8 @@
|
||||||
#!/bin/bash -l
|
#!/bin/bash -l
|
||||||
|
|
||||||
#prerequisites
|
# jenkins machine prerequisites
|
||||||
#sudo aptitude -q -y install libpq-dev
|
# sudo aptitude -q -y install libpq-dev
|
||||||
|
# install rvm with user gemsets
|
||||||
|
|
||||||
source "$HOME/.rvm/scripts/rvm"
|
source "$HOME/.rvm/scripts/rvm"
|
||||||
rvm use $(cat .ruby-version) || \
|
rvm use $(cat .ruby-version) || \
|
||||||
|
@ -20,5 +21,8 @@ sed -i -e "s/DB_USERNAME='.*'/DB_USERNAME='jenkins'/" .env
|
||||||
|
|
||||||
#test
|
#test
|
||||||
bundle install
|
bundle install
|
||||||
rake db:create db:test:prepare
|
rake db:drop
|
||||||
bundle exec rspec
|
rake db:create
|
||||||
|
rake db:schema:load
|
||||||
|
rake db:migrate
|
||||||
|
COVERAGE=on bundle exec rspec
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
class AddAttachmentIconToMetacodes < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
change_table :metacodes do |t|
|
||||||
|
t.rename :icon, :manual_icon
|
||||||
|
t.attachment :aws_icon
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
12
db/schema.rb
12
db/schema.rb
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20160120061513) do
|
ActiveRecord::Schema.define(version: 20160223061711) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
@ -89,10 +89,14 @@ ActiveRecord::Schema.define(version: 20160120061513) do
|
||||||
|
|
||||||
create_table "metacodes", force: :cascade do |t|
|
create_table "metacodes", force: :cascade do |t|
|
||||||
t.text "name"
|
t.text "name"
|
||||||
t.string "icon"
|
t.string "manual_icon"
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
t.string "color"
|
t.string "color"
|
||||||
|
t.string "aws_icon_file_name"
|
||||||
|
t.string "aws_icon_content_type"
|
||||||
|
t.integer "aws_icon_file_size"
|
||||||
|
t.datetime "aws_icon_updated_at"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "synapses", force: :cascade do |t|
|
create_table "synapses", force: :cascade do |t|
|
||||||
|
|
94
db/seeds.rb
94
db/seeds.rb
|
@ -24,283 +24,283 @@ User.new({
|
||||||
## METACODES
|
## METACODES
|
||||||
Metacode.create({
|
Metacode.create({
|
||||||
name: 'Action',
|
name: 'Action',
|
||||||
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_action.png',
|
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_action.png',
|
||||||
color: '#BD6C85'
|
color: '#BD6C85'
|
||||||
})
|
})
|
||||||
|
|
||||||
Metacode.create({
|
Metacode.create({
|
||||||
name: 'Activity',
|
name: 'Activity',
|
||||||
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_activity.png',
|
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_activity.png',
|
||||||
color: '#6EBF65'
|
color: '#6EBF65'
|
||||||
})
|
})
|
||||||
|
|
||||||
Metacode.create({
|
Metacode.create({
|
||||||
name: 'Catalyst',
|
name: 'Catalyst',
|
||||||
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_catalyst.png',
|
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_catalyst.png',
|
||||||
color: '#EF8964',
|
color: '#EF8964',
|
||||||
})
|
})
|
||||||
|
|
||||||
Metacode.create({
|
Metacode.create({
|
||||||
name: 'Closed',
|
name: 'Closed',
|
||||||
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_closedissue.png',
|
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_closedissue.png',
|
||||||
color: '#ABB49F',
|
color: '#ABB49F',
|
||||||
})
|
})
|
||||||
|
|
||||||
Metacode.create({
|
Metacode.create({
|
||||||
name: 'Process',
|
name: 'Process',
|
||||||
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_process.png',
|
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_process.png',
|
||||||
color: '#BDB25E',
|
color: '#BDB25E',
|
||||||
})
|
})
|
||||||
|
|
||||||
Metacode.create({
|
Metacode.create({
|
||||||
name: 'Future',
|
name: 'Future',
|
||||||
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_futuredev.png',
|
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_futuredev.png',
|
||||||
color: '#25A17F',
|
color: '#25A17F',
|
||||||
})
|
})
|
||||||
|
|
||||||
Metacode.create({
|
Metacode.create({
|
||||||
name: 'Group',
|
name: 'Group',
|
||||||
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_group.png',
|
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_group.png',
|
||||||
color: '#7076BC',
|
color: '#7076BC',
|
||||||
})
|
})
|
||||||
|
|
||||||
Metacode.create({
|
Metacode.create({
|
||||||
name: 'Implication',
|
name: 'Implication',
|
||||||
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_implication.png',
|
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_implication.png',
|
||||||
color: '#83DECA',
|
color: '#83DECA',
|
||||||
})
|
})
|
||||||
|
|
||||||
Metacode.create({
|
Metacode.create({
|
||||||
name: 'Insight',
|
name: 'Insight',
|
||||||
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_insight.png',
|
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_insight.png',
|
||||||
color: '#B074AD',
|
color: '#B074AD',
|
||||||
})
|
})
|
||||||
|
|
||||||
Metacode.create({
|
Metacode.create({
|
||||||
name: 'Intention',
|
name: 'Intention',
|
||||||
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_intention.png',
|
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_intention.png',
|
||||||
color: '#BAEAFF',
|
color: '#BAEAFF',
|
||||||
})
|
})
|
||||||
|
|
||||||
Metacode.create({
|
Metacode.create({
|
||||||
name: 'Knowledge',
|
name: 'Knowledge',
|
||||||
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_knowledge.png',
|
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_knowledge.png',
|
||||||
color: '#60ACF7',
|
color: '#60ACF7',
|
||||||
})
|
})
|
||||||
|
|
||||||
Metacode.create({
|
Metacode.create({
|
||||||
name: 'Location',
|
name: 'Location',
|
||||||
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_location.png',
|
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_location.png',
|
||||||
color: '#ABD9A7',
|
color: '#ABD9A7',
|
||||||
})
|
})
|
||||||
|
|
||||||
Metacode.create({
|
Metacode.create({
|
||||||
name: 'Need',
|
name: 'Need',
|
||||||
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_need.png',
|
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_need.png',
|
||||||
color: '#D2A7D4',
|
color: '#D2A7D4',
|
||||||
})
|
})
|
||||||
|
|
||||||
Metacode.create({
|
Metacode.create({
|
||||||
name: 'Open',
|
name: 'Open',
|
||||||
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_openissue.png',
|
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_openissue.png',
|
||||||
color: '#9BBF71',
|
color: '#9BBF71',
|
||||||
})
|
})
|
||||||
|
|
||||||
Metacode.create({
|
Metacode.create({
|
||||||
name: 'Opportunity',
|
name: 'Opportunity',
|
||||||
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_opportunity.png',
|
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_opportunity.png',
|
||||||
color: '#889F64',
|
color: '#889F64',
|
||||||
})
|
})
|
||||||
|
|
||||||
Metacode.create({
|
Metacode.create({
|
||||||
name: 'Person',
|
name: 'Person',
|
||||||
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_person.png',
|
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_person.png',
|
||||||
color: '#DE925F',
|
color: '#DE925F',
|
||||||
})
|
})
|
||||||
|
|
||||||
Metacode.create({
|
Metacode.create({
|
||||||
name: 'Platform',
|
name: 'Platform',
|
||||||
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_platform.png',
|
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_platform.png',
|
||||||
color: '#21C8FE',
|
color: '#21C8FE',
|
||||||
})
|
})
|
||||||
|
|
||||||
Metacode.create({
|
Metacode.create({
|
||||||
name: 'Problem',
|
name: 'Problem',
|
||||||
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_problem.png',
|
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_problem.png',
|
||||||
color: '#99CFC4',
|
color: '#99CFC4',
|
||||||
})
|
})
|
||||||
|
|
||||||
Metacode.create({
|
Metacode.create({
|
||||||
name: 'Resource',
|
name: 'Resource',
|
||||||
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_resource.png',
|
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_resource.png',
|
||||||
color: '#C98C63',
|
color: '#C98C63',
|
||||||
})
|
})
|
||||||
|
|
||||||
Metacode.create({
|
Metacode.create({
|
||||||
name: 'Role',
|
name: 'Role',
|
||||||
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_role.png',
|
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_role.png',
|
||||||
color: '#A8595D',
|
color: '#A8595D',
|
||||||
})
|
})
|
||||||
|
|
||||||
Metacode.create({
|
Metacode.create({
|
||||||
name: 'Task',
|
name: 'Task',
|
||||||
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_task.png',
|
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_task.png',
|
||||||
color: '#3397C4',
|
color: '#3397C4',
|
||||||
})
|
})
|
||||||
|
|
||||||
Metacode.create({
|
Metacode.create({
|
||||||
name: 'Trajectory',
|
name: 'Trajectory',
|
||||||
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_trajectory.png',
|
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_trajectory.png',
|
||||||
color: '#D3AA4C',
|
color: '#D3AA4C',
|
||||||
})
|
})
|
||||||
|
|
||||||
Metacode.create({
|
Metacode.create({
|
||||||
name: 'Argument',
|
name: 'Argument',
|
||||||
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_argument.png',
|
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_argument.png',
|
||||||
color: '#7FAEFD',
|
color: '#7FAEFD',
|
||||||
})
|
})
|
||||||
|
|
||||||
Metacode.create({
|
Metacode.create({
|
||||||
name: 'Con',
|
name: 'Con',
|
||||||
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_con.png',
|
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_con.png',
|
||||||
color: '#CF7C74',
|
color: '#CF7C74',
|
||||||
})
|
})
|
||||||
|
|
||||||
Metacode.create({
|
Metacode.create({
|
||||||
name: 'Subject',
|
name: 'Subject',
|
||||||
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_subject.png',
|
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_subject.png',
|
||||||
color: '#8293D8',
|
color: '#8293D8',
|
||||||
})
|
})
|
||||||
|
|
||||||
Metacode.create({
|
Metacode.create({
|
||||||
name: 'Decision',
|
name: 'Decision',
|
||||||
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_decision.png',
|
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_decision.png',
|
||||||
color: '#CCA866',
|
color: '#CCA866',
|
||||||
})
|
})
|
||||||
|
|
||||||
Metacode.create({
|
Metacode.create({
|
||||||
name: 'Event',
|
name: 'Event',
|
||||||
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_event.png',
|
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_event.png',
|
||||||
color: '#F5854B',
|
color: '#F5854B',
|
||||||
})
|
})
|
||||||
|
|
||||||
Metacode.create({
|
Metacode.create({
|
||||||
name: 'Example',
|
name: 'Example',
|
||||||
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_example.png',
|
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_example.png',
|
||||||
color: '#618C61',
|
color: '#618C61',
|
||||||
})
|
})
|
||||||
|
|
||||||
Metacode.create({
|
Metacode.create({
|
||||||
name: 'Experience',
|
name: 'Experience',
|
||||||
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_experience.png',
|
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_experience.png',
|
||||||
color: '#BE995F',
|
color: '#BE995F',
|
||||||
})
|
})
|
||||||
|
|
||||||
Metacode.create({
|
Metacode.create({
|
||||||
name: 'Feedback',
|
name: 'Feedback',
|
||||||
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_feedback.png',
|
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_feedback.png',
|
||||||
color: '#54A19D',
|
color: '#54A19D',
|
||||||
})
|
})
|
||||||
|
|
||||||
Metacode.create({
|
Metacode.create({
|
||||||
name: 'Aim',
|
name: 'Aim',
|
||||||
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_aim.png',
|
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_aim.png',
|
||||||
color: '#B0B0B0',
|
color: '#B0B0B0',
|
||||||
})
|
})
|
||||||
|
|
||||||
Metacode.create({
|
Metacode.create({
|
||||||
name: 'Good',
|
name: 'Good',
|
||||||
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_goodpractice.png',
|
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_goodpractice.png',
|
||||||
color: '#BD9E86',
|
color: '#BD9E86',
|
||||||
})
|
})
|
||||||
|
|
||||||
Metacode.create({
|
Metacode.create({
|
||||||
name: 'Idea',
|
name: 'Idea',
|
||||||
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_idea.png',
|
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_idea.png',
|
||||||
color: '#C4BC5E',
|
color: '#C4BC5E',
|
||||||
})
|
})
|
||||||
|
|
||||||
Metacode.create({
|
Metacode.create({
|
||||||
name: 'List',
|
name: 'List',
|
||||||
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_list.png',
|
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_list.png',
|
||||||
color: '#B7A499',
|
color: '#B7A499',
|
||||||
})
|
})
|
||||||
|
|
||||||
Metacode.create({
|
Metacode.create({
|
||||||
name: 'Media',
|
name: 'Media',
|
||||||
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_media.png',
|
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_media.png',
|
||||||
color: '#6D94CC',
|
color: '#6D94CC',
|
||||||
})
|
})
|
||||||
|
|
||||||
Metacode.create({
|
Metacode.create({
|
||||||
name: 'Metamap',
|
name: 'Metamap',
|
||||||
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_metamap.png',
|
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_metamap.png',
|
||||||
color: '#AEA9FD',
|
color: '#AEA9FD',
|
||||||
})
|
})
|
||||||
|
|
||||||
Metacode.create({
|
Metacode.create({
|
||||||
name: 'Model',
|
name: 'Model',
|
||||||
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_model.png',
|
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_model.png',
|
||||||
color: '#B385BA',
|
color: '#B385BA',
|
||||||
})
|
})
|
||||||
|
|
||||||
Metacode.create({
|
Metacode.create({
|
||||||
name: 'Note',
|
name: 'Note',
|
||||||
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_note.png',
|
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_note.png',
|
||||||
color: '#A389A1',
|
color: '#A389A1',
|
||||||
})
|
})
|
||||||
|
|
||||||
Metacode.create({
|
Metacode.create({
|
||||||
name: 'Perspective',
|
name: 'Perspective',
|
||||||
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_perspective.png',
|
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_perspective.png',
|
||||||
color: '#2EB6CC',
|
color: '#2EB6CC',
|
||||||
})
|
})
|
||||||
|
|
||||||
Metacode.create({
|
Metacode.create({
|
||||||
name: 'Pro',
|
name: 'Pro',
|
||||||
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_pro.png',
|
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_pro.png',
|
||||||
color: '#89B879',
|
color: '#89B879',
|
||||||
})
|
})
|
||||||
|
|
||||||
Metacode.create({
|
Metacode.create({
|
||||||
name: 'Project',
|
name: 'Project',
|
||||||
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_project.png',
|
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_project.png',
|
||||||
color: '#85A050',
|
color: '#85A050',
|
||||||
})
|
})
|
||||||
|
|
||||||
Metacode.create({
|
Metacode.create({
|
||||||
name: 'Question',
|
name: 'Question',
|
||||||
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_question.png',
|
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_question.png',
|
||||||
color: '#5CB3B3',
|
color: '#5CB3B3',
|
||||||
})
|
})
|
||||||
|
|
||||||
Metacode.create({
|
Metacode.create({
|
||||||
name: 'Reference',
|
name: 'Reference',
|
||||||
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_reference.png',
|
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_reference.png',
|
||||||
color: '#A7A7A7',
|
color: '#A7A7A7',
|
||||||
})
|
})
|
||||||
|
|
||||||
Metacode.create({
|
Metacode.create({
|
||||||
name: 'Research',
|
name: 'Research',
|
||||||
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_research.png',
|
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_research.png',
|
||||||
color: '#CD8E89',
|
color: '#CD8E89',
|
||||||
})
|
})
|
||||||
|
|
||||||
Metacode.create({
|
Metacode.create({
|
||||||
name: 'Status',
|
name: 'Status',
|
||||||
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_status.png',
|
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_status.png',
|
||||||
color: '#EFA7C0',
|
color: '#EFA7C0',
|
||||||
})
|
})
|
||||||
|
|
||||||
Metacode.create({
|
Metacode.create({
|
||||||
name: 'Tool',
|
name: 'Tool',
|
||||||
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_tool.png',
|
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_tool.png',
|
||||||
color: '#828282',
|
color: '#828282',
|
||||||
})
|
})
|
||||||
|
|
||||||
Metacode.create({
|
Metacode.create({
|
||||||
name: 'Wildcard',
|
name: 'Wildcard',
|
||||||
icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_wildcard.png',
|
manual_icon: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_wildcard.png',
|
||||||
color: '#73C7DE',
|
color: '#73C7DE',
|
||||||
})
|
})
|
||||||
## END METACODES
|
## END METACODES
|
||||||
|
|
|
@ -1,57 +0,0 @@
|
||||||
//parse arguments passed from command line (or more likely, from rails)
|
|
||||||
var system = require('system');
|
|
||||||
var args = system.args;
|
|
||||||
if (args.length <= 1) {
|
|
||||||
phantom.exit();
|
|
||||||
throw new Error("no arguments supplied on command line");
|
|
||||||
}//if
|
|
||||||
|
|
||||||
//configurable variables - CHANGE ME
|
|
||||||
var mapID = args[1];
|
|
||||||
var environment = args[2];
|
|
||||||
var address = environment === 'development' ? 'http://localhost:3000' : 'http://metamaps.herokuapp.com';
|
|
||||||
var url = address + '/maps/' + mapID;
|
|
||||||
var width = 940;
|
|
||||||
var height = 630;
|
|
||||||
|
|
||||||
//set up page and the area we'll render as a PNG
|
|
||||||
var page = require('webpage').create();
|
|
||||||
page.viewportSize = {
|
|
||||||
width: width,
|
|
||||||
height: height
|
|
||||||
};
|
|
||||||
|
|
||||||
page.open(url, function (status) {
|
|
||||||
if (status === 'success') {
|
|
||||||
//since this isn't evaluateAsync, it should also ensure the asynchronous
|
|
||||||
//js stuff is loaded too, hopefully?
|
|
||||||
|
|
||||||
page.onCallback = function(data){
|
|
||||||
|
|
||||||
//pass to ruby
|
|
||||||
console.log(page.renderBase64('PNG'));
|
|
||||||
|
|
||||||
//render to the metamaps_gen002 directory for debug
|
|
||||||
//page.render('map1.png', 'PNG');
|
|
||||||
|
|
||||||
phantom.exit();
|
|
||||||
};
|
|
||||||
|
|
||||||
page.evaluate(function() {
|
|
||||||
|
|
||||||
$(document).ready(function () {
|
|
||||||
//$(document).on(Metamaps.JIT.events.animationDone, function() {
|
|
||||||
setTimeout(function(){
|
|
||||||
$('.upperLeftUI, .upperRightUI, .mapControls, .infoAndHelp, .uv-icon, .footer').hide();
|
|
||||||
Metamaps.JIT.zoomExtents();
|
|
||||||
window.callPhantom();
|
|
||||||
}, 5000);
|
|
||||||
});
|
|
||||||
|
|
||||||
});//page.evaluate
|
|
||||||
|
|
||||||
} else {
|
|
||||||
//failed to load
|
|
||||||
phantom.exit();
|
|
||||||
}//if
|
|
||||||
});
|
|
|
@ -1,60 +1,16 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
# This spec was generated by rspec-rails when you ran the scaffold generator.
|
|
||||||
# It demonstrates how one might use RSpec to specify the controller code that
|
|
||||||
# was generated by Rails when you ran the scaffold generator.
|
|
||||||
#
|
|
||||||
# It assumes that the implementation code is generated by the rails scaffold
|
|
||||||
# generator. If you are using any extension libraries to generate different
|
|
||||||
# controller code, this generated spec may or may not pass.
|
|
||||||
#
|
|
||||||
# It only uses APIs available in rails and/or rspec-rails. There are a number
|
|
||||||
# of tools you can use to make these specs even more expressive, but we're
|
|
||||||
# sticking to rails and rspec-rails APIs to keep things simple and stable.
|
|
||||||
#
|
|
||||||
# Compared to earlier versions of this generator, there is very limited use of
|
|
||||||
# stubs and message expectations in this spec. Stubs are only used when there
|
|
||||||
# is no simpler way to get a handle on the object needed for the example.
|
|
||||||
# Message expectations are only used when there is no simpler way to specify
|
|
||||||
# that an instance is receiving a specific message.
|
|
||||||
|
|
||||||
RSpec.describe MappingsController, type: :controller do
|
RSpec.describe MappingsController, type: :controller do
|
||||||
# This should return the minimal set of attributes required to create a valid
|
let!(:mapping) { create(:mapping) }
|
||||||
# Mapping. As you add validations to Mapping, be sure to
|
let(:valid_attributes) { mapping.attributes.except('id') }
|
||||||
# adjust the attributes here as well.
|
let(:invalid_attributes) { { xloc: 0 } }
|
||||||
let(:valid_attributes) do
|
before :each do
|
||||||
skip('Add a hash of attributes valid for your model')
|
sign_in
|
||||||
end
|
|
||||||
|
|
||||||
let(:invalid_attributes) do
|
|
||||||
skip('Add a hash of attributes invalid for your model')
|
|
||||||
end
|
|
||||||
|
|
||||||
# This should return the minimal set of values that should be in the session
|
|
||||||
# in order to pass any filters (e.g. authentication) defined in
|
|
||||||
# MappingsController. Be sure to keep this updated too.
|
|
||||||
let(:valid_session) { {} }
|
|
||||||
|
|
||||||
describe 'GET #index' do
|
|
||||||
it 'assigns all mappings as @mappings' do
|
|
||||||
mapping = Mapping.create! valid_attributes
|
|
||||||
get :index, {}, valid_session
|
|
||||||
expect(assigns(:mappings)).to eq([mapping])
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'GET #show' do
|
describe 'GET #show' do
|
||||||
it 'assigns the requested mapping as @mapping' do
|
it 'assigns the requested mapping as @mapping' do
|
||||||
mapping = Mapping.create! valid_attributes
|
get :show, { id: mapping.to_param }
|
||||||
get :show, { id: mapping.to_param }, valid_session
|
|
||||||
expect(assigns(:mapping)).to eq(mapping)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'GET #edit' do
|
|
||||||
it 'assigns the requested mapping as @mapping' do
|
|
||||||
mapping = Mapping.create! valid_attributes
|
|
||||||
get :edit, { id: mapping.to_param }, valid_session
|
|
||||||
expect(assigns(:mapping)).to eq(mapping)
|
expect(assigns(:mapping)).to eq(mapping)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -63,98 +19,56 @@ RSpec.describe MappingsController, type: :controller do
|
||||||
context 'with valid params' do
|
context 'with valid params' do
|
||||||
it 'creates a new Mapping' do
|
it 'creates a new Mapping' do
|
||||||
expect do
|
expect do
|
||||||
post :create, { mapping: valid_attributes }, valid_session
|
post :create, { mapping: valid_attributes }
|
||||||
end.to change(Mapping, :count).by(1)
|
end.to change(Mapping, :count).by(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'assigns a newly created mapping as @mapping' do
|
it 'assigns a newly created mapping as @mapping' do
|
||||||
post :create, { mapping: valid_attributes }, valid_session
|
post :create, { mapping: valid_attributes }
|
||||||
expect(assigns(:mapping)).to be_a(Mapping)
|
expect(assigns(:mapping)).to be_a(Mapping)
|
||||||
expect(assigns(:mapping)).to be_persisted
|
expect(assigns(:mapping)).to be_persisted
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'redirects to the created mapping' do
|
|
||||||
post :create, { mapping: valid_attributes }, valid_session
|
|
||||||
expect(response).to redirect_to(Mapping.last)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with invalid params' do
|
context 'with invalid params' do
|
||||||
it 'assigns a newly created but unsaved mapping as @mapping' do
|
it 'assigns a newly created but unsaved mapping as @mapping' do
|
||||||
post :create, { mapping: invalid_attributes }, valid_session
|
post :create, { mapping: invalid_attributes }
|
||||||
expect(assigns(:mapping)).to be_a_new(Mapping)
|
expect(assigns(:mapping)).to be_a_new(Mapping)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "re-renders the 'new' template" do
|
|
||||||
post :create, { mapping: invalid_attributes }, valid_session
|
|
||||||
expect(response).to render_template('new')
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'PUT #update' do
|
describe 'PUT #update' do
|
||||||
context 'with valid params' do
|
context 'with valid params' do
|
||||||
let(:new_attributes) do
|
let(:new_attributes) { build(:mapping_random_location).attributes.except('id') }
|
||||||
skip('Add a hash of attributes valid for your model')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'updates the requested mapping' do
|
it 'updates the requested mapping' do
|
||||||
mapping = Mapping.create! valid_attributes
|
|
||||||
put :update,
|
put :update,
|
||||||
{ id: mapping.to_param, mapping: new_attributes },
|
{ id: mapping.to_param, mapping: new_attributes }
|
||||||
valid_session
|
|
||||||
mapping.reload
|
mapping.reload
|
||||||
skip('Add assertions for updated state')
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'assigns the requested mapping as @mapping' do
|
it 'assigns the requested mapping as @mapping' do
|
||||||
mapping = Mapping.create! valid_attributes
|
|
||||||
put :update,
|
put :update,
|
||||||
{ id: mapping.to_param, mapping: valid_attributes },
|
{ id: mapping.to_param, mapping: valid_attributes }
|
||||||
valid_session
|
|
||||||
expect(assigns(:mapping)).to eq(mapping)
|
expect(assigns(:mapping)).to eq(mapping)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'redirects to the mapping' do
|
|
||||||
mapping = Mapping.create! valid_attributes
|
|
||||||
put :update,
|
|
||||||
{ id: mapping.to_param, mapping: valid_attributes },
|
|
||||||
valid_session
|
|
||||||
expect(response).to redirect_to(mapping)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with invalid params' do
|
context 'with invalid params' do
|
||||||
it 'assigns the mapping as @mapping' do
|
it 'assigns the mapping as @mapping' do
|
||||||
mapping = Mapping.create! valid_attributes
|
|
||||||
put :update,
|
put :update,
|
||||||
{ id: mapping.to_param, mapping: invalid_attributes },
|
{ id: mapping.to_param, mapping: invalid_attributes }
|
||||||
valid_session
|
|
||||||
expect(assigns(:mapping)).to eq(mapping)
|
expect(assigns(:mapping)).to eq(mapping)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "re-renders the 'edit' template" do
|
|
||||||
mapping = Mapping.create! valid_attributes
|
|
||||||
put :update,
|
|
||||||
{ id: mapping.to_param, mapping: invalid_attributes },
|
|
||||||
valid_session
|
|
||||||
expect(response).to render_template('edit')
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'DELETE #destroy' do
|
describe 'DELETE #destroy' do
|
||||||
it 'destroys the requested mapping' do
|
it 'destroys the requested mapping' do
|
||||||
mapping = Mapping.create! valid_attributes
|
|
||||||
expect do
|
expect do
|
||||||
delete :destroy, { id: mapping.to_param }, valid_session
|
delete :destroy, { id: mapping.to_param }
|
||||||
end.to change(Mapping, :count).by(-1)
|
end.to change(Mapping, :count).by(-1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'redirects to the mappings list' do
|
|
||||||
mapping = Mapping.create! valid_attributes
|
|
||||||
delete :destroy, { id: mapping.to_param }, valid_session
|
|
||||||
expect(response).to redirect_to(mappings_url)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,60 +1,30 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
# This spec was generated by rspec-rails when you ran the scaffold generator.
|
|
||||||
# It demonstrates how one might use RSpec to specify the controller code that
|
|
||||||
# was generated by Rails when you ran the scaffold generator.
|
|
||||||
#
|
|
||||||
# It assumes that the implementation code is generated by the rails scaffold
|
|
||||||
# generator. If you are using any extension libraries to generate different
|
|
||||||
# controller code, this generated spec may or may not pass.
|
|
||||||
#
|
|
||||||
# It only uses APIs available in rails and/or rspec-rails. There are a number
|
|
||||||
# of tools you can use to make these specs even more expressive, but we're
|
|
||||||
# sticking to rails and rspec-rails APIs to keep things simple and stable.
|
|
||||||
#
|
|
||||||
# Compared to earlier versions of this generator, there is very limited use of
|
|
||||||
# stubs and message expectations in this spec. Stubs are only used when there
|
|
||||||
# is no simpler way to get a handle on the object needed for the example.
|
|
||||||
# Message expectations are only used when there is no simpler way to specify
|
|
||||||
# that an instance is receiving a specific message.
|
|
||||||
|
|
||||||
RSpec.describe MapsController, type: :controller do
|
RSpec.describe MapsController, type: :controller do
|
||||||
# This should return the minimal set of attributes required to create a valid
|
let(:map) { create(:map) }
|
||||||
# Map. As you add validations to Map, be sure to
|
let(:valid_attributes) { map.attributes.except(:id) }
|
||||||
# adjust the attributes here as well.
|
let(:invalid_attributes) { { permission: :commons } }
|
||||||
let(:valid_attributes) do
|
before :each do
|
||||||
skip('Add a hash of attributes valid for your model')
|
sign_in
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:invalid_attributes) do
|
|
||||||
skip('Add a hash of attributes invalid for your model')
|
|
||||||
end
|
|
||||||
|
|
||||||
# This should return the minimal set of values that should be in the session
|
|
||||||
# in order to pass any filters (e.g. authentication) defined in
|
|
||||||
# MapsController. Be sure to keep this updated too.
|
|
||||||
let(:valid_session) { {} }
|
|
||||||
|
|
||||||
describe 'GET #index' do
|
describe 'GET #index' do
|
||||||
it 'assigns all maps as @maps' do
|
it 'viewable maps as @maps' do
|
||||||
map = Map.create! valid_attributes
|
get :index, {}
|
||||||
get :index, {}, valid_session
|
|
||||||
expect(assigns(:maps)).to eq([map])
|
expect(assigns(:maps)).to eq([map])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'GET #contains' do
|
||||||
|
it 'returns json matching schema' do
|
||||||
|
get :contains, { id: map.to_param, format: :json }
|
||||||
|
expect(response.body).to match_json_schema(:map_contains)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe 'GET #show' do
|
describe 'GET #show' do
|
||||||
it 'assigns the requested map as @map' do
|
it 'assigns the requested map as @map' do
|
||||||
map = Map.create! valid_attributes
|
get :show, { id: map.to_param }
|
||||||
get :show, { id: map.to_param }, valid_session
|
|
||||||
expect(assigns(:map)).to eq(map)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'GET #edit' do
|
|
||||||
it 'assigns the requested map as @map' do
|
|
||||||
map = Map.create! valid_attributes
|
|
||||||
get :edit, { id: map.to_param }, valid_session
|
|
||||||
expect(assigns(:map)).to eq(map)
|
expect(assigns(:map)).to eq(map)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -62,99 +32,72 @@ RSpec.describe MapsController, type: :controller do
|
||||||
describe 'POST #create' do
|
describe 'POST #create' do
|
||||||
context 'with valid params' do
|
context 'with valid params' do
|
||||||
it 'creates a new Map' do
|
it 'creates a new Map' do
|
||||||
|
map.reload
|
||||||
expect do
|
expect do
|
||||||
post :create, { map: valid_attributes }, valid_session
|
post :create, valid_attributes.merge(format: :json)
|
||||||
end.to change(Map, :count).by(1)
|
end.to change(Map, :count).by(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'assigns a newly created map as @map' do
|
it 'assigns a newly created map as @map' do
|
||||||
post :create, { map: valid_attributes }, valid_session
|
post :create, valid_attributes.merge(format: :json)
|
||||||
expect(assigns(:map)).to be_a(Map)
|
expect(assigns(:map)).to be_a(Map)
|
||||||
expect(assigns(:map)).to be_persisted
|
expect(assigns(:map)).to be_persisted
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'redirects to the created map' do
|
|
||||||
post :create, { map: valid_attributes }, valid_session
|
|
||||||
expect(response).to redirect_to(Map.last)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with invalid params' do
|
context 'with invalid params' do
|
||||||
it 'assigns a newly created but unsaved map as @map' do
|
it 'assigns a newly created but unsaved map as @map' do
|
||||||
post :create, { map: invalid_attributes }, valid_session
|
post :create, invalid_attributes.merge(format: :json)
|
||||||
expect(assigns(:map)).to be_a_new(Map)
|
expect(assigns(:map)).to be_a_new(Map)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "re-renders the 'new' template" do
|
|
||||||
post :create, { map: invalid_attributes }, valid_session
|
|
||||||
expect(response).to render_template('new')
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'PUT #update' do
|
describe 'PUT #update' do
|
||||||
context 'with valid params' do
|
context 'with valid params' do
|
||||||
let(:new_attributes) do
|
let(:new_attributes) { { name: "Uncool map", permission: :private } }
|
||||||
skip('Add a hash of attributes valid for your model')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'updates the requested map' do
|
it 'updates the requested map' do
|
||||||
map = Map.create! valid_attributes
|
|
||||||
put :update,
|
put :update,
|
||||||
{ id: map.to_param, map: new_attributes },
|
{ id: map.to_param, map: new_attributes, format: :json }
|
||||||
valid_session
|
expect(assigns(:map).name).to eq "Uncool map"
|
||||||
map.reload
|
expect(assigns(:map).permission).to eq 'private'
|
||||||
skip('Add assertions for updated state')
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'assigns the requested map as @map' do
|
it 'assigns the requested map as @map' do
|
||||||
map = Map.create! valid_attributes
|
|
||||||
put :update,
|
put :update,
|
||||||
{ id: map.to_param, map: valid_attributes },
|
{ id: map.to_param, map: valid_attributes, format: :json }
|
||||||
valid_session
|
|
||||||
expect(assigns(:map)).to eq(map)
|
expect(assigns(:map)).to eq(map)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'redirects to the map' do
|
|
||||||
map = Map.create! valid_attributes
|
|
||||||
put :update,
|
|
||||||
{ id: map.to_param, map: valid_attributes },
|
|
||||||
valid_session
|
|
||||||
expect(response).to redirect_to(map)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with invalid params' do
|
context 'with invalid params' do
|
||||||
it 'assigns the map as @map' do
|
it 'assigns the map as @map' do
|
||||||
map = Map.create! valid_attributes
|
|
||||||
put :update,
|
put :update,
|
||||||
{ id: map.to_param, map: invalid_attributes },
|
{ id: map.to_param, map: invalid_attributes, format: :json }
|
||||||
valid_session
|
|
||||||
expect(assigns(:map)).to eq(map)
|
expect(assigns(:map)).to eq(map)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "re-renders the 'edit' template" do
|
|
||||||
map = Map.create! valid_attributes
|
|
||||||
put :update,
|
|
||||||
{ id: map.to_param, map: invalid_attributes },
|
|
||||||
valid_session
|
|
||||||
expect(response).to render_template('edit')
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'DELETE #destroy' do
|
describe 'DELETE #destroy' do
|
||||||
it 'destroys the requested map' do
|
let(:unowned_map) { create(:map) }
|
||||||
map = Map.create! valid_attributes
|
let(:owned_map) { create(:map, user: controller.current_user) }
|
||||||
|
|
||||||
|
it 'prevents deletion by non-owners' do
|
||||||
|
unowned_map.reload
|
||||||
expect do
|
expect do
|
||||||
delete :destroy, { id: map.to_param }, valid_session
|
delete :destroy, { id: unowned_map.to_param, format: :json }
|
||||||
end.to change(Map, :count).by(-1)
|
end.to change(Map, :count).by(0)
|
||||||
|
expect(response.body).to eq("unauthorized")
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'redirects to the maps list' do
|
it 'deletes owned map' do
|
||||||
map = Map.create! valid_attributes
|
owned_map.reload # ensure it's in the database
|
||||||
delete :destroy, { id: map.to_param }, valid_session
|
expect do
|
||||||
expect(response).to redirect_to(maps_url)
|
delete :destroy, { id: owned_map.to_param, format: :json }
|
||||||
|
end.to change(Map, :count).by(-1)
|
||||||
|
expect(response.body).to eq("success")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,72 +1,30 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
# This spec was generated by rspec-rails when you ran the scaffold generator.
|
|
||||||
# It demonstrates how one might use RSpec to specify the controller code that
|
|
||||||
# was generated by Rails when you ran the scaffold generator.
|
|
||||||
#
|
|
||||||
# It assumes that the implementation code is generated by the rails scaffold
|
|
||||||
# generator. If you are using any extension libraries to generate different
|
|
||||||
# controller code, this generated spec may or may not pass.
|
|
||||||
#
|
|
||||||
# It only uses APIs available in rails and/or rspec-rails. There are a number
|
|
||||||
# of tools you can use to make these specs even more expressive, but we're
|
|
||||||
# sticking to rails and rspec-rails APIs to keep things simple and stable.
|
|
||||||
#
|
|
||||||
# Compared to earlier versions of this generator, there is very limited use of
|
|
||||||
# stubs and message expectations in this spec. Stubs are only used when there
|
|
||||||
# is no simpler way to get a handle on the object needed for the example.
|
|
||||||
# Message expectations are only used when there is no simpler way to specify
|
|
||||||
# that an instance is receiving a specific message.
|
|
||||||
|
|
||||||
RSpec.describe MetacodesController, type: :controller do
|
RSpec.describe MetacodesController, type: :controller do
|
||||||
|
let(:metacode) { create(:metacode) }
|
||||||
|
let(:valid_attributes) { metacode.attributes.except('id') }
|
||||||
before :each do
|
before :each do
|
||||||
@user = create(:user, admin: true)
|
sign_in create(:user, admin: true)
|
||||||
sign_in @user
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# This should return the minimal set of attributes required to create a valid
|
|
||||||
# Metacode. As you add validations to Metacode, be sure to
|
|
||||||
# adjust the attributes here as well.
|
|
||||||
let(:valid_attributes) do
|
|
||||||
skip('Add a hash of attributes valid for your model')
|
|
||||||
end
|
|
||||||
|
|
||||||
let(:invalid_attributes) do
|
|
||||||
skip('Add a hash of attributes invalid for your model')
|
|
||||||
end
|
|
||||||
|
|
||||||
# This should return the minimal set of values that should be in the session
|
|
||||||
# in order to pass any filters (e.g. authentication) defined in
|
|
||||||
# MetacodesController. Be sure to keep this updated too.
|
|
||||||
let(:valid_session) { {} }
|
|
||||||
|
|
||||||
describe 'GET #index' do
|
describe 'GET #index' do
|
||||||
it 'assigns all metacodes as @metacodes' do
|
it 'assigns all metacodes as @metacodes' do
|
||||||
metacode = Metacode.create! valid_attributes
|
metacode.reload # ensure it's created
|
||||||
get :index, {}, valid_session
|
get :index, {}
|
||||||
expect(assigns(:metacodes)).to eq([metacode])
|
expect(Metacode.all.to_a).to eq([metacode])
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'GET #show' do
|
|
||||||
it 'assigns the requested metacode as @metacode' do
|
|
||||||
metacode = Metacode.create! valid_attributes
|
|
||||||
get :show, { id: metacode.to_param }, valid_session
|
|
||||||
expect(assigns(:metacode)).to eq(metacode)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'GET #new' do
|
describe 'GET #new' do
|
||||||
it 'assigns a new metacode as @metacode' do
|
it 'assigns a new metacode as @metacode' do
|
||||||
get :new, {}, valid_session
|
get :new, { format: :json }
|
||||||
expect(assigns(:metacode)).to be_a_new(Metacode)
|
expect(assigns(:metacode)).to be_a_new(Metacode)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'GET #edit' do
|
describe 'GET #edit' do
|
||||||
it 'assigns the requested metacode as @metacode' do
|
it 'assigns the requested metacode as @metacode' do
|
||||||
metacode = Metacode.create! valid_attributes
|
get :edit, { id: metacode.to_param }
|
||||||
get :edit, { id: metacode.to_param }, valid_session
|
|
||||||
expect(assigns(:metacode)).to eq(metacode)
|
expect(assigns(:metacode)).to eq(metacode)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -74,32 +32,22 @@ RSpec.describe MetacodesController, type: :controller do
|
||||||
describe 'POST #create' do
|
describe 'POST #create' do
|
||||||
context 'with valid params' do
|
context 'with valid params' do
|
||||||
it 'creates a new Metacode' do
|
it 'creates a new Metacode' do
|
||||||
|
metacode.reload # ensure it's present to start
|
||||||
expect do
|
expect do
|
||||||
post :create, { metacode: valid_attributes }, valid_session
|
post :create, { metacode: valid_attributes }
|
||||||
end.to change(Metacode, :count).by(1)
|
end.to change(Metacode, :count).by(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'assigns a newly created metacode as @metacode' do
|
it 'has the correct attributes' do
|
||||||
post :create, { metacode: valid_attributes }, valid_session
|
post :create, { metacode: valid_attributes }
|
||||||
|
# expect(Metacode.last.attributes.expect(:id)).to eq(metacode.attributes.except(:id))
|
||||||
expect(assigns(:metacode)).to be_a(Metacode)
|
expect(assigns(:metacode)).to be_a(Metacode)
|
||||||
expect(assigns(:metacode)).to be_persisted
|
expect(assigns(:metacode)).to be_persisted
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'redirects to the created metacode' do
|
it 'redirects to the metacode index' do
|
||||||
post :create, { metacode: valid_attributes }, valid_session
|
post :create, { metacode: valid_attributes }
|
||||||
expect(response).to redirect_to(Metacode.last)
|
expect(response).to redirect_to(metacodes_url)
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'with invalid params' do
|
|
||||||
it 'assigns a newly created but unsaved metacode as @metacode' do
|
|
||||||
post :create, { metacode: invalid_attributes }, valid_session
|
|
||||||
expect(assigns(:metacode)).to be_a_new(Metacode)
|
|
||||||
end
|
|
||||||
|
|
||||||
it "re-renders the 'new' template" do
|
|
||||||
post :create, { metacode: invalid_attributes }, valid_session
|
|
||||||
expect(response).to render_template('new')
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -107,66 +55,34 @@ RSpec.describe MetacodesController, type: :controller do
|
||||||
describe 'PUT #update' do
|
describe 'PUT #update' do
|
||||||
context 'with valid params' do
|
context 'with valid params' do
|
||||||
let(:new_attributes) do
|
let(:new_attributes) do
|
||||||
skip('Add a hash of attributes valid for your model')
|
{ manual_icon: 'https://newimages.ca/cool-image.jpg',
|
||||||
|
aws_icon: nil,
|
||||||
|
color: '#ffffff',
|
||||||
|
name: 'Cognition' }
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'updates the requested metacode' do
|
it 'updates the requested metacode' do
|
||||||
metacode = Metacode.create! valid_attributes
|
|
||||||
put :update,
|
put :update,
|
||||||
{ id: metacode.to_param, metacode: new_attributes },
|
{ id: metacode.to_param, metacode: new_attributes }
|
||||||
valid_session
|
|
||||||
metacode.reload
|
metacode.reload
|
||||||
skip('Add assertions for updated state')
|
expect(metacode.icon).to eq 'https://newimages.ca/cool-image.jpg'
|
||||||
end
|
expect(metacode.color).to eq '#ffffff'
|
||||||
|
expect(metacode.name).to eq 'Cognition'
|
||||||
it 'assigns the requested metacode as @metacode' do
|
|
||||||
metacode = Metacode.create! valid_attributes
|
|
||||||
put :update,
|
|
||||||
{ id: metacode.to_param, metacode: valid_attributes },
|
|
||||||
valid_session
|
|
||||||
expect(assigns(:metacode)).to eq(metacode)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'redirects to the metacode' do
|
|
||||||
metacode = Metacode.create! valid_attributes
|
|
||||||
put :update,
|
|
||||||
{ id: metacode.to_param, metacode: valid_attributes },
|
|
||||||
valid_session
|
|
||||||
expect(response).to redirect_to(metacode)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'with invalid params' do
|
|
||||||
it 'assigns the metacode as @metacode' do
|
|
||||||
metacode = Metacode.create! valid_attributes
|
|
||||||
put :update,
|
|
||||||
{ id: metacode.to_param, metacode: invalid_attributes },
|
|
||||||
valid_session
|
|
||||||
expect(assigns(:metacode)).to eq(metacode)
|
|
||||||
end
|
|
||||||
|
|
||||||
it "re-renders the 'edit' template" do
|
|
||||||
metacode = Metacode.create! valid_attributes
|
|
||||||
put :update,
|
|
||||||
{ id: metacode.to_param, metacode: invalid_attributes },
|
|
||||||
valid_session
|
|
||||||
expect(response).to render_template('edit')
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'DELETE #destroy' do
|
context 'not admin' do
|
||||||
it 'destroys the requested metacode' do
|
it 'denies access to create' do
|
||||||
metacode = Metacode.create! valid_attributes
|
sign_in create(:user, admin: false)
|
||||||
expect do
|
post :create, { metacode: valid_attributes }
|
||||||
delete :destroy, { id: metacode.to_param }, valid_session
|
expect(response).to redirect_to root_url
|
||||||
end.to change(Metacode, :count).by(-1)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'redirects to the metacodes list' do
|
it 'denies access to update' do
|
||||||
metacode = Metacode.create! valid_attributes
|
sign_in create(:user, admin: false)
|
||||||
delete :destroy, { id: metacode.to_param }, valid_session
|
post :update, { id: metacode.to_param, metacode: valid_attributes }
|
||||||
expect(response).to redirect_to(metacodes_url)
|
expect(response).to redirect_to root_url
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,60 +1,16 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
# This spec was generated by rspec-rails when you ran the scaffold generator.
|
|
||||||
# It demonstrates how one might use RSpec to specify the controller code that
|
|
||||||
# was generated by Rails when you ran the scaffold generator.
|
|
||||||
#
|
|
||||||
# It assumes that the implementation code is generated by the rails scaffold
|
|
||||||
# generator. If you are using any extension libraries to generate different
|
|
||||||
# controller code, this generated spec may or may not pass.
|
|
||||||
#
|
|
||||||
# It only uses APIs available in rails and/or rspec-rails. There are a number
|
|
||||||
# of tools you can use to make these specs even more expressive, but we're
|
|
||||||
# sticking to rails and rspec-rails APIs to keep things simple and stable.
|
|
||||||
#
|
|
||||||
# Compared to earlier versions of this generator, there is very limited use of
|
|
||||||
# stubs and message expectations in this spec. Stubs are only used when there
|
|
||||||
# is no simpler way to get a handle on the object needed for the example.
|
|
||||||
# Message expectations are only used when there is no simpler way to specify
|
|
||||||
# that an instance is receiving a specific message.
|
|
||||||
|
|
||||||
RSpec.describe SynapsesController, type: :controller do
|
RSpec.describe SynapsesController, type: :controller do
|
||||||
# This should return the minimal set of attributes required to create a valid
|
let(:synapse) { create(:synapse) }
|
||||||
# Synapse. As you add validations to Synapse, be sure to
|
let(:valid_attributes) { synapse.attributes.except('id') }
|
||||||
# adjust the attributes here as well.
|
let(:invalid_attributes) { { permission: :invalid_lol } }
|
||||||
let(:valid_attributes) do
|
before :each do
|
||||||
skip('Add a hash of attributes valid for your model')
|
sign_in
|
||||||
end
|
|
||||||
|
|
||||||
let(:invalid_attributes) do
|
|
||||||
skip('Add a hash of attributes invalid for your model')
|
|
||||||
end
|
|
||||||
|
|
||||||
# This should return the minimal set of values that should be in the session
|
|
||||||
# in order to pass any filters (e.g. authentication) defined in
|
|
||||||
# SynapsesController. Be sure to keep this updated too.
|
|
||||||
let(:valid_session) { {} }
|
|
||||||
|
|
||||||
describe 'GET #index' do
|
|
||||||
it 'assigns all synapses as @synapses' do
|
|
||||||
synapse = Synapse.create! valid_attributes
|
|
||||||
get :index, {}, valid_session
|
|
||||||
expect(assigns(:synapses)).to eq([synapse])
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'GET #show' do
|
describe 'GET #show' do
|
||||||
it 'assigns the requested synapse as @synapse' do
|
it 'assigns the requested synapse as @synapse' do
|
||||||
synapse = Synapse.create! valid_attributes
|
get :show, { id: synapse.to_param, format: :json }
|
||||||
get :show, { id: synapse.to_param }, valid_session
|
|
||||||
expect(assigns(:synapse)).to eq(synapse)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'GET #edit' do
|
|
||||||
it 'assigns the requested synapse as @synapse' do
|
|
||||||
synapse = Synapse.create! valid_attributes
|
|
||||||
get :edit, { id: synapse.to_param }, valid_session
|
|
||||||
expect(assigns(:synapse)).to eq(synapse)
|
expect(assigns(:synapse)).to eq(synapse)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -62,32 +18,28 @@ RSpec.describe SynapsesController, type: :controller do
|
||||||
describe 'POST #create' do
|
describe 'POST #create' do
|
||||||
context 'with valid params' do
|
context 'with valid params' do
|
||||||
it 'creates a new Synapse' do
|
it 'creates a new Synapse' do
|
||||||
|
synapse.reload # ensure it's present
|
||||||
expect do
|
expect do
|
||||||
post :create, { synapse: valid_attributes }, valid_session
|
post :create, { synapse: valid_attributes, format: :json }
|
||||||
end.to change(Synapse, :count).by(1)
|
end.to change(Synapse, :count).by(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'assigns a newly created synapse as @synapse' do
|
it 'assigns a newly created synapse as @synapse' do
|
||||||
post :create, { synapse: valid_attributes }, valid_session
|
post :create, { synapse: valid_attributes, format: :json }
|
||||||
expect(assigns(:synapse)).to be_a(Synapse)
|
expect(assigns(:synapse)).to be_a(Synapse)
|
||||||
expect(assigns(:synapse)).to be_persisted
|
expect(assigns(:synapse)).to be_persisted
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'redirects to the created synapse' do
|
it 'returns 201 CREATED' do
|
||||||
post :create, { synapse: valid_attributes }, valid_session
|
post :create, { synapse: valid_attributes, format: :json }
|
||||||
expect(response).to redirect_to(Synapse.last)
|
expect(response.status).to eq 201
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with invalid params' do
|
context 'with invalid params' do
|
||||||
it 'assigns a newly created but unsaved synapse as @synapse' do
|
it 'returns 422 UNPROCESSABLE ENTITY' do
|
||||||
post :create, { synapse: invalid_attributes }, valid_session
|
post :create, { synapse: invalid_attributes, format: :json }
|
||||||
expect(assigns(:synapse)).to be_a_new(Synapse)
|
expect(response.status).to eq 422
|
||||||
end
|
|
||||||
|
|
||||||
it "re-renders the 'new' template" do
|
|
||||||
post :create, { synapse: invalid_attributes }, valid_session
|
|
||||||
expect(response).to render_template('new')
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -95,66 +47,49 @@ RSpec.describe SynapsesController, type: :controller do
|
||||||
describe 'PUT #update' do
|
describe 'PUT #update' do
|
||||||
context 'with valid params' do
|
context 'with valid params' do
|
||||||
let(:new_attributes) do
|
let(:new_attributes) do
|
||||||
skip('Add a hash of attributes valid for your model')
|
{ desc: 'My new description',
|
||||||
|
category: 'both',
|
||||||
|
permission: :public }
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'updates the requested synapse' do
|
it 'updates the requested synapse' do
|
||||||
synapse = Synapse.create! valid_attributes
|
|
||||||
put :update,
|
put :update,
|
||||||
{ id: synapse.to_param, synapse: new_attributes },
|
{ id: synapse.to_param, synapse: new_attributes, format: :json }
|
||||||
valid_session
|
|
||||||
synapse.reload
|
synapse.reload
|
||||||
skip('Add assertions for updated state')
|
expect(synapse.desc).to eq 'My new description'
|
||||||
|
expect(synapse.category).to eq 'both'
|
||||||
|
expect(synapse.permission).to eq 'public'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'assigns the requested synapse as @synapse' do
|
it 'returns 204 NO CONTENT' do
|
||||||
synapse = Synapse.create! valid_attributes
|
|
||||||
put :update,
|
put :update,
|
||||||
{ id: synapse.to_param, synapse: valid_attributes },
|
{ id: synapse.to_param, synapse: valid_attributes, format: :json }
|
||||||
valid_session
|
expect(response.status).to eq 204
|
||||||
expect(assigns(:synapse)).to eq(synapse)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'redirects to the synapse' do
|
|
||||||
synapse = Synapse.create! valid_attributes
|
|
||||||
put :update,
|
|
||||||
{ id: synapse.to_param, synapse: valid_attributes },
|
|
||||||
valid_session
|
|
||||||
expect(response).to redirect_to(synapse)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with invalid params' do
|
context 'with invalid params' do
|
||||||
it 'assigns the synapse as @synapse' do
|
it 'assigns the synapse as @synapse' do
|
||||||
synapse = Synapse.create! valid_attributes
|
|
||||||
put :update,
|
put :update,
|
||||||
{ id: synapse.to_param, synapse: invalid_attributes },
|
{ id: synapse.to_param, synapse: invalid_attributes, format: :json }
|
||||||
valid_session
|
|
||||||
expect(assigns(:synapse)).to eq(synapse)
|
expect(assigns(:synapse)).to eq(synapse)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "re-renders the 'edit' template" do
|
|
||||||
synapse = Synapse.create! valid_attributes
|
|
||||||
put :update,
|
|
||||||
{ id: synapse.to_param, synapse: invalid_attributes },
|
|
||||||
valid_session
|
|
||||||
expect(response).to render_template('edit')
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'DELETE #destroy' do
|
describe 'DELETE #destroy' do
|
||||||
|
let(:synapse) { create(:synapse, user: controller.current_user) }
|
||||||
|
|
||||||
it 'destroys the requested synapse' do
|
it 'destroys the requested synapse' do
|
||||||
synapse = Synapse.create! valid_attributes
|
synapse.reload # ensure it's present
|
||||||
expect do
|
expect do
|
||||||
delete :destroy, { id: synapse.to_param }, valid_session
|
delete :destroy, { id: synapse.to_param, format: :json }
|
||||||
end.to change(Synapse, :count).by(-1)
|
end.to change(Synapse, :count).by(-1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'redirects to the synapses list' do
|
it 'returns 204 NO CONTENT' do
|
||||||
synapse = Synapse.create! valid_attributes
|
delete :destroy, { id: synapse.to_param, format: :json }
|
||||||
delete :destroy, { id: synapse.to_param }, valid_session
|
expect(response.status).to eq 204
|
||||||
expect(response).to redirect_to(synapses_url)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,36 +1,16 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe TopicsController, type: :controller do
|
RSpec.describe TopicsController, type: :controller do
|
||||||
let(:valid_attributes) do
|
let(:topic) { create(:topic) }
|
||||||
skip('Add a hash of attributes valid for your model')
|
let(:valid_attributes) { topic.attributes.except('id') }
|
||||||
end
|
let(:invalid_attributes) { { permission: :invalid_lol } }
|
||||||
|
before :each do
|
||||||
let(:invalid_attributes) do
|
sign_in
|
||||||
skip('Add a hash of attributes invalid for your model')
|
|
||||||
end
|
|
||||||
|
|
||||||
let(:valid_session) { {} }
|
|
||||||
|
|
||||||
describe 'GET #index' do
|
|
||||||
it 'assigns all topics as @topics' do
|
|
||||||
topic = Topic.create! valid_attributes
|
|
||||||
get :index, {}, valid_session
|
|
||||||
expect(assigns(:topics)).to eq([topic])
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'GET #show' do
|
describe 'GET #show' do
|
||||||
it 'assigns the requested topic as @topic' do
|
it 'assigns the requested topic as @topic' do
|
||||||
topic = Topic.create! valid_attributes
|
get :show, { id: topic.to_param, format: :json }
|
||||||
get :show, { id: topic.to_param }, valid_session
|
|
||||||
expect(assigns(:topic)).to eq(topic)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'GET #edit' do
|
|
||||||
it 'assigns the requested topic as @topic' do
|
|
||||||
topic = Topic.create! valid_attributes
|
|
||||||
get :edit, { id: topic.to_param }, valid_session
|
|
||||||
expect(assigns(:topic)).to eq(topic)
|
expect(assigns(:topic)).to eq(topic)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -38,99 +18,85 @@ RSpec.describe TopicsController, type: :controller do
|
||||||
describe 'POST #create' do
|
describe 'POST #create' do
|
||||||
context 'with valid params' do
|
context 'with valid params' do
|
||||||
it 'creates a new Topic' do
|
it 'creates a new Topic' do
|
||||||
|
topic.reload # ensure it's created
|
||||||
expect do
|
expect do
|
||||||
post :create, { topic: valid_attributes }, valid_session
|
post :create, { topic: valid_attributes, format: :json }
|
||||||
end.to change(Topic, :count).by(1)
|
end.to change(Topic, :count).by(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'assigns a newly created topic as @topic' do
|
it 'assigns a newly created topic as @topic' do
|
||||||
post :create, { topic: valid_attributes }, valid_session
|
post :create, { topic: valid_attributes, format: :json }
|
||||||
expect(assigns(:topic)).to be_a(Topic)
|
expect(assigns(:topic)).to be_a(Topic)
|
||||||
expect(assigns(:topic)).to be_persisted
|
expect(assigns(:topic)).to be_persisted
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'redirects to the created topic' do
|
it 'returns 201 CREATED' do
|
||||||
post :create, { topic: valid_attributes }, valid_session
|
post :create, { topic: valid_attributes, format: :json }
|
||||||
expect(response).to redirect_to(Topic.last)
|
expect(response.status).to eq 201
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with invalid params' do
|
context 'with invalid params' do
|
||||||
it 'assigns a newly created but unsaved topic as @topic' do
|
it 'assigns a newly created but unsaved topic as @topic' do
|
||||||
post :create, { topic: invalid_attributes }, valid_session
|
post :create, { topic: invalid_attributes, format: :json }
|
||||||
expect(assigns(:topic)).to be_a_new(Topic)
|
expect(assigns(:topic)).to be_a_new(Topic)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "re-renders the 'new' template" do
|
|
||||||
post :create, { topic: invalid_attributes }, valid_session
|
|
||||||
expect(response).to render_template('new')
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'PUT #update' do
|
describe 'PUT #update' do
|
||||||
context 'with valid params' do
|
context 'with valid params' do
|
||||||
let(:new_attributes) do
|
let(:new_attributes) do
|
||||||
skip('Add a hash of attributes valid for your model')
|
{ name: 'Cool Topic with no number',
|
||||||
|
desc: 'This is a cool topic.',
|
||||||
|
link: 'https://cool-topics.com/4',
|
||||||
|
permission: :public }
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'updates the requested topic' do
|
it 'updates the requested topic' do
|
||||||
topic = Topic.create! valid_attributes
|
|
||||||
put :update,
|
put :update,
|
||||||
{ id: topic.to_param, topic: new_attributes },
|
{ id: topic.to_param, topic: new_attributes, format: :json }
|
||||||
valid_session
|
|
||||||
topic.reload
|
topic.reload
|
||||||
skip('Add assertions for updated state')
|
expect(topic.name).to eq 'Cool Topic with no number'
|
||||||
|
expect(topic.desc).to eq 'This is a cool topic.'
|
||||||
|
expect(topic.link).to eq 'https://cool-topics.com/4'
|
||||||
|
expect(topic.permission).to eq 'public'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'assigns the requested topic as @topic' do
|
it 'assigns the requested topic as @topic' do
|
||||||
topic = Topic.create! valid_attributes
|
|
||||||
put :update,
|
put :update,
|
||||||
{ id: topic.to_param, topic: valid_attributes },
|
{ id: topic.to_param, topic: valid_attributes, format: :json }
|
||||||
valid_session
|
|
||||||
expect(assigns(:topic)).to eq(topic)
|
expect(assigns(:topic)).to eq(topic)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'redirects to the topic' do
|
it 'returns status of no content' do
|
||||||
topic = Topic.create! valid_attributes
|
|
||||||
put :update,
|
put :update,
|
||||||
{ id: topic.to_param, topic: valid_attributes },
|
{ id: topic.to_param, topic: valid_attributes, format: :json }
|
||||||
valid_session
|
expect(response.status).to eq 204
|
||||||
expect(response).to redirect_to(topic)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with invalid params' do
|
context 'with invalid params' do
|
||||||
it 'assigns the topic as @topic' do
|
it 'assigns the topic as @topic' do
|
||||||
topic = Topic.create! valid_attributes
|
|
||||||
put :update,
|
put :update,
|
||||||
{ id: topic.to_param, topic: invalid_attributes },
|
{ id: topic.to_param, topic: invalid_attributes, format: :json }
|
||||||
valid_session
|
|
||||||
expect(assigns(:topic)).to eq(topic)
|
expect(assigns(:topic)).to eq(topic)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "re-renders the 'edit' template" do
|
|
||||||
topic = Topic.create! valid_attributes
|
|
||||||
put :update,
|
|
||||||
{ id: topic.to_param, topic: invalid_attributes },
|
|
||||||
valid_session
|
|
||||||
expect(response).to render_template('edit')
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'DELETE #destroy' do
|
describe 'DELETE #destroy' do
|
||||||
|
let(:owned_topic) { create(:topic, user: controller.current_user) }
|
||||||
it 'destroys the requested topic' do
|
it 'destroys the requested topic' do
|
||||||
topic = Topic.create! valid_attributes
|
owned_topic.reload # ensure it's there
|
||||||
expect do
|
expect do
|
||||||
delete :destroy, { id: topic.to_param }, valid_session
|
delete :destroy, { id: owned_topic.to_param, format: :json }
|
||||||
end.to change(Topic, :count).by(-1)
|
end.to change(Topic, :count).by(-1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'redirects to the topics list' do
|
it 'return 204 NO CONTENT' do
|
||||||
topic = Topic.create! valid_attributes
|
delete :destroy, { id: topic.to_param, format: :json }
|
||||||
delete :destroy, { id: topic.to_param }, valid_session
|
expect(response.status).to eq 204
|
||||||
expect(response).to redirect_to(topics_url)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
14
spec/factories/mappings.rb
Normal file
14
spec/factories/mappings.rb
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
FactoryGirl.define do
|
||||||
|
factory :mapping do
|
||||||
|
xloc 0
|
||||||
|
yloc 0
|
||||||
|
map
|
||||||
|
user
|
||||||
|
association :mappable, factory: :topic
|
||||||
|
|
||||||
|
factory :mapping_random_location do
|
||||||
|
xloc { rand(-100...100) }
|
||||||
|
yloc { rand(-100...100) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,4 +1,8 @@
|
||||||
FactoryGirl.define do
|
FactoryGirl.define do
|
||||||
factory :metacode do
|
factory :metacode do
|
||||||
|
sequence(:name) { |n| "Cool Metacode ##{n}" }
|
||||||
|
manual_icon 'https://images.com/image.png'
|
||||||
|
aws_icon nil
|
||||||
|
color '#cccccc'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
FactoryGirl.define do
|
FactoryGirl.define do
|
||||||
factory :synapse do
|
factory :synapse do
|
||||||
sequence(:desc) { |n| "Cool synapse ##{n}" }
|
sequence(:desc) { |n| "Cool synapse ##{n}" }
|
||||||
category :to
|
category :'from-to'
|
||||||
permission :commons
|
permission :commons
|
||||||
association :topic1, factory: :topic
|
association :topic1, factory: :topic
|
||||||
association :topic2, factory: :topic
|
association :topic2, factory: :topic
|
||||||
|
user
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,11 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe Mapping, type: :model do
|
RSpec.describe Mapping, type: :model do
|
||||||
pending "add some examples to (or delete) #{__FILE__}"
|
it { is_expected.to belong_to :user }
|
||||||
|
it { is_expected.to belong_to :map }
|
||||||
|
it { is_expected.to belong_to :mappable }
|
||||||
|
it { is_expected.to validate_presence_of :xloc }
|
||||||
|
it { is_expected.to validate_presence_of :yloc }
|
||||||
|
it { is_expected.to validate_presence_of :map }
|
||||||
|
it { is_expected.to validate_presence_of :mappable }
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe Metacode, type: :model do
|
RSpec.describe Metacode, type: :model do
|
||||||
pending "add some examples to (or delete) #{__FILE__}"
|
it { is_expected.to have_many :topics }
|
||||||
it { is_expected.to have_many(:topics) }
|
it { is_expected.to have_many :metacode_sets }
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,6 +8,7 @@ RSpec.describe Synapse, type: :model do
|
||||||
it { is_expected.to have_many :mappings }
|
it { is_expected.to have_many :mappings }
|
||||||
it { is_expected.to validate_presence_of :permission }
|
it { is_expected.to validate_presence_of :permission }
|
||||||
it { is_expected.to validate_inclusion_of(:permission).in_array Perm::ISSIONS.map(&:to_s) }
|
it { is_expected.to validate_inclusion_of(:permission).in_array Perm::ISSIONS.map(&:to_s) }
|
||||||
|
it { is_expected.to validate_inclusion_of(:category).in_array ['from-to', 'both'] }
|
||||||
it { is_expected.to validate_length_of(:desc).is_at_least(0) } # TODO don't allow nil
|
it { is_expected.to validate_length_of(:desc).is_at_least(0) } # TODO don't allow nil
|
||||||
|
|
||||||
context 'permissions' do
|
context 'permissions' do
|
||||||
|
|
0
spec/schemas/map.json
Normal file
0
spec/schemas/map.json
Normal file
42
spec/schemas/map_contains.json
Normal file
42
spec/schemas/map_contains.json
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
{
|
||||||
|
"name": "Map Contents",
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"map": {
|
||||||
|
"type": "object"
|
||||||
|
},
|
||||||
|
"topics": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "object"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"synapses": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "object"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"mappings": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "object"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"mappers": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "object"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"map",
|
||||||
|
"topics",
|
||||||
|
"synapses",
|
||||||
|
"mappings",
|
||||||
|
"mappers"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
require 'simplecov'
|
||||||
|
require 'support/controller_helpers'
|
||||||
|
|
||||||
RSpec.configure do |config|
|
RSpec.configure do |config|
|
||||||
config.expect_with :rspec do |expectations|
|
config.expect_with :rspec do |expectations|
|
||||||
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
# https://github.com/plataformatec/devise/wiki/How-To:-Stub-authentication-in-controller-specs
|
# https://github.com/plataformatec/devise/wiki/How-To:-Stub-authentication-in-controller-specs
|
||||||
|
|
||||||
|
require 'devise'
|
||||||
|
|
||||||
module ControllerHelpers
|
module ControllerHelpers
|
||||||
# rubocop:disable Metrics/AbcSize
|
# rubocop:disable Metrics/AbcSize
|
||||||
def sign_in(user = create(:user))
|
def sign_in(user = create(:user))
|
||||||
|
@ -7,6 +10,7 @@ module ControllerHelpers
|
||||||
receive(:authenticate!).and_throw(:warden, scope: :user)
|
receive(:authenticate!).and_throw(:warden, scope: :user)
|
||||||
)
|
)
|
||||||
else # simulate authenticated
|
else # simulate authenticated
|
||||||
|
allow_message_expectations_on_nil
|
||||||
allow(request.env['warden']).to(
|
allow(request.env['warden']).to(
|
||||||
receive(:authenticate!).and_return(user)
|
receive(:authenticate!).and_return(user)
|
||||||
)
|
)
|
||||||
|
@ -15,3 +19,8 @@ module ControllerHelpers
|
||||||
end
|
end
|
||||||
# rubocop:enable Metrics/AbcSize
|
# rubocop:enable Metrics/AbcSize
|
||||||
end
|
end
|
||||||
|
|
||||||
|
RSpec.configure do |config|
|
||||||
|
config.include Devise::TestHelpers, :type => :controller
|
||||||
|
config.include ControllerHelpers, :type => :controller
|
||||||
|
end
|
||||||
|
|
7
spec/support/schema_matcher.rb
Normal file
7
spec/support/schema_matcher.rb
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
RSpec::Matchers.define :match_json_schema do |schema|
|
||||||
|
match do |json|
|
||||||
|
schema_directory = Rails.root.join('spec', 'schemas').to_s
|
||||||
|
schema_path = "#{schema_directory}/#{schema}.json"
|
||||||
|
JSON::Validator.validate!(schema_path, json)
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue