mercredi 1 octobre 2014

Ember CLI testing complicated model relationships


Vote count:

0




As far as I can see, when testing ember-data models in ember CLI, all relationships have to be listed in needs. This is fine if the structure is simple, but in many cases there will be multiple layers.


For example, if models are set up with the following relationships defined:



Model a:
belongsTo: b
belongsTo: c

Model b:
hasMany: a
hasMany: d

Model c:
hasMany: a
belongsTo: e

Model d:
hasMany b

Model e:
hasMany c


Then every unit test for any of these models will require every other model listed in needs, e.g. A test for c:



needs: [
'model:a' // Because c -> a
'model:e' // Because c -> e
'model:b' // Because c -> a -> b
'model:d' // Because c -> a -> b -> d
]


My actual configuration is a lot more complication with 14 models, and each one indirectly related to all the others.


Is my understanding correct? Is there a more efficient way of doing this?



asked 2 mins ago

aquavitae

4,580






Ember CLI testing complicated model relationships

use cookbook install nginx. compile passenger error


Vote count:

0




I use this nginx cookbook to install nginx in vagrant.


When run command knife solo cook user@ip, i got error below:



checking for getaddrinfo() ... found
configuring additional modules
adding module in /opt/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/passenger-4.0.52/ext/nginx
*** The Phusion Passenger support files are not yet compiled. Compiling them for you... ***
*** Running 'rake nginx CACHING=false' in /opt/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/passenger-4.0.52/ext/nginx... ***
STDERR: /opt/chef/embedded/bin/rake:9:in `require': no such file to load -- rubygems (LoadError)
from /opt/chef/embedded/bin/rake:9
---- End output of "bash" "/tmp/chef-script20141001-14979-2i0uo6" ----


It seems /opt/chef/embedded/bin/rake make this error. I use rbenv, so use rbenv's rake is correct. /opt/chef/embedded/bin/rake is wrong.


After run:



vagrant ssh
cd /passenger/path
rake nginx CACHING=false


and knife solo cook user@ip is success and no error.


My node.json:



{
"run_list": [
"recipe[rbenv]",
"recipe[rbenv::ruby_build]",
"recipe[install_rbenv_ruby]",
"recipe[postgresql::server]",
"recipe[nginx::source]"
],
"rbenv": {
"group_users": [ "vagrant" ]
},
"nginx": {
"version": "1.4.7",
"passenger": {
"version": "4.0.52",
"gem_binary": "/opt/rbenv/versions/2.1.2/bin/gem",
"root": "/opt/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/passenger-4.0.52",
"ruby": "/opt/rbenv/versions/2.1.2/bin/ruby"
},
"source": {
"modules": [
"nginx::http_stub_status_module",
"nginx::http_ssl_module",
"nginx::http_gzip_static_module",
"nginx::passenger"
]
}
}
}


Does anyone know how to fix rake's problem when passenger compile?


I also can add recipe to run passenger comiple, but run complie is spend the very much time. How can i write not_if block?



bash 'compile_passenger_source' do
cwd "/opt/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/passenger-4.0.52/ext"
code <<-EOH
/opt/rbenv/versions/2.1.2/bin/rake nginx CACHING=false
EOH

end


asked 49 secs ago







use cookbook install nginx. compile passenger error

How do I change permission to 440 to /etc/sudoers in aws ec2 using terminal


Vote count:

0




I am trying to login as a super user in amazon ec2 but I see come error that sudo is world writable.


I tried using pkexec chmod 440 /etc/sudoers


but pkexec commend is not found.


Please can anyone help me with this...


Thanks.



asked 1 min ago







How do I change permission to 440 to /etc/sudoers in aws ec2 using terminal

Adding additional information to Wire-Tapped Channels for logging in Spring


Vote count:

0




I'm using Wire-Tap to handle logging and I'm not allowed to use logging-channel-adapter (hence log4j).


I've the need to add additional informations to the payload that get sent to a gateway that has an interface that handles logs.


Is there a way without specifying a header-enricher in the middle of the flow?


Code for clarification:


The Wire-Tap part



<int:channel id="IN_messageRouterFactory">
<int:interceptors>
<int:wire-tap channel="IN_log_gateway" />
</int:interceptors>
</int:channel>


The logging gateway:



<int:gateway service-interface="foo.bar.loginterface">
<int:method name="log" request-channel="IN_log_gateway" />
</int:gateway>


The logging service:



<int:chain input-channel="IN_log_gateway">
<!-- transformations here... -->
<int:service-activator ref="fileLoggerService"/>
</int:chain>


I would like to add some informations so that I could log specific managed payload informations



asked 2 mins ago







Adding additional information to Wire-Tapped Channels for logging in Spring

Disable landscape or portrait orientation with CSS mobile query


Vote count:

0




Is it possible to disable orientation on smart phones with CSS media query?



asked 55 secs ago







Disable landscape or portrait orientation with CSS mobile query

How to make reuseable blocks of HTML based upon a model object


Vote count:

0




Say I have a simple model with Title, Price, Description and Image fields. I would like 3 html outputs/blocks that I can reuse for each object of this model. For added 'complexity', 2 of the outputs will be combined to make the 3rd. So, here is what these 3 output might look like in a template.


output_image



<span class="output_image"><img src="{{ object.image.url }}" alt="{{ object.title}}></span>


output_info



<ul class="output_info">
<li>{{ object.title }}</li>
<li>Price: {{ object.price }}</li>
<li>{{ object.description }}</li>
</ul>


output_all (wraps up the previous 2)



<div class="output_all">
<span class="output_image">...</span>
<ul class="output_info">...</ul>
</div>


I might want to use output_image on a search page, and output_all on listing and advanced search, for example. Hence I only want to write this output once, and reuse it. What is the best way to achieve this?


Initially I thought to add methods/properties to the model class, which would return the formatted html. This worked, and in my template I could just call {{ object.output_all }}, for example. Is it bad practice to output html like this?


I have briefly looked at other ways too. Inclusion tags seems to work, but I have only tested with a 'complete' version of the output_all case (ie have not 'nested' the other 2 output tags within output_all yet). Is this the correct method, and is it possible to 'nest' the tags?



asked 38 secs ago







How to make reuseable blocks of HTML based upon a model object

NSManagedObjectContext? does not have a member named 'executeFetchRequest'


Vote count:

0




I'm trying to convert my objective-c code: NSArray *objects = [context executeFetchRequest:request error:&error]; to swift: var objects : NSArray = context.executeFetchRequest(request, error: &error) but it doesn't seem to work that way. Any ideas on what to do?



asked 1 min ago







NSManagedObjectContext? does not have a member named 'executeFetchRequest'