File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change 59
59
# Parse wp-cli siteurl into smaller parts
60
60
uri = URI ( target_url )
61
61
62
- # Create random test user, try to login with it and delete it after tests
63
- username = "wp-palvelu-tester- #{ Time . now . to_i } "
62
+ # Use this specific user for tests
63
+ username = "wp-rspec-test-user "
64
64
password = rand ( 36 **32 ) . to_s ( 36 )
65
- system "wp user create #{ username } #{ username } @#{ uri . host } --user_pass=#{ password } --role=administrator"
65
+ system "wp user create #{ username } #{ username } @#{ uri . host } --user_pass=#{ password } --role=administrator --first_name=WP --last_name=Rspec-Test-Bot > /dev/null 2>&1"
66
+ unless $?. success?
67
+ system "wp user update #{ username } --user_pass=#{ password } --role=administrator > /dev/null 2>&1"
68
+ end
66
69
67
70
# If we couldn't create user just skip the last test
68
71
unless $?. success?
69
72
username = nil
70
73
end
71
74
72
- # Cleanup afterwise
75
+ # After the tests put user into lesser mode so that it's harmless
76
+ # This way tests won't increase the index of user IDs everytime
73
77
RSpec . configure do |config |
74
78
config . after ( :suite ) {
75
79
puts "\n doing the cleanup..."
76
- system "wp user delete #{ username } --yes "
80
+ system "wp user update #{ username } --role=subscriber > /dev/null 2>&1 "
77
81
}
78
82
end
79
83
You can’t perform that action at this time.
0 commit comments