New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added fast switch option #1806
Added fast switch option #1806
Conversation
@ragesoss this build will most probably fail because it needs to add a key to the |
app/presenters/features.rb
Outdated
def self.disable_help? | ||
ENV['disable_help'] == 'true' | ||
PE.each do |method| | ||
define_singleton_method method do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather not do this with metaprogramming. Repeating ENV['wiki_education'] == 'true'
isn't a big deal, and will keep the code extremely transparent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did that first but it felt weird to have the same code repeated many times. Also thought since we are whitelisting the methods, there wouldn't be anything to worry about. But your point seems fair. Have refactored like you asked.
@AmitJoki you can add the ENV value to |
@ragesoss this build is failing due to some VCR error. Can you please rebuild this? |
@AmitJoki that doesn't look like an error that will fix itself. I'll rebuild just to be sure, but I think it's related to this PR. |
@ragesoss you're right that this PR is causing it. It is failing locally for me too. But, the features.rb is replicating whatever the earlier one with lots of ENV variables was doing. So, I can't fathom why this is causing the build to break. Will check into it and if you could nitpick any cause for the error, it would be great in the meantime :) |
The error looks like it's related to the wiki trainings feature being enabled at some place in the code where it was not previously. |
app/presenters/features.rb
Outdated
@@ -33,10 +37,6 @@ def self.enable_account_requests? | |||
ENV['wiki_education'] != 'true' | |||
end | |||
|
|||
def self.wiki_trainings? | |||
ENV['wiki_education'] != 'true' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was correct. Wiki trainings should be enabled with it's not wiki ed.
config/environments/test.rb
Outdated
@@ -5,6 +5,7 @@ | |||
ENV['open_course_creation'] = 'false' | |||
ENV['course_prefix'] = 'Wikipedia:Wiki_Ed' | |||
ENV['wiki_language'] = 'en' | |||
ENV['wiki_education'] = 'false' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also remove the ENV values in this file that are no longer used in Features.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got more errors when I had that true
hence put false
out there. Will change and delete the redundant ENV variables.
spec/presenters/features_spec.rb
Outdated
@@ -7,7 +7,7 @@ | |||
describe '.wiki_ed?' do | |||
context 'when the url is dashboard-testing.wikiedu.org' do | |||
before do | |||
allow(ENV).to receive(:[]).with('dashboard_url').and_return('dashboard-testing.wikiedu.org') | |||
allow(ENV).to receive(:[]).with('wiki_education').and_return('true') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can either change the 'context' description for these, or delete them altogether. After this change, they no longer test anything useful.
Most or all of these are probably cases where the test environment previous was configured in a way that didn't match either of the two main environments. Features were enabled based on convenience of testing, and now those features are disabled. For example, the RequestedAccountsController spec is written based on the default of |
@ragesoss that explains a lot. Thanks. |
@ragesoss I tried your suggested method and it didn't seem to have any effect on the outcome. Hence, I've updated the tests to run conditionally. |
@ragesoss I have no rubocop errors for the file shown in the build logs. Can you please rebuild this one? |
This is because of the new release of rubocop 0.54; the lastest version gets installed and run by travis. I'm fixing this today. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The conditional specs approach will result in never running those tests, since the test environment is set for the wiki_ed config by default. We need to tweak the tests so that they will still test everything.
ENV['wiki_education'] != 'true' | ||
end | ||
|
||
def self.disable_help? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one shows up three times.
end | ||
|
||
def self.open_course_creation? | ||
ENV['open_course_creation'] == 'true' | ||
def self.disable_wiki_output? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should keep its old definition. Wiki output is currently enabled on both dashboard (and is usually disabled in dev environments).
ENV['default_course_type'] = 'ClassroomProgramCourse' | ||
ENV['open_course_creation'] = 'false' | ||
ENV['disable_wiki_output'] = 'false' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep this.
it 'renders' do | ||
get :index | ||
expect(response.status).to eq(200) | ||
if Features.enable_article_finder? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of skipping these tests, you should do allow(Features).to receive(:enable_article_finder?).and_return(true)
in a before
block.
post :create_accounts, params: { campaign_slug: campaign.slug } | ||
expect(response.status).to eq(200) | ||
expect(RequestedAccount.count).to eq(0) | ||
if Features.enable_account_requests? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing here; use allow
to turn the feature on for these tests, rather than skip the tests.
let(:username) { 'username' } | ||
let(:email) { 'valid@example.com' } | ||
|
||
if Features.enable_account_requests? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same.
@@ -5,22 +5,13 @@ | |||
|
|||
describe Features do | |||
describe '.wiki_ed?' do | |||
context 'when the url is dashboard-testing.wikiedu.org' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole spec file can probably just be deleted, since the implementation is now trivial.
…t toggles This should fix the code review comments from PR #1806
thanks @AmitJoki! I finished this up and merged it. |
@ragesoss glad you could patch it up 😃 |
Fixes #1804
Use in
application.yml