Disable JavaScript for a RSpecTest - rspec-rails

I want to disable javascript for a rspec test.
Ex
it '[SP01/UC18/TC25] title error for 31 letters' do
#=> Disable javascript (because text box is already validated by JS to max input 30 characters)
fill_in('title', :with => 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA')
#=> Enable javascript (because I want to track the error messages)
click_button 'submit'
page.should have_content 'error in title'
page.should have_content 'please enter less than 30 characters'
end

Here is the answer
describe '[SP01/UC25] title error for 31 letters', :js => false, :type => :request do
end

Related

telegram bot api pass empty inline_keyboard -> delete keyboard

I'd like to use the methode editMessageReplyMarkup to get rid of my inline_keyboard buttons. I can get rid of them by passing the 'reply_markup' a json encoded keyboard like that:
$k = ['inline_keyboard' =>
[
[ ]
]
];
but as a result I get that error
Request has failed with error 400: Bad Request: object expected as reply markup
I tried a couple variants include not sending a 'reply_markup' at all as attribute to the methode, but I get the error "Bad Request: object expected as reply markup" or "Bad Request: can't parse inline keyboard button: InlineKeyboardButton must be an Object".
That is how I call the methode:
$bot->apiRequestJson("editMessageReplyMarkup", array(
'chat_id'=>$cb_chat_id,
'message_id'=>$cb_msg_id,
'reply_markup' => json_encode($k)
));
The function is taken from here: function taken from hellobot example https://core.telegram.org/bots/samples/hellobot
And to prove my function is working, that results in a new inline keyboard without any error
$k = ['inline_keyboard' => [
[
['text' => 'caption', 'callback_data' => 'test']
]
]];
Thanks for your help!
Markus

wp_cron scheduled but not firing

I am trying to run a background script fired on a user action using wp_schedule_single_event, and although I have confirmed that the event is being scheduled and that wp_cron recognizes that the scheduled time has passed, it will not fire the event handler. To further complicate things, the code runs fine on my local WP install, but does nothing on my server.
To schedule the event, I am using:
if ( ! wp_next_scheduled( 'my_action_name' ) ) {
wp_schedule_single_event( time(), 'my_action_name' );
}
My handler action is defined as:
add_action('my_action_name', 'my_action_handler');
function my_action_handler () {
// do stuff
}
I have testing the wp core files and found that the following block (from wp-includes/cron.php:322) is where the script terminates:
var_dump('test1');
$cron_request = apply_filters( 'cron_request', array(
'url' => add_query_arg( 'doing_wp_cron', $doing_wp_cron, site_url( 'wp-cron.php' ) ),
'key' => $doing_wp_cron,
'args' => array(
'timeout' => 0.01,
'blocking' => false,
/** This filter is documented in wp-includes/class-wp-http-streams.php */
'sslverify' => apply_filters( 'https_local_ssl_verify', false )
)
), $doing_wp_cron );
var_dump('test2'); //exit here to test
wp_remote_post( $cron_request['url'], $cron_request['args'] );
On my local machine, the filter is applied, 'test2' is printed, and the script can continue to call wp_remote_post. On the server, however, the script terminates during the execution of apply_filter('cron_request'), printing 'test1' but not 'test2' and failing to reach wp_remost_post.
I have been unable to find the source for this filter to further debug. Wordpress.org says that the filter is defined within wp-includes/cron.php and that the one instance I have already cited is the only place it is ever applied, however, using Sublime multi-file search reveals that the string 'cron_request' appears only in the filter application I have cited.
I have read many post on wp_cron failing and have found no help other than non-descript 'Server configuration blocking wp_cron' answers. Any additional information on what type of server config or what else could be occuring here?
This action will trigger when someone visits your WordPress site, if the scheduled time has passed.
Maybe you can use
wp_schedule_event()
Instead of
wp_schedule_single_event()

Dynamic error style password field accounts-core in Meteor

I am using accounts-core package in meteor to make my registration form in my application.
I configure own custom validation field in password. i.e.
var password = AccountsTemplates.removeField('password');
AccountsTemplates.addField({
_id: 'password',
type: 'password',
required: true,
displayName: 'Password',
re: /^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9]).{8,}$/,
errStr: 'At least 8 characters, 1 uppercase, 1 lowercase and 1 number'
});
Now i want to show error message with different style according to what character user missed to type. Something like:
As per Documentation : Field Configuration we need give errStr when field is configured.
And we can write func for custom validation:
AccountsTemplates.addField({
...
func : function(pwd){
... // check your password
}
...
});
But How can i pass dynamic markup to show error message?

Corrupt Drupal menu

Running Drupal 7.26 with nothing fancy and have started to encounter a corruption issue with the menu system. We started seeing the following error (truncated to fit). Doing a drush or a manual clear cache doesn't fix it, setting menu_router.weight to NULL yes, truncating both the menu_links and menu_router tables still produces the error. Links oddly menu still appear on the site, but only some not all.
I suspect that the issue might be caused by a page view (using views3) with a set path, but I can't see why that would be as it is again just a normal path.
PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column
'weight' at row 9: INSERT INTO {menu_router} (path, load_functions, to_arg_functions,
access_callback, access_arguments, page_callback, page_arguments, delivery_callback, fit,
number_parts, context, tab_parent, tab_root, title, title_callback, title_arguments,
theme_callback, theme_arguments, type, description, position, weight, include_file) VALUES
.... (truncated) ....
(:db_insert_placeholder_184, :db_insert_placeholder_185, :db_insert_placeholder_186,
:db_insert_placeholder_187, :db_insert_placeholder_188, :db_insert_placeholder_189,
:db_insert_placeholder_190, :db_insert_placeholder_191, :db_insert_placeholder_192,
:db_insert_placeholder_193, :db_insert_placeholder_194, :db_insert_placeholder_195,
:db_insert_placeholder_196, :db_insert_placeholder_197,); Array (
.... (truncated) ....
[:db_insert_placeholder_180] => Ajax callback for view loading.
[:db_insert_placeholder_181] => [:db_insert_placeholder_182] => 0
[:db_insert_placeholder_183] => sites/all/modules/contrib/views/includes/ajax.inc
[:db_insert_placeholder_184] => volunteering/opportunities [:db_insert_placeholder_185] =>
[:db_insert_placeholder_186] => [:db_insert_placeholder_187] => ctools_access_menu
[:db_insert_placeholder_188] => a:1:{i:0;a:2:{s:4:"type";s:4:"none";s:8:"settings";N;}}
[:db_insert_placeholder_189] => page_manager_page_execute [:db_insert_placeholder_190] =>
a:1:{i:0;s:13:"volunteering_";} [:db_insert_placeholder_191] =>
[:db_insert_placeholder_192] => 3 [:db_insert_placeholder_193] => 2
[:db_insert_placeholder_194] => 0 [:db_insert_placeholder_195] =>
[:db_insert_placeholder_196] => volunteering/opportunities [:db_insert_placeholder_197] =>
Volunteering opportunities [:db_insert_placeholder_198] => t [:db_insert_placeholder_199]
=> [:db_insert_placeholder_200] => [:db_insert_placeholder_201] => a:0:{} ) in
_menu_router_save() (line 3837 of /var/mysite/dev/includes/menu.inc).
For some strange reason the function page_manager_list_page() in ctools page manager > page_manager.admin.inc wasn't setting a numeric weight. Not sure how or why it isn't checking it is not a an integer, but it doesn't which caused the issue.

Symfony 2 - Validate a field with NotBlank & Type constraints

I am having problems validating a form component when i have added both NotBlank and Type validation to an integer field.
My validation.yml looks like the following:
Acme\StoreBundle\Entity\Foo:
properties:
bar:
- NotBlank:
message: You must specify a bar
- Type:
type: integer
message: bar must be an integer
My FormType file looks like the following:
$builder->add('bar', 'integer', array(
'label' => bar',
'error_bubbling' => true
));
When I type 'abc' into the field and submit, validate the form and getErrors(), the errors reported are -
This value is not valid.
You must specify a bar.
any ideas whats going wrong? I'm running Symfony 2.0.10
I had the same problem. In the end, I used a normal 'text' field, and made my own 'Integer' validator which uses regular expression.
I am not sure but maybe this helps:
$builder->add('bar', 'integer', array(
'label' => bar',
'invalid_message' => 'bar must be an integer'
'error_bubbling' => true
));
Check this out
Your problem may be related to this issue. From the discussion of the issue it seems that the solution of the problem is replacing line 40 of the DelegatingValidator.php with this code
if ($form->isRoot() && $form->isSynchronized()) {
I haven't tested it though. You can try and tell about the result :).
I am pretty late but this can help
validation.yml
contactNo:
- NotBlank: ~
- Regex:
pattern: '/\d/'
match: true
message: Your contact no. must be a number
- Length:
min: 10
max: 15
minMessage: 'You contact no. must be at least {{ limit }} digits.'
maxMessage: 'You contact no. can not be greater than {{ limit }} digits.'

Resources